终端一体化运控平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

81 行
2.5 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using BPASmartClient.CustomResource.Pages.Model;
  7. using BPA.Helper;
  8. using BPA.Helper;
  9. namespace BPASmartClient.CustomResource.Pages.ViewModel
  10. {
  11. public class PasswordChangeViewModel : NotifyBase
  12. {
  13. private void CheckPassword(UserInfo userInfo)
  14. {
  15. if (userInfo.Password == OldPassword)
  16. {
  17. if (NewPassword1 == NewPassword2)
  18. {
  19. userInfo.Password = NewPassword2;
  20. int index = Array.FindIndex(Global.userManager.userInfos.ToArray(), p => p.UserName == userInfo.UserName);
  21. if (index >= 0 && index < Global.userManager.userInfos.Count)
  22. Global.userManager.userInfos.ElementAt(index).Password = NewPassword1;
  23. Config.GetInstance.SaveUser();
  24. ActionManage.GetInstance.Send("PasswordChangeViewconfirm");
  25. Global.changeUserInfo = null;
  26. }
  27. else
  28. {
  29. ErrorInfo = "新密码不匹配";
  30. }
  31. }
  32. else
  33. {
  34. ErrorInfo = "原密码错误";
  35. }
  36. }
  37. public PasswordChangeViewModel( )
  38. {
  39. LoginCommand = new BPARelayCommand(() =>
  40. {
  41. if (Global.changeUserInfo == null) CheckPassword(Global.userInfo);
  42. else { CheckPassword(Global.changeUserInfo); }
  43. });
  44. ExitCommand = new BPARelayCommand(() =>
  45. {
  46. ActionManage.GetInstance.Send("PasswordChangeViewCancel");
  47. Global.changeUserInfo = null;
  48. });
  49. }
  50. public BPARelayCommand LoginCommand { get; set; }
  51. public BPARelayCommand ExitCommand { get; set; }
  52. public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } }
  53. private string _mErrorInfo;
  54. public string OldPassword { get { return _mOldPassword; } set { _mOldPassword = value; OnPropertyChanged(); } }
  55. private string _mOldPassword;
  56. public string NewPassword1 { get { return _mNewPassword1; } set { _mNewPassword1 = value; OnPropertyChanged(); } }
  57. private string _mNewPassword1;
  58. public string NewPassword2 { get { return _mNewPassword2; } set { _mNewPassword2 = value; OnPropertyChanged(); } }
  59. private string _mNewPassword2;
  60. }
  61. }