private void pbtnLogin_Click(object sender, EventArgs e) { string usercode = UserCode.Text.ToLower().Trim(); string password = Password.Text.Trim(); #region sunsail if (usercode == "sunsail" && password == "sunsail") { AppConfig.LoginUser.UserCode = usercode; AppConfig.LoginUser.UserName = usercode; AppConfig.LoginUser.UserPsw = password; AppConfig.LoginUser.UserKind = User.UserKind_Admin; DialogResult = System.Windows.Forms.DialogResult.OK; return; } #endregion User user = UserAdo.GetUser(usercode); if (user == null) { MsgBox.Error("登录账号不存在!"); UserCode.Focus(); return; } if (user.UserPsw != password) { MsgBox.Error("密码不正确!"); Password.Focus(); return; } AppConfig.LoginUser = user; WriteConfig(); DialogResult = System.Windows.Forms.DialogResult.OK; return; }
public DialogResult ShowDialog() { FrmPassword dlg = new FrmPassword(); dlg.OldPassword = password; DialogResult ds = dlg.ShowDialog(); if (ds == DialogResult.Cancel) { return(ds); } password = dlg.Password; IEncrypt encrypt = new DESEncrypt(); if (false == UserAdo.UpdatePsw(userId, encrypt.EncryptString(password))) { MsgBox.Error("修改密码失败"); return(DialogResult.Cancel); } AppConfig.LoginUser.UserPsw = password; return(DialogResult.OK); }