예제 #1
0
 //method to edit a recipe ingredient
 private void btnAddrecipeEditRecipeIngredient_Click(object sender, RoutedEventArgs e)
 {
     //if the user has selected a recipe ingredient from the datagrid a new window will open with the information from ingredient user wants to edit
     if (dgRecipeIngredients.SelectedItem != null)
     {
         //calls method get recipeIngredient to set value of recipeIngredient
         RecipeIngredient      recipeIngredient = getRecipeIngredient(dgRecipeIngredients.SelectedItem);
         EditRecipeIngredients edit             = new EditRecipeIngredients(recipeIngredient);
         edit.ShowDialog();
         dgRecipeIngredients.ItemsSource = recipe.RecipeIngredients.Select(ingredient => new { ingredient.Id, ingredient.Quantity, ingredient.Measurement, Ingredient = ingredient.Ingredient.Name });
     }
     else
     {
         MessageBox.Show("Please select a ingredient to update.", "Edit Ingredient");
     }
 }
예제 #2
0
 //this button adds a recipe ingredient to the recipe ingredient datagrid and resets the text boxes
 private void btnAddRecipeIngredient_Click(object sender, RoutedEventArgs e)
 {
     if (txtRecipeIngredientQuantity.Text != "" && cbRecipeIngredientMeasurement.Text != "" && txtRecipeIngredientIngredient.Text != "")
     {
         RecipeIngredient recipeIngredient = new RecipeIngredient();
         recipeIngredient.Ingredient = new Ingredient()
         {
             Name = txtRecipeIngredientIngredient.Text
         };
         recipeIngredient.Recipe      = recipe;
         recipeIngredient.Quantity    = Convert.ToDouble(txtRecipeIngredientQuantity.Text);
         recipeIngredient.Measurement = cbRecipeIngredientMeasurement.Text;
         recipe.RecipeIngredients.Add(recipeIngredient);
         dgRecipeIngredients.ItemsSource    = recipe.RecipeIngredients.Select(ingredient => new { ingredient.Id, ingredient.Quantity, ingredient.Measurement, Ingredient = ingredient.Ingredient.Name });
         txtRecipeIngredientQuantity.Text   = "";
         txtRecipeIngredientIngredient.Text = "";
     }
     else
     {
         MessageBox.Show("Please fill in all ingredient fields.", "Add Ingredient");
     }
 }
예제 #3
0
 private void detach_RecipeIngredients(RecipeIngredient entity)
 {
     this.SendPropertyChanging();
     entity.Recipe = null;
 }
예제 #4
0
 partial void DeleteRecipeIngredient(RecipeIngredient instance);
예제 #5
0
 partial void UpdateRecipeIngredient(RecipeIngredient instance);
예제 #6
0
 partial void InsertRecipeIngredient(RecipeIngredient instance);
예제 #7
0
 private void attach_RecipeIngredients(RecipeIngredient entity)
 {
     this.SendPropertyChanging();
     entity.Ingredient = this;
 }