示例#1
0
 public ActionResult Create(PLCY_TBL policyModel,FormCollection collection)
 {
     try
     {
         using (DMSDbEntities db = new DMSDbEntities())
         {
             db.PLCY_TBL.Add(policyModel);
             db.SaveChanges();
             return RedirectToAction("Index",db.PLCY_TBL.ToList());
         }
     }
     catch
     {
         return View();
     }
 }
示例#2
0
        public ActionResult Edit(int id, PLCY_TBL policyModel, FormCollection collection)
        {
            try
            {
                policyModel.Plcy_id = id;
                using (DMSDbEntities db = new DMSDbEntities())
                {
                    var entry = db.Entry<PLCY_TBL>(policyModel);
                    if (entry.State.Equals(EntityState.Detached))
                    {
                        db.PLCY_TBL.Attach(policyModel);
                    }
                    entry.State = EntityState.Modified;
                    db.SaveChanges();
                    return RedirectToAction("Index",db.PLCY_TBL.ToList());
                }

                
            }
            catch
            {
                return View();
            }
        }
示例#3
0
 public ActionResult Delete(int id, PLCY_TBL policyModel, FormCollection collection)
 {
     try
     {
         using (DMSDbEntities db = new DMSDbEntities())
         {
             policyModel = db.PLCY_TBL.FirstOrDefault(p => p.Plcy_id == id);
             var entry = db.Entry<PLCY_TBL>(policyModel);
             entry.State = EntityState.Deleted;
             db.PLCY_TBL.ToList().RemoveAll(p => p.Plcy_id == policyModel.Plcy_id);
             db.SaveChanges();
             return RedirectToAction("Index",db.PLCY_TBL.ToList());
         }   
     }
     catch
     {
         return View();
     }
 }