Пример #1
0
        public void saveIngredient(Ingredient Ing)
        {
            cmd.CommandText = "INSERT INTO ingredient(name, quantity, price, status)" +
                        " values(@name, @quantity, @price, @status)";
            cmd.Parameters.AddWithValue("@name", Ing.getName());
            cmd.Parameters.AddWithValue("@quantity", Ing.getQuantity());
            cmd.Parameters.AddWithValue("@price", Ing.getPrice());
            cmd.Parameters.AddWithValue("@status", Ing.getStatus());

            cmd.ExecuteNonQuery();
            conn.Close();
        }
Пример #2
0
        public void updateIngredient(Ingredient Ing)
        {
            cmd.CommandText = " UPDATE ingredient SET name = @name, quantity = @quantity, " +
                              " price= @price , status = @status " +
                              " where id = @id ";

            cmd.Parameters.AddWithValue("@name", Ing.getName());
            cmd.Parameters.AddWithValue("@quantity", Ing.getQuantity());
            cmd.Parameters.AddWithValue("@price", Ing.getPrice());
            cmd.Parameters.AddWithValue("@status", Ing.getStatus());
            cmd.Parameters.AddWithValue("@id", Ing.getId());

            cmd.ExecuteNonQuery();
            conn.Close();
        }