public static void DB_deleteBarService(SomerenModel.BarService newBarSrvice) { // make a sql connection SqlConnection connection = openConnectionDB(); // the sql query for deleting data from DB string sqlQuery = "DELETE FROM BarService WHERE drink_id = @drink_id"; SqlCommand command = new SqlCommand(sqlQuery, connection); // execute queries command.Parameters.AddWithValue("@drink_id", newBarSrvice.getDrinkId()); command.ExecuteNonQuery(); // close the connection connection.Close(); }
public static void DB_uppdateBarService(SomerenModel.BarService newBarSrvice) { // make a sql connection SqlConnection connection = openConnectionDB(); // the sql query for updating data of the DB string sqlQuery = "UPDATE BarService SET drink_name = @drink_name, price = @price, stock_amount= @stock_amount WHERE drink_id = @drink_id "; SqlCommand command = new SqlCommand(sqlQuery, connection); // execute queries command.Parameters.AddWithValue("@drink_id", newBarSrvice.getDrinkId()); command.Parameters.AddWithValue("@drink_name", newBarSrvice.getDrinkName()); command.Parameters.AddWithValue("@price", newBarSrvice.getDrinkPrice()); command.Parameters.AddWithValue("@stock_amount", newBarSrvice.getStockAmount()); command.ExecuteNonQuery(); // close the connection connection.Close(); }