AccountPageViewModel.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using LogoForceTestApp.Modules.MainModule.Models;
  2. using Prism.Commands;
  3. using Prism.Mvvm;
  4. using Repository;
  5. using Repository.Entiies;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Security.Cryptography;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. namespace LogoForceTestApp.Modules.MainModule.ViewModels
  14. {
  15. public class AccountPageViewModel: BindableBase
  16. {
  17. IRepository _repository;
  18. public string IdAcc { get; set; }
  19. public string ChangeP { get; set; }
  20. public DelegateCommand PasswordCommand { get; set; }
  21. public AccountPageViewModel(IRepository repository)
  22. {
  23. _repository = repository;
  24. PasswordCommand = new DelegateCommand(ChangePassword);
  25. }
  26. private void ChangePassword()
  27. {
  28. System.Windows.Forms.DialogResult digres = MessageBox.Show("确认是否修改密码?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
  29. if (digres == System.Windows.Forms.DialogResult.OK)
  30. {
  31. var change= _repository.GetFirstDefault<Account>(c => c.AccountID == IdAcc);//数据库查
  32. change.ChangePassword = ChangeP;//改
  33. _repository.Update(change);//更新
  34. }
  35. else
  36. {
  37. ChangeP = string.Empty;
  38. }
  39. }
  40. }
  41. }