private void MainGoButtonClick(object sender, RoutedEventArgs e)
        {
            if (((mainCityFrom.Text == "") || (mainCityFrom.Text == " ")) || ((mainCityTo.Text == "") || (mainCityTo.Text == " ")))
            {
                MessageBox.Show("Пожалуйста заполните все поля!", "Ууупс!");
            }
            else
            {
                var mainWindow = App.Current.MainWindow;
                var searchPage = (SearchPage)mainWindow.FindName("searchPage");
                searchPage.Visibility = System.Windows.Visibility.Visible;
                this.Visibility       = System.Windows.Visibility.Hidden;


                searchPage.GetListViewForFromToFlight().Items.Clear();
                searchPage.GetListViewForToFromFlight().Items.Clear();
                searchPage.firstFlightInfo.Content = "";
                searchPage.firstFlightDepartureTimeInfo.Content  = "";
                searchPage.firstFlightArrivalTimeInfo.Content    = "";
                searchPage.secondFlightInfo.Content              = "";
                searchPage.secondFlightDepartureTimeInfo.Content = "";
                searchPage.secondFlightArrivalTimeInfo.Content   = "";

                string   cityFrom        = mainCityFrom.Text;
                string   cityTo          = mainCityTo.Text;
                DateTime flightDateFrom  = mainDatePickerFrom.SelectedDate.Value;
                DateTime flightDateTo    = mainDatePickerTo.SelectedDate.Value;
                bool     isBothWayTicket = mainIsBothWays.IsChecked.Value;
                bool     isBusiness      = mainIsBusiness.IsChecked.Value;

                searchPage.SendUserInfoToSearchPageControls(cityFrom,
                                                            cityTo,
                                                            flightDateFrom,
                                                            flightDateTo,
                                                            isBothWayTicket,
                                                            isBusiness);

                SearchForListViewUtils utils = new SearchForListViewUtils();
                utils.AddFlightsToListView(cityFrom, cityTo, flightDateFrom, isBusiness, searchPage.GetListViewForFromToFlight());

                if (isBothWayTicket == true)
                {
                    utils.AddFlightsToListView(cityTo, cityFrom, flightDateTo, isBusiness, searchPage.GetListViewForToFromFlight());
                }
            }
        }
Esempio n. 2
0
        private void searchGoButtonClick(object sender, RoutedEventArgs e)
        {
            if (((searchCityFrom.Text == "") || (searchCityFrom.Text == " ")) || ((searchCityTo.Text == "") || (searchCityTo.Text == " ")))
            {
                MessageBox.Show("Пожалуйста заполните все поля!", "Ууупс!");
            }
            else
            {
                //очищаем все поля с информацией
                flightListViewToFrom.Items.Clear();
                flightListViewFromTo.Items.Clear();
                secondFlightInfo.Content = "";
                secondFlightDepartureTimeInfo.Content = "";
                secondFlightArrivalTimeInfo.Content   = "";
                firstFlightInfo.Content = "";
                firstFlightDepartureTimeInfo.Content = "";
                firstFlightArrivalTimeInfo.Content   = "";
                borderInfoFromTo.Visibility          = Visibility.Hidden;
                borderInfoToFrom.Visibility          = Visibility.Hidden;

                firstFlightArrivalTimeInfo.Content                  = "";
                firstFlightTransferInfoLabel.Visibility             = Visibility.Hidden;
                firstFlightDepartureTimeInfoTransitLabel.Visibility = Visibility.Hidden;
                firstFlightArrivalTimeInfoTransitLabel.Visibility   = Visibility.Hidden;

                firstFlightTransferInfo.Content             = "";
                firstFlightDepartureTimeInfoTransit.Content = "";
                firstFlightArrivalTimeInfoTransit.Content   = "";

                secondFlightArrivalTimeInfo.Content                  = "";
                secondFlightTransferInfoLabel.Visibility             = Visibility.Hidden;
                secondFlightDepartureTimeInfoTransitLabel.Visibility = Visibility.Hidden;
                secondFlightArrivalTimeInfoTransitLabel.Visibility   = Visibility.Hidden;

                secondFlightTransferInfo.Content             = "";
                secondFlightDepartureTimeInfoTransit.Content = "";
                secondFlightArrivalTimeInfoTransit.Content   = "";

                string   cityFrom        = searchCityFrom.Text;
                string   cityTo          = searchCityTo.Text;
                DateTime flightDateFrom  = searchDatePickerFrom.SelectedDate.Value;
                DateTime flightDateTo    = searchDatePickerTo.SelectedDate.Value;
                bool     isBothWayTicket = searchIsBothWays.IsChecked.Value;
                bool     isBusiness      = searchIsBusiness.IsChecked.Value;

                SearchForListViewUtils utils = new SearchForListViewUtils();
                utils.AddFlightsToListView(cityFrom, cityTo, flightDateFrom, isBusiness, GetListViewForFromToFlight());

                if (isBothWayTicket == true)
                {
                    m_isBothWayTicket = true;
                    GetListViewForToFromFlight().Visibility = System.Windows.Visibility.Visible;
                    Grid.SetRowSpan(GetListViewForFromToFlight(), 1);
                    Grid.SetRowSpan(borderInfoFromTo, 1);
                    utils.AddFlightsToListView(cityTo, cityFrom, flightDateTo, isBusiness, GetListViewForToFromFlight());
                }
                else
                {
                    m_isBothWayTicket = false;

                    GetListViewForToFromFlight().Visibility = System.Windows.Visibility.Hidden;
                    Grid.SetRowSpan(GetListViewForFromToFlight(), 4);
                    Grid.SetRowSpan(borderInfoFromTo, 2);
                }
            }
        }