pgAddHotel.xaml.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 WpfApp1
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для pgAddHotel.xaml
  19. /// </summary>
  20. public partial class pgAddHotel : Page
  21. {
  22. Hotel hotel;
  23. public pgAddHotel()
  24. {
  25. InitializeComponent();
  26. hotel = new Hotel();
  27. DataContext = hotel;
  28. cbCountry.ItemsSource = BaseConnect.BaseModel.Country.ToList();
  29. cbCountry.SelectedValuePath = "Code";
  30. cbCountry.DisplayMemberPath = "Name";
  31. }
  32. private void cbCountry_SelectionChanged(object sender, SelectionChangedEventArgs e)
  33. {
  34. hotel.CountryCode = (string)cbCountry.SelectedValue;
  35. }
  36. private void btnSave_Click(object sender, RoutedEventArgs e)
  37. {
  38. BaseConnect.BaseModel.Hotel.Add(hotel);
  39. BaseConnect.BaseModel.SaveChanges();
  40. }
  41. }
  42. }