public static void insertOrder(int chair, int table, int sofa, int totalsum) { using (MySqlConnection con = MySqlService.getConnection()) { try { con.Open(); AddBaldas(chair, table, sofa, totalsum, con); MessageBox.Show("Your order was placed"); } catch (Exception e) { MessageBox.Show("Unable to connect to MySql"); } } }
public static void insertOrder(int chair, int table, int sofa, int totalsum) { MySqlConnection con = MySqlService.getConnection(); con.Open(); MySqlCommand comm = con.CreateCommand(); comm.CommandText = "INSERT INTO uzsakymai(kedes,stalai,sofos,suma) VALUES(@kedes, @stalai, @sofos, @suma)"; comm.Parameters.AddWithValue("@kedes", chair); comm.Parameters.AddWithValue("@stalai", table); comm.Parameters.AddWithValue("@sofos", sofa); comm.Parameters.AddWithValue("@suma", totalsum); comm.ExecuteNonQuery(); con.Close(); }
public static List <Baldas> getBaldai() { using (MySqlConnection con = MySqlService.getConnection()) { using (MySqlCommand cmd = new MySqlCommand("select Pavadinimas, Kaina, Laikas from baldai", con)) { try { con.Open(); return(extractBaldai(cmd)); } catch (Exception e) { MessageBox.Show("Unable to connect to MySql"); List <Baldas> baldai = new List <Baldas>(); baldai.Add(new Baldas(Tipas.DESK, 10, 5)); baldai.Add(new Baldas(Tipas.CHAIR, 10, 5)); baldai.Add(new Baldas(Tipas.SOFA, 10, 5)); return(baldai); } } } }
public static DataTable getOrderTable() { using (MySqlConnection con = MySqlService.getConnection()) { try { con.Open(); MySqlDataAdapter MyDA = new MySqlDataAdapter(); string sqlSelectAll = "SELECT * from uzsakymai"; MyDA.SelectCommand = new MySqlCommand(sqlSelectAll, con); DataTable table = new DataTable(); MyDA.Fill(table); return(table); } catch (Exception e) { MessageBox.Show("Unable to connect to MySql"); return(new DataTable()); } } }