public JsonResult LoadSearchContractsGrid(string sidx, string sord, int page, int rows, string startTime, string endTime, string contractNo, string originalContractNo, string startCountry, string startProvince, string startCity, string destCountry, string destProvince, string destCity, string carNo, string organId) { //读取数据 string strErrText; ContractSystem contract = new ContractSystem(); List<Contract> listContract = contract.LoadContractsByConditions(startTime, endTime, contractNo, originalContractNo, startCountry, startProvince, startCity, 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 ?? "ContractNo") + " " + (sord ?? "ASC"); 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.StartPlace, c.DestPlace, c.CarNo, c.TrailerNo, c.GoodsName, c.TotalTunnages.ToString("#0.######"), c.TotalPiles.ToString("#0.######"), c.TotalTransportCharges.ToString(), c.ApproveState == InnoSoft.LS.Resources.Options.Approved ? (c.ApproveCount > 0 ? c.ApproveState : string.Empty) : c.ApproveFlowStepName, c.OwnOrganName } }).ToArray() }; return Json(ret, JsonRequestBehavior.AllowGet); }