Ejemplo n.º 1
0
        public ActionResult TaoPhieuNhap()
        {
            var       pn           = (PhieuNhapViewModel)Session["PhieuNhap"];
            PhieuNhap newPhieuNhap = new PhieuNhap();

            newPhieuNhap.UpdatePhieuNhap(pn);

            phieuNhapService.Add(newPhieuNhap);
            phieuNhapService.Save();

            foreach (var ctpn in (List <CtPhieuNhapViewModel>)Session["dsCtPhieuNhap"])
            {
                ctpn.IdPhieuNhap = newPhieuNhap.Id;
                CtPhieuNhap ctPhieuNhap = new CtPhieuNhap();
                ctPhieuNhap.UpdateCtPhieuNhap(ctpn);
                ctPhieuNhapService.Add(ctPhieuNhap);

                var sach = sachService.GetById(ctpn.IdSach);
                if (sach.GiaNhap != ctpn.DonGiaNhap)
                {
                    sach.GiaNhap = ctpn.DonGiaNhap;
                    sachService.Update(sach);
                }
            }
            phieuNhapService.Save();

            Session["dsCtPhieuNhap"] = null;
            Session["PhieuNhap"]     = null;
            Session.RemoveAll();

            TempData["Success"] = "Đã thêm mới một phiếu nhập.";
            return(Redirect("/phieu-nhap/"));
        }
Ejemplo n.º 2
0
 public static void UpdateCtPhieuNhap(this CtPhieuNhap ctPhieuNhap, CtPhieuNhapViewModel ctPhieuNhapVm)
 {
     ctPhieuNhap.Id          = ctPhieuNhapVm.Id;
     ctPhieuNhap.IdPhieuNhap = ctPhieuNhapVm.IdPhieuNhap;
     ctPhieuNhap.IdSach      = ctPhieuNhapVm.IdSach;
     ctPhieuNhap.SoLuongNhap = ctPhieuNhapVm.SoLuongNhap;
     ctPhieuNhap.ThanhTien   = ctPhieuNhapVm.ThanhTien;
     ctPhieuNhap.DonGiaNhap  = ctPhieuNhapVm.DonGiaNhap;
 }
Ejemplo n.º 3
0
 public void Update(CtPhieuNhap ctPhieuNhap)
 {
     ctPhieuNhapRepository.Update(ctPhieuNhap);
 }
Ejemplo n.º 4
0
 public CtPhieuNhap Delete(CtPhieuNhap ctPhieuNhap)
 {
     return(ctPhieuNhapRepository.Delete(ctPhieuNhap));
 }
Ejemplo n.º 5
0
 public CtPhieuNhap Add(CtPhieuNhap ctPhieuNhap)
 {
     return(ctPhieuNhapRepository.Add(ctPhieuNhap));
 }