private void btnSave_Click(object sender, RoutedEventArgs e) { UserInfo user = userInfoController.GetUserByName(SessionInfo.LoginName); string prePassword = txtPrePassword.Password.Trim(); string password = txtPassword.Password.Trim(); string passwordTwo = txtPasswordTwo.Password.Trim(); if (password == string.Empty) { MessageBox.Show("密码不能为空!", "系统提示"); return; } if (prePassword != user.LoginPassWord) { MessageBox.Show("旧密码输入错误。", "系统提示"); return; } if (password != passwordTwo) { MessageBox.Show("确认密码错误。", "系统提示"); return; } user.LoginPassWord = password; user.UpdateTime = DateTime.Now; string message; userInfoController.Update(user, out message); LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "修改密码 " + message, SessionInfo.LoginName, this.GetType().Name, SessionInfo.ExperimentID); MessageBox.Show(message, "系统提示"); this.Close(); }
private void btnSave_Click(object sender, RoutedEventArgs e) { string userName = txtUserName.Text.Trim(); string password = txtPassword.Password.Trim(); if (userName == string.Empty) { MessageBox.Show("用户名不允许为空", "系统提示"); return; } if (password == string.Empty) { MessageBox.Show("密码不允许为空", "系统提示"); return; } if (System.Text.Encoding.Default.GetByteCount(userName) > 255) { MessageBox.Show("用户名最大长度为127个汉字。", "系统提示"); return; } string passwordTwo = txtPasswordTwo.Password.Trim(); if (System.Text.Encoding.Default.GetByteCount(password) > 255) { MessageBox.Show("密码最大长度为127个汉字。", "系统提示"); return; } if (password == passwordTwo) { if (userInfoController.GetUserByName(userName) != null) { MessageBox.Show("用户名[" + userName + "]已经存在。", "系统提示"); } else { UserInfo userInfo = new UserInfo() { UserID = WanTaiObjectService.NewSequentialGuid(), CreateName = SessionInfo.LoginName, LoginName = userName, LoginPassWord = password, CreateTime = DateTime.Now, RoleName = comboRole.SelectedValue.ToString() }; string message; userInfoController.Add(userInfo, out message); LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "添加用户 成功", SessionInfo.LoginName, this.GetType().Name, SessionInfo.ExperimentID); MessageBox.Show(message, "系统提示"); this.Close(); } } else { MessageBox.Show("两次输入密码不一致!请重新输入。", "系统提示"); } }