示例#1
0
 public ActionResult Create(ROLE_TBL roleModel)
 {
     try
     {
         using (DMSDbEntities db = new DMSDbEntities())
         {
             db.ROLE_TBL.Add(roleModel);
             db.SaveChanges();
             return RedirectToAction("Index",db.ROLE_TBL.ToList());
         }                
     }
     catch
     {
         return View();
     }
 }
示例#2
0
 public ActionResult Edit(ROLE_TBL roleModel)
 {
     try
     {
         using (DMSDbEntities db = new DMSDbEntities())
         {
             var entry = db.Entry<ROLE_TBL>(roleModel);
             if (entry.State.Equals(EntityState.Detached))
             {
                 db.ROLE_TBL.Attach(roleModel);
             }
             entry.State = EntityState.Modified;
             db.SaveChanges();
             return RedirectToAction("Index", db.ROLE_TBL.ToList());
         }
     }
     catch (Exception ex)
     {
         return View(roleModel);
     }
 }
示例#3
0
 public ActionResult Delete(ROLE_TBL roleModel)
 {
     try
     {
         using (DMSDbEntities db = new DMSDbEntities())
         {
             var entry = db.Entry<ROLE_TBL>(roleModel);
             entry.State = EntityState.Deleted;
             db.ROLE_TBL.ToList().RemoveAll(p => p.ROLE_ID == roleModel.ROLE_ID);
             db.SaveChanges();
             return RedirectToAction("Index",db.ROLE_TBL.ToList());
         }
     }
     catch
     {
         return View();
     }
 }