Beispiel #1
0
        public JsonResult LoadReverseContractsGrid(string sidx, string sord, int page, int rows, string startTime, string endTime, string contractNo, string originalContractNo, string carrierName, string carNo, string organId)
        {
            //读取数据
            string strErrText;
            ContractSystem contract = new ContractSystem();
            List<Contract> listContract = contract.LoadReverseContractsByConditions(startTime, endTime, contractNo, originalContractNo, carrierName, 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.GoodsName,
                              c.StartPlace,
                              c.DestPlace,
                              c.ShipmentTime.ToString("yyyy-MM-dd"),
                              c.CarNo,
                              c.TrailerNo,
                              c.DriverName,
                              c.DriverMobileTel,
                              c.TotalTunnages.ToString("#0.######"),
                              c.TotalPiles.ToString("#0.######"),
                              c.TotalTransportCharges.ToString(),
                              c.PrepayTransportCharges.ToString(),
                              c.ResidualTransportCharges.ToString(),
                              c.ReverseAmount.ToString(),
                              (c.TotalTransportCharges - c.ReverseAmount).ToString()
                          }
                      }).ToArray(),
                userdata = new
                {
                    ContractNo = InnoSoft.LS.Resources.Labels.Total,
                    TotalTransportCharges = data.Sum(s => s.TotalTransportCharges),
                    PrepayTransportCharges = data.Sum(s => s.PrepayTransportCharges),
                    ResidualTransportCharges = data.Sum(s => s.ResidualTransportCharges),
                    ReverseAmount = data.Sum(s => s.ReverseAmount),
                    ResidualReverseAmount = data.Sum(s => s.TotalTransportCharges - s.ReverseAmount)
                }
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }