1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace ПодготовкаКДемо1.Pages
- {
- /// <summary>
- /// Логика взаимодействия для AddHotelWindow.xaml
- /// </summary>
- public partial class AddHotelWindow : Window
- {
- Hotel hotel;
- bool flag = true;
- public AddHotelWindow()
- {
- InitializeComponent();
- hotel = new Hotel();
- flag = false;
- Contry.DisplayMemberPath = "Name";
- Contry.SelectedValuePath = "Code";
- Contry.ItemsSource = BaseConnect.BaseModel.Country.ToList();
- }
- public AddHotelWindow(Hotel hotel)
- {
- InitializeComponent();
- this.hotel = hotel;
- DataContext = hotel;
-
- Contry.DisplayMemberPath = "Name";
- Contry.SelectedValuePath = "Code";
- Contry.ItemsSource = BaseConnect.BaseModel.Country.ToList();
- //Contry.SelectedItem = hotel.Country.Code;
- Contry.Text = hotel.Country.Name;
- }
- private void btnSave_Click(object sender, RoutedEventArgs e)
- {
- if (Name.Text!=""&& Name.Text != ""&& Name.Text != ""&& Contry.SelectedItem!=null)
- {
- if (flag)
- {
- BaseConnect.BaseModel.SaveChanges();
- MessageBox.Show("Добавлено!");
- }
- else
- {
- BaseConnect.BaseModel.Hotel.Add(hotel);
- BaseConnect.BaseModel.SaveChanges();
- MessageBox.Show("Добавлено!");
- }
- }
- else
- {
- MessageBox.Show("Не все поля заполненны");
- }
- }
- }
- }
|