日期:2014-05-18 浏览次数:20412 次
//密码修改保存 private void btnSave_Click(object sender, EventArgs e) { string oldpwd = this.txtOldPwd.Text.Trim().ToString(); string newpwd = this.txtNewPwd.Text.Trim().ToString(); string confirmpwd = this.txtConfirmPwd.Text.Trim().ToString(); string sql = string.Format("select EmpNum,EmpName from Hospital_Employees where EmpName='{0}'", oldpwd); if(this.txtOldPwd.Text.Equals("")) { //提示信息 ToolTip toolTip1 = new ToolTip(); toolTip1.ShowAlways = true; toolTip1.IsBalloon = true; toolTip1.BackColor = Color.Red; toolTip1.SetToolTip(this.txtOldPwd, "旧密码不能为空!"); } if (!BLL.RunSqlExists(sql)) { MessageBox.Show("旧密码错误!","系统提示"); } else { if(newpwd.Length<5) { MessageBox.Show("密码长度必须大于4个字符!", "系统提示"); } if (!newpwd.Equals(confirmpwd)) { MessageBox.Show("两次密码输入不一致!", "系统提示"); } else { string updatesql = string.Format("update Hospital_Employees set EmpPassword='{0}' where EmpName='{1}'", confirmpwd,lblUserName.Text); BLL.RunSql(updatesql); MessageBox.Show("密码修改成功,请重新登录!", "系统提示"); frmLogin fr = new frmLogin(); fr.ShowDialog(); } } }
------解决方案--------------------