Example #1
0
        public ActionResult XoaCTPhieumuon(int idPhieu, int idSach)
        {
            //CTPhieuMuon ctpms = data.CTPhieuMuons.SingleOrDefault(n => n.MaPhieuMuon == id);
            //CTPhieuMuon ctpms = data.CTPhieuMuons.Where(n => n.MaPhieuMuon == id).SingleOrDefault();

            CTPhieuMuon ctpms = data.CTPhieuMuons.Where(n => n.MaPhieuMuon == idPhieu && n.MaSach == idSach).SingleOrDefault();

            ViewBag.MaPhieuMuon = ctpms.MaPhieuMuon;
            if (ctpms == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(ctpms));
        }
Example #2
0
        public ActionResult XacnhanxoaCTPhieumuon(int idPhieu, int idSach)
        {
            //CTPhieuMuon ctpms = data.CTPhieuMuons.SingleOrDefault(n => n.MaPhieuMuon == id);

            CTPhieuMuon ctpms = data.CTPhieuMuons.Where(n => n.MaPhieuMuon == idPhieu && n.MaSach == idSach).SingleOrDefault();

            ViewBag.MaPhieuMuon = ctpms.MaPhieuMuon;
            if (ctpms == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            data.CTPhieuMuons.Remove(ctpms);
            data.SaveChanges();
            return(RedirectToAction("PhieuMuon"));
        }
Example #3
0
        public ActionResult DatPhieu(FormCollection collection)
        {
            PhieuMuonSach    pms          = new PhieuMuonSach();
            TheDocGia        kh           = (TheDocGia)Session["Taikhoan"];
            List <Phieumuon> lstPhieumuon = LayPhieumuon();

            pms.MaTheDocGia = kh.MaTheDocGia;
            pms.NgayMuon    = DateTime.Now;
            pms.NgayTra     = DateTime.Now.AddDays(7);
            data.PhieuMuonSaches.Add(pms);
            data.SaveChanges();
            foreach (var item in lstPhieumuon)
            {
                CTPhieuMuon ctpm = new CTPhieuMuon();
                ctpm.MaPhieuMuon = pms.MaPhieuMuon;
                ctpm.MaSach      = item.iMasach;
                ctpm.SoLuong     = item.iSoluong;
                data.CTPhieuMuons.Add(ctpm);
            }
            data.SaveChanges();
            Session["Phieumuon"] = null;
            return(RedirectToAction("XacnhanPhieumuon", "Phieumuon"));
        }