// GET: PhieuNhap/Edit/5
 public ActionResult Edit(int?id)
 {
     if (id == null)
     {
         putErrorMessage("Đường dẫn không chính xác");
         return(RedirectToAction("All"));
     }
     if (_currentPhieu == null || _currentPhieu != id)
     {
         _currentPhieu = id;
         _phieu        = PhieuXuatManager.find((int)id);
         if (_phieu == null)
         {
             putErrorMessage("Không tìm thấy");
             return(RedirectToAction("All"));
         }
         if (_phieu.TrangThai == 1)
         {
             //Nếu đã duyệt thì không cho sửa, chuyển sang trang chi tiết
             _currentPhieu = null;
             putErrorMessage("Phiếu đã duyệt");
             return(RedirectToAction("Details", new { id = id }));
         }
     }
     ViewBag.cultureInfo = CultureInfo;
     ViewBag.DMSach      = new SelectList(SachManager.getAllAlive()
                                          .Where(s => s.Soluong > 0).ToList(),
                                          nameof(SachManager.Properties.MaSoSach),
                                          nameof(SachManager.Properties.TenSach), "");
     ViewBag.DMDaiLy = new SelectList(DaiLyManager.getAllAlive(),
                                      nameof(DaiLyManager.Properties.MaSoDaiLy),
                                      nameof(DaiLyManager.Properties.TenDaiLy), "");
     setAlertMessage();
     return(View(_phieu));
 }
        private void LoadDaiLy()
        {
            _DMDaiLy = DaiLyManager.getAllAlive()
                       .Where(dl => dl.tinhTongSoLuongNoTheoThang(_startMonth, _startYear, _endMonth, _endYear) > 0 &&
                              dl.tongTienNoThang(_startMonth, _startYear, _endMonth, _endYear) > 0 &&
                              dl.tongTienXuatThang(_startMonth, _startYear, _endMonth, _endYear) > 0).ToList();

            gdvDMCongNo.DataSource = _DMDaiLy;
            _tongTienNo            = _DMDaiLy.Sum(dl => dl.TongTienNoThang);
            _tongTienXuat          = _DMDaiLy.Sum(dl => dl.TongTienXuatTheoThang);
            lbTongConNo.Text       = DataDisplayHelper.displayMoney((decimal)_tongTienNo);
            lbTongTienSach.Text    = DataDisplayHelper.displayMoney((decimal)_tongTienXuat);
            lbTongDaThu.Text       = DataDisplayHelper.displayMoney((decimal)(_tongTienXuat - _tongTienNo));
        }
 public ActionResult DoanhThu(DateTime?startDate,
                              DateTime?endDate,
                              int dlpage         = 1,
                              int dlpageSize     = 10,
                              int nxbpage        = 1,
                              int nxbpageSize    = 10,
                              string searchDaiLy = null,
                              string searchNXB   = null)
 {
     if (startDate != null && endDate != null)
     {
         ViewBag.cultureInfo = CultureInfo;
         ViewBag.startDate   = startDate;
         ViewBag.endDate     = endDate;
         List <DaiLy> DMDaily = DaiLyManager.getAllAlive()
                                .Where(dl => dl.tinhTongTienThanhToanTheoThang(
                                           ((DateTime)startDate).Month,
                                           ((DateTime)startDate).Year,
                                           ((DateTime)endDate).Month,
                                           ((DateTime)endDate).Year) > 0).ToList();
         ViewBag.tongTienThu = DMDaily.Sum(s => s.TongTienThanhToanTheoThang);
         if (!String.IsNullOrEmpty(searchDaiLy))
         {
             DMDaily = DaiLyManager.filter(searchDaiLy, DMDaily);
             ViewBag.SearchKeyDaiLy = searchDaiLy;
         }
         List <NhaXuatBan> DMNXB = NhaXuatBanManager.getAllAlive()
                                   .Where(nxb => nxb.tinhTongTienThanhToanTheoThang(
                                              ((DateTime)startDate).Month,
                                              ((DateTime)startDate).Year,
                                              ((DateTime)endDate).Month,
                                              ((DateTime)endDate).Year) > 0).ToList();
         ViewBag.tongTienChi = DMNXB.Sum(s => s.TongTienThanhToanTheoThang);
         if (!String.IsNullOrEmpty(searchNXB))
         {
             DMNXB = NhaXuatBanManager.filter(searchNXB, DMNXB);
             ViewBag.SearchKeyNXB = searchNXB;
         }
         ViewBag.tongCongDaiLy          = DMDaily.Sum(dl => dl.TongTienThanhToan);
         ViewBag.tongCongDaiLyTheoThang = DMDaily.Sum(dl => dl.TongTienThanhToanTheoThang);
         ViewBag.tongCongNXB            = DMNXB.Sum(nxb => nxb.TongTienThanhToan);
         ViewBag.tongCongNXBTheoThang   = DMNXB.Sum(nxb => nxb.TongTienThanhToanTheoThang);
         ViewBag.DaiLymodels            = DMDaily.ToPagedList(dlpage, dlpageSize);
         ViewBag.NXBmodels = DMNXB.ToPagedList(nxbpage, nxbpageSize);
         setAlertMessage();
         return(View());
     }
     setAlertMessage();
     return(View());
 }
        private void LoadTT()
        {
            _DSDaiLy = DaiLyManager.getAllAlive()
                       .Where(dl => dl.tinhTongTienThanhToanTheoThang(_startMonth, _startYear, _endMonth, _endYear) > 0).ToList();
            gdvDaiLy.DataSource = _DSDaiLy;
            lbTongThu.Text      = _DSDaiLy.Sum(s => s.TongTienThanhToanTheoThang) + "";
            int tongthu = int.Parse(lbTongThu.Text.ToString());

            _DSNXB = NhaXuatBanManager.getAllAlive()
                     .Where(dl => dl.tinhTongTienThanhToanTheoThang(_startMonth, _startYear, _endMonth, _endYear) > 0).ToList();
            gdvNXB.DataSource = _DSNXB;
            lbTongChi.Text    = _DSNXB.Sum(s => s.TongTienThanhToanTheoThang) + "";
            int tongchi = int.Parse(lbTongChi.Text.ToString());

            lbLoiNhuan.Text = tongthu - tongchi + "";
        }
 // GET: PhieuNhap/Create
 public ActionResult Create()
 {
     ViewBag.cultureInfo = CultureInfo;
     ViewBag.DMSach      = new SelectList(SachManager.getAllAlive()
                                          .Where(s => s.Soluong > 0).ToList(),
                                          nameof(SachManager.Properties.MaSoSach),
                                          nameof(SachManager.Properties.TenSach), "");
     ViewBag.DMDaiLy = new SelectList(DaiLyManager.getAllAlive(),
                                      nameof(DaiLyManager.Properties.MaSoDaiLy),
                                      nameof(DaiLyManager.Properties.TenDaiLy), "");
     if (_phieu == null)
     {
         _phieu = new PhieuXuat();
     }
     _phieu.NgayLap = DateTime.Now;
     setAlertMessage();
     return(View(_phieu));
 }
        // GET: DaiLy
        public ActionResult Index(int page = 1, int pageSize = 10, string search = null)
        {
            List <DaiLy> DMDaiLy = null;

            if (!String.IsNullOrEmpty(search))
            {
                DMDaiLy           = DaiLyManager.filter(search);
                ViewBag.SearchKey = search;
            }
            else
            {
                DMDaiLy = DaiLyManager.getAllAlive();
            }
            var models = DMDaiLy.ToPagedList(page, pageSize);

            setAlertMessage();
            return(View(models));
        }
 public ActionResult TheoDoi(DateTime?startDate, DateTime?endDate, int page = 1, int pageSize = 10, string search = null)
 {
     if (startDate != null && endDate != null)
     {
         ViewBag.cultureInfo = CultureInfo;
         ViewBag.startDate   = startDate;
         ViewBag.endDate     = endDate;
         List <DaiLy> DMDaiLy = DaiLyManager.getAllAlive()
                                .Where(dl => dl.tinhTongSoLuongNoTheoThang(
                                           ((DateTime)startDate).Month,
                                           ((DateTime)startDate).Year,
                                           ((DateTime)endDate).Month,
                                           ((DateTime)endDate).Year) > 0 &&
                                       dl.tongTienNoThang(
                                           ((DateTime)startDate).Month,
                                           ((DateTime)startDate).Year,
                                           ((DateTime)endDate).Month,
                                           ((DateTime)endDate).Year) > 0 &&
                                       dl.tongTienXuatThang(
                                           ((DateTime)startDate).Month,
                                           ((DateTime)startDate).Year,
                                           ((DateTime)endDate).Month,
                                           ((DateTime)endDate).Year) > 0).ToList();
         if (!String.IsNullOrEmpty(search))
         {
             DMDaiLy           = DaiLyManager.filter(search, DMDaiLy);
             ViewBag.SearchKey = search;
         }
         ViewBag.tongTienXuat  = DMDaiLy.Sum(nxb => nxb.TongTienXuatTheoThang);
         ViewBag.tongSoLuongNo = DMDaiLy.Sum(nxb => nxb.TongSoLuongNoTheoThang);
         ViewBag.tongTienNo    = DMDaiLy.Sum(s => s.TongTienNoThang);
         var models = DMDaiLy.ToPagedList(page, pageSize);
         setAlertMessage();
         return(View(models));
     }
     setAlertMessage();
     return(View());
 }
        public FileStreamResult DoanhThu(DateTime startDate, DateTime endDate)
        {
            List <DaiLy> DMDaily = DaiLyManager.getAllAlive()
                                   .Where(dl => dl.tinhTongTienThanhToanTheoThang(
                                              ((DateTime)startDate).Month,
                                              ((DateTime)startDate).Year,
                                              ((DateTime)endDate).Month,
                                              ((DateTime)endDate).Year) > 0).ToList();
            List <NhaXuatBan> DMNXB = NhaXuatBanManager.getAllAlive()
                                      .Where(nxb => nxb.tinhTongTienThanhToanTheoThang(
                                                 ((DateTime)startDate).Month,
                                                 ((DateTime)startDate).Year,
                                                 ((DateTime)endDate).Month,
                                                 ((DateTime)endDate).Year) > 0).ToList();
            var printer = new PrintHelper();

            printer.FileName   = "report.pdf";
            printer.FolderPath = "D://";
            printer.Title      = "Thống kê doanh thu";
            var info = new MemoryStream(printer.printDoanhThu(DMDaily, DMNXB, startDate, endDate));

            return(new FileStreamResult(info, "application/pdf"));
        }
 // GET: PhieuNhap/ThanhToan
 public ActionResult ThanhToan(int?masodaily)
 {
     if (masodaily != null)
     {
         var dl = DaiLyManager.find((int)masodaily);
         if (dl == null || dl.TrangThai == 0)
         {
             putErrorMessage("Không tìm thấy đại lý");
             return(RedirectToAction("ThanhToan"));
         }
         ViewBag.cultureInfo  = CultureInfo;
         ViewBag.currentDaiLy = dl;
         ViewBag.DMSach       = new SelectList(dl.getSachNo(),
                                               nameof(SachManager.Properties.MaSoSach),
                                               nameof(SachManager.Properties.TenSach), "");
         if (_hoadon == null)
         {
             _hoadon = new HoaDonDaiLy();
         }
         _hoadon.MaSoDaiLy = dl.MaSoDaiLy;
         _hoadon.DaiLy     = dl;
         _hoadon.NgayLap   = DateTime.Now;
         setAlertMessage();
         return(View(_hoadon));
     }
     else
     {
         ViewBag.DMDaiLy = new SelectList(DaiLyManager.getAllAlive()
                                          .Where(dl => dl.TongTienNo > 0).ToList(),
                                          nameof(DaiLyManager.Properties.MaSoDaiLy),
                                          nameof(DaiLyManager.Properties.TenDaiLy), "");
         _hoadon = new HoaDonDaiLy();
         setAlertMessage();
         return(View());
     }
 }
Example #10
0
 public void loadDaiLy()
 {
     _DMDaiLy = DaiLyManager.getAllAlive();
     gdvDMDaiLy.DataSource = _DMDaiLy;
 }