コード例 #1
0
        private void ExitToHotelButton_Click(object sender, RoutedEventArgs e)
        {
            var hotelWindow = new HotelWindow(Hotel, Guest, CheckIn, CheckOut);

            hotelWindow.Show();
            this.Close();
        }
コード例 #2
0
 private void ButtonShow_Click(object sender, RoutedEventArgs e)
 {
     if (hotelsList.SelectedItem != null)
     {
         var hotelWindow = new HotelWindow(hotelsList.SelectedItem as Hotel, Guest, CheckIn, CheckOut);
         hotelWindow.Show();
     }
     else
     {
         MessageBox.Show("Select a hotel first", "Error");
         return;
     }
 }
コード例 #3
0
        private void ButtonSearch_Click(object sender, RoutedEventArgs e)
        {
            List <Hotel> SuitableHotels = new List <Hotel>();
            int          PossibleBeds   = 0;

            if (HotelNameCombobox.SelectedIndex != -1)
            {
                foreach (var h in _repo._hotels)
                {
                    if (h == HotelNameCombobox.SelectedItem)
                    {
                        ////////////////////////открыть окно отеля
                        List <Room> SuitableRooms = new List <Room>();
                        _repo.SearchEngine(h.Rooms, decimal.Parse(MaxPriceTextBox.Text), CheckInCalendar.SelectedDate.Value, CheckOutCalendar.SelectedDate.Value, out SuitableRooms, out PossibleBeds);
                        h.SuitableRooms = SuitableRooms;
                        var hotelWindow = new HotelWindow(h, Guest, CheckInCalendar.SelectedDate.Value, CheckOutCalendar.SelectedDate.Value);
                        hotelWindow.Show();
                        this.Close();
                    }
                }
            }

            else if (DistrictHotelCombobox.SelectedIndex != -1)
            {
                foreach (var h in _repo._hotels)
                {
                    //h.SuitableRooms = null;
                    if (h.District == DistrictHotelCombobox.SelectedItem.ToString())
                    {
                        List <Room> SuitableRooms = new List <Room>();
                        _repo.SearchEngine(h.Rooms, decimal.Parse(MaxPriceTextBox.Text), CheckInCalendar.SelectedDate.Value, CheckOutCalendar.SelectedDate.Value, out SuitableRooms, out PossibleBeds);
                        h.SuitableRooms = SuitableRooms;
                        if ((h.SuitableRooms.Count >= int.Parse(RoomsTextBox.Text)) && (PossibleBeds >= int.Parse(PeopleTextBox.Text)))
                        {
                            SuitableHotels.Add(h);
                        }
                    }
                }
                /////////////////////Вывод списка отелей
                var hotelslistWindow = new HotelsListWindow(SuitableHotels, Guest, CheckInCalendar.SelectedDate.Value, CheckOutCalendar.SelectedDate.Value);
                hotelslistWindow.Show();
                this.Close();
            }

            else
            {
                foreach (var h in _repo._hotels)
                {
                    //h.SuitableRooms = null;
                    List <Room> SuitableRooms = new List <Room>();
                    _repo.SearchEngine(h.Rooms, decimal.Parse(MaxPriceTextBox.Text), CheckInCalendar.SelectedDate.Value, CheckOutCalendar.SelectedDate.Value, out SuitableRooms, out PossibleBeds);

                    if ((SuitableRooms.Count >= int.Parse(RoomsTextBox.Text)) && (PossibleBeds >= int.Parse(PeopleTextBox.Text)))
                    {
                        SuitableHotels.Add(h);
                        h.SuitableRooms = SuitableRooms;
                    }
                }
                /////////////////////Вывод списка отелей
                var hotelslistWindow = new HotelsListWindow(SuitableHotels, Guest, CheckInCalendar.SelectedDate.Value, CheckOutCalendar.SelectedDate.Value);
                hotelslistWindow.Show();
                this.Close();
            }
        }