Ejemplo n.º 1
0
        public ActionResult themsach(DoanquanlysachV3.Models.SACH sACH)
        {
            //if (ModelState.IsValid)
            //{
            //    Models.TACGIA tg = null;
            //    if (tg != null)
            //    {
            //        Session["DStacgia"] = tg;
            //        return RedirectToAction("IndexS");
            //    }
            //}
            if (ModelState.IsValid)
            {
                List <Models.TACGIA> ds = Session["DStacgia"] as List <Models.TACGIA>;
                //dc.TACGIAs.AddRange(ds);
                foreach (var item in ds)
                {
                    sACH.TACGIAs.Add(dc.TACGIAs.Find(item.MaTacGia));
                }
                dc.SACHes.Add(sACH);
                dc.SaveChanges();
                return(RedirectToAction("IndexS"));
            }
            ViewBag.DSnxb     = dc.NHAXUATBANs.ToList();
            ViewBag.DStheloai = dc.THELOAIs.ToList();
            //ViewBag.DStacgia = new SelectList(dc.TACGIAs, "MaTacGia", "TenTacGia");
            ViewBag.DStacgia = dc.TACGIAs.ToList();
            return(View("Formthemsach"));
            //return RedirectToAction("IndexS");


            //dc.SaveChanges();

            //return RedirectToAction("IndexS");
        }
Ejemplo n.º 2
0
 public ActionResult Formsuasach(string id)
 {
     DoanquanlysachV3.Models.SACH sACH = dc.SACHes.Find(id);
     if (sACH != null)
     {
         ViewBag.DSnxb     = dc.NHAXUATBANs.ToList();
         ViewBag.DStheloai = dc.THELOAIs.ToList();
         ViewBag.DStacgia  = dc.TACGIAs.ToList();
         return(View(sACH));
     }
     return(RedirectToAction("IndexS"));
 }
Ejemplo n.º 3
0
 public ActionResult suasach(DoanquanlysachV3.Models.SACH sACH)
 {
     DoanquanlysachV3.Models.SACH aCH = dc.SACHes.Find(sACH.MaSach);
     if (ModelState.IsValid)
     {
         aCH.TenSach      = sACH.TenSach;
         aCH.MaTheLoai    = sACH.MaTheLoai;
         aCH.MaNhaXuatBan = sACH.MaNhaXuatBan;
         aCH.SoLuong      = sACH.SoLuong;
         dc.SaveChanges();
         return(RedirectToAction("IndexS"));
     }
     ViewBag.DSnxb     = dc.NHAXUATBANs.ToList();
     ViewBag.DStheloai = dc.THELOAIs.ToList();
     ViewBag.DStacgia  = dc.TACGIAs.ToList();
     return(View(sACH));
 }