public ActionResult ThemMoiBaoCao() { var baoCao = (BaoCaoDLViewModel)Session["BaoCao"]; baoCao.NgayXacNhan = baoCao.ThoiGianLapPhieu; baoCao.TongTienConNo += baoCao.TienNoThangTruoc; var dsSachDaKhaiSL = (List <CtBaoCaoDLViewModel>)Session["dsCtBaoCao"]; BaoCaoDL newBaoCao = new BaoCaoDL(); newBaoCao.UpdateBaoCaoDL(baoCao); newBaoCao.NgayXacNhan = newBaoCao.ThoiGianLapPhieu; newBaoCao.IdTinhTrang = CommonConstant.DA_BAO_CAO; baoCaoDLService.Add(newBaoCao); baoCaoDLService.Save(); var dsSachChuaKhaiSL = baoCaoDLService.GetListAnalysisReport(baoCao.IdDaiLy, baoCao.NgayBatDau, baoCao.NgayKetThuc); foreach (var ctbc in dsSachDaKhaiSL) { ctbc.IdBaoCao = newBaoCao.Id; var ctBaoCao = new CtBaoCaoDL(); ctBaoCao.UpdateCtBaoCaoDL(ctbc); ctBaoCaoDLService.Add(ctBaoCao); dsSachChuaKhaiSL.RemoveAll(t => t.Id == ctbc.IdSach); } foreach (var s in dsSachChuaKhaiSL) { var giaBan = (double)sachService.GetById(s.Id).GiaBan; var ctBaoCao = new CtBaoCaoDL(); ctBaoCao.IdBaoCao = newBaoCao.Id; ctBaoCao.IdSach = s.Id; ctBaoCao.DonGiaXuat = giaBan; ctBaoCao.SoLuongNhap = s.SoLuongNhap; ctBaoCao.SoLuongTonDotTruoc = s.SoLuongTonDotTruoc; ctBaoCao.TongTienNhap = (s.SoLuongNhap + s.SoLuongTonDotTruoc) * giaBan; ctBaoCao.SoLuongCon = s.SoLuongNhap + s.SoLuongTonDotTruoc; ctBaoCao.TongTienNo = giaBan * ctBaoCao.SoLuongCon; ctBaoCao.SoLuongXuat = 0; ctBaoCao.TongTienXuat = 0; newBaoCao.TongTienSachBan += (double)ctBaoCao.TongTienXuat; newBaoCao.TongTienConNo += (double)ctBaoCao.TongTienNo; ctBaoCaoDLService.Add(ctBaoCao); } baoCaoDLService.Update(newBaoCao); baoCaoDLService.Save(); Session["BaoCao"] = null; Session["dsCtBaoCao"] = null; Session.RemoveAll(); TempData["Success"] = "Đã thêm mới một báo cáo đại lý."; return(Redirect("/bao-cao/dai-ly/")); }
public static void UpdateCtBaoCaoDL(this CtBaoCaoDL ctBaoCaoDL, CtBaoCaoDLViewModel ctBaoCaoDLVm) { ctBaoCaoDL.Id = ctBaoCaoDLVm.Id; ctBaoCaoDL.IdBaoCao = ctBaoCaoDLVm.IdBaoCao; ctBaoCaoDL.IdSach = ctBaoCaoDLVm.IdSach; ctBaoCaoDL.DonGiaXuat = ctBaoCaoDLVm.DonGiaXuat; ctBaoCaoDL.SoLuongNhap = ctBaoCaoDLVm.SoLuongNhap; ctBaoCaoDL.SoLuongTonDotTruoc = ctBaoCaoDLVm.SoLuongTonDotTruoc; ctBaoCaoDL.TongTienNhap = ctBaoCaoDLVm.TongTienNhap; ctBaoCaoDL.SoLuongXuat = ctBaoCaoDLVm.SoLuongXuat; ctBaoCaoDL.SoLuongCon = ctBaoCaoDLVm.SoLuongCon; ctBaoCaoDL.TongTienNo = ctBaoCaoDLVm.TongTienNo; ctBaoCaoDL.TongTienXuat = ctBaoCaoDLVm.TongTienXuat; }
public void Update(CtBaoCaoDL ctBaoCaoDL) { ctBaoCaoDLRepository.Update(ctBaoCaoDL); }
public CtBaoCaoDL Delete(CtBaoCaoDL ctBaoCaoDL) { return(ctBaoCaoDLRepository.Delete(ctBaoCaoDL)); }
public CtBaoCaoDL Add(CtBaoCaoDL ctBaoCaoDL) { return(ctBaoCaoDLRepository.Add(ctBaoCaoDL)); }