示例#1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MainWindow()
        {
            try
            {
                InitializeComponent();
                Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;

                CanvasA380.Visibility = Visibility.Collapsed;
                Canvas767.Visibility  = Visibility.Collapsed;

                //Start with change seat button off until user clicks on a label that contains a passenger
                cmdChangeSeat.IsEnabled = false;

                //Start with delete passenger button off until user clicks on a label that contains a passenger
                cmdDeletePassenger.IsEnabled = false;

                //new instance of clsFlightManager class
                clsFlightManager = new clsFlightManager();

                //bind flights to cbChooseFlight combobox
                cbChooseFlight.ItemsSource = clsFlightManager.GetFlights();

                //Clear passenger combobox each flight change.
                cbChoosePassenger.Items.Clear();
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
示例#2
0
        /// <summary>
        /// AddPassenger click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdAddPassenger_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //create new instance of add passenger window
                wndAddPass = new wndAddPassenger();

                //display it
                wndAddPass.ShowDialog();

                //if the user is in save passenger mode
                if (wndAddPass.saveMode)
                {
                    //new instance of clsFlightManager class
                    clsFlightManager = new clsFlightManager();

                    //disable buttons, forcing user to click on a label
                    cmdDisableButtons();
                }
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
 /// <summary>
 /// constructor for the add passenger window
 /// </summary>
 public wndAddPassenger()
 {
     try
     {
         InitializeComponent();
         Flightman = new clsFlightManager();
     }
     catch (Exception ex)
     {
         throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
     }
 }
示例#4
0
        /// <summary>
        /// UI Button Event click that saves the new passengers information
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FlightManager = new clsFlightManager();
                Passenger     = new clsPassengers();
                wndMainWindow = new MainWindow();

                //Enable add passenger save mode
                saveMode = true;

                //if flight name 767
                if (wndMainWindow.cbChooseFlight.ToString() == "412 - Boeing 767")
                {
                    //show 767
                    wndMainWindow.CanvasA380.Visibility = Visibility.Hidden;
                    wndMainWindow.Canvas767.Visibility  = Visibility.Visible;

                    //then flight id is 2
                    wndMainWindow.iFlight_ID = 2;
                }
                else
                {
                    //show A380
                    wndMainWindow.Canvas767.Visibility  = Visibility.Hidden;
                    wndMainWindow.CanvasA380.Visibility = Visibility.Visible;

                    //else flight id is 1
                    wndMainWindow.iFlight_ID = 1;
                }

                //Add passenger to database - first name, last name, and which flight they are on
                FlightManager.AddPassenger(txtFirstName.Text, txtLastName.Text, wndMainWindow.iFlight_ID);

                //Gets the newly added passengers ID
                Passenger.sID = FlightManager.GetPassengerID(txtFirstName.Text, txtLastName.Text);

                //temp variable to hold passengers id
                sTempID = Passenger.sID;

                //refresh
                wndMainWindow.cbChoosePassenger.Items.Clear();


                this.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }
        }
示例#5
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();
                Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;

                wndAddPass = new wndAddPassenger();
                Flightman  = new clsFlightManager();
                selFlight  = new clsFlight();
                cbChooseFlight.ItemsSource = Flightman.GetFlights();
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
示例#6
0
        /// <summary>
        /// UI Event For a Seat Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Seat_Click(object sender, MouseButtonEventArgs e)
        {
            try
            {
                //Label called bckgroundColor to be used for checking the labels background color
                Label bckgroundColor = (Label)sender;

                //start with fresh updated seats
                cmdUpdateSeats(iFlight_ID);

                //Check to see if someone is sitting in the selected seat
                CheckWhoIsSittingHere(bckgroundColor, sender);

                //Enable the change seat button
                cmdChangeSeat.IsEnabled = true;

                //Enable the delete passenger button
                cmdDeletePassenger.IsEnabled = true;

                //if add passanger save mode is true and wndAddPass instance is not null
                if (wndAddPass != null && wndAddPass.saveMode)
                {
                    //if the labels background is red, then the seat is already taken - return and pick a different seat
                    if (bckgroundColor.Background.ToString() == Brushes.Red.ToString())
                    {
                        lblError.Content = "Seat is already taken!";
                        return;
                    }

                    //userPick is the label the user clicked on
                    Label userPick = (Label)sender;

                    //set the passenger seat number label to be the same as the userPick label (This is the seat the new passenger selected)
                    lblPassengersSeatNumber.Content = userPick.Content;

                    //new instance of clsFlightManager
                    clsFlightManager = new clsFlightManager();

                    //Add the passenger link to database (first name, last name, and flight id have already been added at this point)
                    clsFlightManager.AddPassengerLink(iFlight_ID, Convert.ToInt32(wndAddPass.sTempID), Convert.ToInt32(userPick.Content));

                    //update the ui
                    cmdUpdateUI();

                    //Enable UI buttons
                    cmdEnableButtons();

                    //no longer need add passenger mode active
                    wndAddPass.saveMode = false;

                    //clean label error if there was one
                    lblError.Content = "";
                }
                //if Change seat mode is true
                if (bChangeSeat)
                {
                    //if the labels background is red, then the seat is already taken - return and pick a different seat

                    if (bckgroundColor.Background.ToString() == Brushes.Red.ToString())
                    {
                        lblError.Content = "Seat is already taken!";
                        return;
                    }

                    //Call change seat and pass the selected seat
                    ChangeSeat(sender);

                    //Enable UI buttons
                    cmdEnableButtons();

                    //Update the ui
                    cmdUpdateUI();

                    //no longer need save seat mode active
                    bChangeSeat = false;
                }

                //if button clicked is blue, change it to green - this acts as a "This button has been selected!" notifier
                if (bckgroundColor.Background.ToString() == Brushes.Blue.ToString())
                {
                    cmdUpdateSeats(iFlight_ID);
                    bckgroundColor.Background = Brushes.Lime;

                    //if the button is blue, then the seat is available. Can't change a seat that doesn't have a person attached to it
                    cmdChangeSeat.IsEnabled = false;

                    //if the button is blue, then the seat is available. Can't delete a passenger that doesn't have a seat
                    cmdDeletePassenger.IsEnabled = false;
                }
                //if button clicked is red, change it to green - this acts as a "This button has been selected!" notifier
                if (CheckWhoIsSittingHere(bckgroundColor, sender))
                {
                    bckgroundColor.Background = Brushes.Lime;
                }
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }