示例#1
0
 private void ViewAllFlights_Load(object sender, EventArgs e)
 {
     //Select Quert to search all patients
     try
     {
         DataTable     flight_table = new DataTable();
         CRUDOperation crud         = new CRUDOperation();
         flight_table             = crud.getTable("SELECT * From flights");
         dataGridView1.DataSource = flight_table;
     }
     catch (Exception excep)
     {
         MessageBox.Show(excep.Message + " Sorry; Couldn't Search the Data");
     }
 }
        private void btn_SearchFight_Click(object sender, EventArgs e)
        {
            try
            {
                string query;

                if (comboBox5.Text == "ALL" || comboBox5.Text == "")
                {
                    query = "SELECT * From `flights` WHERE `fromcity` = '" + comboBox1.Text + "' AND  `tocity` = '" + comboBox2.Text + "' AND  `FlightDeparture` LIKE '%" + dateTimePicker1.Value.ToString().Split(' ')[0] + "%' AND  `FlightArrival` LIKE '%" + dateTimePicker2.Value.ToString().Split(' ')[0] + "%'";
                }
                else
                {
                    query = "SELECT * From `flights` WHERE `fromcity` = '" + comboBox1.Text + "' AND  `tocity` = '" + comboBox2.Text + "' AND  `FlightDeparture` LIKE '%" + dateTimePicker1.Value.ToString().Split(' ')[0] + "%' AND  `FlightArrival` LIKE '%" + dateTimePicker2.Value.ToString().Split(' ')[0] + "%' AND `FlightType` = '" + comboBox5.Text + "'";
                }
                DataTable     dtable = new DataTable();
                CRUDOperation crud   = new CRUDOperation();



                dtable = crud.getTable(query);
                dataGridView1.DataSource = dtable;
                DataGridViewButtonColumn btn = new DataGridViewButtonColumn();

                dataGridView1.Columns.Add(btn);
                btn.HeaderText = "Booking";
                btn.Text       = "Book Now";
                btn.Name       = "btn";

                //Button test = new Button();
                //dataGridView1.Columns["Booking"].c

                btn.UseColumnTextForButtonValue = true;
            }
            catch (Exception excep)
            {
                MessageBox.Show(excep.Message + " Sorry; Couldn't Search the Data");
            }


            //this.Hide();
            //FightsDetail Flightobj = new FightsDetail();
            //Flightobj.Show ();
        }
示例#3
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtbox_FlightName.Text != "")
                {
                    if (dateTimePicker1.Text != "" && dateTimePicker2.Text != "" && comboBox1.Text != "" && comboBox2.Text != "" && txtbox_Amount.Text != "" && comboBox3.Text != "")
                    {
                        if (comboBox1.Text != comboBox2.Text)
                        {
                            CRUDOperation.addFlightInsertion(txtbox_FlightName.Text, comboBox1.Text, comboBox2.Text, dateTimePicker2.Text, dateTimePicker1.Text, comboBox3.Text, Convert.ToInt32(txtbox_Amount.Text));
                            MessageBox.Show("Congrats. New flight has been added in system");

                            this.Hide();
                            AdminDashboard admindash = new AdminDashboard();
                            admindash.Show();
                        }
                        else
                        {
                            MessageBox.Show("Departure and Arrival flights can not be same");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Flight Date/time, Amount and Flight types details are required");
                    }
                }
                else
                {
                    MessageBox.Show("Enter PIA flight name");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " Error occurred");
            }
        }