RedUserInfoWin.xaml.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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.Shapes;
  14. namespace MusicSmth
  15. {
  16. /// <summary>
  17. /// Логика взаимодействия для RedUserInfoWin.xaml
  18. /// </summary>
  19. public partial class RedUserInfoWin : Window
  20. {
  21. Music Muse = new Music();
  22. Users user = new Users();
  23. public RedUserInfoWin(int UsId)
  24. {
  25. InitializeComponent();
  26. user = Muse.Users.Where(x => x.Id == UsId).FirstOrDefault();
  27. Srname.Text = user.Surname;
  28. Nam.Text = user.Name;
  29. Patr.Text = user.Patronymic;
  30. Birthd.SelectedDate = user.BirthDate;
  31. }
  32. private void Edit(object sender, RoutedEventArgs e)
  33. {
  34. user.Surname = Srname.Text;
  35. user.Name = Nam.Text;
  36. user.Patronymic = Patr.Text;
  37. user.BirthDate = Birthd.SelectedDate;
  38. Muse.SaveChanges();
  39. MainFrame.mframe.Navigate(new UserPage(user.Id));
  40. MessageBox.Show("Изменения успешно сохранены");
  41. }
  42. private void Back(object sender, RoutedEventArgs e)
  43. {
  44. this.Close();
  45. }
  46. }
  47. }