Exemple #1
0
        void ThuChiModelToThuChi(ThuChiModel nvfrom, ThuChi nvto)
        {
            nvto.Id = nvfrom.Id;
            //nvto.Ma = nvfrom.Ma;
            //nvto.NgayTao = nvfrom.NgayTao;
            nvto.NgayGiaoDich = nvfrom.NgayGiaoDich;

            nvto.LoaiThuChiId = nvfrom.LoaiThuChiId;
            nvto.DienGiai     = nvfrom.DienGiai;
            nvto.GiaTri       = nvfrom.GiaTri;
            if (nvfrom.NguoiNopId > 0)
            {
                nvto.NguoiNopId = nvfrom.NguoiNopId;
            }
            else
            {
                nvto.NguoiNopId = null;
            }
            if (nvfrom.NguoiThuId > 0)
            {
                nvto.NguoiThuId = nvfrom.NguoiThuId;
            }
            else
            {
                nvto.NguoiThuId = null;
            }
            //nvto.NguoiTaoId = nvfrom.NguoiTaoId;
            nvto.isChi = nvfrom.isChi;
        }
Exemple #2
0
        public ActionResult ThuChiTao(ThuChiModel model, bool continueEditing)
        {
            if (this.CheckNoAccessIntoNhaXe(_workContext, _permissionService, StandardPermissionProvider.CVHoatDongBanVe))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                //kiem tra loai thu chi
                if (model.LoaiThuChiId == 0)
                {
                    if (string.IsNullOrEmpty(model.tenloaithuchi))
                    {
                        ErrorNotification("Tên loại thu chi không được trống");
                        return(View(model));
                    }
                    var ltc = new LoaiThuChi();
                    ltc.Ten     = model.tenloaithuchi;
                    ltc.NhaXeId = _workContext.NhaXeId;
                    _ketoanService.Insert(ltc);
                    model.LoaiThuChiId = ltc.Id;
                }
                var item = new ThuChi();
                ThuChiModelToThuChi(model, item);
                item.NgayTao    = DateTime.Now;
                item.NguoiTaoId = _workContext.CurrentNhanVien.Id;
                item.NhaXeId    = _workContext.NhaXeId;
                _ketoanService.Insert(item);
                SuccessNotification("Tạo mới thành công");
                return(continueEditing ? RedirectToAction("ThuChiSua", new { id = item.Id }) : RedirectToAction("List"));
            }
            ThuChiModelPrepare(model);
            return(View(model));
        }
Exemple #3
0
        public ActionResult _ChiTiet(int Id)
        {
            var model = new ThuChiModel();
            var item  = _ketoanService.GetThuChiById(Id);

            ThuChiToThuChiModel(item, model);
            return(PartialView(model));
        }
Exemple #4
0
        public ActionResult ThuChiTao(bool?isChi)
        {
            if (this.CheckNoAccessIntoNhaXe(_workContext, _permissionService, StandardPermissionProvider.CVHoatDongBanVe))
            {
                return(AccessDeniedView());
            }

            var model = new ThuChiModel();

            ThuChiModelPrepare(model);
            model.isChi = isChi.HasValue ?isChi.Value: true;
            return(View(model));
        }
Exemple #5
0
        void ThuChiModelPrepare(ThuChiModel model)
        {
            var loaithuchis = _ketoanService.GetAllLoaiThuChi(_workContext.NhaXeId);

            model.loaithuchis = loaithuchis.Select(c =>
            {
                var item      = new SelectListItem();
                item.Value    = c.Id.ToString();
                item.Text     = c.Ten;
                item.Selected = (c.Id == model.LoaiThuChiId);
                return(item);
            }).ToList();
        }
Exemple #6
0
        public ActionResult ThuChiSua(ThuChiModel model, bool continueEditing)
        {
            if (this.CheckNoAccessIntoNhaXe(_workContext, _permissionService, StandardPermissionProvider.CVHoatDongBanVe))
            {
                return(AccessDeniedView());
            }

            var item = _ketoanService.GetThuChiById(model.Id);

            if (item == null)
            {
                //No manufacturer found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                if (model.LoaiThuChiId == 0)
                {
                    if (string.IsNullOrEmpty(model.tenloaithuchi))
                    {
                        ErrorNotification("Tên loại thu chi không được trống");
                        return(View(model));
                    }
                    var ltc = new LoaiThuChi();
                    ltc.Ten     = model.tenloaithuchi;
                    ltc.NhaXeId = _workContext.NhaXeId;
                    _ketoanService.Insert(ltc);
                    model.LoaiThuChiId = ltc.Id;
                }

                ThuChiModelToThuChi(model, item);
                _ketoanService.Update(item);
                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return(RedirectToAction("ThuChiSua", item.Id));
                }
                return(RedirectToAction("List"));
            }


            return(View(model));
        }
Exemple #7
0
        public ActionResult _DanhSachThuChi(QLThuChiModel model)
        {
            bool?isChi = null;

            if (model.isChi >= 0)
            {
                isChi = model.isChi == 1?true : false;
            }
            model.TonDauKy = _ketoanService.GetTonDauKy(_workContext.NhaXeId, model.TuNgay);
            var danhsachs = _ketoanService.GetAllThuChi(_workContext.NhaXeId, model.LoaiThuChiId, isChi, model.TuNgay, model.DenNgay, model.KeySearch);

            model.thuchis = danhsachs.Select(c =>
            {
                var m = new ThuChiModel();
                ThuChiToThuChiModel(c, m);
                return(m);
            }).ToList();
            return(PartialView(model));
        }
Exemple #8
0
        public ActionResult ThuChiSua(int id)
        {
            if (this.CheckNoAccessIntoNhaXe(_workContext, _permissionService, StandardPermissionProvider.CVHoatDongBanVe))
            {
                return(AccessDeniedView());
            }

            var item = _ketoanService.GetThuChiById(id);

            if (item == null)
            {
                return(RedirectToAction("List"));
            }
            var model = new ThuChiModel();

            ThuChiToThuChiModel(item, model);
            //default values
            ThuChiModelPrepare(model);

            return(View(model));
        }
Exemple #9
0
        void ThuChiToThuChiModel(ThuChi nvfrom, ThuChiModel nvto)
        {
            nvto.Id               = nvfrom.Id;
            nvto.Ma               = nvfrom.Ma;
            nvto.NgayTao          = nvfrom.NgayTao;
            nvto.NgayGiaoDich     = nvfrom.NgayGiaoDich;
            nvto.ChuyenDiId       = nvfrom.ChuyenDiId.GetValueOrDefault(0);
            nvto.thongtinchuyendi = nvfrom.chuyendi != null?nvfrom.chuyendi.toMoTa() : "";

            nvto.NgayDi        = nvfrom.chuyendi != null ? nvfrom.chuyendi.NgayDi : DateTime.Now;
            nvto.LoaiThuChiId  = nvfrom.LoaiThuChiId;
            nvto.tenloaithuchi = nvfrom.loaithuchi.Ten;
            nvto.DienGiai      = nvfrom.DienGiai;
            nvto.GiaTri        = nvfrom.GiaTri;
            nvto.NguoiNopId    = nvfrom.NguoiNopId.GetValueOrDefault(0);
            nvto.tennguoinop   = nvfrom.nguoinop != null ? nvfrom.nguoinop.HoVaTen : "";
            nvto.NguoiThuId    = nvfrom.NguoiThuId.GetValueOrDefault(0);
            nvto.tennguoithu   = nvfrom.nguoithu != null ? nvfrom.nguoithu.HoVaTen : "";
            nvto.NguoiTaoId    = nvfrom.NguoiTaoId;
            nvto.tennguoitao   = nvfrom.nguoitao.HoVaTen;
            nvto.isChi         = nvfrom.isChi;
            nvto.isChiText     = nvfrom.isChi ? "Chi" : "Thu";
        }