UserPwdChangeView.xaml.cs 2.3 KB

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