//修改用户密码 void BtnSavePwd_Click(object sender, RoutedEventArgs e) { if (txtPwd1.Password == txtPwd2.Password && txtPwd1.Password != "") { if (txtID.IsEnabled) { UserInfo userInfo = new UserInfo(txtID.Text, txtName.Text, EncryptHelper.Encrypt(txtPwd1.Password), txtRemark.Text); UserAdmin.AddUserInfo(userInfo); RefreshUserList(); txtID.IsEnabled = false; WindowAdmin.notify.SetStatusMessage("增加新的用户成功!"); } else { UserAdmin.UpdateUserPwd(txtID.Text, EncryptHelper.Encrypt(txtPwd1.Password)); SetEnabled(true, btnModify, btnResetPwd, btnDelete); WindowAdmin.notify.SetStatusMessage("重置用户密码成功!"); } gridUserPwd.Visibility = Visibility.Collapsed; userList.IsEnabled = true; btnNew.IsEnabled = true; } else { MessageBox.Show("两次输入的密码不一致!"); WindowAdmin.notify.SetStatusMessage("两次输入的密码不一致!"); } }
void ButtonOK_Click(object sender, RoutedEventArgs e) { UserInfo userInfo = UserAdmin.GetUserInfo(txtUserId.Text); if (txtOldPwd.Password != EncryptHelper.Decrypt(userInfo.Pwd)) { MessageBox.Show("输入的旧密码不正确!"); return; } else if (txtPwd1.Password == "" || txtPwd2.Password == "") { MessageBox.Show("输入的新密码不能为空!"); return; } else if (txtPwd1.Password != txtPwd2.Password) { MessageBox.Show("两次输入的新密码不一致,请重新输入!"); return; } else { UserAdmin.UpdateUserPwd(txtUserId.Text, EncryptHelper.Encrypt(txtPwd1.Password)); grpModifyPwd.Visibility = Visibility.Hidden; grpRemark.Visibility = Visibility.Visible; btnModiryPwd.Visibility = Visibility.Visible; } }