FormEditPwd.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using CCWin;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using WCS_Client.UC;
  12. using System.Text.RegularExpressions;
  13. namespace WCS_Client.From
  14. {
  15. public partial class FormEditPwd : CCSkinMain
  16. {
  17. DataRow _dr;
  18. public FormEditPwd(DataRow dr)
  19. {
  20. InitializeComponent();
  21. _dr = dr;
  22. }
  23. private void skinButton2_Click(object sender, EventArgs e)
  24. {
  25. this.Close();
  26. }
  27. private void skinButton1_Click(object sender, EventArgs e)
  28. {
  29. string user_no = _dr["USER_NO"].ToString();
  30. string user_pwd = txtUser_NewPwd.Text.Trim();
  31. string user_newpwd = txtUser_TwoNewPwd.Text.Trim();
  32. if (string.IsNullOrWhiteSpace(user_newpwd))
  33. {
  34. MessageUtil.ShowError(string.Format("密码不能为空!"));
  35. return;
  36. }
  37. if (string.IsNullOrWhiteSpace(user_newpwd))
  38. {
  39. MessageUtil.ShowError(string.Format("确认密码不能为空!"));
  40. return;
  41. }
  42. if (user_pwd.Trim().Length < 8)
  43. {
  44. MessageUtil.ShowError(string.Format("密码太短,不足8个字符!"));
  45. return;
  46. }
  47. if (user_pwd.Trim().Length > 16)
  48. {
  49. MessageUtil.ShowError(string.Format("密码过长,大于16个字符!"));
  50. return;
  51. }
  52. if (!Regex.IsMatch(user_pwd, "[A-Z]"))
  53. {
  54. MessageUtil.ShowError(string.Format("密码必须包含大写字母!"));
  55. return;
  56. }
  57. if(!Regex.IsMatch(user_pwd, "[a-z]"))
  58. {
  59. MessageUtil.ShowError(string.Format("密码必须包含小写字母!"));
  60. return;
  61. }
  62. if (!Regex.IsMatch(user_pwd, "[0-9]"))
  63. {
  64. MessageUtil.ShowError(string.Format("密码必须包含数字!"));
  65. return;
  66. }
  67. if (user_pwd != user_newpwd)
  68. {
  69. MessageUtil.ShowError("两次用户密码不一致。");
  70. }
  71. else
  72. {
  73. string result = BaseWorkflow.AdminModifyPwd(user_no, user_pwd);
  74. if (string.IsNullOrWhiteSpace(result))
  75. MessageUtil.ShowTips(string.Format("用户{0}修改密码成功。", user_no));
  76. else
  77. MessageUtil.ShowError(result);
  78. this.Close();
  79. }
  80. }
  81. }
  82. }