ChangePassword.xaml.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace HelpHelf.Pages
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для ChangePassword.xaml
  19. /// </summary>
  20. public partial class ChangePassword : Page
  21. {
  22. LoginedTable loginedTable;
  23. public ChangePassword(LoginedTable logined)
  24. {
  25. InitializeComponent();
  26. loginedTable = logined;
  27. }
  28. private void btnSave_Click(object sender, RoutedEventArgs e)
  29. {
  30. if(Classes.CheckFields.CheckUpdatePassword(pswOldPassword.Password, pswNewPassword.Password, pswRepeatePassword.Password))
  31. {
  32. if(Classes.CheckFields.CheckOldPassword(pswOldPassword.Password, loginedTable))
  33. {
  34. if(Classes.CheckFields.CheckRepeatePassword(pswNewPassword.Password, pswRepeatePassword.Password))
  35. {
  36. try
  37. {
  38. int password = pswNewPassword.Password.GetHashCode();
  39. loginedTable.Password = password;
  40. Classes.DateBase.connect.SaveChanges();
  41. MessageBox.Show("Успешная смена пароля\nПовторите вход", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
  42. Classes.DebugClass.diagWrite("Переход на страницу авторизации");
  43. Classes.FrameClass.frmMain.Navigate(new AuthorizationPage());
  44. }
  45. catch (Exception ex)
  46. {
  47. Classes.DebugClass.diagWrite(ex.Message);
  48. MessageBox.Show("Ошибка", "Ошибка", MessageBoxButton.OK,MessageBoxImage.Error);
  49. }
  50. }
  51. }
  52. }
  53. }
  54. private void btnCancel_Click(object sender, RoutedEventArgs e)
  55. {
  56. Classes.FrameClass.frmMain.Navigate(new PersonalAccount(loginedTable));// переход на страницу данных пользователя
  57. }
  58. }
  59. }