コード例 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            HotelsPage ht = new HotelsPage();

            ht.Visibility = Visibility.Visible;
            this.Close();
        }
コード例 #2
0
        private void hotelsWindow(object sender, RoutedEventArgs e)
        {
            HotelsPage ht = new HotelsPage();

            if (WhatTheRole.role == Role.Client)
            {
                ht.BtnAdd.Visibility    = Visibility.Hidden;
                ht.BtnDelete.Visibility = Visibility.Hidden;
                ht.BtnChange.Visibility = Visibility.Hidden;
            }

            ht.Visibility = Visibility.Visible;
            this.Close();
        }
コード例 #3
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(_currentHotel.CountOfStars.ToString()))
            {
                errors.AppendLine("Укажите количество звезд у отеля");
            }
            if (_currentHotel.CountOfStars > 5)
            {
                errors.AppendLine("Количество звезд у отеля не может быть больше 5");
            }
            if (_currentHotel.CountOfStars < 1)
            {
                errors.AppendLine("Количество звезд у отеля не может быть меньше 1");
            }
            if (string.IsNullOrWhiteSpace(_currentHotel.Name))
            {
                errors.AppendLine("Укажите наименование отеля");
            }
            if (string.IsNullOrWhiteSpace(_currentHotel.CountryCode))
            {
                errors.AppendLine("Укажите страну у отеля");
            }



            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            else
            {
                TourBaseEntitiesDB.GetContext().Hotel.Add(_currentHotel);
            }


            TourBaseEntitiesDB.GetContext().SaveChanges();
            MessageBox.Show("Запись успешно сохранена!");
            HotelsPage ht = new HotelsPage();

            ht.Visibility = Visibility.Visible;
            this.Close();
        }