12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- 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.Navigation;
- using System.Windows.Shapes;
- namespace WpfApp1
- {
- /// <summary>
- /// Логика взаимодействия для pgUpdateHotel.xaml
- /// </summary>
- public partial class pgUpdateHotel : Page
- {
- Hotel hotel;
- public pgUpdateHotel(int id)
- {
- InitializeComponent();
- hotel = BaseConnect.BaseModel.Hotel.FirstOrDefault(x => x.Id == id);
- DataContext = hotel;
- Country country = BaseConnect.BaseModel.Country.FirstOrDefault(x => x.Code == hotel.CountryCode);
- List<Country> countryList = BaseConnect.BaseModel.Country.Where(x => x.Code != hotel.CountryCode).ToList();
- countryList.Insert(0, country);
- cbCountry.ItemsSource = countryList;
- cbCountry.SelectedValuePath = "Code";
- cbCountry.DisplayMemberPath = "Name";
- cbCountry.SelectedIndex = 0;
- }
- private void btnSave_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- if (Convert.ToInt32(tbStars.Text) <= 5 && Convert.ToInt32(tbStars.Text) >= 0)
- BaseConnect.BaseModel.SaveChanges();
- else
- MessageBox.Show("sasa");
- }
- catch
- {
- MessageBox.Show("sasa");
- }
- }
- private void cbCountry_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- hotel.CountryCode = (string)cbCountry.SelectedValue;
- }
- }
- }
|