public JsonResult LoadCarrierTransportPriceGrid(string id, string sidx, string sord, int page, int rows) { //读取全部数据 string strErrText; DDSystem dd = new DDSystem(); List<CarrierTransportPrice> listPrice = dd.LoadCarrierTransportPrices(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText); if (listPrice == null) { throw new Exception(strErrText); } //提取当前页面数据 int nTotalRows = listPrice.Count; int nPageIndex = page; int nPageSize = rows; int nTotalPages = nTotalRows / nPageSize; if (nTotalRows % nPageSize > 0) nTotalPages++; string sortExpression = (sidx ?? "Id") + " " + (sord ?? "ASC"); var data = listPrice.OrderBy(sortExpression).Skip((nPageIndex - 1) * nPageSize).Take(nPageSize).ToList(); //生成表格数据 var ret = new { total = nTotalPages, page = nPageIndex, records = nTotalRows, rows = ( from p in data select new { id = p.Id, cell = new string[] { p.Id.ToString(), p.StartCountry, p.StartProvince, p.StartCity, p.DestCountry, p.DestProvince, p.DestCity, p.PlanType, p.StartTime.ToString("yyyy-MM-dd"), p.EndTime.ToString("yyyy-MM-dd"), p.TransportPrice.ToString("#0.######") } }).ToArray() }; return Json(ret, JsonRequestBehavior.AllowGet); }