예제 #1
0
 private void Window_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (Visibility == Visibility.Visible)
     {
         TourBaseEntitiesDB.GetContext().ChangeTracker.Entries().ToList().ForEach(p => p.Reload());
         DGridTours.ItemsSource = TourBaseEntitiesDB.GetContext().Tour.ToList();
     }
 }
예제 #2
0
        private void UpdateEquipment()
        {
            var currentTour = TourBaseEntitiesDB.GetContext().Tour.ToList();

            currentTour = currentTour.Where(p => p.Name.ToLower().Contains(TBoxSearch.Text.ToLower())).ToList();


            DGridTours.ItemsSource = currentTour.OrderBy(p => p.Name).ToList();
        }
예제 #3
0
 public AddHotel(Hotel selectedHotel)
 {
     InitializeComponent();
     if (selectedHotel != null)
     {
         _currentHotel = selectedHotel;
     }
     DataContext           = _currentHotel;
     CountryCB.ItemsSource = TourBaseEntitiesDB.GetContext().Country.ToList();
     countries             = TourBaseEntitiesDB.GetContext().Country.ToList();
 }
예제 #4
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();
        }
예제 #5
0
        private void RemoveBtn(object sender, RoutedEventArgs e)
        {
            var TourForRemoving = DGridTours.SelectedItems.Cast <Tour>().ToList();

            if (MessageBox.Show($"Вы точно хотите удалить следующие {TourForRemoving.Count()} элементов?", "Внимание", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                try
                {
                    TourBaseEntitiesDB.GetContext().Tour.RemoveRange(TourForRemoving);
                    TourBaseEntitiesDB.GetContext().SaveChanges();
                    MessageBox.Show("Данны успешно удалены!");

                    DGridTours.ItemsSource = TourBaseEntitiesDB.GetContext().Tour.ToList();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
예제 #6
0
        private void btnSave(object sender, RoutedEventArgs e)
        {
            var imageBuffer = BitmapSourceToByteArray((BitmapSource)Picture.Source);

            _currentTour.ImagePreview = imageBuffer;
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(_currentTour.TicketCount.ToString()))
            {
                errors.AppendLine("Укажите количество билетов у тура");
            }
            if (string.IsNullOrWhiteSpace(_currentTour.Name))
            {
                errors.AppendLine("Укажите наименование тура");
            }
            if (string.IsNullOrWhiteSpace(_currentTour.Price.ToString()))
            {
                errors.AppendLine("Укажите цену у тура");
            }



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


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

            tr.Visibility = Visibility.Visible;
            this.Close();
        }
예제 #7
0
 public TakeTicket()
 {
     InitializeComponent();
     CBoxTour.ItemsSource  = TourBaseEntitiesDB.GetContext().Tour.ToList();
     CBoxHotel.ItemsSource = TourBaseEntitiesDB.GetContext().Hotel.ToList();
 }
예제 #8
0
 public ToursPage()
 {
     InitializeComponent();
     DGridTours.ItemsSource = TourBaseEntitiesDB.GetContext().Tour.ToList();
 }