Exemple #1
0
        public JsonResult LoadSearchContractReverseDetailsGrid(string sidx, string sord, int page, int rows, string reverseId)
        {
            //读取数据
            string strErrText;
            ContractSystem contract = new ContractSystem();
            List<ContractReverseDetail> listDetail = contract.LoadContractReverseDetailsByReverseId(long.Parse(reverseId), LoginAccountId, LoginStaffName, out strErrText);
            if (listDetail == null)
            {
                throw new Exception(strErrText);
            }

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

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

            //生成表格数据
            var ret = new
            {
                total = nTotalPages,
                page = nPageIndex,
                records = nTotalRows,
                rows = (
                      from d in data
                      select new
                      {
                          id = d.Id,
                          cell = new string[] {
                              d.Id.ToString(),
                              d.ContractId.ToString(),
                              d.ContractNo,
                              d.OriginalContractNo,
                              d.GoodsName,
                              d.StartPlace,
                              d.DestPlace,
                              d.ShipmentTime.ToString("yyyy-MM-dd"),
                              d.CarNo,
                              d.TrailerNo,
                              d.DriverName,
                              d.DriverMobileTel,
                              d.TotalTunnages.ToString("#0.######"),
                              d.TotalPiles.ToString("#0.######"),
                              d.TotalTransportCharges.ToString(),
                              d.ReverseAmount.ToString(),
                              d.WithholdAmount.ToString(),
                              d.FactpaymentAmount.ToString()
                          }
                      }).ToArray(),
                userdata = new
                {
                    ContractNo = InnoSoft.LS.Resources.Labels.Total,
                    TotalTransportCharges = data.Sum(s => s.TotalTransportCharges),
                    ReverseAmount = data.Sum(s => s.ReverseAmount),
                    WithholdAmount = data.Sum(s => s.WithholdAmount),
                    FactpaymentAmount = data.Sum(s => s.FactpaymentAmount)
                }
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }