革博士V2程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

90 linhas
2.8 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using static Org.BouncyCastle.Math.EC.ECCurve;
  11. namespace GeBoShi.UI.User
  12. {
  13. public partial class ModifyPWFrm : Form
  14. {
  15. User _FatherUser;
  16. public ModifyPWFrm(User fatherUser)
  17. {
  18. InitializeComponent();
  19. this.uiTitel1.ShowContrlBox(false, false, true);
  20. this.uiTitel1.FatherForm = this;
  21. _FatherUser = fatherUser;
  22. log1.Text = log2.Text = log3.Text = "";
  23. //log1.Visible = log2.Visible = log3.Visible = false;
  24. }
  25. private void btnSave_Click(object sender, EventArgs e)
  26. {
  27. UserService service = new UserService();
  28. try
  29. {
  30. string pw = this.txtPW.Text.Trim();
  31. //pw = Utils.Util.GetMD5(pw);
  32. string newpw = this.txtNewPW.Text.Trim();
  33. string newpw2 = this.txtNewPW2.Text.Trim();
  34. if (newpw == "")
  35. {
  36. log2.Text = "请输入新密码!";
  37. return;
  38. }
  39. else
  40. log2.Text = "";
  41. if (newpw.Length < 3)
  42. {
  43. log2.Text = "新密码长度至少3位!";
  44. return;
  45. }
  46. else
  47. log2.Text = "";
  48. if (newpw2 != newpw)
  49. {
  50. log3.Text = "确认新密码输入不一致!";
  51. return;
  52. }
  53. else
  54. log3.Text = "";
  55. if (string.IsNullOrWhiteSpace(_FatherUser.Password))
  56. _FatherUser.Password = "";
  57. if (_FatherUser.Password != pw)
  58. {
  59. log1.Text = "旧密码错误!";
  60. return;
  61. }
  62. else
  63. log1.Text = "";
  64. if (!service.ModifyPw(_FatherUser.Id, (newpw)))
  65. throw new Exception("密码修改失败!");
  66. MessageBox.Show("修改成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
  67. DialogResult = DialogResult.OK;
  68. this.Close();
  69. }
  70. catch (Exception ex)
  71. {
  72. MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
  73. }
  74. }
  75. private void btnCancel_Click(object sender, EventArgs e)
  76. {
  77. this.Close();
  78. }
  79. }
  80. }