Пример #1
0
        public ActionResult PlantGridViewPartialUpdate(HovisMillingPortal.Models.t_Milling_Plant item)
        {
            ViewBag.Sites = new SelectList(db.t_Milling_Site, "SiteRecid", "SiteDesc");
            var model = db.t_Milling_Plant;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.PlantRecid == item.PlantRecid);
                    if (modelItem != null)
                    {
                        this.UpdateModel(modelItem);
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            var Newmodel = db.t_Milling_Plant.ToList();

            return(PartialView("_PlantGridViewPartial", Newmodel));
        }
Пример #2
0
        public ActionResult PlantGridViewPartialAddNew(HovisMillingPortal.Models.t_Milling_Plant item)
        {
            ViewBag.Sites    = new SelectList(db.t_Milling_Site, "SiteRecid", "SiteDesc");
            ViewBag.Function = new SelectList(db.t_Milling_Function, "FuncRecid", "FuncDesc");
            var model = db.t_Milling_Plant;

            if (ModelState.IsValid)
            {
                try
                {
                    model.Add(item);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            var Newmodel = db.t_Milling_Plant.ToList();

            return(PartialView("_PlantGridViewPartial", Newmodel));
        }