Beispiel #1
0
        /// <summary>
        /// Seat button Calls the class Passenger Container that will save all the passengers in a list to use for the seat form.
        /// The seat form is created and Passenger's form is closed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void seat_button2_Click(object sender, EventArgs e)
        {
            //fill passenger list in class
            //PassengerContainer.loadPassengers(FlightP.getFlightNumber(), AccountP.getAccountID());
            PassengerContainer.loadPassengers(FlightP.getFlightNumber(), AccountP.getAccountID());
            Price.loadPrices(FlightP.getFlightNumber());
            Price.resetDiscount();
            Seating nfseat = new Seating();

            this.Close();
        }
        /// <summary>
        /// Saves the seat chosen by user to the corresponding passenger in the database.
        /// Removes passenger from passenger list and calls next passenger and
        /// if passenger list is empty the form opens the payment form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void seat_select_button_Click(object sender, EventArgs e)
        {
            if (select_count > 1)
            {
                MessageBox.Show(select_count.ToString() + " seats selected. Please select only one seat");
            }
            else
            {
                SQLConnection.Instance.OpenConnection();

                MySqlCommand seatCommand     = new MySqlCommand("UPDATE Seat Set Available = 1 where FlightID = '" + flightNumber + "' AND classSeat = '" + Seat.getClassSeat() + "' AND Row = '" + jlocation + "' AND selectSeat = '" + ilocation + "';", SQLConnection.Instance.GetConnection());
                MySqlCommand findseatCommand = new MySqlCommand("select SeatID from Seat where FlightID = '" + flightNumber + "' AND classSeat = '" + Seat.getClassSeat() + "' AND Row = '" + jlocation + "' AND selectSeat = '" + ilocation + "';", SQLConnection.Instance.GetConnection());

                seatCommand.ExecuteNonQuery();
                Seat.setSeatPassenger(Convert.ToInt32(findseatCommand.ExecuteScalar()));

                //passengerID carrier //check
                MySqlCommand passengerEnter = new MySqlCommand("UPDATE Passenger Set SeatID = '" + Seat.getSeatPassenger() + "'  where PassengerID = '" + PassengerID + "';", SQLConnection.Instance.GetConnection());
                passengerEnter.ExecuteNonQuery();

                //class into passenger table
                MySqlCommand passengerClass = new MySqlCommand("UPDATE Passenger Set Class = '" + Seat.getClassSeat() + "'  where PassengerID = '" + PassengerID + "';", SQLConnection.Instance.GetConnection());
                passengerClass.ExecuteNonQuery();

                SQLConnection.Instance.CloseConnection();

                //MessageBox.Show("Seat Reserved on Row: " + jlocation.ToString() + " Column: " + ilocation.ToString() + " SeatID: " + Seat.getSeatPassenger() + " For Passenger: " + PassengerContainer.getPassengerID());

                //testing this
                PassengerContainer.removePassengers();

                if (!PassengerContainer.emptyPassenger())
                {
                    this.Close();
                    Seating nextperson = new Seating();
                }
                else
                {
                    this.Close();
                    Payment payhere = new Payment();
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int seatID = Seat.randomSeat(Seat.getClassSeat(), airplaneTotaSeats, flightNumber);

            SQLConnection.Instance.OpenConnection();

            MySqlCommand seatCommand = new MySqlCommand("UPDATE Seat Set Available = 1 where SeatID = '" + seatID + "';", SQLConnection.Instance.GetConnection());

            //MySqlCommand findseatCommand = new MySqlCommand("select SeatID from Seat where FlightID = '" + FlightP.getFlightNumber() + "' AND classSeat = '" + Seat.getClassSeat() + "' AND Row = '" + jlocation + "' AND selectSeat = '" + ilocation + "';", SQLConnection.Instance.GetConnection());
            seatCommand.ExecuteNonQuery();
            //Seat.setSeatPassenger(Convert.ToInt32(findseatCommand.ExecuteScalar()));
            //Seat.setSeatPassenger(seatID);

            //passengerID carrier //check
            MySqlCommand passengerEnter = new MySqlCommand("UPDATE Passenger Set SeatID = '" + seatID + "'  where PassengerID = '" + PassengerID + "';", SQLConnection.Instance.GetConnection());

            passengerEnter.ExecuteNonQuery();

            //class into passenger table
            MySqlCommand passengerClass = new MySqlCommand("UPDATE Passenger Set Class = '" + Seat.getClassSeat() + "'  where PassengerID = '" + PassengerID + "';", SQLConnection.Instance.GetConnection());

            passengerClass.ExecuteNonQuery();

            SQLConnection.Instance.CloseConnection();

            Price.Discount();

            PassengerContainer.removePassengers();

            if (!PassengerContainer.emptyPassenger())
            {
                this.Close();
                Seating nextperson = new Seating();
            }
            else
            {
                this.Close();
                Payment payhere = new Payment();
            }
        }