Izmen.xaml.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 SSS
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для Izmen.xaml
  19. /// </summary>
  20. public partial class Izmen : Page
  21. {
  22. Entities ent = new Entities();
  23. Client user = new Client();
  24. public Izmen(int UsId)
  25. {
  26. InitializeComponent();
  27. user = ent.Client.Where(x => x.id_Client == UsId).FirstOrDefault();
  28. Srname.Text = user.Surname;
  29. Nam.Text = user.Name;
  30. Patr.Text = user.Patronymic;
  31. DateBirth.SelectedDate = user.BirthDate;
  32. }
  33. private void Edit(object sender, RoutedEventArgs e)
  34. {
  35. user.Surname = Srname.Text;
  36. user.Name = Nam.Text;
  37. user.Patronymic = Patr.Text;
  38. user.BirthDate = DateBirth.SelectedDate;
  39. ent.SaveChanges();
  40. MainFrame.Name1.Navigate(new Page3(user.id_Client));
  41. MessageBox.Show("Изменения сохранены");
  42. }
  43. private void Back(object sender, RoutedEventArgs e)
  44. {
  45. this.Close();
  46. }
  47. }
  48. }