示例#1
0
        // Insert into the database a new ingredient (It's necessary that its fields are not null)
        public bool InsertIngredient(IngredientEN item)
        {
            bool añadido;

            SqlConnection con = new SqlConnection(db);
            string sql = "INSERT INTO Ingredient (Name,Description) VALUES (" + item.Name + "," + item.Description + ")";
            SqlCommand cmd = new SqlCommand(sql, con);

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                añadido = true;
            }
            catch (Exception ex)
            {
                añadido = false;
            }
            finally
            {
                con.Close();
            }

            return añadido;
        }
示例#2
0
        // Deletes the ingredient from the database that is passed by parameter
        public bool DeleteIngredient(IngredientEN item)
        {
            bool borrado;

            SqlConnection con = new SqlConnection(db);
            string sql = "DELETE FROM Ingredient WHERE Name = " + item.Name;
            SqlCommand cmd = new SqlCommand(sql, con);

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                borrado = true;
            }
            catch (Exception ex)
            {
                borrado = false;
            }
            finally
            {
                con.Close();
            }

            return borrado;
        }
示例#3
0
        /********************************/
        public int Quantity(IngredientEN ingredient)
        {
            int cantidad = 0;

            return cantidad;
        }
示例#4
0
        // Modify the description of an ingredient
        public void ModifyDescription(IngredientEN item, string description)
        {
            {
                SqlConnection con = new SqlConnection(db);
                string sql = "UPDATE Ingredient SET DATE = " + item.Name + ", DESCRIPTION = " + description + "WHERE Name = " + item.Name;
                SqlCommand cmd = new SqlCommand(sql, con);

                try
                {
                    con.Open();
                    cmd.ExecuteNonQuery();
                }
                catch { }
                finally
                {
                    con.Close();
                }
            }
        }
示例#5
0
        // Returns a list with the recipes that use this ingredient
        public List<RecipeEN> ListRecipes(IngredientEN ing)
        {
            List<RecipeEN> recetas = new List<RecipeEN>();

            return recetas;
        }
示例#6
0
        public int Quantity(RecipeEN recipe, IngredientEN ingredient)
        {
            int cantidad = 0;

            return cantidad;
        }
示例#7
0
 // Modify the description of an ingredient
 public void ModifyDescription(IngredientEN ing, string description)
 {
 }
示例#8
0
 // Insert into the database a new ingredient (It's necessary that its fields are not null)
 public void InsertIngredient(IngredientEN ing)
 {
 }
示例#9
0
 // Deletes the ingredient from the database that is passed by parameter
 public void DeleteIngredient(IngredientEN ing)
 {
 }