Пример #1
0
 public ActionResult Create(FormCollection collection,PLAN_TBL planModel)
 {
     try
     {
         using (DMSDbEntities db = new DMSDbEntities())
         {
             db.PLAN_TBL.Add(planModel);
             db.SaveChanges();
             return RedirectToAction("Index", db.PLAN_TBL.ToList());
         }
     }
     catch
     {
         return View();
     }
 }
Пример #2
0
        public ActionResult Edit(int id,PLAN_TBL planModel, FormCollection collection)
        {
            try
            {
                planModel.Plan_id = id;
                using (DMSDbEntities db = new DMSDbEntities())
                {
                    var entry = db.Entry<PLAN_TBL>(planModel);
                    if (entry.State.Equals(EntityState.Detached))
                    {
                        db.PLAN_TBL.Attach(planModel);
                    }
                    entry.State = EntityState.Modified;
                    db.SaveChanges();
                    return RedirectToAction("Index", db.PLAN_TBL.ToList());
                }


            }
            catch
            {
                return View();
            }
        }
Пример #3
0
 public ActionResult Delete(int id, PLAN_TBL planModel, FormCollection collection)
 {
     try
     {
         using (DMSDbEntities db = new DMSDbEntities())
         {
             planModel = db.PLAN_TBL.FirstOrDefault(p => p.Plan_id == id);
             var entry = db.Entry<PLAN_TBL>(planModel);
             entry.State = EntityState.Deleted;
             db.PLAN_TBL.ToList().RemoveAll(p => p.Plan_id == planModel.Plan_id);
             db.SaveChanges();
             return RedirectToAction("Index", db.PLAN_TBL.ToList());
         }
     }
     catch
     {
         return View();
     }
 }