private void saveRecipeButton_Click(object sender, EventArgs e)
        {
            string successMessage = "Save successful!";
            string successTitle   = "Success!";
            string failedMessage  = "Save not completed. Missing recipe name or recipe ingredients";
            string failedTitle    = "Error";

            if (recipeNameTB.Text != "" && ingredients.Count != 0)
            {
                if (newRecipeDescriptionTB.Text != "")
                {
                    instructions = newRecipeDescriptionTB.Text;
                }
                else
                {
                    instructions = "";
                }
                recipe = new Recipe(recipeNameTB.Text, ingredients, instructions);
                user.addRecipe(recipe);
                newRecipeItemLB.Items.Clear();
                recipeNameTB.Clear();
                MessageBox.Show(successMessage, successTitle);

                if (cooked)
                {
                    CookedForm newForm = new CookedForm(user);
                    newForm.Show();
                }
            }
            else
            {
                MessageBox.Show(failedMessage, failedTitle);
            }
            this.Close();
        }
Esempio n. 2
0
        private void cookedButton_Click(object sender, EventArgs e)
        {
            /*
             * This section for what happens when the "I cooked something!" button is clicked.
             * Basically, if you make something that uses more than one ingredient,
             * you can click here to deduct entire recipes worth of ingredients at once.
             * The ingredients and amounts (servings/serving sizes) will then be deducted
             * from the master food list. Ex: PB&J
             */

            CookedForm cookedForm = new CookedForm(user); // Initialize new form

            cookedForm.Show();                            // Show the new form
            // Hide the current form
        }