private void ShowRecipeForm_Load(object sender, EventArgs e)
        {
            CurrRecipeId = RecipeMain.currRecipeId;
            Recipe currRecipe = RecipeDb.GetRecipe(CurrRecipeId);

            PopulateCurrentRecipe(currRecipe);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Refreshes the recipe combo box after the recipe has been added/deleted.
        /// </summary>

        private void RefreshBtn_Click(object sender, EventArgs e)
        {
            List <Recipe> allRecipes = RecipeDb.GetAllRecipes();

            PopulateRecipeList(allRecipes);
            MessageBox.Show("Recipe List has been refreshed!" + " Click the combo box to see your new recipes!" +
                            " If there were no new recipes added, then the list is already up to date, or you haven't made a new one yet!" +
                            " To do this, click the Add Recipe Button to fill out the form, then add it to the Recipe List by clicking the" +
                            " Add to Recipe Database Button!", "Recipe List Updated!");
        }
        /// <summary>
        /// When the user clicks this button, the recipe in the
        /// database gets updated with the new information.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditBtn_Click(object sender, EventArgs e)
        {
            Recipe tempRecipe = new Recipe();

            tempRecipe.RecipeId     = CurrRecipeId;
            tempRecipe.Title        = RecipeTitleTxt.Text;
            tempRecipe.TotalTime    = Convert.ToInt32(TotalTimeTxt.Text);
            tempRecipe.PrepTime     = Convert.ToInt32(TotalTimeTxt.Text);
            tempRecipe.Servings     = Convert.ToInt32(ServingsTxt.Text);
            tempRecipe.Ingredients  = IngredientsTxt.Text;
            tempRecipe.Instructions = InstructionsTxt.Text;
            RecipeDb.Update(tempRecipe);
            MessageBox.Show(tempRecipe.Title + " was updated!");
        }
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            CurrRecipeId = RecipeMain.currRecipeId;
            Recipe currRecipe = RecipeDb.GetRecipe(CurrRecipeId);

            const string message = "Do you want to delete this recipe?";
            var          caption = "Delete?";
            var          result  = MessageBox.Show(message, caption, MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                RecipeDb.Delete(currRecipe);
                Close();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// This method will add a recipe
        /// to the database when the "Add Recipe"
        /// button is clicked.
        /// </summary>
        private void AddRecipeBtn_Click(object sender, EventArgs e)
        {
            Recipe r = new Recipe()
            {
                Title        = RecipeTitleTxt.Text,
                TotalTime    = Convert.ToInt32(TotalTimeTxt.Text),
                PrepTime     = Convert.ToInt32(PrepTimeTxt.Text),
                Servings     = Convert.ToInt32(ServingsTxt.Text),
                Ingredients  = IngredientsTxt.Text,
                Instructions = InstructionsTxt.Text
            };

            RecipeDb.Add(r);
            ClearTextBoxes();
            MessageBox.Show(r.Title + " has been added!");
        }
Ejemplo n.º 6
0
        private void RecipeMain_Load(object sender, EventArgs e)
        {
            List <Recipe> allRecipes = RecipeDb.GetAllRecipes();

            PopulateRecipeList(allRecipes);
        }