TableHotelPage.xaml.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 ПодготовкаКДемо1.Pages
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для TableHotelPage.xaml
  19. /// </summary>
  20. public partial class TableHotelPage : Page
  21. {
  22. public TableHotelPage()
  23. {
  24. InitializeComponent();
  25. DataGridHotel.ItemsSource = Hotel.GetHotels();
  26. }
  27. private void btnChange_Click(object sender, RoutedEventArgs e)
  28. {
  29. Button button = (Button)sender;
  30. int i = Convert.ToInt32(button.Uid);
  31. Hotel hotel = BaseConnect.BaseModel.Hotel.FirstOrDefault(x=>x.Id==i);
  32. AddHotelWindow addHotelWindow = new AddHotelWindow(hotel);
  33. if ((bool)addHotelWindow.ShowDialog())
  34. {
  35. }
  36. }
  37. private void ButtonDelete_Click(object sender, RoutedEventArgs e)
  38. {
  39. string s = "";
  40. foreach (Hotel hotel in DataGridHotel.SelectedItems)
  41. {
  42. s += "\n" + hotel.Name;
  43. BaseConnect.BaseModel.Hotel.Remove(hotel);
  44. BaseConnect.BaseModel.SaveChanges();
  45. }
  46. MessageBox.Show("Были удалены:"+s);
  47. DataGridHotel.ItemsSource = Hotel.GetHotels();
  48. }
  49. }
  50. }