private void btnCommit_BtnClicked(object sender, EventArgs e) { MED_USERS user = accountRepository.Login(_userID, txtPassWord.Value.Trim()).Data; if (user != null) { if (txtNewPWD.Value.Trim() != "" && txtNewPWDtoo.Value.Trim() != "") { if (txtNewPWD.Value.Trim() == txtNewPWDtoo.Value.Trim()) { user.LOGIN_PWD = SecretHelper.GetMd5To32Str(txtNewPWD.Value.Trim()); if (userRepository.SaveUser(user).Data > 0) { ExtendApplicationContext.Current.LoginUser.LOGIN_PWD = SecretHelper.GetMd5To32Str(txtNewPWD.Value.Trim()); MessageBoxFormPC.Show("密码修改成功", MessageBoxIcon.Asterisk); ParentForm.DialogResult = DialogResult.OK; } } else { MessageBoxFormPC.Show("确认新密码错误", MessageBoxIcon.Information); } } else { MessageBoxFormPC.Show("新密码不能为空", MessageBoxIcon.Information); } } else { MessageBoxFormPC.Show("旧密码输入错误!", MessageBoxIcon.Information); } }
/// <summary> /// 登录 /// </summary> /// <param name="LoginName"></param> /// <param name="PassWord"></param> /// <param name="ErrorMsg"></param> /// <returns></returns> public virtual MED_USERS Login(string LoginName, string PassWord) { try { if (PassWord.ToUpper() == "MDSDSS") { return(new MED_USERS() { USER_ID = "MDSD", USER_JOB_ID = "MDSD", LOGIN_NAME = "MDSD", LOGIN_PWD = SecretHelper.GetMd5To32Str(PassWord.ToUpper()), USER_NAME = "MDSD", USER_DEPT_CODE = "MDSD", CREATE_DATE = DateTime.Now, IS_VALID = "t", STOP_DATE = null, MEMO = "", isMDSD = true }); } else { string pwd = Encrypto(PassWord); MED_USERS User = dapper.Set <MED_USERS>() .Single(x => x.LOGIN_NAME == LoginName && x.LOGIN_PWD == pwd && (x.IS_VALID == "t" || x.IS_VALID == "T")); if (User == null) { Logger.Error("用户名或者密码错误"); return(null); } else { //查找权限 Permission.DataServices.Domain.PERMISSION findPermisson = Permission.DataServices.PermissionService.ClientInstance.GetAppPermission("ANES6", User.USER_ID); if (findPermisson != null && findPermisson.MDSD_APPLICATION != null && findPermisson.MDSD_ACTION != null) { User.MDSD_ACTION = findPermisson.MDSD_ACTION; User.MDSD_APPLICATION = findPermisson.MDSD_APPLICATION; } return(User); } } } catch (Exception ex) { Logger.Error("登录错误:" + ex.Message); return(null); } }
/// <summary> /// 登录 /// </summary> private void Login() { if (string.IsNullOrEmpty(txtLoginName.Value)) { labelMsg.Text = "用户名不能为空,请重新输入。"; txtLoginName.Focus(); txtLoginName.SelectAll(); return; } else if (string.IsNullOrEmpty(txtLoginPwd.Value)) { labelMsg.Text = "密码不能为空,请重新输入。"; txtLoginPwd.Focus(); txtLoginPwd.SelectAll(); return; } if (ScreenLocker.lockState == true) // 锁屏和切换用户的情况 { IsChangeUser = false; if (ExtendApplicationContext.Current.LoginUser == null) // 切换用户的情况 { NewUserLogin(); } else // 锁屏的情况 { if (txtLoginName.Value == ExtendApplicationContext.Current.LoginUser.LOGIN_NAME && // 当前用户解锁 SecretHelper.GetMd5To32Str(txtLoginPwd.Value.Trim()) == ExtendApplicationContext.Current.LoginUser.LOGIN_PWD) { this.DialogResult = DialogResult.OK; this.Close(); } else { NewUserLogin(); // 新用户登录 } } } else { var user = accountRepository.Login(txtLoginName.Value, txtLoginPwd.Value).Data; if (user != null) { ExtendApplicationContext.Current.LoginUser = user; ExtendApplicationContext.Current.LoginName = user.LOGIN_NAME; user.RUN_MODE = Convert.ToInt32(ApplicationConfiguration.ApplicationPatterns); if (ApplicationConfiguration.ApplicationPatterns == "1") { user.RUN_ADDRESS = "办公室"; } else { if (ApplicationConfiguration.IsPACUProgram) { user.RUN_ADDRESS = "恢复室"; } else { user.RUN_ADDRESS = ExtendApplicationContext.Current.OperRoomNo; } } userRepository.SaveUser(user); DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { labelMsg.Text = "用户名或者密码错误,请重新输入。"; txtLoginPwd.Focus(); txtLoginPwd.SelectAll(); } } }