예제 #1
0
        public ActionResult SuaDMDonVi(int?MaDonVi)
        {
            DonViGN dv = db.DonViGNs.Find(MaDonVi);

            if (dv == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(dv));
        }
예제 #2
0
        public ActionResult SuaDMDonVi([Bind(Include = "MaDonVi,TenDonVi")] DonViGN donvi)
        {
            //Thêm vào cơ sở dữ liệu
            if (ModelState.IsValid)
            {
                db.Entry(donvi).State = EntityState.Modified;
                db.SaveChanges();
                Logging log = new Logging();
                log.SaveLog(donvi.TenDonVi + "-" + db.HanhDongs.Where(n => n.MaAction == 2).FirstOrDefault().TenAction, 2, int.Parse(Session["MaThanhVien"].ToString()));
                return(RedirectToAction("XemDMDonVi", "DanhMuc"));
            }


            return(View(donvi));
        }
예제 #3
0
 public ActionResult ThemDMDonVi(DonViGN donvi)
 {
     if (ModelState.IsValid)
     {
         var count = db.DonViGNs.Count(n => n.TenDonVi == donvi.TenDonVi);
         if (count == 0)
         {
             db.DonViGNs.Add(donvi);
             db.SaveChanges();
             Logging log = new Logging();
             log.SaveLog(donvi.TenDonVi + "-" + db.HanhDongs.Where(n => n.MaAction == 1).FirstOrDefault().TenAction, 1, int.Parse(Session["MaThanhVien"].ToString()));
             return(Redirect("../DanhMuc/XemDMDonVi"));
         }
         else
         {
             ViewBag.Message = 0;
         }
     }
     return(View(donvi));
 }