private void Create_Customer_Load(object sender, EventArgs e) { //Load the customer id // Random rnd = new Random(); // custid = rnd.Next(1, 100000); //load the aircraft list method with the data from mysql MySqlConnection connection = new MySqlConnection(connec); connection.Open(); string query3 = "SELECT Aircraft_Model, Aircraft_ID FROM btm495.aircrafts "; MySqlDataAdapter adapt = new MySqlDataAdapter(query3, connection); adapt.Fill(table); while (row < table.Rows.Count) { AircraftsDA air = new AircraftsDA(); air.Aircraft_id = Convert.ToInt32(table.Rows[row]["Aircraft_ID"]); air.Aircraft_model = (string)table.Rows[row]["Aircraft_Model"]; aircraft_list.Items.Add(air.Show_aircraft()); row += 1; } row = 0; connection.Close(); }
private void Modify_Products_Load_1(object sender, EventArgs e) { int chosenItem; chosenItem = Products.product; MySqlConnection connection2 = new MySqlConnection(connec); connection2.Open(); string queryProducts = "SELECT * FROM btm495.Products where Product_ID =" + chosenItem; MySqlCommand comm = new MySqlCommand(queryProducts, connection2); MySqlDataReader mdr; mdr = comm.ExecuteReader(); string type = "Flight Manual"; string airid, typetest; int aircraftid; if (mdr.Read()) { label3.Text = mdr.GetString("Product_id"); mProductNameTxt.Text = mdr.GetString("Product_name"); mProdPriceBtn.Text = mdr.GetDecimal("Product_price").ToString(); typetest = mdr.GetString("Product_type"); if (typetest.Contains(type)) { flightButton.Checked = true; } else { mtnButton.Checked = true; } aircraftid = mdr.GetInt32("Aircraft_id"); airid = Convert.ToString(aircraftid); MySqlConnection connection1 = new MySqlConnection(connec); connection1.Open(); string queryAircrafts = "SELECT * FROM btm495.Aircrafts"; MySqlCommand comm1 = connection1.CreateCommand(); comm1.CommandText = queryAircrafts; DataTable table1 = new DataTable(); MySqlDataAdapter adapt1 = new MySqlDataAdapter(queryAircrafts, connection1); adapt1.Fill(table1); int row1 = 0; while (row1 < table1.Rows.Count) { AircraftsDA air = new AircraftsDA(); air.Aircraft_id = Convert.ToInt32(table1.Rows[row1]["Aircraft_ID"]); air.Aircraft_model = (string)table1.Rows[row1]["Aircraft_Model"]; airCraftLB.Items.Add(air.Show_aircraftID() + ":" + " " + air.Show_aircraft()); row1 += 1; } airCraftLB.SelectedIndex = airCraftLB.FindString(airid); } }
private void Add_Products_Load(object sender, EventArgs e) { MySqlConnection connection = new MySqlConnection(connec); connection.Open(); string queryAircrafts = "SELECT * FROM btm495.Aircrafts"; MySqlCommand comm = connection.CreateCommand(); comm.CommandText = queryAircrafts; DataTable table = new DataTable(); MySqlDataAdapter adapt = new MySqlDataAdapter(queryAircrafts, connection); adapt.Fill(table); while (row < table.Rows.Count) { AircraftsDA air = new AircraftsDA(); air.Aircraft_id = Convert.ToInt32(table.Rows[row]["Aircraft_ID"]); air.Aircraft_model = (string)table.Rows[row]["Aircraft_Model"]; airCraftLB.Items.Add(air.Show_aircraftID() + ":" + " " + air.Show_aircraft()); row += 1; } }