ChangePwd.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Windows.Forms;
  3. using DevExpress.XtraEditors;
  4. using GCAS.Code;
  5. using GCAS.Model;
  6. namespace GCAS
  7. {
  8. public partial class ChangePwd : XtraForm
  9. {
  10. private OperatorRepository operatorRepository;
  11. public OperatorModel currentOperator;
  12. public ChangePwd()
  13. {
  14. InitializeComponent();
  15. }
  16. private void ChangePwd_Load(object sender, EventArgs e)
  17. {
  18. operatorRepository = new OperatorRepository();
  19. }
  20. private async void simpleButton1_Click(object sender, EventArgs e)
  21. {
  22. if (string.IsNullOrEmpty(text_old.Text))
  23. {
  24. XtraMessageBox.Show("旧密码不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
  25. return;
  26. }
  27. if (string.IsNullOrEmpty(text_new.Text))
  28. {
  29. XtraMessageBox.Show("新密码不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
  30. }
  31. if (text_confim.Text != text_new.Text)
  32. {
  33. XtraMessageBox.Show("新密码与确认密码不一致", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
  34. }
  35. if (currentOperator.Pwd != SHAHelper.SHAmd5Encrypt(text_old.Text))
  36. {
  37. XtraMessageBox.Show("您输入的旧密码不正确,请重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
  38. }
  39. currentOperator.Pwd = SHAHelper.SHAmd5Encrypt(text_new.Text);
  40. if (await operatorRepository.Update(currentOperator) > 0)
  41. {
  42. XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  43. DialogResult = DialogResult.OK;
  44. Close();
  45. }
  46. }
  47. private void text_old_Click(object sender, EventArgs e)
  48. {
  49. SoftKeyboard.ActiveSoftKeyboard(sender);
  50. }
  51. private void text_new_Click(object sender, EventArgs e)
  52. {
  53. SoftKeyboard.ActiveSoftKeyboard(sender);
  54. }
  55. private void text_confim_Click(object sender, EventArgs e)
  56. {
  57. SoftKeyboard.ActiveSoftKeyboard(sender);
  58. }
  59. }
  60. }