public JsonResult LoadContractApproveCommentsGrid(string sidx, string sord, int page, int rows, string contractId, string planId) { //读取数据 string strErrText; ContractSystem contract = new ContractSystem(); List<ContractApproveComment> listComment = contract.LoadContractApproveComments(long.Parse(contractId), long.Parse(planId), LoginAccountId, LoginStaffName, out strErrText); if (listComment == null) { throw new Exception(strErrText); } //提取当前页面数据 int nTotalRows = listComment.Count; int nPageIndex = page; int nPageSize = rows; int nTotalPages = nTotalRows / nPageSize; if (nTotalRows % nPageSize > 0) nTotalPages++; string sortExpression = (sidx ?? "ApproveTime") + " " + (sord ?? "ASC"); var data = listComment.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.ApproveTime.ToString("yyyy-MM-dd"), p.ApproverName, p.ApprovedTransportPrice.ToString("#0.######"), p.ApprovedTransportCharges.ToString() } }).ToArray() }; return Json(ret, JsonRequestBehavior.AllowGet); }