public ActionResult XacnhanxoaPL(int id)
        {
            var MaSP = (from sp in data.SANPHAMs
                        join cd in data.CHUDEs on sp.MaCD equals cd.MaCD
                        join pl in data.PHANLOAIs on cd.MaPL equals pl.MaPL
                        where pl.MaPL == id
                        select sp);

            foreach (var sp in MaSP)
            {
                data.SANPHAMs.DeleteOnSubmit(sp);
            }
            var MaCD = (from cd in data.CHUDEs
                        where cd.MaPL == id
                        select cd);

            foreach (var cd in MaCD)
            {
                data.CHUDEs.DeleteOnSubmit(cd);
            }
            PHANLOAI phanloai = data.PHANLOAIs.SingleOrDefault(n => n.MaPL == id);

            ViewBag.MaPL = phanloai.MaPL;
            if (phanloai == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            data.PHANLOAIs.DeleteOnSubmit(phanloai);
            data.SubmitChanges();
            return(RedirectToAction("Phanloai"));
        }
 public ActionResult ThemmoiPL(PHANLOAI phanloai)
 {
     if (ModelState.IsValid)
     {
         data.PHANLOAIs.InsertOnSubmit(phanloai);
         data.SubmitChanges();
     }
     return(View());
 }
        public ActionResult Suapl(PHANLOAI pl, FormCollection col)
        {
            PHANLOAI phloai = data.PHANLOAIs.SingleOrDefault(n => n.MaLoaiRuou == pl.MaLoaiRuou);

            phloai.Loairuou = col["Loairuou"];
            UpdateModel(phloai);
            data.SubmitChanges();
            return(RedirectToAction("Phanloai"));
        }
        public ActionResult themmoipl(PHANLOAI pl, FormCollection collection)
        {
            var loairuou = collection["Loairuou"];

            pl.Loairuou = loairuou;
            data.PHANLOAIs.InsertOnSubmit(pl);
            data.SubmitChanges();

            return(RedirectToAction("phanloai", "Admin"));
        }
 public ActionResult SuaPL(PHANLOAI phanloai)
 {
     if (ModelState.IsValid)
     {
         PHANLOAI pl = data.PHANLOAIs.SingleOrDefault(n => n.MaPL == phanloai.MaPL);
         pl.TenPL = phanloai.TenPL;
         UpdateModel(phanloai);
         data.SubmitChanges();
     }
     return(RedirectToAction("Chude"));
 }
 public int InserPhanLoaiSach(PHANLOAI entity)
 {
     try
     {
         db.PHANLOAIs.Add(entity);
         db.SaveChanges();
         return(1);
     }
     catch (Exception)
     {
         return(0);
     }
 }
        public ActionResult Xacnhanxoapl(int id)
        {
            PHANLOAI phanloai = data.PHANLOAIs.SingleOrDefault(n => n.MaLoaiRuou == id);

            ViewBag.MaPL = phanloai.MaLoaiRuou;
            if (phanloai == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            data.PHANLOAIs.DeleteOnSubmit(phanloai);
            data.SubmitChanges();
            return(RedirectToAction("phanloai", "Admin"));
        }
        public ActionResult SuaPL(int id)
        {
            if (Session["Taikhoanadmin"] == null || Session["Taikhoanadmin"].ToString() == "")
            {
                return(RedirectToAction("Login", "Admin"));
            }
            PHANLOAI phanloai = data.PHANLOAIs.SingleOrDefault(n => n.MaPL == id);

            ViewBag.MaPL = phanloai.MaPL;
            if (phanloai == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(phanloai));
        }
        public ActionResult Suapl(int id)
        {
            if (Session["Taikhoanadmin"] == null || Session["Taikhoanadmin"].ToString() == "")
            {
                return(RedirectToAction("Login"));
            }
            PHANLOAI pl = data.PHANLOAIs.SingleOrDefault(n => n.MaLoaiRuou == id);

            if (pl == null)
            {
                Response.StatusCode = 404;
                return(null);
            }

            return(View(pl));
        }
示例#10
0
 public int ThemPhanLoai(string idParent, string text)
 {
     try
     {
         string id = CreateIDPLAuto("PL");
         var    pl = new PHANLOAI()
         {
             MAPHANLOAI    = id,
             MAPHANLOAICHA = idParent,
             TENPHANLOAI   = text
         };
         db.PHANLOAIs.Add(pl);
         db.SaveChanges();
         return(1);
     }
     catch
     {
         return(0);
     }
 }