Ejemplo n.º 1
0
 private void buttonPurchase_Click(object sender, EventArgs e)
 {
     if (clickTicket < totalTickets)
     {
         MessageBox.Show("Select remain seat");
     }
     else
     {
         FileHandle obj1 = new FileHandle();
         obj1.seatFill(flightName, seatNumber);
         obj1.storeInfo(seat, totalCost, flightName);
         DataBase DB = new DataBase();
         if (flightName != null)
         {
             DB.update(flightName, totalseat - totalTickets, cabin);
             DB.ticketManegment();
             PrintTicket print = new PrintTicket();
             this.Hide();
             print.ShowDialog();
             this.Close();
         }
     }
 }
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            //DataBase Db = new DataBase();

            bool flag = false;

            if (textBoxName.Text == "" || textBoxCO.Text == "")
            {
                MessageBox.Show("Name or CareOf is empty");
                flag = true;
            }

            if (comboBoxFrom.Text == comboBoxTo.Text)
            {
                MessageBox.Show("Arriaval and Destination is same");
                flag = true;
            }
            else if (comboBoxFrom.Text == "" || comboBoxTo.Text == "")
            {
                MessageBox.Show("Select Arriaval and Destination");
                flag = true;
            }
            int adult    = 0;
            int children = 0;
            int infants  = 0;

            if (sourcePath == null)
            {
                MessageBox.Show("Picture is empty");
                flag = true;
            }
            if (comboBoxAdult.Text == "" || comboBoxChildren.Text == "" || comboBoxInfants.Text == "")
            {
                MessageBox.Show("Select The Number of Tickets");
                flag = true;
            }

            else if (comboBoxAdult.Text == "More" && comboBoxChildren.Text != "More" && comboBoxInfants.Text != "More")
            {
                try
                {
                    adult    = Int32.Parse(textBoxAdult.Text);
                    children = Int32.Parse(comboBoxChildren.Text);
                    infants  = Int32.Parse(comboBoxInfants.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid Number Format");
                    flag = true;
                }
            }
            else if (comboBoxAdult.Text == "More" && comboBoxChildren.Text == "More" && comboBoxInfants.Text != "More")
            {
                try
                {
                    adult    = Int32.Parse(textBoxAdult.Text);
                    children = Int32.Parse(textBoxChildren.Text);
                    infants  = Int32.Parse(comboBoxInfants.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid Number Format");
                    flag = true;
                }
            }
            else if (comboBoxAdult.Text == "More" && comboBoxChildren.Text == "More" && comboBoxInfants.Text == "More")
            {
                try
                {
                    adult    = Int32.Parse(textBoxAdult.Text);
                    children = Int32.Parse(textBoxChildren.Text);
                    infants  = Int32.Parse(textBoxInfants.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid Number Format");
                    flag = true;
                }
            }
            else if (comboBoxAdult.Text == "More" && comboBoxChildren.Text != "More" && comboBoxInfants.Text == "More")
            {
                try
                {
                    adult    = Int32.Parse(textBoxAdult.Text);
                    children = Int32.Parse(comboBoxChildren.Text);
                    infants  = Int32.Parse(textBoxInfants.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid Number Format");
                    flag = true;
                }
            }
            else if (comboBoxAdult.Text != "More" && comboBoxChildren.Text == "More" && comboBoxInfants.Text == "More")
            {
                try
                {
                    adult    = Int32.Parse(comboBoxAdult.Text);
                    children = Int32.Parse(textBoxChildren.Text);
                    infants  = Int32.Parse(textBoxInfants.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid Number Format");
                    flag = true;
                }
            }
            else if (comboBoxAdult.Text != "More" && comboBoxChildren.Text != "More" && comboBoxInfants.Text == "More")
            {
                try
                {
                    adult    = Int32.Parse(comboBoxAdult.Text);
                    children = Int32.Parse(comboBoxChildren.Text);
                    infants  = Int32.Parse(textBoxInfants.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid Number Format");
                    flag = true;
                }
            }
            else if (comboBoxAdult.Text != "More" && comboBoxChildren.Text == "More" && comboBoxInfants.Text != "More")
            {
                try
                {
                    adult    = Int32.Parse(comboBoxAdult.Text);
                    children = Int32.Parse(textBoxChildren.Text);
                    infants  = Int32.Parse(comboBoxInfants.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid Number Format");
                    flag = true;
                }
            }

            else
            {
                try {
                    adult    = Int32.Parse(comboBoxAdult.Text);
                    children = Int32.Parse(comboBoxChildren.Text);
                    infants  = Int32.Parse(comboBoxInfants.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid Number Format");
                    flag = true;
                }
            }
            if (flag == false)
            {
                if (comboBoxChoose.Text == "International")
                {
                    if (textBoxPassport.Text == "")
                    {
                        MessageBox.Show("Passport is empty");
                    }
                    else
                    {
                        SearchFlight flight = new SearchFlight(comboBoxFrom.Text, comboBoxTo.Text, dateTimePicker1.Value.ToString("yyyy-MM-dd"), comboBoxSelectCabin.Text);
                        flight.totalTickets = adult + children + infants;
                        flight.adult        = adult;
                        flight.children     = children;
                        flight.infants      = infants;
                        flight.Name         = textBoxName.Text;
                        flight.CO           = textBoxCO.Text;

                        flight.passport = textBoxPassport.Text;
                        flight.flight1  = comboBoxChoose.Text;
                        flight.sfrom    = comboBoxFrom.Text;
                        flight.sto      = comboBoxTo.Text;
                        flight.date     = dateTimePicker1.Text;
                        flight.cabin    = comboBoxSelectCabin.Text;
                        FileHandle obj1 = new FileHandle();
                        obj1.storeInfo(textBoxName.Text, textBoxCO.Text, comboBoxChoose.Text, textBoxPassport.Text, comboBoxFrom.Text, comboBoxTo.Text, dateTimePicker1.Text, sourcePath, comboBoxSelectCabin.Text, adult, children, infants);
                        this.Hide();
                        flight.ShowDialog();
                        this.Close();
                    }
                }
                else
                {
                    SearchFlight flight = new SearchFlight(comboBoxFrom.Text, comboBoxTo.Text, dateTimePicker1.Value.ToString("yyyy-MM-dd"), comboBoxSelectCabin.Text);
                    flight.totalTickets = adult + children + infants;
                    flight.adult        = adult;
                    flight.children     = children;
                    flight.infants      = infants;
                    flight.Name         = textBoxName.Text;
                    flight.CO           = textBoxCO.Text;

                    flight.passport = textBoxPassport.Text;
                    flight.flight1  = comboBoxChoose.Text;
                    flight.sfrom    = comboBoxFrom.Text;
                    flight.sto      = comboBoxTo.Text;
                    flight.date     = dateTimePicker1.Text;
                    flight.cabin    = comboBoxSelectCabin.Text;

                    FileHandle obj1 = new FileHandle();
                    obj1.storeInfo(textBoxName.Text, textBoxCO.Text, comboBoxChoose.Text, "N/A", comboBoxFrom.Text, comboBoxTo.Text, dateTimePicker1.Text, sourcePath, comboBoxSelectCabin.Text, adult, children, infants);

                    this.Hide();
                    flight.ShowDialog();
                    this.Close();
                }
            }
        }
Ejemplo n.º 3
0
        private void button1ViewSeat_Click(object sender, EventArgs e)
        {
            //DataGridViewRow row = this.dataGridView1.SelectedRows.;

            FileHandle    obj      = new FileHandle();
            bool          status   = obj.seatCheck(flightName);
            List <string> seatList = new List <string>();

            if (status == false)
            {
                MessageBox.Show("Error file Loading");
            }
            else
            {
                seatList.Clear();
                for (int k = 0; k < obj.seatList.Count; k++)
                {
                    seatList.Add(obj.seatList[k]);
                }
            }

            this.buttonPurchase.Show();


            if (cabin == "First Class")
            {
                for (int i = 0; i < seatList.Count; i++)
                {
                    if (buttonA1.Text == seatList[i])
                    {
                        buttonA1.BackColor = Color.Red;
                        seatPerClick[37]   = 4;
                    }
                    else if (buttonA2.Text == seatList[i])
                    {
                        buttonA2.BackColor = Color.Red;
                        seatPerClick[36]   = 4;
                    }
                    else if (buttonB1.Text == seatList[i])
                    {
                        buttonB1.BackColor = Color.Red;
                        seatPerClick[35]   = 4;
                    }
                    else if (buttonB2.Text == seatList[i])
                    {
                        buttonB2.BackColor = Color.Red;
                        seatPerClick[34]   = 4;
                    }
                }
                tableLayoutPanelFirstClass.Show();
            }
            else if (cabin == "Business Class")
            {
                for (int i = 0; i < seatList.Count; i++)
                {
                    if (buttonA3.Text == seatList[i])
                    {
                        buttonA3.BackColor = Color.Red;
                        seatPerClick[0]    = 4;
                    }
                    else if (buttonA4.Text == seatList[i])
                    {
                        buttonA4.BackColor = Color.Red;
                        seatPerClick[1]    = 4;
                    }
                    else if (buttonA5.Text == seatList[i])
                    {
                        buttonA5.BackColor = Color.Red;
                        seatPerClick[2]    = 4;
                    }
                    else if (buttonA6.Text == seatList[i])
                    {
                        buttonA6.BackColor = Color.Red;
                        seatPerClick[3]    = 4;
                    }
                    else if (buttonA7.Text == seatList[i])
                    {
                        buttonA7.BackColor = Color.Red;
                        seatPerClick[9]    = 4;
                    }
                    else if (buttonB3.Text == seatList[i])
                    {
                        buttonB3.BackColor = Color.Red;
                        seatPerClick[4]    = 4;
                    }
                    else if (buttonB4.Text == seatList[i])
                    {
                        buttonB4.BackColor = Color.Red;
                        seatPerClick[5]    = 4;
                    }
                    else if (buttonB5.Text == seatList[i])
                    {
                        buttonB5.BackColor = Color.Red;
                        seatPerClick[6]    = 4;
                    }
                    else if (buttonB6.Text == seatList[i])
                    {
                        buttonB6.BackColor = Color.Red;
                        seatPerClick[7]    = 4;
                    }
                    else if (buttonB7.Text == seatList[i])
                    {
                        buttonB7.BackColor = Color.Red;
                        seatPerClick[8]    = 4;
                    }
                }
                tableLayoutPanelBusiness.Show();
            }
            else
            {
                for (int i = 0; i < seatList.Count; i++)
                {
                    if (buttonC1.Text == seatList[i])
                    {
                        buttonC1.BackColor = Color.Red;
                        seatPerClick[10]   = 4;
                    }
                    else if (buttonC2.Text == seatList[i])
                    {
                        buttonC2.BackColor = Color.Red;
                        seatPerClick[11]   = 4;
                    }
                    else if (buttonC3.Text == seatList[i])
                    {
                        buttonC3.BackColor = Color.Red;
                        seatPerClick[12]   = 4;
                    }
                    else if (buttonC4.Text == seatList[i])
                    {
                        buttonC4.BackColor = Color.Red;
                        seatPerClick[13]   = 4;
                    }
                    else if (buttonC5.Text == seatList[i])
                    {
                        buttonC5.BackColor = Color.Red;
                        seatPerClick[14]   = 4;
                    }
                    else if (buttonC6.Text == seatList[i])
                    {
                        buttonC6.BackColor = Color.Red;
                        seatPerClick[15]   = 4;
                    }
                    else if (buttonD1.Text == seatList[i])
                    {
                        buttonD1.BackColor = Color.Red;
                        seatPerClick[16]   = 4;
                    }
                    else if (buttonD2.Text == seatList[i])
                    {
                        buttonD2.BackColor = Color.Red;
                        seatPerClick[17]   = 4;
                    }
                    else if (buttonD3.Text == seatList[i])
                    {
                        buttonD3.BackColor = Color.Red;
                        seatPerClick[18]   = 4;
                    }
                    else if (buttonD4.Text == seatList[i])
                    {
                        buttonD4.BackColor = Color.Red;
                        seatPerClick[19]   = 4;
                    }
                    else if (buttonD5.Text == seatList[i])
                    {
                        buttonD5.BackColor = Color.Red;
                        seatPerClick[20]   = 4;
                    }
                    else if (buttonD6.Text == seatList[i])
                    {
                        buttonD6.BackColor = Color.Red;
                        seatPerClick[21]   = 4;
                    }
                    else if (buttonE1.Text == seatList[i])
                    {
                        buttonE1.BackColor = Color.Red;
                        seatPerClick[28]   = 4;
                    }
                    else if (buttonE2.Text == seatList[i])
                    {
                        buttonE2.BackColor = Color.Red;
                        seatPerClick[29]   = 4;
                    }
                    else if (buttonE3.Text == seatList[i])
                    {
                        buttonE3.BackColor = Color.Red;
                        seatPerClick[30]   = 4;
                    }
                    else if (buttonE4.Text == seatList[i])
                    {
                        buttonE4.BackColor = Color.Red;
                        seatPerClick[31]   = 4;
                    }
                    else if (buttonE5.Text == seatList[i])
                    {
                        buttonE5.BackColor = Color.Red;
                        seatPerClick[32]   = 4;
                    }
                    else if (buttonE6.Text == seatList[i])
                    {
                        buttonE6.BackColor = Color.Red;
                        seatPerClick[33]   = 4;
                    }
                    else if (buttonF1.Text == seatList[i])
                    {
                        buttonF1.BackColor = Color.Red;
                        seatPerClick[22]   = 4;
                    }
                    else if (buttonF2.Text == seatList[i])
                    {
                        buttonF2.BackColor = Color.Red;
                        seatPerClick[23]   = 4;
                    }
                    else if (buttonF3.Text == seatList[i])
                    {
                        buttonF3.BackColor = Color.Red;
                        seatPerClick[24]   = 4;
                    }
                    else if (buttonF4.Text == seatList[i])
                    {
                        buttonF4.BackColor = Color.Red;
                        seatPerClick[25]   = 4;
                    }
                    else if (buttonF5.Text == seatList[i])
                    {
                        buttonF5.BackColor = Color.Red;
                        seatPerClick[26]   = 4;
                    }
                    else if (buttonF6.Text == seatList[i])
                    {
                        buttonF6.BackColor = Color.Red;
                        seatPerClick[27]   = 4;
                    }
                }
                tableLayoutPanelEconomyClass.Show();
            }
        }