FrmChangePassword.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.SystemSettings
  10. {
  11. public partial class FrmChangePassword : LYFZ.Software.UI.SystemSettings.FrmChangePassword
  12. {
  13. public FrmChangePassword()
  14. {
  15. }
  16. #region 加载
  17. protected override void FrmChangePassword_Load(object sender, EventArgs e)
  18. {
  19. txtUser_Account.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Account;
  20. }
  21. #endregion
  22. #region 确定
  23. protected override void btnSave_Click(object sender, EventArgs e)
  24. {
  25. if (string.IsNullOrEmpty(txtUser_Account.Text))
  26. {
  27. MessageBoxCustom.Show("用户账号不能为空!");
  28. return;
  29. }
  30. if (string.IsNullOrEmpty(txtOldUser_Password.Text))
  31. {
  32. MessageBoxCustom.Show("旧密码不能为空!");
  33. return;
  34. }
  35. if (string.IsNullOrEmpty(txtNewUser_Password.Text))
  36. {
  37. MessageBoxCustom.Show("新密码不能为空!");
  38. return;
  39. }
  40. if (string.IsNullOrEmpty(txtOkUser_Password.Text))
  41. {
  42. MessageBoxCustom.Show("确定密码不能为空!");
  43. return;
  44. }
  45. if (txtNewUser_Password.Text != txtOkUser_Password.Text)
  46. {
  47. MessageBoxCustom.Show("新密码与确定密码不一致!");
  48. return;
  49. }
  50. LYFZ.BLL.BLL_ErpUser userbll = new BLL.BLL_ErpUser();
  51. DataTable dt = new DataTable();
  52. #region 检查输入旧密码是否正确
  53. dt = userbll.GetList("User_Account='" + txtUser_Account.Text + "' and User_Password='"+LYFZ.Command.Command_MD5.md5(txtOldUser_Password.Text)+"'").Tables[0];
  54. if (dt.Rows.Count <= 0)
  55. {
  56. MessageBoxCustom.Show("旧密码输入错误!");
  57. return;
  58. }
  59. #endregion
  60. #region 更新密码
  61. int i= userbll.UpdateUser_Password(LYFZ.Command.Command_MD5.md5(txtNewUser_Password.Text), txtUser_Account.Text);
  62. if (i > 0)
  63. {
  64. MessageBoxCustom.Show("保存成功,请重新启动!");
  65. // 模拟键盘;
  66. System.Threading.Tasks.Task task = new System.Threading.Tasks.Task(()=> {
  67. SendKeys.SendWait("{F12}");
  68. });
  69. task.Start();
  70. this.Close();
  71. }
  72. else
  73. {
  74. MessageBoxCustom.Show("保存失败!");
  75. txtOldUser_Password.Text = "";
  76. txtNewUser_Password.Text = "";
  77. txtOkUser_Password.Text = "";
  78. }
  79. #endregion
  80. }
  81. #endregion
  82. #region 关闭
  83. protected override void BtnClose_Click(object sender, EventArgs e)
  84. {
  85. this.Close();
  86. }
  87. #endregion
  88. }
  89. }