版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

62 lines
1.9 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. namespace ProductionControl
  11. {
  12. public partial class FrmModifyPW : Form
  13. {
  14. public FrmModifyPW()
  15. {
  16. InitializeComponent();
  17. }
  18. private void FrmModifyPW_Load(object sender, EventArgs e)
  19. {
  20. }
  21. private void btnSave_Click(object sender, EventArgs e)
  22. {
  23. Service.UserService service=new Service.UserService();
  24. try
  25. {
  26. string pw = this.txtPW.Text.Trim();
  27. pw = Utils.Util.GetMD5(pw);
  28. string newpw=this.txtNewPW.Text.Trim();
  29. string newpw2 = this.txtNewPW2.Text.Trim();
  30. if (newpw == "")
  31. throw new Exception("请输入新密码!");
  32. if (newpw.Length <6)
  33. throw new Exception("新密码长度至少6位!");
  34. if (newpw2 !=newpw)
  35. throw new Exception("确认新密码输入不一致!");
  36. if (string.IsNullOrWhiteSpace(Config.loginUser.Password))
  37. Config.loginUser.Password = "";
  38. if (Config.loginUser.Password!=pw)
  39. throw new Exception("旧密码错误!");
  40. if(!service.ModifyPw(Config.loginUser.Id, Utils.Util.GetMD5(newpw)))
  41. throw new Exception("密码修改失败!");
  42. MessageBox.Show("修改成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
  43. DialogResult = DialogResult.OK;
  44. this.Close();
  45. }
  46. catch (Exception ex)
  47. {
  48. MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
  49. }
  50. }
  51. }
  52. }