public ActionResult DeleteConfirmed(int id)
        {
            rcp_ingredients_costsheet_child_t rcp_ingredients_costsheet_child_t = db.rcp_ingredients_costsheet_child_t.Find(id);

            db.rcp_ingredients_costsheet_child_t.Remove(rcp_ingredients_costsheet_child_t);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "id,rcp_ingredients_costsheet_id,ingredients_id,rct_ingredients_measurement_unit,rec_standard_cost,rec_standard_deviation_percentage")] rcp_ingredients_costsheet_child_t rcp_ingredients_costsheet_child_t)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rcp_ingredients_costsheet_child_t).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(rcp_ingredients_costsheet_child_t));
 }
        // GET: IngredientsCostsheet/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            rcp_ingredients_costsheet_child_t rcp_ingredients_costsheet_child_t = db.rcp_ingredients_costsheet_child_t.Find(id);

            if (rcp_ingredients_costsheet_child_t == null)
            {
                return(HttpNotFound());
            }
            return(View(rcp_ingredients_costsheet_child_t));
        }
示例#4
0
        public ActionResult Add(List <rcp_viewmodel> _rcp_Viewmodel, List <FormCollection> form)
        {
            try
            {
                rcp_viewmodel rcp_Viewmodel = new rcp_viewmodel();

                ViewBag.IngredieList = HomeBll.getIngredieList();
                ViewBag.UnitList     = HomeBll.getUnitList();

                rcp_Viewmodel.ingredieList = HomeBll.getIngredieList();
                rcp_Viewmodel.unitList     = HomeBll.getUnitList();


                string[] IngredieId = form[0]["ingredieList"].ToString().Split(',');
                string[] UnitID     = form[1]["UnitList"].ToString().Split(',');

                rcp_ingredients_costsheet_parent_t rcp_Ingredients_Costsheet_Parent_T = new rcp_ingredients_costsheet_parent_t();
                rcp_Ingredients_Costsheet_Parent_T.effective_from_date = _rcp_Viewmodel[0].fromDate;
                rcp_Ingredients_Costsheet_Parent_T.effective_to_date   = _rcp_Viewmodel[0].toDate;

                db.rcp_ingredients_costsheet_parent_t.Add(rcp_Ingredients_Costsheet_Parent_T);
                db.SaveChanges();

                int costsheet_id = HomeBll.get_ingredients_costsheet_id();
                for (int i = 0; i < 4; i++)
                {
                    if (!(HomeBll.isIngredientInserted(_rcp_Viewmodel[0].fromDate, _rcp_Viewmodel[0].toDate, Convert.ToInt32(IngredieId[i]))))
                    {
                        rcp_ingredients_costsheet_child_t rcp_Ingredients_Costsheet_Child_T = new rcp_ingredients_costsheet_child_t();
                        rcp_Ingredients_Costsheet_Child_T.ingredients_id = Convert.ToInt32(IngredieId[i]);
                        rcp_Ingredients_Costsheet_Child_T.rct_ingredients_measurement_unit = Convert.ToInt32(UnitID[i]);
                        rcp_Ingredients_Costsheet_Child_T.rcp_ingredients_costsheet_id     = costsheet_id;
                        rcp_Ingredients_Costsheet_Child_T.rec_standard_cost = _rcp_Viewmodel[i].price;
                        rcp_Ingredients_Costsheet_Child_T.rec_standard_deviation_percentage = _rcp_Viewmodel[i].deviation;
                        db.rcp_ingredients_costsheet_child_t.Add(rcp_Ingredients_Costsheet_Child_T);
                        db.SaveChanges();
                    }
                }
                TempData["Success"] = "Added Successfully!";
                return(RedirectToAction("Index", "IngredientsCostsheet"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }