protected void Button1_Click(object sender, EventArgs e) { dbModule dm = new dbModule(); pbModule pm = new pbModule(); string oldpass = oldpassTextbox.Text.Trim(); string newpass1 = newpassTextbox1.Text.Trim(); string newpass2 = newpassTextbox2.Text.Trim(); if ( !pm.isValidString( oldpass) || !pm.isValidString( newpass1 )||!pm.isValidString(newpass2) ) { errors.Text = Resources.Resource.strNotValidString; return; } if (pm.isNullString(newpass1)) { errors.Text = ""; } Security s1 = Session["sec"] as Security; if (s1 == null) { errors.Text = "sorry"; return; } string username = s1.getUserCode(); if (dm.jsLogin ( username , oldpass )==1) { if (newpass1==newpass2) { String sqlstr = "update t_jsxxb set dlmm='" + newpass1 + "' where gzh='" + username + "'"; if (dm.updatePasswd(sqlstr)==1) Response.Write("密码修改成功"); else Response.Write("密码修改失败"); } else Response.Write("两次密码输入不一致"); } else Response.Write("旧密码错误"); }
protected void loginButton_Click( object sender , EventArgs e ) { dbModule dm = new dbModule(); pbModule pm = new pbModule(); string uCode = ucodeTextbox.Text.Trim(); string uPass = upassTextbox.Text.Trim(); if ( !pm.isValidString( uCode) || !pm.isValidString( uPass ) ) { errors.Text = Resources.Resource.strNotValidString; return; } int result = 0; Security s = new Security(); string url = ""; switch (Convert.ToInt32(lb_DropList.SelectedValue)) { case 0://学生 result = dm.xsLogin(uCode, uPass); url = "stuDefault.aspx"; s.setSecurity(priCode.xs); s.setUserName(dm.getUnameByUcode(uCode, priCode.xs)); s.setUserXy(dm.getUxyByUcode(uCode, priCode.xs)); break; case 1://任课教师 result = dm.jsLogin(uCode, uPass); url = "teaDefault.aspx"; s.setUserName(dm.getUnameByUcode(uCode, priCode.js)); s.setUserXy(dm.getUxyByUcode(uCode, priCode.js)); s.setSecurity(priCode.js); break; case 2://实验教师 result = dm.eadmLogin(uCode, uPass); url = "eadmDefault.aspx"; s.setSecurity(priCode.sygly); s.setUserName(dm.getUnameByUcode(uCode, priCode.sygly)); s.setUserXy(dm.getUxyByUcode(uCode, priCode.sygly)); break; case 3://管理员 result = dm.adminLogin(uCode, uPass); url = "adminDefault.aspx"; s.setSecurity(priCode.xtgly); s.setUserName(dm.getUnameByUcode(uCode, priCode.xtgly)); s.setUserXy(dm.getUxyByUcode(uCode, priCode.xtgly)); break; case 4://教务管理员 result = dm.aadmLogin(uCode, uPass); url = "aadmDefault.aspx"; s.setSecurity(priCode.jwgly); s.setUserName(dm.getUnameByUcode(uCode, priCode.jwgly)); s.setUserXy(dm.getUxyByUcode(uCode, priCode.jwgly)); break; } switch ( result ) { case -1 : errors.Text = Resources.Resource.strWrongPasswordString; break; case 0: errors.Text = Resources.Resource.strWrongUsernameString; break; case 1: s.setUserCode(ucodeTextbox.Text.Trim()); Session["sec"] = s; Session["usercode"] = s.getUserCode(); Response.Redirect(url); break; default: errors.Text = Resources.Resource.strDuplicateUserNameString; break; } }