public PartialViewResult IndexPartialView(int?billId, string billCode, int?customerId, string customerName, DateTime?fromDate, DateTime?toDate, int?currentPageIndex) { if (string.IsNullOrEmpty(customerName)) { customerName = string.Empty; customerId = 0; } if (string.IsNullOrEmpty(billCode)) { billCode = string.Empty; billId = 0; } if (fromDate == null) { fromDate = SystemConstant.MIN_DATE; } if (toDate == null) { toDate = SystemConstant.MAX_DATE; } var ctx = new SmsContext(); var exportedList = ctx.SP_GET_HOA_DON_EXPORTED(Convert.ToInt32(billId), billCode, Convert.ToInt32(customerId), customerName, Convert.ToDateTime(fromDate), Convert.ToDateTime(toDate)).Take(SystemConstant.MAX_ROWS).ToList <SP_GET_HOA_DON_EXPORTED_Result>(); int pageSize = SystemConstant.ROWS; int pageIndex = currentPageIndex == null ? 1 : (int)currentPageIndex; ExportModel model = new ExportModel(); model.ExportedList = exportedList.ToPagedList(pageIndex, pageSize); model.PageCount = exportedList.Count; ViewBag.BillId = billId; ViewBag.BillCode = billCode; ViewBag.FromDate = ((DateTime)fromDate).ToString("dd/MM/yyyy"); ViewBag.ToDate = ((DateTime)toDate).ToString("dd/MM/yyyy"); ViewBag.CustomerId = customerId; ViewBag.CustomerName = customerName; ctx.Dispose(); return(PartialView("IndexPartialView", model)); }