private void LoadAllIngredients() { IngredientDAO dao = new IngredientDAO(); DataTable dtIngredient = new DataTable(); dtIngredient.Columns.Add("IngredientID"); dtIngredient.Columns.Add("IngredientName"); dtIngredient.Columns.Add("Amount"); dtIngredient.Columns.Add("Note"); for (int i = 0; i < recipeIngredients.Count; i++) { DataRow dr = dtIngredient.NewRow(); dr["IngredientID"] = recipeIngredients[i].IngredientID; dr["IngredientName"] = dao.GetIngredientNameByID(recipeIngredients[i].IngredientID); dr["Amount"] = recipeIngredients[i].AmountIngredient; dr["Note"] = recipeIngredients[i].Note; dtIngredient.Rows.Add(dr); } txtIngredient.DataBindings.Clear(); txtIngredientAmount.DataBindings.Clear(); txtNote.DataBindings.Clear(); txtIngredient.DataBindings.Add("Text", dtIngredient, "IngredientName"); txtIngredientAmount.DataBindings.Add("Text", dtIngredient, "Amount"); txtNote.DataBindings.Add("Text", dtIngredient, "Note"); dgvIngredientDetail.DataSource = dtIngredient; }
private void btnUpdateIngre_Click(object sender, EventArgs e) { IngredientDAO dao = new IngredientDAO(); string name = txtIngredient.Text; int id = dao.GetIngredientIDByName(name); string amount = txtIngredientAmount.Text; string note = txtNote.Text; if (id > 0) { if (string.IsNullOrWhiteSpace(amount)) { errProvider.SetError(txtIngredientAmount, "Amount must not be blank."); } else { RecipeIngredient ingredient = new RecipeIngredient(id, amount, note); for (int i = 0; i < recipeIngredients.Count; i++) { if (recipeIngredients[i].Equals(ingredient)) { recipeIngredients[i] = ingredient; break; } } LoadAllIngredients(); //clear ingredient field only } } else { MessageBox.Show("Invalid ingredient"); } }
private void btnDeleteIngre_Click(object sender, EventArgs e) { IngredientDAO dao = new IngredientDAO(); string name = txtIngredient.Text; int id = dao.GetIngredientIDByName(name); if (id > 0) { RecipeIngredient ingredient = new RecipeIngredient(id, null, null); for (int i = 0; i < recipeIngredients.Count; i++) { if (recipeIngredients[i].Equals(ingredient)) { recipeIngredients.RemoveAt(i); break; } } LoadAllIngredients(); //clear ingredient field only } else { MessageBox.Show("Invalid ingredient"); } }
public InformationWareHouse() { this._ingredientDAO = (IngredientDAO) new IngredientDAOImpl(); this._supplierDAO = (SupplierDAO) new SupplierDAOImpl(); this._receiptDAO = (ReceiptDAO) new ReceiptDAOImpl(); this._receiptDetailDAO = (ReceiptDetailDAO) new ReceiptDetailDAOImpl(); }
// GET: Ingredients public ActionResult Index() { var ingredientDbInterface = new IngredientDAO(); var allIngredients = ingredientDbInterface.FetchAllIngredients(); return(View("IngredientIndex", allIngredients)); }
public ActionResult ProcessIngredientToCreate(Ingredient ingredientToAddToDb) { var ingredientDbInterface = new IngredientDAO(); ingredientDbInterface.AddIngredientToDb(ingredientToAddToDb); var allIngredients = ingredientDbInterface.FetchAllIngredients(); return(View("IngredientIndex", allIngredients)); }
public InformationBatender() { this._orderDAO = (OrderDAO) new OrderDAOImpl(); this._orderItemDAO = (OrderItemDAO) new OrderItemDAOImpl(); this._recipeDAO = (RecipeDAO) new RecipeDAOImpl(); this._recipeDetailDAO = (RecipeDetailDAO) new RecipeDetailDAOImpl(); this._foodAndDrinkDAO = (FoodAndDrinkDAO) new FoodAndDrinkDAOImpl(); this._ingredientDAO = (IngredientDAO) new IngredientDAOImpl(); this._ingredientMessageDAO = (IngredientMessageDAO) new IngredientMessageDAOImpl(); this._ingreExchangeDAO = (IngreExchangeDAO) new IngreExchangeDAOImpl(); }
private void LoadIngredientsAutoComplete() { IngredientDAO dao = new IngredientDAO(); ingredients = dao.GetAllIngredients(); AutoCompleteStringCollection collection = new AutoCompleteStringCollection(); foreach (Ingredient ingredient in ingredients) { collection.Add(ingredient.Name); } txtIngredient.AutoCompleteCustomSource = collection; }
private void btnAddIngre_Click(object sender, EventArgs e) { IngredientDAO dao = new IngredientDAO(); string name = txtIngredient.Text; int id = dao.GetIngredientIDByName(name); string amount = txtIngredientAmount.Text; string note = txtNote.Text; if (id > 0) { if (string.IsNullOrWhiteSpace(amount)) { errProvider.SetError(txtIngredientAmount, "Amount must not be blank."); } else { errProvider.SetError(txtIngredientAmount, ""); RecipeIngredient ingredient = new RecipeIngredient(id, amount, note); if (recipeIngredients.Contains(ingredient)) { //Neu trong list da co ingredient roi thi chi duoc update hoac delete MessageBox.Show(name + " has already existed. You can only update or delete it"); } else { recipeIngredients.Add(ingredient); LoadAllIngredients(); //clear ingredient field only } } } else { MessageBox.Show("Invalid ingredient"); } }
public ViewRecipePanel(Recipe recipe, User user) { this.user = user; InitializeComponent(); this.Dock = DockStyle.Fill; this.recipe = recipe; this.lblTitle.Text = recipe.Title; // This will get the current WORKING directory (i.e. \bin\Debug) string workingDirectory = AppDomain.CurrentDomain.BaseDirectory; // This will get the current PROJECT directory string projectDirectory = Directory.GetParent(workingDirectory).Parent.Parent.FullName; String path = projectDirectory + @"\resources\" + recipe.Image; this.imgRecipe.ImageLocation = path; // get all ingredients and render on view IngredientDAO dao = new IngredientDAO(); this.recipe.Ingredients = dao.GetAllIngredientsByRecipe(recipe); lblDetails.Text = "<h3>Ingredients</h3>" + RenderIngredients(); // get all steps and render on view this.recipe.RecipeSteps = RecipeStepDAO.GetRecipeStepsByRecipe(recipe); lblDetails.Text += "<h3>Steps</h3><div style='width: 780px;'>" + RenderSteps() + "</div>"; // add update button if (!this.User.Email.Equals(recipe.Email)) { controlPanel.Hide(); } }
private void frmDishNutritionCalculation_Load(object sender, EventArgs e) { if (dishDetails == null || dishDetails.Count() <= 0) { } else { labError.Text = ""; ingredient.IngredientID = 0; ingredient.Name = "ingredientTotal"; ingredient.IngredientTypeID = 0; ingredient.Unit = ""; ingredient.Kcal = 0; ingredient.Protein = 0; ingredient.Fat = 0; ingredient.Glucose = 0; ingredient.Fiber = 0; ingredient.Canxi = 0; ingredient.Iron = 0; ingredient.Photpho = 0; ingredient.Kali = 0; ingredient.Natri = 0; ingredient.VitaminA = 0; ingredient.VitaminB1 = 0; ingredient.VitaminC = 0; ingredient.AxitFolic = 0; ingredient.Cholesterol = 0; ingredient.Status = true; foreach (DataConnect.DishDetail item in dishDetails) { DataConnect.Ingredient res = new IngredientDAO().GetByID(item.IngredientID); ingredient.Unit = ""; ingredient.Kcal += res.Kcal * item.QuantiyOfUnit; ingredient.Protein += res.Protein * item.QuantiyOfUnit; ingredient.Fat += res.Fat * item.QuantiyOfUnit; ingredient.Glucose += res.Glucose * item.QuantiyOfUnit; ingredient.Fiber += res.Fiber * item.QuantiyOfUnit; ingredient.Canxi += res.Canxi * item.QuantiyOfUnit; ingredient.Iron += res.Iron * item.QuantiyOfUnit; ingredient.Photpho += res.Photpho * item.QuantiyOfUnit; ingredient.Kali += res.Kali * item.QuantiyOfUnit; ingredient.Natri += res.Natri * item.QuantiyOfUnit; ingredient.VitaminA += res.VitaminA * item.QuantiyOfUnit; ingredient.VitaminB1 += res.VitaminB1 * item.QuantiyOfUnit; ingredient.VitaminC += res.VitaminC * item.QuantiyOfUnit; ingredient.AxitFolic += res.AxitFolic * item.QuantiyOfUnit; ingredient.Cholesterol += res.Cholesterol * item.QuantiyOfUnit; } txtKcal.Text = ingredient.Kcal.ToString(); txtProtein.Text = ingredient.Protein.ToString(); txtFat.Text = ingredient.Fat.ToString(); txtGlucose.Text = ingredient.Glucose.ToString(); txtFiber.Text = ingredient.Fiber.ToString(); txtCanxi.Text = ingredient.Canxi.ToString(); txtIron.Text = ingredient.Iron.ToString(); txtPhotpho.Text = ingredient.Photpho.ToString(); txtKali.Text = ingredient.Kali.ToString(); txtNatri.Text = ingredient.Natri.ToString(); txtVitaminA.Text = ingredient.VitaminA.ToString(); txtVitaminB1.Text = ingredient.VitaminB1.ToString(); txtVitaminC.Text = ingredient.VitaminC.ToString(); txtAxitFolic.Text = ingredient.AxitFolic.ToString(); txtCholesterol.Text = ingredient.Cholesterol.ToString(); SetChartNutrition(); } }