public void submitRecipe(object sender, RoutedEventArgs e) { if (RecipeName.Text == "") { System.Console.WriteLine("submit failed"); return; } choiceArray = 2; m_recipe.Name = RecipeName.Text; m_recipe.Description = RecipeDescription.Text; Kitchen_Database.Add_RecipeToList(m_recipe); System.Console.WriteLine("Submit suceeded"); PageFinished(new object(), new EventArgs()); }
public void submitIngredient(object sender, RoutedEventArgs e) { if (IngredientNameToAdd.Text == "") { System.Console.WriteLine("submit failed"); return; } string name = IngredientNameToAdd.Text; string description = IngredientDescriptionToAdd.Text; string quantity = IngredientQuantityToAdd.Text; string measurementType = IngredientTypeToAdd.Text; Measurement newMeasurement = new Measurement(int.Parse(quantity), measurementType); Ingredient newIngredient = new Ingredient(newMeasurement, description, name); Kitchen_Database.Add_IngredientToInventory(newIngredient); System.Console.WriteLine("Submit suceeded"); PageFinished(new object(), new EventArgs()); }
private void Button_Click(object sender, RoutedEventArgs e) { Kitchen_Database.SaveData(); }
public void loadView() { stackPanel = new StackPanel(); List <Recipe> recipes = new List <Recipe>(); for (int i = 0; i < 7; i++) { Recipe bRecipe = mealWeek.getMeal(Meals.Breakfast, i); Recipe lRecipe = mealWeek.getMeal(Meals.Lunch, i); Recipe dRecipe = mealWeek.getMeal(Meals.Dinner, i); if (bRecipe.Name != "") { for (int x = 0; x < bRecipe.Ingredients.Count; x++) { float amount = Kitchen_Database.Use_IngredientInInventory(bRecipe.Ingredients[x]); if (amount < 0) { continue; } TextBlock textBlock = new TextBlock(); textBlock.Text = bRecipe.Ingredients[x].Name + " (" + amount.ToString() + " " + bRecipe.Ingredients[x].Amount.UnitsOfMeasurement + ")"; textBlock.Background = Brushes.Transparent; textBlock.FontWeight = FontWeights.Bold; stackPanel.Children.Add(textBlock); } } if (dRecipe.Name != "") { for (int x = 0; x < lRecipe.Ingredients.Count; x++) { float amount = Kitchen_Database.Use_IngredientInInventory(lRecipe.Ingredients[x]); if (amount < 0) { continue; } TextBlock textBlock = new TextBlock(); textBlock.Text = lRecipe.Ingredients[x].Name + " (" + amount.ToString() + " " + lRecipe.Ingredients[x].Amount.UnitsOfMeasurement + ")"; textBlock.Background = Brushes.Transparent; textBlock.FontWeight = FontWeights.Bold; stackPanel.Children.Add(textBlock); } } if (lRecipe.Name != "") { for (int x = 0; x < dRecipe.Ingredients.Count; x++) { float amount = Kitchen_Database.Use_IngredientInInventory(dRecipe.Ingredients[x]); if (amount < 0) { continue; } TextBlock textBlock = new TextBlock(); textBlock.Text = dRecipe.Ingredients[x].Name + " (" + amount.ToString() + " " + dRecipe.Ingredients[x].Amount.UnitsOfMeasurement + ")"; textBlock.Background = Brushes.Transparent; textBlock.FontWeight = FontWeights.Bold; stackPanel.Children.Add(textBlock); } } } Border border = new Border(); border.Background = Brushes.GhostWhite; border.BorderBrush = Brushes.Gainsboro; border.BorderThickness = new Thickness(1); border.Margin = new Thickness(0, 0, 10, 0); border.Child = stackPanel; Grid.SetColumn(border, 1); Grid.SetRow(border, 4); TheGrid.Children.Add(border); }