UserPwdChangeView.xaml.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System.Windows;
  2. namespace MECF.Framework.UI.Core.Accounts
  3. {
  4. /// <summary>
  5. /// Interaction logic for UserPwdChangeView.xaml
  6. /// </summary>
  7. public partial class UserPwdChangeView : Window
  8. {
  9. /// <summary>
  10. /// account Id
  11. /// </summary>
  12. /// <param name="accountId"></param>
  13. public UserPwdChangeView(string accountId)
  14. {
  15. InitializeComponent();
  16. _accountId = accountId;
  17. groupBox1.Header = string.Format(Application.Current.Resources["GlobalLableAccountViewResetPasswordInfo"].ToString(), accountId);
  18. btnOK.IsEnabled = false;
  19. }
  20. private string _accountId;
  21. private void passwordBox1_PasswordChanged(object sender, RoutedEventArgs e)
  22. {
  23. ValidatePwd();
  24. }
  25. private void passwordBox2_PasswordChanged(object sender, RoutedEventArgs e)
  26. {
  27. ValidatePwd();
  28. }
  29. private void ValidatePwd()
  30. {
  31. btnOK.IsEnabled = System.Text.RegularExpressions.Regex.Match(passwordBox1.Password, "^(?=.*\\d)(?=.*[a-zA-Z]).{4,12}$").Success &&
  32. System.Text.RegularExpressions.Regex.Match(passwordBox2.Password, "^(?=.*\\d)(?=.*[a-zA-Z]).{4,12}$").Success &&
  33. passwordBox1.Password == passwordBox2.Password;
  34. }
  35. private void btnOK_Click(object sender, RoutedEventArgs e)
  36. {
  37. var ret = AccountClient.Instance.Service.ChangePassword(_accountId, passwordBox1.Password);
  38. if (ret.ActSucc)
  39. {
  40. MessageBox.Show(Application.Current.Resources["GlobalLableAccountViewResetPasswordOk"].ToString(), Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Information);
  41. Close();
  42. }
  43. else
  44. {
  45. MessageBox.Show(Application.Current.Resources["GlobalLableAccountViewResetPasswordFailed"].ToString() + ret.Description, Application.Current.Resources["GlobalLableAccountViewMsgTitle"].ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
  46. }
  47. }
  48. private void btnClose_Click(object sender, RoutedEventArgs e)
  49. {
  50. this.Close();
  51. }
  52. }
  53. }