Example #1
0
        private void flightInstanceBtn_Click(object sender, RoutedEventArgs e)
        {
            try {
                //check
                if (!db.checkFlightInstance(flightInstanceComboBox.SelectedItem.ToString(), flightInstanceCal.SelectedDate.Value))
                {
                    errorMsg.Content = "Flight Instance does not exist.";
                }
                else
                {
                    DataTable dt = db.getPassengers(flightInstanceComboBox.SelectedItem.ToString(), flightInstanceCal.SelectedDate.Value);
                    if (dt.Rows.Count == 0)
                    {
                        errorMsg.Content = "This flight instance has no passengers.";
                    }
                    else
                    {
                        passengersDataGrid.DataContext = dt.DefaultView;
                        errorMsg.Content            = "";
                        remainingSeatsLabel.Content = "Remaining Seats: " + db.getRemainingSeats(flightInstanceComboBox.SelectedValue.ToString(), flightInstanceCal.SelectedDate.Value);
                    }
                }
                //populate

                //remaining seats
            } catch (Exception ex) {
                Console.WriteLine(ex);
            }
        }
Example #2
0
        private void OKBtn_Click(object sender, RoutedEventArgs e)
        {
            //check
            string arr = "arr";
            string dep = "dep";

            if (!leavingAirports.Content.Equals("") && !returningAirports.Content.Equals(""))
            {
                arr = leavingAirports.Content.ToString().Substring(leavingAirports.Content.ToString().Length - 3);
                dep = returningAirports.Content.ToString().Substring(0, 3);
            }
            if (multiWayRadio.IsChecked == true)
            {
                if (pidComboBox.SelectedValue == "" || leavingCal.SelectedDate == null || leaveFlightComboBox.SelectedValue == "" || returningFlightComboBox.SelectedValue == "" || returningCal.SelectedDate == null)
                {
                    errorMsg.Content = "All fields must be selected.";
                }
                else if (!db.checkFlightInstance(leaveFlightComboBox.SelectedValue.ToString(), leavingCal.SelectedDate.Value))
                {
                    errorMsg.Content = "First flight does not exist.";
                }
                else if (!db.checkFlightInstance(returningFlightComboBox.SelectedValue.ToString(), returningCal.SelectedDate.Value))
                {
                    errorMsg.Content = "Second flight does not exist.";
                }
                else if (!db.checkEmptySpace(leaveFlightComboBox.SelectedValue.ToString(), leavingCal.SelectedDate.Value))
                {
                    errorMsg.Content = "No empty space on first flight.";
                }
                else if (!db.checkEmptySpace(returningFlightComboBox.SelectedValue.ToString(), returningCal.SelectedDate.Value))
                {
                    errorMsg.Content = "No empty space on second flight.";
                }
                else if (!arr.Equals(dep))
                {
                    errorMsg.Content = "Arrival airport of first flight must be the same as the departure flight of the second flight.";
                }
                else if (checkCalDays())
                {
                    db.insertBookings(leaveFlightComboBox.SelectedValue.ToString(), leavingCal.SelectedDate.Value, pidComboBox.SelectedValue.ToString());
                    db.insertBookings(returningFlightComboBox.SelectedValue.ToString(), returningCal.SelectedDate.Value, pidComboBox.SelectedValue.ToString());
                    this.Close();
                }
            }
            else
            {
                if (pidComboBox.SelectedValue == "" || leavingCal.SelectedDate == null || leaveFlightComboBox.SelectedValue == "")
                {
                    errorMsg.Content = "All fields must be selected.";
                }
                else if (!db.checkFlightInstance(leaveFlightComboBox.SelectedValue.ToString(), leavingCal.SelectedDate.Value))
                {
                    errorMsg.Content = "Flight does not exist.";
                }
                else if (!db.checkEmptySpace(leaveFlightComboBox.SelectedValue.ToString(), leavingCal.SelectedDate.Value))
                {
                    errorMsg.Content = "No empty space on flight.";
                }
                else
                {
                    db.insertBookings(leaveFlightComboBox.SelectedValue.ToString(), leavingCal.SelectedDate.Value, pidComboBox.SelectedValue.ToString());
                    this.Close();
                }
            }
        }