protected void Save_OnClick(object sender, EventArgs e) { #region if (String.IsNullOrEmpty(UserPasswordTBX.Text.Trim())) { Common.JShelper.JSAlert(Page, "script", "请输入旧密码!"); return; } if (UserPasswordTBX.Text.Length > 50) { Common.JShelper.JSAlert(Page, "script", "旧密码长度输入过长!"); return; } if (String.IsNullOrEmpty(NewPasswordTBX.Text.Trim())) { Common.JShelper.JSAlert(Page, "script", "请输入新密码密码!"); return; } if (NewPasswordTBX.Text.Length > 50) { Common.JShelper.JSAlert(Page, "script", "新密码长度输入过长!"); return; } if (!Regex.IsMatch(NewPasswordTBX.Text.Trim(), @"^\w+$")) { Common.JShelper.JSAlert(Page, "script", "新密码输入不合法(只能为数字、英文或下划线的组合)!"); return; } //if (String.IsNullOrEmpty(RePasswordTBX.Text.Trim())) //{ // Common.JShelper.JSAlert(Page, "script", "请重复输入新密码!"); //} //if (RePasswordTBX.Text.Length > 50) //{ // Common.JShelper.JSAlert(Page, "script", "重复新密码长度输入过长!"); //} //if (!Regex.IsMatch(RePasswordTBX.Text.Trim(), @"^\w+$")) //{ // Common.JShelper.JSAlert(Page, "script", "重复新密码输入不合法(只能为数字、英文或下划线的组合)!"); //} if (String.Compare(RePasswordTBX.Text, NewPasswordTBX.Text) != 0) { Common.JShelper.JSAlert(Page, "script", "两次新密码输入不一致!"); return; } //验证用户名和密码输入是否正确 if (!IsUserNameAndPassword()) { Common.JShelper.JSAlert(Page, "script", "用户名和密码输入不匹配!"); return; } #endregion if (!String.IsNullOrEmpty(UserID)) { int ID; if (int.TryParse(UserID, out ID)) { if (UserType == "mana") { LabMS.BLL.UserTable userTable = new LabMS.BLL.UserTable(); LabMS.Model.UserTable userTableModel = new LabMS.Model.UserTable(); userTableModel = userTable.GetModel(ID); userTableModel.Password = NewPasswordTBX.Text.Trim(); try { userTable.Update(userTableModel); Common.JShelper.JsAlertAndClose(Page, "script", "密码修改成功!"); } catch { Common.JShelper.JsAlertAndClose(Page, "script", "密码修改失败!"); } } else if (UserType == "teacher") { LabMS.BLL.Teacher userTable = new LabMS.BLL.Teacher(); LabMS.Model.Teacher userTableModel = new LabMS.Model.Teacher(); userTableModel = userTable.GetModel(ID); userTableModel.Password = NewPasswordTBX.Text.Trim(); try { userTable.Update(userTableModel); Common.JShelper.JsAlertAndClose(Page, "script", "密码修改成功!"); } catch { Common.JShelper.JsAlertAndClose(Page, "script", "密码修改失败!"); } } else { LabMS.BLL.Student userTable = new LabMS.BLL.Student(); LabMS.Model.Student userTableModel = new LabMS.Model.Student(); userTableModel = userTable.GetModel(ID); userTableModel.Student_Pass = NewPasswordTBX.Text.Trim(); try { userTable.Update(userTableModel); Common.JShelper.JsAlertAndClose(Page, "script", "密码修改成功!"); } catch { Common.JShelper.JsAlertAndClose(Page, "script", "密码修改失败!"); } } } else { Common.JShelper.JsAlertAndClose(Page, "script", "用户ID存储不合法,请退出系统,重新登录后进行修改密码!"); } } else { Common.JShelper.JsAlertAndClose(Page, "script", "用户Session丢失,请退出系统,重新登录后进行修改密码!"); } }