终端一体化运控平台
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

PasswordChangeViewModel.cs 2.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 BPASmartClient.Helper;
  8. using Microsoft.Toolkit.Mvvm.ComponentModel;
  9. using Microsoft.Toolkit.Mvvm.Input;
  10. namespace BPASmartClient.CustomResource.Pages.ViewModel
  11. {
  12. public class PasswordChangeViewModel : ObservableObject
  13. {
  14. public PasswordChangeViewModel()
  15. {
  16. LoginCommand = new RelayCommand(() =>
  17. {
  18. if (Global.userInfo.Password == OldPassword)
  19. {
  20. if (NewPassword1 == NewPassword2)
  21. {
  22. Global.userInfo.Password = NewPassword2;
  23. int index = Array.FindIndex(Global.userManager.userInfos.ToArray(), p => p.UserName == Global.userInfo.UserName);
  24. if (index >= 0 && index < Global.userManager.userInfos.Count)
  25. Global.userManager.userInfos.ElementAt(index).Password = NewPassword1;
  26. Config.GetInstance.SaveUser();
  27. ActionManage.GetInstance.Send("PasswordChangeViewconfirm");
  28. }
  29. else
  30. {
  31. ErrorInfo = "新密码不匹配";
  32. }
  33. }
  34. else
  35. {
  36. ErrorInfo = "原密码错误";
  37. }
  38. });
  39. ExitCommand = new RelayCommand(() =>
  40. {
  41. ActionManage.GetInstance.Send("PasswordChangeViewCancel");
  42. });
  43. }
  44. public RelayCommand LoginCommand { get; set; }
  45. public RelayCommand ExitCommand { get; set; }
  46. public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } }
  47. private string _mErrorInfo;
  48. public string OldPassword { get { return _mOldPassword; } set { _mOldPassword = value; OnPropertyChanged(); } }
  49. private string _mOldPassword;
  50. public string NewPassword1 { get { return _mNewPassword1; } set { _mNewPassword1 = value; OnPropertyChanged(); } }
  51. private string _mNewPassword1;
  52. public string NewPassword2 { get { return _mNewPassword2; } set { _mNewPassword2 = value; OnPropertyChanged(); } }
  53. private string _mNewPassword2;
  54. }
  55. }