Exemplo n.º 1
0
        public PartialViewResult _DanhSachChiPhi(int pageNumber = 1, int pageSize = 10, string keyText = "")
        {
            List <ChiPhiDAO> chiPhi = new List <ChiPhiDAO>();

            try
            {
                List <LoaiChiPhiDAO> loaiChiPhi = LoaiChiPhi_Service.GetAll();
                Hashtable            hs         = new Hashtable();
                for (int i = 0; i < loaiChiPhi.Count; i++)
                {
                    hs.Add(loaiChiPhi[i].MaLoaiChiPhi, loaiChiPhi[i].TenLoaiChiPhi);
                }
                ViewBag.dsLoaiChiPhi = hs;

                int totalEntries;
                chiPhi                 = ChiPhi_Service.GetAllBy(pageNumber, pageSize, keyText, out totalEntries);
                ViewBag.maxNumber      = Math.Ceiling(totalEntries / (double)pageSize);
                ViewBag.pageNumber     = pageNumber;
                ViewBag.pageSize       = pageSize;
                TempData["loaiChiPhi"] = loaiChiPhi;
                TempData["chiPhi"]     = chiPhi;
                TempData.Keep();
            }
            catch (Exception e)
            {
                throw e;
            }
            return(PartialView(chiPhi));
        }
Exemplo n.º 2
0
        public JsonResult addOrUpdateExpense(ChiPhiDAO obj, bool isUpdate)
        {
            AjaxResultModel Result = new AjaxResultModel();

            bool check = true;

            try
            {
                if (isUpdate)
                {
                    check = ChiPhi_Service.Update(obj);
                }
                else
                {
                    obj.NgayTao = DateTime.Now;
                    check       = ChiPhi_Service.Insert(obj);
                }
                if (check)
                {
                    Result.Code    = 0;
                    Result.Message = "Thành công";
                }
                else
                {
                    Result.Code    = 1;
                    Result.Message = "Đã có lỗi xảy ra. Vui lòng thử lại.";
                }
            }
            catch (Exception e)
            {
                Result.Code    = 1;
                Result.Message = e.Message;
                //throw;
            }
            return(Json(new JsonResult()
            {
                Data = Result
            }));
        }