private void addRecipeButton_Click(object sender, EventArgs e) { RecipeStep rs = new RecipeStep(); rs.Ingredients = new List <StepIngredient>(); rs.Step_order_no = (int)recipesNewSteps.Value; newRecipe.Steps.Add(rs); recipesNewSteps.Maximum = recipesNewSteps.Maximum + 1; recipesNewStepsCount.Text = recipesNewSteps.Maximum + ""; }
private void delRecipeButton_Click(object sender, EventArgs e) { if (recipesNewSteps.Value == 0) { return; } newRecipe.Steps.RemoveAt((int)recipesNewSteps.Value - 1); recipesNewSteps.Maximum = recipesNewSteps.Maximum - 1; recipesNewStepsCount.Text = recipesNewSteps.Maximum + ""; int newstep = (int)Math.Min(recipesNewSteps.Maximum, recipesNewSteps.Value); recipesNewSteps.Value = newstep; if (newstep > 0) { RecipeStep rs = newRecipe.Steps[newstep - 1]; recipesNewStepDescription.Text = rs.Description; recipesNewStepName.Text = rs.Name; recipesNewStepIngredients.Text = ""; foreach (StepIngredient ingrid in rs.Ingredients) { if (ingrid.Product == null) { continue; } recipesNewStepIngredients.Text += ingrid.Product.Name + " " + ingrid.Amount + "\n"; } recipesNewServings.Hide(); recipesNewServingsVal.Hide(); recipesNewTime.Hide(); recipesNewTimeVal.Hide(); recipesNewStepIngredients.Show(); recipesNewStepIngridLabel.Show(); } else { recipesNewStepDescription.Text = newRecipe.Description; recipesNewStepName.Text = newRecipe.Name; recipesNewServingsVal.Text = newRecipe.NumberOfServings + ""; recipesNewTimeVal.Text = newRecipe.MinutesToPrepare + ""; recipesNewServings.Show(); recipesNewServingsVal.Show(); recipesNewTime.Show(); recipesNewTimeVal.Show(); recipesNewStepIngredients.Hide(); recipesNewStepIngridLabel.Hide(); } }
private void recipesInfoSteps_ValueChanged(object sender, EventArgs e) { if (recipesDataGrid.CurrentRowIndex < 0 || recipesDataGrid.CurrentRowIndex >= dataManager.RecipesList.Recipes.Count) { } else { Recipe recipe = dataManager.RecipesList.Recipes[recipesDataGrid.CurrentRowIndex]; if (recipesInfoSteps.Value == 0) { recipesInfoStepDescription.Text = recipe.Description; recipesInfoStepName.Text = recipe.Name; recipesInfoServVal.Text = recipe.NumberOfServings + ""; recipesInfoTimeVal.Text = recipe.MinutesToPrepare + ""; recipesInfoServ.Show(); recipesInfoServVal.Show(); recipesInfoTime.Show(); recipesInfoTimeVal.Show(); recipesInfoStepIngredients.Hide(); recipesInfoIngridLabel.Hide(); } else { RecipeStep step = recipe.Steps[(int)recipesInfoSteps.Value - 1]; recipesInfoStepDescription.Text = step.Description; recipesInfoStepIngredients.Text = ""; foreach (StepIngredient ingrid in step.Ingredients) { Product p = dataManager.ProductsList.getById(ingrid.ProductId); if (p == null) { continue; } recipesInfoStepIngredients.Text += p.Name + " " + ingrid.Amount + "; "; } recipesInfoStepName.Text = step.Name; recipesInfoServ.Hide(); recipesInfoServVal.Hide(); recipesInfoTime.Hide(); recipesInfoTimeVal.Hide(); recipesInfoStepIngredients.Show(); recipesInfoIngridLabel.Show(); } } }
private void addRecipeButton_Click(object sender, EventArgs e) { RecipeStep rs = new RecipeStep(); rs.Ingredients = new List<StepIngredient>(); rs.Step_order_no = (int)recipesNewSteps.Value; newRecipe.Steps.Add(rs); recipesNewSteps.Maximum = recipesNewSteps.Maximum + 1; recipesNewStepsCount.Text = recipesNewSteps.Maximum+""; }
private void recipesNewSteps_ValueChanged(object sender, EventArgs e) { if (prev == 0) { newRecipe.Description = recipesNewStepDescription.Text; newRecipe.Name = recipesNewStepName.Text; try { newRecipe.NumberOfServings = decimal.Parse(recipesNewServingsVal.Text); newRecipe.MinutesToPrepare = decimal.Parse(recipesNewTimeVal.Text); } catch (Exception ee) { } } else { RecipeStep rs = newRecipe.Steps[prev - 1]; rs.Description = recipesNewStepDescription.Text; rs.Name = recipesNewStepName.Text; } if (recipesNewSteps.Value == 0) { recipesNewStepDescription.Text = newRecipe.Description; recipesNewStepName.Text = newRecipe.Name; recipesNewServingsVal.Text = newRecipe.NumberOfServings + ""; recipesNewTimeVal.Text = newRecipe.MinutesToPrepare + ""; recipesNewServings.Show(); recipesNewServingsVal.Show(); recipesNewTime.Show(); recipesNewTimeVal.Show(); recipesNewStepIngredients.Hide(); recipesNewStepIngridLabel.Hide(); } else { RecipeStep step = newRecipe.Steps[(int)recipesNewSteps.Value - 1]; recipesNewStepDescription.Text = step.Description; recipesNewStepName.Text = step.Name; recipesNewStepIngredients.Text = ""; foreach (StepIngredient ingrid in step.Ingredients) { if (ingrid.Product == null) { continue; } recipesNewStepIngredients.Text += ingrid.Product.Name + " " + ingrid.Amount + "\n"; } recipesNewServings.Hide(); recipesNewServingsVal.Hide(); recipesNewTime.Hide(); recipesNewTimeVal.Hide(); recipesNewStepIngredients.Show(); recipesNewStepIngridLabel.Show(); } prev = (int)recipesNewSteps.Value; }