コード例 #1
0
        public PartialViewResult PagingContent(DateTime?fromdate, DateTime?todate,
                                               int?customerId, string customerName, int?storeId, string storeName, int?currentPageIndex)
        {
            if (string.IsNullOrEmpty(storeName))
            {
                storeName = string.Empty;
                storeId   = 0;
            }
            if (fromdate == null)
            {
                fromdate = SystemConstant.MIN_DATE;
            }
            else
            {
                ViewBag.FromDate = DateTime.Parse(fromdate.ToString()).ToString("dd/MM/yyyy");
            }

            if (todate == null)
            {
                todate = SystemConstant.MAX_DATE;
            }
            else
            {
                ViewBag.toDate = DateTime.Parse(todate.ToString()).ToString("dd/MM/yyyy");
            }
            var ctx       = new SmsContext();
            int pageSize  = SystemConstant.ROWS;
            int pageIndex = currentPageIndex == null ? 1 : (int)currentPageIndex;
            var list      = ctx.SP_GET_HOA_DON_CAN_XUAT_KHO(Convert.ToInt32(customerId), customerName, Convert.ToInt32(storeId), storeName, fromdate, todate).OrderByDescending(uh => uh.NGAY_BAN)
                            .Take(SystemConstant.MAX_ROWS).ToList <SP_GET_HOA_DON_CAN_XUAT_KHO_Result>();
            ExportModel model = new ExportModel();

            model.WaitingList    = list.ToPagedList(pageIndex, pageSize);
            model.PageCount      = list.Count;
            ViewBag.storeId      = storeId;
            ViewBag.StoreId      = storeId;
            ViewBag.StoreName    = storeName;
            ViewBag.CustomerId   = customerId;
            ViewBag.CustomerName = customerName;
            ViewBag.Todate       = ((DateTime)todate).ToString("dd/MM/yyyy");
            ViewBag.Fromdate     = ((DateTime)fromdate).ToString("dd/MM/yyyy");
            ctx.Dispose();
            return(PartialView("IndexPartialView", model));
        }