示例#1
0
        public ActionResult DeleteRule(int id)
        {
            try
            {
                loaivp vp = db.loaivps.SingleOrDefault(m => m.MaloaiVP == id);
                db.loaivps.DeleteOnSubmit(vp);
                db.SubmitChanges();
                TempData["message"] = "success";
            }
            catch (Exception ex)
            {
                TempData["message"] = "fail";
            }

            TempData["message2"] = "delete";
            return(RedirectToAction("Rule"));
        }
示例#2
0
        public ActionResult AddRule(loaivp vp)
        {
            if (Session["LoggedAD"] == null || Session["LoggedAD"].ToString() == "")
            {
                return(RedirectToAction("Login", "Admin"));
            }
            try
            {
                db.loaivps.InsertOnSubmit(vp);
                db.SubmitChanges();
                TempData["message"] = "success";
            }
            catch (Exception ex)
            {
                TempData["message"] = "fail";
            }

            TempData["message2"] = "add";
            return(RedirectToAction("Rule"));
        }
示例#3
0
 public ActionResult EditRule(loaivp vp)
 {
     if (Session["LoggedAD"] == null || Session["LoggedAD"].ToString() == "")
     {
         return(RedirectToAction("Login", "Admin"));
     }
     try
     {
         loaivp vpp = db.loaivps.SingleOrDefault(n => n.MaloaiVP == vp.MaloaiVP);
         vpp.TenloaiVP    = vp.TenloaiVP == null ? vpp.TenloaiVP: vp.TenloaiVP;
         vpp.Hinhthucxuly = vp.Hinhthucxuly == null ? vpp.Hinhthucxuly: vp.Hinhthucxuly;
         db.SubmitChanges();
         TempData["message"] = "success";
     }
     catch (Exception e)
     {
         TempData["message"] = "fail";
     }
     TempData["message2"] = "edit";
     return(RedirectToAction("Rule"));
 }