コード例 #1
0
        /* Constructor
         *
         * Initializes the window and calls the data provider to initialize
         * airports lists. Creates the autocomplete boxes. In case the connection
         * to the database is unavailable, displays an information and exits.
         */
        public MainWindow()
        {
            SplashScreen splash = new SplashScreen("SplashScreen.png");
            splash.Show(true);
            InitializeComponent();
            try
            {
                EtosPRODataProvider provider = new EtosPRODataProvider(this);
                airportsFullList = provider.GetFullAirportsList();
                airportCodes = provider.GetAirportsCodesList();

                SearchDepartureBox = new AutoCompleteBox();
                SearchDepartureBox.FilterMode = AutoCompleteFilterMode.Contains;
                SearchDepartureBox.ItemsSource = airportsFullList;
                SearchDeparturePanel.Children.Add(SearchDepartureBox);

                SearchArrivalBox = new AutoCompleteBox();
                SearchArrivalBox.FilterMode = AutoCompleteFilterMode.Contains;
                SearchArrivalBox.ItemsSource = airportsFullList;
                SearchArrivalPanel.Children.Add(SearchArrivalBox);
            }
            catch (SqlException e)
            {
                splash.Close(TimeSpan.Zero);
                ErrorWindow error = new ErrorWindow("Could not connect to the server! The application will exit.\n\n" +
                                                    "Verify your connection or contact the developers.");
                error.Show();
                this.Hide();
            }
            splash.Close(TimeSpan.FromSeconds(1));
        }
コード例 #2
0
 /* Constructor
  *
  * Initializes the window and stores the ID of the flight
  * it concernes. Calls the data provider to get all the
  * information about the flight and display it.
  */
 /* BEFORE
  * public DetailedWindow(String flightid, String airline)
  */
 public DetailedWindow(String flightid, String airline, String arrival, String departure)
 {
     InitializeComponent();
     GlobalFlightID = flightid;
     GlobalAirline = airline;
     /* BEFORE
     * without assigning GlobalDeparture and Global Arrival
     */
     GlobalDeparture = departure;
     GlobalArrival = arrival;
     this.Title = "Details about flight " + flightid;
     EtosPRODataProvider provider = new EtosPRODataProvider(this);
     DepartureInfoLabel.Content = departure + ". " + provider.GetDepartureInfo(flightid, airline);
     ArrivalInfoLabel.Content = arrival + ". " + provider.GetArrivalInfo(flightid, airline);
     AirlineInfoLabel.Content = GlobalAirline;
     PlacesInfoLabel.Content = provider.GetPlacesInfo(flightid, airline);
 }
コード例 #3
0
        /* Callback for clicking the search button
         *
         * Validate all input fields - if anything is out of
         * order, show a message box with an appropriate information
         * and return. If everything is fine, show an information that
         * the program is working and call the data provider
         * to fire off the searching thread.
         */
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            int departure = MatchAirport(SearchDepartureBox);
            int arrival = MatchAirport(SearchArrivalBox);
            /* Validating Airports */
            if (departure == -1 || arrival == -1 || departure == arrival)
            {
                MessageBox.Show("Please Select Airports!", "Error");
                return;
            }
            /* Validating Leave Date */
            if (!SearchLeaveBox.SelectedDate.HasValue)
            {
                MessageBox.Show("Please select a valid leave date!");
                return;
            }
            /* Validating Return Date */
            if (SearchOneWayCheckbox.IsChecked == false && !SearchReturnBox.SelectedDate.HasValue)
            {
                MessageBox.Show("Please select a valid return date!");
                return;
            }
            /* Searching */
            SearchResultLabel.Visibility = Visibility.Visible;
            SearchResultLabel.Content = "Please wait while searching...";
            SearchResultBox.ItemsSource = null;

            EtosPRODataProvider provider = new EtosPRODataProvider(this);
            provider.FindConnections(airportCodes.ElementAt(departure),
                                     airportCodes.ElementAt(arrival),
                                     SearchOneWayCheckbox.IsChecked,
                                     SearchLeaveBox.SelectedDate,
                                     SearchReturnBox.SelectedDate);
        }
コード例 #4
0
        /* Handler for clicking the reserve flight button
         *
         * Checks if a name was entered. If it was, it warns
         * the user not to make stupid jokes. If the user still
         * wants to use the name, calls the data provider to start
         * a thread reserving tickets.
         */
        private void ReserveFlightButton_Click(object sender, RoutedEventArgs e)
        {
            /* Check the input box */
            if (PassengerNameBox.Text.Length <= 0)
            {
                MessageBox.Show("Please input yout name!");
                return;
            }
            if (MessageBox.Show(PassengerNameBox.Text +
                        ",\nAre you SURE this is your name? This will be on your ticket!",
                                "Warning!", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
            {
                return;
            }
            ReserveResultLabel.Content = "Your ticket is being reserved, please wait...";
            ReserveResultLabel.Visibility = Visibility.Visible;
            EtosPRODataProvider provider = new EtosPRODataProvider(this);
            provider.ReserveTicket(GlobalFlightID, PassengerNameBox.Text, GlobalAirline);

            /*
             * File creating
             */
            Microsoft.Win32.SaveFileDialog DialogSave = new Microsoft.Win32.SaveFileDialog();
            DialogSave.DefaultExt = "txt";
            DialogSave.OverwritePrompt = true;
            DialogSave.ValidateNames = true;
            DialogSave.FileName = "etospro_ticket_reservation.txt";
            DialogSave.Filter = "Text file (*.txt)|*.txt|All files (*.*)|*.*";
            DialogSave.AddExtension = true;
            DialogSave.RestoreDirectory = true;
            DialogSave.Title = "Save reservation file";
            DialogSave.InitialDirectory = @"C:/";
            if (DialogSave.ShowDialog() == true)
            {
                MessageBox.Show("You saved the reservation file: " + DialogSave.FileName);
                string[] lines = { "\t\tETOS Pro", "\tTicket reservation",
                                   "",
                                   "Name:\t\t"+PassengerNameBox.Text,
                                   "Airlines:\t"+GlobalAirline,
                                   "FlightID:\t"+GlobalFlightID,
                                   "Departure:\t"+GlobalDeparture,
                                   "Arrival:\t"+GlobalArrival};
                System.IO.File.WriteAllLines(@DialogSave.FileName, lines);
            }
            else
            {
                MessageBox.Show("You did not save the reservation file.");
            }
            //DialogSave.Dispose();
            DialogSave = null;
            /*
             * End of file creating
             */
        }