IzmenPar.xaml.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Cryptography;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace SSS
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для IzmenPar.xaml
  20. /// </summary>
  21. public partial class IzmenPar : Window
  22. {
  23. Entities ent = new Entities();
  24. Client user = new Client();
  25. public IzmenPar(int UsId)
  26. {
  27. InitializeComponent();
  28. user = ent.Client.Where(x => x.id_Client == UsId).FirstOrDefault();
  29. Login.Text = user.Login.ToString();
  30. }
  31. private void FixChange(object sender, RoutedEventArgs e)
  32. {
  33. user.Login = Login.Text;
  34. string CurPass = Pass.Text;
  35. using (SHA256 hash = SHA256.Create())
  36. {
  37. CurPass = BitConverter.ToString(hash.ComputeHash(Encoding.UTF8.GetBytes(CurPass))).Replace("-", "");
  38. }
  39. user.Password = CurPass;
  40. ent.SaveChanges();
  41. MainFrame.Name1.Navigate(new Page3(user.id_Client));
  42. MessageBox.Show("Изменения сохранены");
  43. }
  44. private void Back(object sender, RoutedEventArgs e)
  45. {
  46. this.Close();
  47. }
  48. }
  49. }