Esempio n. 1
0
 private HoaDonPresenter(IHoaDonForm _view, IHoaDonRepository _repository, IModelStateWraper _state)
 {
     state           = _state;
     view            = _view;
     repository      = _repository;
     _view.Presenter = this;
 }
Esempio n. 2
0
 static HoaDonServices()
 {
     HDrepo    = new HoaDonRepository();
     DkHocRepo = new DangKyHocRepository();
     HsRepo    = new HocSinhRepository();
     LDKRepo   = new LopDangKyRepository();
 }
 public DashboardController(IHoaDonRepository hoadonRepo, IMapper mapper, ILinhKienRepository lkRepo, IUserRepository userRepo)
 {
     _hoadonRepo = hoadonRepo;
     _mapper     = mapper;
     _lkRepo     = lkRepo;
     _userRepo   = userRepo;
 }
Esempio n. 4
0
 internal LibraryService(IBenhNhanRepository benhNhanRepository, ICanLamSanRepository canLamSanRepository, IChiTietCLSRepository chiTietCLSRepository, IChiTietDonThuocRepository chiTietDonThuocRepository, IChiTietNhapVatTuRepository chiTietNhapVatTuRepository, IChiTietNhapThuocRepository chiTietNhapThuocRepository, IChucDanhRepository chucDanhRepository, IChucVuRepository chucVuRepository, IDichVuCLSRepository dichVuCLSRepository, IDonThuocRepository donThuocRepository, IDonViTinhRepository donViTinhRepository, IHangSanXuatRepository hangSanXuatRepository, IHinhThucKhamRepository hinhThucKhamRepository, IHoaDonRepository hoaDonRepository, IKhoaRepository khoaRepository, ILoaiCanLamSangRepository loaiCanLamSanRepository, ILoaiThuocRepository loaiThuocRepository, INhaCungCapRepository nhaCungCapRepository, INhanVienRepository nhanVienRepository, IPhanQuyenRepository phanQuyenRepository, IPhieuKhamRepository phieuKhamRepository, IPhieuNhapRepository phieuNhapRepository, IQuocGiaRepository quocGiaRepository, ITaiKhoanRepository taiKhoanRepository, IThuocRepository thuocRepository, IVatTuYTeRepository vatTuYTeRepository)
 {
     this.benhNhanRepository         = benhNhanRepository;
     this.canLamSanRepository        = canLamSanRepository;
     this.chiTietCLSRepository       = chiTietCLSRepository;
     this.chiTietDonThuocRepository  = chiTietDonThuocRepository;
     this.chiTietNhapVatTuRepository = chiTietNhapVatTuRepository;
     this.chiTietNhapThuocRepository = chiTietNhapThuocRepository;
     this.chucDanhRepository         = chucDanhRepository;
     this.chucVuRepository           = chucVuRepository;
     this.dichVuCLSRepository        = dichVuCLSRepository;
     this.donThuocRepository         = donThuocRepository;
     this.donViTinhRepository        = donViTinhRepository;
     this.hangSanXuatRepository      = hangSanXuatRepository;
     this.hinhThucKhamRepository     = hinhThucKhamRepository;
     this.hoaDonRepository           = hoaDonRepository;
     this.khoaRepository             = khoaRepository;
     this.loaiCanLamSanRepository    = loaiCanLamSanRepository;
     this.loaiThuocRepository        = loaiThuocRepository;
     this.nhaCungCapRepository       = nhaCungCapRepository;
     this.nhanVienRepository         = nhanVienRepository;
     this.phanQuyenRepository        = phanQuyenRepository;
     this.phieuKhamRepository        = phieuKhamRepository;
     this.phieuNhapRepository        = phieuNhapRepository;
     this.quocGiaRepository          = quocGiaRepository;
     this.taiKhoanRepository         = taiKhoanRepository;
     this.thuocRepository            = thuocRepository;
     this.vatTuYTeRepository         = vatTuYTeRepository;
 }
Esempio n. 5
0
        /// <summary>
        /// Hủy giao dịch với id xác định
        /// </summary>
        /// <requires>
        /// lastGiaoDich != null /\ lastGiaoDich.GiaoDich.SoTien != null
        /// </requires>
        /// <effects>
        /// soTien = lastGiaoDich.SoTien
        /// delete GiaoDich
        ///
        /// update model
        ///     SoTienDaThu -= soTien
        ///
        /// duNo = SoTienPhaiNop - SoTienDaThu
        /// if duNo > 0
        ///     TrangThaiThu = false
        ///     if DuCo != null
        ///         delete DuCo
        /// else
        ///     if DuCo != null
        ///         DuCo.SoTienDu -= soTien
        ///         if DuCo.SoTienDu eq 0
        ///             delete DuCo
        /// </effects>
        public static bool HuyGiaoDich(GiaoDichModel model, HDNHDUnitOfWork uow = null)
        {
            if (uow == null)
            {
                uow = new HDNHDUnitOfWork();
            }

            IGiaoDichRepository giaoDichRepository = uow.Repository <GiaoDichRepository>();
            IDuCoRepository     duCoRepository     = uow.Repository <DuCoRepository>();

            uow.BeginTransaction();
            try
            {
                var soTien = model.GiaoDich.SoTien.Value;
                giaoDichRepository.Delete(model.GiaoDich);

                // update model
                model.SoTienNopTheoThang.SoTienDaThu -= soTien;

                int duNo = (int)(model.SoTienNopTheoThang.SoTienPhaiNop - model.SoTienNopTheoThang.SoTienDaThu);

                if (duNo > 0)
                {
                    model.HoaDon.Trangthaithu = false;
                    model.HoaDon.NgayNopTien  = null;
                }

                // trừ dư có
                if (model.DuCo != null)
                {
                    // thu hồi dư có nếu đã áp dụng cho hóa đơn tháng sau
                    IHoaDonRepository hoaDonRepository = uow.Repository <HoaDonRepository>();
                    var hoaDonModel = hoaDonRepository.GetHoaDonModelByID(model.HoaDon.HoadonnuocID);

                    // cập nhật dư có
                    model.DuCo.SoTienDu -= soTien;

                    if (model.DuCo.SoTienDu <= 0)
                    {
                        duCoRepository.Delete(model.DuCo);
                        thuHoiDuCo(hoaDonModel, uow);
                    }
                    else
                    {
                        apDungDuCo(hoaDonModel, uow);
                    }
                }

                uow.SubmitChanges();
                uow.Commit();
            }
            catch (Exception)
            {
                uow.RollBack();
                return(false);
            }

            return(true);
        }
Esempio n. 6
0
 static HocSinhServices()
 {
     HocSinhRepo   = new HocSinhRepository();
     LopDangKyRepo = new LopDangKyRepository();
     DKHocRepo     = new DangKyHocRepository();
     HDRepo        = new HoaDonRepository();
     CLBRepo       = new CLBRepository();
 }
Esempio n. 7
0
 public OrderController(ITheRepository theRepository, IDSNURepository dsnuRepository, INURepository nuRepository, IHoaDonRepository hoadonRepository, ICTHDRepository cthdRepository)
 {
     this.theRepository    = theRepository;
     this.dsnuRepository   = dsnuRepository;
     this.nuRepository     = nuRepository;
     this.hoadonRepository = hoadonRepository;
     this.cthdRepository   = cthdRepository;
 }
 static LopDangKyServices()
 {
     LopDangKyRepo = new LopDangKyRepository();
     dkhocRepo = new DangKyHocRepository();
     dsHDRepo = new HoaDonRepository();
     hsRepo = new HocSinhRepository();
     dkHocRepo = new DangKyHocRepository();
     CLBRepo = new CLBRepository();
 }
Esempio n. 9
0
        public AjaxResult ThemGiaoDich(int hoaDonID, int soTien, string ngayGiaoDich)
        {
            IHoaDonRepository hoaDonRepository = uow.Repository <HoaDonRepository>();
            var model = hoaDonRepository.GetHoaDonModelByID(hoaDonID);

            if (model == null)
            {
                return(AjaxResult.Fail("Hóa đơn không tồn tại. Vui lòng tải lại trang.", true));
            }

            if (model.CoDuNoQuaHan)
            {
                return(AjaxResult.Fail("Khách hàng có dư nợ quá hạn cần thanh toán trước.", true));
            }

            var current = DateTime.Now.AddMonths(-1);

            if (!(!model.CoDuNoQuaHan && // không có dư nợ & (tháng hiện tại || (< tháng hiện tại & chưa thu))
                  ((model.HoaDon.ThangHoaDon == current.Month && model.HoaDon.NamHoaDon == current.Year) ||
                   ((model.HoaDon.NamHoaDon < current.Year || (model.HoaDon.NamHoaDon == current.Year && model.HoaDon.ThangHoaDon < current.Month)) &&
                    (model.HoaDon.Trangthaithu == false || model.HoaDon.Trangthaithu == null)))))
            {
                return(AjaxResult.Fail("Không thể thêm giao dịch cho hóa đơn này. Dữ liệu bất đồng bộ, vui lòng load lại trang.", true));
            }

            DateTime dt;

            if (!DateTime.TryParseExact(ngayGiaoDich, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
            {
                dt = DateTime.Now;
            }

            if (!GiaoDichHelpers.ThemGiaoDich(model, soTien, dt, uow))
            {
                return(AjaxResult.Fail("Lỗi thêm giao dịch. Vui lòng thử lại."));
            }

            int duNo = (int)(model.SoTienNopTheoThang.SoTienPhaiNop - model.SoTienNopTheoThang.SoTienDaThu);

            return(AjaxResult.Success("Giao dịch thành công.", false,
                                      new
            {
                HoaDon = new
                {
                    ID = model.HoaDon.HoadonnuocID,
                    TrangThaiThu = model.HoaDon.Trangthaithu,
                    NgayNopTien = model.HoaDon.NgayNopTien != null ? model.HoaDon.NgayNopTien.Value.ToString("dd/MM/yyyy") : ""
                },
                SoTienNopTheoThang = new
                {
                    SoTienDaThu = CurrencyHelpers.FormatVN(model.SoTienNopTheoThang.SoTienDaThu ?? 0),
                    DuNo = CurrencyHelpers.FormatVN(duNo > 0 ? duNo : -duNo)
                }
            }));
        }
Esempio n. 10
0
        public ActionResult LoaiGia(int?month, int?year, LoaiGiaFilterModel filter, Pager pager, ViewMode viewMode = ViewMode.Default)
        {
            title = "Báo cáo khách hàng theo các loại giá";

            IHoaDonRepository hoaDonRepository = uow.Repository <HoaDonRepository>();

            // default values: xem báo cáo tháng trước
            var dtBaoCao = DateTime.Now.AddMonths(-1);

            if (month == null)
            {
                month = dtBaoCao.Month;
            }
            if (year == null)
            {
                year = dtBaoCao.Year;
            }

            var items = hoaDonRepository.GetAllLoaiGiaModel(month.Value, year.Value);

            items = filter.ApplyFilter(items);

            ViewBag.Month = month.Value;
            ViewBag.Year  = year.Value;

            ViewBag.TongSH1 = items.Sum(m => m.LichSuHoaDon.SH1);
            ViewBag.TongSH2 = items.Sum(m => m.LichSuHoaDon.SH2);
            ViewBag.TongSH3 = items.Sum(m => m.LichSuHoaDon.SH3);
            ViewBag.TongSH4 = items.Sum(m => m.LichSuHoaDon.SH4);
            ViewBag.TongHC  = items.Sum(m => m.LichSuHoaDon.HC);
            ViewBag.TongSX  = items.Sum(m => m.LichSuHoaDon.SX);
            ViewBag.TongKD  = items.Sum(m => m.LichSuHoaDon.KD);
            ViewBag.TongSL  = items.Sum(m => m.LichSuHoaDon.SanLuongTieuThu);
            ViewBag.TongSoTienTrenHoaDon = items.Sum(m => m.SoTien) ?? 0;

            if (viewMode == ViewMode.Excel)
            {
                return(ExcelResult("LoaiGiaExport", items.ToList()));
            }
            if (viewMode == ViewMode.Print)
            {
                return(View("LoaiGiaPrint", items.ToList()));
            }

            items = pager.ApplyPager(items);

            #region view data
            ViewBag.Filter = filter;
            ViewBag.Pager  = pager;
            #endregion

            return(View(items.ToList()));
        }
Esempio n. 11
0
 public HomeController(ILogger <HomeController> logger,
                       ILinhKienRepository linhkienRepo,
                       IHoaDonRepository hoadonRepository,
                       IGioHangRepository giohangRepo,
                       ILoaiLinhKienRepository loailinhkienRepo,
                       IMapper mapper,
                       UserManager <ApplicationUser> userManager
                       )
 {
     _logger           = logger;
     _linhkienRepo     = linhkienRepo;
     _hoadonRepository = hoadonRepository;
     _userManager      = userManager;
     _giohangRepo      = giohangRepo;
     _loailinhkienRepo = loailinhkienRepo;
     this.mapper       = mapper;
 }
Esempio n. 12
0
        /// <summary>
        /// Báo cáo KH ko có sl chọn theo tháng / khu vực / tổ / nhân viên / tuyến
        /// </summary>
        public ActionResult KhongSanLuong(int?month, int?year, KhongSanLuongFilterModel filter, Pager pager, ViewMode viewMode = ViewMode.Default)
        {
            title = "Báo cáo KH không sản lượng";

            IHoaDonRepository hoaDonRepository = uow.Repository <HoaDonRepository>();

            // default values: xem báo cáo tháng trước
            var dtBaoCao = DateTime.Now.AddMonths(-1);

            if (month == null)
            {
                month = dtBaoCao.Month;
            }
            if (year == null)
            {
                year = dtBaoCao.Year;
            }

            var items = hoaDonRepository.GetAllKhongSanLuongModel(month.Value, year.Value);

            items = filter.ApplyFilter(items);

            ViewBag.Month = month.Value;
            ViewBag.Year  = year.Value;

            if (viewMode == ViewMode.Excel)
            {
                return(ExcelResult("KhongSanLuongExport", items.ToList()));
            }
            if (viewMode == ViewMode.Print)
            {
                return(View("KhongSanLuongPrint", items.ToList()));
            }

            items = pager.ApplyPager(items);

            #region view data
            ViewBag.Filter = filter;
            ViewBag.Pager  = pager;
            #endregion

            return(View(items.ToList()));
        }
Esempio n. 13
0
        /// <summary>
        ///     view list HoaDon of KhachHang with specified <tt>id</tt>
        /// </summary>
        /// <effects>
        ///     get KhachHang khachHang with specified <tt>id</tt>
        ///     if khachHang not exists
        ///         redirect user to ds KhachHang
        ///     else
        ///         load all HoaDon of this KhachHang and display
        /// </effects>
        public ActionResult LichSuDungNuoc(int id, Pager pager)
        {
            title = "Chi tiết lịch sử dùng nước";

            var khachHangModel = khachHangRepository.GetKhachHangDetailsModel(id);

            if (khachHangModel == null)
            {
                return(RedirectToAction("Index"));
            }

            IHoaDonRepository hoaDonRepository = uow.Repository <HoaDonRepository>();
            var items = hoaDonRepository.GetAllHoaDonModelByKHID(id);

            pager.PageSize = 12; // hien thi 12 hoa don gan nhat
            items          = pager.ApplyPager(items);

            #region view data
            ViewBag.Pager          = pager;
            ViewBag.KhachHangModel = khachHangModel;
            #endregion

            return(View(items.ToList()));
        }
Esempio n. 14
0
 public HoaDonService(IHoaDonRepository hoadonRepository, IMapper mapper)
 {
     this.hoadonRepository = hoadonRepository;
     this.iMapper          = mapper;
 }
Esempio n. 15
0
 public HoaDonController()
 {
     hoaDonRepository = uow.Repository <HoaDonRepository>();
     toRepository     = uow.Repository <ToRepository>();
 }
 public HoaDonBusiness(IHoaDonRepository res)
 {
     _res = res;
 }
Esempio n. 17
0
 public HoaDonController(INURepository nuRepository, IHoaDonRepository hoadonRepository, ICTHDRepository cthdRepository)
 {
     this.nuRepository     = nuRepository;
     this.hoadonRepository = hoadonRepository;
     this.cthdRepository   = cthdRepository;
 }
Esempio n. 18
0
        /// <summary>
        /// báo cáo dư nợ tính đến tháng hiện tại
        /// </summary>
        public ActionResult DuNo(int?month, int?year, DuNoFilterModel filter, Pager pager, ViewMode viewMode = ViewMode.Default)
        {
            title = "Báo cáo dư nợ";

            IHoaDonRepository hoaDonRepository = uow.Repository <HoaDonRepository>();

            // default values: xem báo cáo tháng trước
            var dtBaoCao = DateTime.Now.AddMonths(-1);

            if (month == null)
            {
                month = dtBaoCao.Month;
            }
            if (year == null)
            {
                year = dtBaoCao.Year;
            }

            //if (filter.Mode == null) // not in filter
            //{
            //    // set selected to, quan huyen = nhanVien's to, quan huyen
            //    if (nhanVien != null)
            //    {
            //        filter.NhanVienID = nhanVien.NhanvienID;
            //        filter.ToID = nhanVien.ToQuanHuyenID;

            //        var to = toRepository.GetByID(nhanVien.ToQuanHuyenID ?? 0);
            //        if (to != null)
            //        {
            //            filter.QuanHuyenID = to.QuanHuyenID;
            //        }
            //    }
            //}

            var items = hoaDonRepository.GetAllDuNoModel(month.Value, year.Value);

            items = filter.ApplyFilter(items);

            ViewBag.TongSoTienPhaiNop = (long)(items.Sum(m => m.SoTienNopTheoThang.SoTienPhaiNop) ?? 0);
            ViewBag.TongSoTienDaNop   = items.Sum(m => m.SoTienDaNop) ?? 0;
            ViewBag.TongSoTienNo      = items.Sum(m => m.SoTienNo) ?? 0;
            ViewBag.Month             = month.Value;
            ViewBag.Year = year.Value;

            if (viewMode == ViewMode.Excel)
            {
                return(ExcelResult("DuNoExport", items.ToList()));
            }
            if (viewMode == ViewMode.Print)
            {
                return(View("DuNoPrint", items.ToList()));
            }

            items = pager.ApplyPager(items);

            #region view data
            ViewBag.Filter = filter;
            ViewBag.Pager  = pager;
            #endregion
            return(View(items.ToList()));
        }
Esempio n. 19
0
 public HoaDonService(IHoaDonRepository hoaDonRepository)
 {
     _hoaDonRepository = hoaDonRepository;
 }
Esempio n. 20
0
 public HoaDonService(IValidationDictionary validationDictionary, IHoaDonRepository repository)
 {
     _validationDictionary = validationDictionary;
     _repository           = repository;
 }
Esempio n. 21
0
 public HoaDonServices(IHoaDonRepository res)
 {
     _res = res;
 }
Esempio n. 22
0
 private readonly IHoaDonRepository _hoadonRepository;     //Tạo biến chứa dữ liệu
 public HoaDonServices(IHoaDonRepository hoadonRepository) //constructor để gán dữ liệu vào biến, chi tiết xem thêm ở SanPhamServices.cs
 {
     _hoadonRepository = hoadonRepository;
 }
Esempio n. 23
0
 public HoaDonService(IHoaDonRepository hoaDonRepository, IUnitOfWork unitOfWork)
 {
     _hoaDonRepository = hoaDonRepository;
     _unitOfWork       = unitOfWork;
 }
Esempio n. 24
0
 public DonHangController(IHoaDonRepository hoadonRepo, IMapper mapper)
 {
     _hoadonRepo = hoadonRepo;
     _mapper     = mapper;
 }
Esempio n. 25
0
 public HoaDonBusiness(IHoaDonRepository res, ISachBusiness rsp)
 {
     _res = res;
     _rsp = rsp;
 }
Esempio n. 26
0
 public HoaDonController()
 {
     hoaDonRepository = uow.Repository <HoaDonRepository>();
     current          = DateTime.Now.AddMonths(-1);
 }