public JsonResult LoadApproveContractsGrid(string sidx, string sord, int page, int rows, string startTime, string endTime, string contractNo, string originalContractNo, string destCountry, string destProvince, string destCity, string carNo, string organId) { //读取数据 string strErrText; ContractSystem contract = new ContractSystem(); List<Contract> listContract = contract.LoadApproveContractsByConditions(startTime, endTime, contractNo, originalContractNo, destCountry, destProvince, destCity, carNo, organId, LoginAccountId, LoginStaffName, out strErrText); if (listContract == null) { throw new Exception(strErrText); } //提取当前页面数据 int nTotalRows = listContract.Count; int nPageIndex = page; int nPageSize = rows; int nTotalPages = nTotalRows / nPageSize; if (nTotalRows % nPageSize > 0) nTotalPages++; string sortExpression = (sidx ?? "ShipmentTime") + " " + (sord ?? "DESC"); var data = listContract.OrderBy(sortExpression).Skip((nPageIndex - 1) * nPageSize).Take(nPageSize).ToList(); //生成表格数据 var ret = new { total = nTotalPages, page = nPageIndex, records = nTotalRows, rows = ( from c in data select new { id = c.Id, cell = new string[] { c.Id.ToString(), c.ContractNo, c.OriginalContractNo, c.ShipmentTime.ToString("yyyy-MM-dd"), c.CarNo, c.TrailerNo, c.CarType, c.DriverName, c.DriverMobileTel, c.GoodsName, c.TotalTunnages.ToString("#0.######"), c.TotalPiles.ToString("#0.######"), c.TotalTransportCharges.ToString() } }).ToArray() }; return Json(ret, JsonRequestBehavior.AllowGet); }