终端一体化运控平台
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

78 строки
2.3 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.CustomResource.Pages.View;
  3. using BPA.Helper;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace BPASmartClient.CustomResource.Pages.ViewModel
  11. {
  12. public class UserManagerViewModel
  13. {
  14. /// <summary>
  15. /// datagrid绑定
  16. /// </summary>
  17. public ObservableCollection<UserInfo> userManager { get; set; } = Global.userManager.userInfos;
  18. public BPARelayCommand<object> ChangePasswardCommand { get; set; }
  19. public BPARelayCommand AddNewUserCommand { get; set; }
  20. public BPARelayCommand<object> DeleteUserCommand { get; set; }
  21. public BPARelayCommand<object> EditUserConfigCommand { get; set; }
  22. private void ChangePassward(object o)
  23. {
  24. if (o != null && o is UserInfo infos)
  25. {
  26. Global.changeUserInfo = infos;
  27. PasswordChangeView passwordChangeView = new PasswordChangeView();
  28. passwordChangeView.ShowDialog();
  29. }
  30. }
  31. private void DeleteUser(object o)
  32. {
  33. if (o != null && o is UserInfo infos)
  34. {
  35. var res = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == infos.UserName);
  36. if (res != null) Global.userManager.userInfos.Remove(res);
  37. Config.GetInstance.SaveUser();
  38. }
  39. }
  40. private void EditUserConfig(object o)
  41. {
  42. if (o != null && o is UserInfo infos)
  43. {
  44. Global.changeUserInfo = null;
  45. Global.changeUserInfo = infos;
  46. UserConfigView userConfigView = new UserConfigView();
  47. userConfigView.ShowDialog();
  48. }
  49. }
  50. public UserManagerViewModel()
  51. {
  52. ChangePasswardCommand = new BPARelayCommand<object>(ChangePassward);
  53. AddNewUserCommand = new BPARelayCommand(() =>
  54. {
  55. AddNewUser addNewUser = new AddNewUser();
  56. addNewUser.ShowDialog();
  57. });
  58. DeleteUserCommand = new BPARelayCommand<object>(DeleteUser);
  59. EditUserConfigCommand = new BPARelayCommand<object>(EditUserConfig);
  60. }
  61. }
  62. }