Exemplo n.º 1
0
        private void ButtonDelete_Click(object sender, RoutedEventArgs e)
        {
            Ingredient ingredientDelete = CheckNulls();

            try
            {
                //ingredient.IngredientId = Convert.ToInt32(txtingrid.Text);
                AdminIngredientBL ingredientValidations = new AdminIngredientBL();
                bool deleteresult = ingredientValidations.DeleteIngredient(ingredientDelete.IngredientId);
                if (deleteresult == true)                                                                   //
                {                                                                                           //
                    bool recipedeleted = ingredientValidations.DeleteIngredient(ingredientDelete.RecipeId); //
                    if (recipedeleted)                                                                      //
                    {
                        System.Windows.MessageBox.Show("Ingredient Deleted");                               //
                    }
                    else //
                    {
                        System.Windows.MessageBox.Show("Ingredient not Deleted");//
                    }
                }
                else
                {
                    System.Windows.MessageBox.Show("No Ingredient Available");//
                }
            }

            catch (RecipeIngredientSystemExceptions ex)     //
            {                                               //
                System.Windows.MessageBox.Show(ex.Message); //
            }//
        }
Exemplo n.º 2
0
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Ingredient ingredient = new Ingredient();
                ingredient = CheckNullsofAdd();
                // ingredient.IngredientId = Convert.ToInt32(txtingrid.Text);

                /*ingredient.RecipeId = Convert.ToInt32(txtrecid.Text);
                 * ingredient.Name = txtingrName.Text;
                 * ingredient.ManufacturerName = txtmanu.Text;
                 * ingredient.ManufacturerDate = Convert.ToDateTime(txtmanudate.DisplayDate);
                 * ingredient.ExpiryDate = Convert.ToDateTime(txtexpdate.DisplayDate);
                 * ingredient.Price = Convert.ToDecimal(txtprice.Text);
                 * ingredient.Description = txtdescrpt.Text;*/

                AdminIngredientBL ingredientValidations = new AdminIngredientBL();
                bool addresult = ingredientValidations.AddIngredient(ingredient);
                if (addresult)
                {
                    System.Windows.MessageBox.Show("Ingredient Added");
                }
                else
                {
                    System.Windows.MessageBox.Show("Ingredient Not Added");
                }
            }
            catch (RecipeIngredientSystemExceptions ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void ButtonModify_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Ingredient        ingredientUpdate      = CheckNulls();
                AdminIngredientBL ingredientValidations = new AdminIngredientBL();

                bool updateresult = ingredientValidations.ModifyIngredient(ingredientUpdate);
                if (updateresult)
                {
                    System.Windows.MessageBox.Show("Ingredient Updated");//
                }
                else
                {
                    System.Windows.MessageBox.Show("Ingredient Not Updated");
                }
            }
            catch (RecipeIngredientSystemExceptions ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 4
0
        private void ButtonSearch_Click(object sender, RoutedEventArgs e)
        {
            Ingredient ingredientSearch = CheckNulls();

            //ingredient.IngredientId = Convert.ToInt32(txtingrid.Text);
            try
            {
                AdminIngredientBL ingredientValidations = new AdminIngredientBL();
                Ingredient        searchingredient      = ingredientValidations.SearchIngredient(ingredientSearch.IngredientId);
                txtingrid.Text   = searchingredient.IngredientId.ToString();
                txtingrName.Text = searchingredient.Name;
                txtrecid.Text    = searchingredient.RecipeId.ToString();
                txtmanu.Text     = searchingredient.ManufacturerName;
                txtmanudate.Text = searchingredient.ManufacturerDate.ToString();
                txtexpdate.Text  = searchingredient.ExpiryDate.ToString();
                txtprice.Text    = searchingredient.Price.ToString();
                txtdescrpt.Text  = searchingredient.Description;
            }
            catch (RecipeIngredientSystemExceptions ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        private void ButtonList_Click(object sender, RoutedEventArgs e)
        {
            AdminIngredientBL ingredientValidations = new AdminIngredientBL();

            ingredientdata.ItemsSource = ingredientValidations.GetIngredient();
        }