Exemplo n.º 1
0
        public JsonResult LoadSearchCustomerStorageAndForceFeeSettlementsGrid(string sidx, string sord, int page, int rows, string startTime, string endTime, string invoiceNo, string customerName)
        {
            //读取数据
            string strErrText;
            StockSystem stock = new StockSystem();
            List<CustomerStorageAndForceFeeSettlement> listCustomerStorageAndForceFeeSettlement = stock.LoadCustomerStorageAndForceFeeSettlementsByConditions(startTime, endTime, invoiceNo, customerName, LoginAccountId, LoginStaffName, out strErrText);
            if (listCustomerStorageAndForceFeeSettlement == null)
            {
                throw new Exception(strErrText);
            }

            //提取当前页面数据
            int nTotalRows = listCustomerStorageAndForceFeeSettlement.Count;
            int nPageIndex = page;
            int nPageSize = rows;
            int nTotalPages = nTotalRows / nPageSize;
            if (nTotalRows % nPageSize > 0)
                nTotalPages++;

            string sortExpression = (sidx ?? "CustomerName") + " " + (sord ?? "ASC");
            var data = listCustomerStorageAndForceFeeSettlement.OrderBy(sortExpression).Skip((nPageIndex - 1) * nPageSize).Take(nPageSize).ToList();

            //生成表格数据
            var ret = new
            {
                total = nTotalPages,
                page = nPageIndex,
                records = nTotalRows,
                rows = (
                      from i in data
                      select new
                      {
                          id = i.Id,
                          cell = new string[] {
                              i.Id.ToString(),
                              i.CustomerName,
                              i.StartTime.ToString("yyyy-MM-dd"),
                              i.EndTime.ToString("yyyy-MM-dd"),
                              i.InvoiceNo,
                              i.InvoiceType,
                              i.InvoiceAmount.ToString(),
                              i.Remark
                          }
                      }).ToArray()
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }