您目前尚未登陆,请选择【登陆】或【注册
首页->行政办公->Asp.net简单网络选课系统源码>>ModifyPwd.aspx.cs>>代码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:Asp.net简单网络选课系统源码


当前文件路径:MyElectCourse/ModifyPwd.aspx.cs 文件类型
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using System.Data.SqlClient; 12 13public partial class ModifyPwd : System.Web.UI.Page 14{ 15 protected void Page_Load(object sender, EventArgs e) 16 { 17 //if (this.Session["userID"] == null) 18 //{ 19 // Response.Redirect("Login.aspx"); 20 //} 21 } 22 23 //修改密码按钮事件 24 protected void imgBtnConfirm_Click(object sender, ImageClickEventArgs e) 25 { 26 //取参数 27 string userName = Session["userName"].ToString(); 28 string oldPwd = txtOldPwd.Text.Trim(); 29 string newPwd = txtNewPwd.Text.Trim(); 30 string selectStr=""; 31 string updateStr=""; 32 switch (Session["userRole"].ToString()) 33 { 34 case "0": //身份为教师时 35 selectStr = "Select * from Teacher where teaID = ='" + userName + "' and teaPwd='" + oldPwd + "'"; 36 updateStr="update Teacher set teaPwd='" + newPwd + "' where teaID='" + userName + "'"; 37 break; 38 case "1": //身份为学生时 39 selectStr = "Select * from Student where stuID = ='" + userName + "' and stuPwd='" + oldPwd + "'"; 40 updateStr="update Student set stuPwd='" + newPwd + "' where stuID='" + userName + "'"; 41 break; 42 case "2": //身份为管理员时 43 selectStr = "Select * from Users where adminName = ='" + userName + "' and adminPwd='" + oldPwd + "'"; 44 updateStr="update Users set adminPwd='" + newPwd + "' where adminName='" + userName + "'"; 45 break; 46 } 47 SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); 48 SqlCommand selectCmd = new SqlCommand(selectStr, conn); 49 try 50 { 51 conn.Open(); 52 SqlDataReader sdr = selectCmd.ExecuteReader(); 53 if (sdr.Read()) //如果用户存在且输入密码正确,修改密码 54 { 55 sdr.Close(); 56 SqlCommand updateCmd = new SqlCommand(updateStr, conn); 57 int i = updateCmd.ExecuteNonQuery(); 58 if (i > 0) //根据修改后返回的结果给出提示 59 { 60 Response.Write("成功修改密码!"); 61 } 62 else 63 { 64 Response.Write("修改密码失败!"); 65 } 66 } 67 else 68 { 69 Response.Write("您输入的密码错误,检查后重新输入!"); 70 } 71 } 72 catch (System.Exception ee) //系统出错,错误处理 73 { 74 Response.Write("系统出错,错误原因:" + ee.Message.ToString()); 75 } 76 finally 77 { 78 conn.Close(); 79 } 80 } 81 protected void imgBtnReset_Click(object sender, ImageClickEventArgs e) 82 { 83 txtOldPwd.Text = ""; 84 txtNewPwd.Text = ""; 85 txtConfirmPwd.Text = ""; 86 } 87} 88
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:Asp.net简单网络选课系统源码

- Ftp在线注册管理系统源码

- 大众小说网Beta版全站项目源码

- ASP.NET合同管理管理系统源码

- 银行模拟登陆系统源码

- 三层结构示例项目源码 Codem..

- 森林Asp.net留言板(C#.net)源..

- NETCMSv1.5(Build0509)完整源..

- 勤网爱问v2008学习版项目源码

51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号