/// <summary> /// btnAddRecipe click handler, calls the addRecipe form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddRecipe_Click(object sender, RoutedEventArgs e) { AddRecipe addRecipe = new AddRecipe(); addRecipe.ShowDialog(); refreshRecipies(); }
//opens the edit recipe window and allows user to edit the recipe before printing private void btnEdit_Click(object sender, RoutedEventArgs e) { AddRecipe addRecipe = new AddRecipe(recipe.RecipeId); addRecipe.labelNewRecipe.Content = "Edit Recipe"; addRecipe.Title = "Edit Recipe"; var result = addRecipe.ShowDialog(); //if user edits recipe the load recipe method is called so that the recipe will be updated in display window loadRecipe(recipe.RecipeId); }
/// <summary> /// btnUpdateRecipe click handler, calls the addRecipe form and passes the selected recipe ID to be updated /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdateRecipe_Click(object sender, RoutedEventArgs e) { if (dgRecipes.SelectedItem != null) { AddRecipe addRecipe = new AddRecipe((dgRecipes.SelectedItem as dynamic).RecipeId); addRecipe.labelNewRecipe.Content = "Edit Recipe"; addRecipe.Title = "Edit Recipe"; addRecipe.ShowDialog(); refreshRecipies(); } else { MessageBox.Show("Please select a recipe to update.", "Update Recipe"); } }
// method called when an item is selected from the Recipe Carousel and the user try to edit this item private void EditRecipeButton_Click(object sender, RoutedEventArgs e) { if (RecipesCarousel.SelectedItem != null) { AddRecipe addRecipe = new AddRecipe((RecipesCarousel.SelectedItem as MediaData).Id); addRecipe.labelNewRecipe.Content = "Edit Recipe"; addRecipe.Title = "Edit Recipe"; addRecipe.ShowDialog(); refreshRecipies(); } else { MessageBox.Show("Please select a recipe to update.", "Update Recipe"); } }