Ejemplo n.º 1
0
        private void search_query_button_Click(object sender, EventArgs e)
        {
            //some formatting to enter into query
            string date = DateTime.Parse(Depart_Date.Text).ToString("yyyy-MM-dd"); //shortens the selected date to date format in the database

            string Ainput  = Arrival_combobox.Text;
            string Aoutput = Ainput.Split(new char[] { '(', ')' })[1]; //retrieves airportID from string

            string Dinput  = Depart_combobox.Text;
            string Doutput = Dinput.Split(new char[] { '(', ')' })[1]; //retrieves airportID from string

            FlightP.setDepName(Doutput);                               //saves city names for use later
            FlightP.setArrName(Aoutput);

            SQLConnection.Instance.OpenConnection();

            //datagrid
            MySqlDataAdapter    dataAdapter     = new MySqlDataAdapter("select * from Flight where DepartID = '" + Doutput + "' and ArriveID = '" + Aoutput + "' and departDate = '" + date + "';", SQLConnection.Instance.GetConnection());
            MySqlCommandBuilder commandBuildder = new MySqlCommandBuilder(dataAdapter);
            DataSet             ds = new DataSet();

            dataAdapter.Fill(ds);
            result_datagrid.ReadOnly   = true;
            result_datagrid.DataSource = ds.Tables[0];

            SQLConnection.Instance.CloseConnection();

            SFlight.Enabled = true;
        }
Ejemplo n.º 2
0
 public void fillLabels()
 {
     reserve_textBox1.ReadOnly = true;
     reserve_textBox1.Text     = RandomStr();
     ticket                = reserve_textBox1.Text;
     flight_label.Text     = "From " + FlightP.getDepName() + " to " + FlightP.getArrName();
     reserve_label.Text   += AccountP.getAccountName();
     payment_textBox2.Text = "$ " + Price.getCharge().ToString();
 }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
        private void SFlight_Click(object sender, EventArgs e)
        {
            if (FlightP.getFlightNumber() == 0)
            {
                getFirst();
            }

            int newflight = FlightP.getFlightNumber();

            ReserveP.setFlightNumber(ReserveP.getTicketID());
            int oldflight = ReserveP.getFlightNumber();

            //MessageBox.Show("Selected: 3:" + newflight.ToString() + " Reservation: 1:" + oldflight.ToString());

            //keep user from entering same flight again
            if (newflight == oldflight)
            {
                MessageBox.Show("Please select a different flight.");
                Arrival_combobox.SelectedIndex = -1;
                Depart_Date.Value = System.DateTime.Now;
                int zero = 0;
                FlightP.setFlightNumber(zero);
            }
            else
            {
                // clear reservation seats from previous flight
                // load passengers to pick new seat on this flight

                clearSeats();
                PassengerInfo.loadPassengersReserve(ReserveP.getTicketID());
                Price.loadPrices(FlightP.getFlightNumber());
                Price.resetDiscount();
                Seating_Update newseats = new Seating_Update();
                this.Close();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Flight is click the flight number selected from the user is checked to see if it was saved.
        /// Checks to see if the passenger criteria is made accordingly like 1 adult should accompany a child
        /// or infant.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SFlight_Click(object sender, EventArgs e)
        {
            //only checks if person does not click on another flight and just presses select
            //this grabs the default selected flight to pass to passenger form
            if (FlightP.getFlightNumber() == 0)
            {
                getFirst();
            }

            //the following checks in case the user wants to fly with only one child or an infant without an adult
            string adultCheck = adult_comboBox1.Text;
            string childCheck = child_comboBox2.Text;

            if ((adultCheck == "0") || (string.IsNullOrEmpty(adultCheck)))
            {
                MessageBox.Show("Child or Infant must travel with one adult");
            }
            else if (((adultCheck == "0") && (childCheck == "0")) ||
                     ((adultCheck == "0") && (string.IsNullOrEmpty(childCheck))) ||
                     ((string.IsNullOrEmpty(adultCheck)) && (childCheck == "0")) ||
                     ((string.IsNullOrEmpty(adultCheck)) && (string.IsNullOrEmpty(childCheck))))
            {
                MessageBox.Show("Adult or Child must have atleast 1 passenger");
                adult_comboBox1.SelectedIndex = -1;
                child_comboBox2.SelectedIndex = -1;
            }
            else
            {
                getPassengers();
                this.Close();
                //MessageBox.Show(Start.flightNumber.ToString());
                Passenger passenger = new Passenger();
            }

            //MessageBox.Show(FlightP.getFlightNumber().ToString());
        }
Ejemplo n.º 6
0
 private void fillGrid()
 {
     PassengerContainer.loadPassengers(FlightP.getFlightNumber(), AccountP.getAccountID());
 }
Ejemplo n.º 7
0
        private void insertTicket()
        {
            //for all passengers you insert ticket number
            MySqlCommand saveReserve = new MySqlCommand("Update Passenger Set TicketID = '" + ticket + "' where FlightID = '" + FlightP.getFlightNumber() + "' and AccountID = '" + AccountP.getAccountID() + "';", SQLConnection.Instance.GetConnection());

            saveReserve.ExecuteNonQuery();
        }
Ejemplo n.º 8
0
        private void insertReserve()
        {
            //pass on further
            DateTime dateTime = DateTime.UtcNow.Date;
            string   today    = dateTime.ToString("d");
            string   date     = DateTime.Parse(today).ToString("yyyy-MM-dd");
            //Price.setPaymentID(AccountP.getAccountID());

            MySqlCommand reserveFlight = new MySqlCommand("insert into Reserve values('','" + date + "', '" + ticket + "', '" + AccountP.getAccountID() + "' , '" + Price.getPaymentID() + "', '" + FlightP.getFlightNumber() + "' );", SQLConnection.Instance.GetConnection());

            reserveFlight.ExecuteNonQuery();
        }
Ejemplo n.º 9
0
        public static int getNumberofRows(string section)
        {
            int    num;
            string sname = getClassName(section);

            SQLConnection.Instance.OpenConnection();
            MySqlCommand findRows = new MySqlCommand("select " + sname + " from Airplane where AirplaneID = '" + FlightP.getAirPlaneID() + "';", SQLConnection.Instance.GetConnection());

            num   = Convert.ToInt16(findRows.ExecuteScalar());
            total = num;
            num   = num / column;
            SQLConnection.Instance.CloseConnection();

            return(num);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Saves the user's payment information into the database.
        /// Closes the Form and goes to reservation form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void next_payment_button_Click(object sender, EventArgs e)
        {
            if (cardnum_textbox.ToString() == "")
            {
                MessageBox.Show("Please enter the last 4 digit of the card number");
            }
            else if (cardowner_textBox1.ToString() == "")
            {
                MessageBox.Show("Please enter the owner of the card");
            }
            else if (cvc_textbox.ToString() == "")
            {
                MessageBox.Show("Please enter the cvc");
            }
            else
            {
                if (cardnum_textbox.ToString().All(char.IsDigit) || cardnum_textbox.TextLength != 4)
                {
                    MessageBox.Show("Please enter a valid card owner");
                    cardnum_textbox.Text = "";
                }
                else if (cardowner_textBox1.ToString().All(char.IsLetter)) //PROBLEM. cardowner is allowing numbers
                {
                    MessageBox.Show("Please enter a correct card owner");
                    cardowner_textBox1.Text = "";
                }
                else if (cvc_textbox.ToString().All(char.IsDigit) || cvc_textbox.TextLength != 3)
                {
                    MessageBox.Show("Please enter a correct cvc");
                    cvc_textbox.Text = "";
                }
                else
                {
                    SQLConnection.Instance.OpenConnection();

                    string date = DateTime.Parse(carddateTimePicker1.Text).ToString("yyyy-MM-dd"); //shortens the selected date to date format in the database

                    MySqlCommand insertPayment = new MySqlCommand("insert into Fare values ('','" + totalPayment + "', '" + cardtype_comboBox1.Text + "', '" + cardnum_textbox.Text + "', '" + cardowner_textBox1.Text + "' , '" + date + "', '" + cvc_textbox.Text + "', '" + AccountP.getAccountID() + "', '" + FlightP.getFlightNumber() + "'); ", SQLConnection.Instance.GetConnection());
                    insertPayment.ExecuteNonQuery();

                    MySqlCommand findFareID = new MySqlCommand("Select FareID from Fare where Amount = '" + totalPayment + "' and FlightID = '" + FlightP.getFlightNumber() + "';", SQLConnection.Instance.GetConnection());

                    Price.setPaymentID(Convert.ToInt32(findFareID.ExecuteScalar()));
                    Price.setCharge(totalPayment);

                    SQLConnection.Instance.CloseConnection();

                    this.Close();
                    Reserve rs = new Reserve();
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Add Passenger button calls the query with the information provided by the user to add to database
        /// and calls clearboxes and fillform to prepare form for the next passenger(s).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (fname_textBox1.ToString() == "")
            {
                MessageBox.Show("Please enter a first name");
            }
            else if (lname_textBox3.ToString() == "")
            {
                MessageBox.Show("Please enter a last name");
            }
            else if (age_textBox1.ToString() == "")
            {
                MessageBox.Show("Please enter an age");
            }
            else
            {
                if (fname_textBox1.ToString().All(char.IsLetter))
                {
                    MessageBox.Show("Please enter a correct first name");
                    fname_textBox1.Text = "";
                }
                else if (lname_textBox3.ToString().All(char.IsLetter))
                {
                    MessageBox.Show("Please enter a correct last name");
                    lname_textBox3.Text = "";
                }
                else if (age_textBox1.ToString().All(char.IsDigit))
                {
                    MessageBox.Show("Error. Please enter an actual age");
                    age_textBox1.Text = "";
                }
                else
                {
                    SQLConnection.Instance.OpenConnection();

                    string date    = DateTime.Parse(birthDateCalender.Text).ToString("yyyy-MM-dd");
                    string agender = gender_comboBox2.Text.ToString();
                    char   letter  = agender[0];
                    string getAge  = age_textBox1.Text.ToString();
                    char   age     = getAge[0];

                    MySqlCommand SelectCommand = new MySqlCommand("insert into Passenger values('', '" + fname_textBox1.Text + "', '" + Mname_textBox2.Text + "', '" + lname_textBox3.Text + "', '" + age + "','" + letter + "' ,'" + date + "','', '" + AccountP.getAccountID() + "', '" + FlightP.getFlightNumber() + "', '', '' ); ", SQLConnection.Instance.GetConnection());

                    SelectCommand.ExecuteNonQuery();

                    SQLConnection.Instance.CloseConnection();

                    //clear
                    //load label second passenger until list empty
                    clearBoxes();
                    fillForm();
                }
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// function saves the flight the user clicked in the data grid.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void result_datagrid_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     //keeps track of the flight number to use later
     FlightP.setFlightNumber(Convert.ToInt16(result_datagrid.Rows[e.RowIndex].Cells[0].Value));
     FlightP.setAirPlaneID(Convert.ToInt16(result_datagrid.Rows[e.RowIndex].Cells[4].Value));
 }
Ejemplo n.º 13
0
 private void fillEmail()
 {
     FlightContainer.loadFlight(FlightP.getFlightNumber());
     SendEmail(Customer.getEmail());
 }
Ejemplo n.º 14
0
        private void next_payment_button_Click(object sender, EventArgs e)
        {
            int fareID = Price.getReserveFareID(ticket);

            SQLConnection.Instance.OpenConnection();

            MySqlCommand updateFare = new MySqlCommand("UPDATE Fare set Amount = '" + totalPayment + "' where FareID = '" + fareID + "';", SQLConnection.Instance.GetConnection());

            updateFare.ExecuteNonQuery();

            MySqlCommand updateReserve = new MySqlCommand("UPDATE Reserve set FlightID = '" + FlightP.getFlightNumber() + "' where ticketNo = '" + ticket + "';", SQLConnection.Instance.GetConnection());

            updateReserve.ExecuteNonQuery();

            SQLConnection.Instance.CloseConnection();

            fillEmail();
            MessageBox.Show("Email Confirmation of Flight Change will be shortly send");

            Account back = new Account();

            this.Close();
        }
Ejemplo n.º 15
0
        private void resetFlight()
        {
            int zero = 0;

            FlightP.setFlightNumber(zero);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Finds seats according to flight and seat class passed into the function.
        /// </summary>
        /// <param name="sc"></param>
        public static void loadSeats(string sc)
        {
            seatCount = 0;
            DataSet dsSeat = new DataSet();

            SQLConnection.Instance.OpenConnection();

            MySqlCommand     cmSeats = new MySqlCommand("select * from Seat where FlightID = '" + FlightP.getFlightNumber() + "' and classSeat = '" + sc + "'", SQLConnection.Instance.GetConnection());
            MySqlDataAdapter daSeats = new MySqlDataAdapter(cmSeats);

            daSeats.Fill(dsSeat);

            SQLConnection.Instance.CloseConnection();

            seatCount = dsSeat.Tables[0].Rows.Count;
            for (int i = 0; i < seatCount; i++)
            {
                seatObject[i] = new Seat();
                DataRow dataRow = dsSeat.Tables[0].Rows[i];
                seatObject[i].setSeatRow(Convert.ToChar(dataRow[3]));     //gets row letter (A) to char
                seatObject[i].setSeatNumber(Convert.ToInt32(dataRow[4])); //gets seatnumber
                seatObject[i].setAvailable(Convert.ToInt32(dataRow[5]));  //gets if seat taken 1 for taken 0 for available
            }
        }
Ejemplo n.º 17
0
 private void result_datagrid_CellClick_1(object sender, DataGridViewCellEventArgs e)
 {
     FlightP.setFlightNumber(Convert.ToInt32(result_datagrid.Rows[e.RowIndex].Cells[0].Value));
     FlightP.setAirPlaneID(Convert.ToInt32(result_datagrid.Rows[e.RowIndex].Cells[4].Value));
 }
Ejemplo n.º 18
0
 private void getFirst()
 {
     FlightP.setFlightNumber(Convert.ToInt32(result_datagrid.Rows[0].Cells[0].Value));
     FlightP.setAirPlaneID(Convert.ToInt32(result_datagrid.Rows[0].Cells[4].Value));
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Querys to find the amount of each type of passengers
        /// for example how many first class passengers were selected for the passenger
        /// in this specific flight
        /// </summary>
        private void getClass()
        {
            SQLConnection.Instance.OpenConnection();

            MySqlCommand findFirstClass    = new MySqlCommand("select count(Class) from Passenger where FlightID = '" + FlightP.getFlightNumber() + "' and AccountID = '" + AccountP.getAccountID() + "' and Class = 'F';", SQLConnection.Instance.GetConnection());
            MySqlCommand findBusinessClass = new MySqlCommand("select count(Class) from Passenger where FlightID = '" + FlightP.getFlightNumber() + "' and AccountID = '" + AccountP.getAccountID() + "' and Class = 'B';", SQLConnection.Instance.GetConnection());
            MySqlCommand findEconomicClass = new MySqlCommand("select count(Class) from Passenger where FlightID = '" + FlightP.getFlightNumber() + "' and AccountID = '" + AccountP.getAccountID() + "' and Class = 'E';", SQLConnection.Instance.GetConnection());

            FirstClassCount = Convert.ToInt32(findFirstClass.ExecuteScalar());
            BusinessCount   = Convert.ToInt32(findBusinessClass.ExecuteScalar());
            EconomicCount   = Convert.ToInt32(findEconomicClass.ExecuteScalar());

            SQLConnection.Instance.CloseConnection();
        }