Example #1
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));
        }
Example #2
0
 public virtual void Delete(LoaiThuChi _item)
 {
     if (_item == null)
     {
         throw new ArgumentNullException("ThuChi");
     }
     _loaithuchiRepository.Delete(_item);
 }
Example #3
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));
        }