/// <summary> /// 密码验证 /// </summary> private void Validates() { FrmLoginComm loginComm = new FrmLoginComm(); if (txtPwd.Text.Trim().Length == 0) { MessageBox.Show("密码不能为空!", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtPwd.Focus(); } else { Admin admin = new Admin() { Admins = this.id, Pwd = txtPwd.Text.Trim() }; if (loginComm.Check(admin)) { this.Close(); } else { MessageBox.Show("密码错误,请重新输入!", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPwd.Clear(); txtPwd.Focus(); } } }
/// <summary> /// 登录 /// </summary> private void Login() { if (NonEmpty()) { string name = txtUser.Text.Trim(); string pwd = txtPwd.Text.Trim(); Admin admin = new Admin() { Admins = name, Pwd = pwd }; FrmLoginComm loginComm = new FrmLoginComm(); if (loginComm.Check(admin)) { new FrmMain() { Admin = txtUser.Text.Trim() }.ShowDialog(); this.Hide(); this.Close(); } else { //用户名或密码错误 MessageBox.Show("用户名或密码错误"); } } }
/// <summary> /// 修改密码 /// </summary> private void ModifyPwd() { if (NonEmpty()) { Admin admin = new Admin() { Admins = this.id, Pwd = txtOldPwd.Text.Trim() }; FrmLoginComm loginComm = new FrmLoginComm(); if (loginComm.Check(admin)) { admin = new Admin() { Admins = this.id, Pwd = txtPwd.Text.Trim() }; FrmLoginComm frmLoginComm = new FrmLoginComm(); if (frmLoginComm.UpadtePwd(admin)) { MessageBox.Show("修改成功"); //this.Close(); Application.Restart(); } else { MessageBox.Show("修改密码失败"); txtOldPwd.Focus(); } } else { MessageBox.Show("原密码输入有误"); txtOldPwd.Focus(); } } }