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 (); }