예제 #1
0
        public JsonResult LoadCarrierSettlementExpressionGrid(string id, string sidx, string sord, int page, int rows)
        {
            //读取全部数据
            string strErrText;
            DDSystem dd = new DDSystem();
            List<CarrierSettlementExpression> listExpression = dd.LoadCarrierSettlementExpressions(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText);
            if (listExpression == null)
            {
                throw new Exception(strErrText);
            }

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

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

            //生成表格数据
            var ret = new
            {
                total = nTotalPages,
                page = nPageIndex,
                records = nTotalRows,
                rows = (
                      from e in data
                      select new
                      {
                          id = e.Id,
                          cell = new string[]
                          {
                              e.Id.ToString(),
                              e.PlanType,
                              e.TransportChargeExpression,
                              e.TransportPriceExpression
                          }
                      }).ToArray()
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }