Example #1
0
        public JsonResult LoadSaveFinesGrid(string sidx, string sord, int page, int rows, string saveFines)
        {
            //读取数据
            List<Contract> listFineContract = new List<Contract>();
            if (saveFines != string.Empty)
            {
                string strErrText;
                ContractSystem contract = new ContractSystem();
                List<Contract> listContract = contract.LoadFineContractsByConditions(string.Empty, string.Empty, string.Empty, LoginAccountId, LoginStaffName, out strErrText);
                if (listContract == null)
                {
                    throw new Exception(strErrText);
                }

                //过滤数据
                string[] fines = saveFines.Split(',');
                foreach (string fine in fines)
                {
                    if (fine != string.Empty)
                    {
                        string[] s = fine.Split('|');
                        long nContractId = long.Parse(s[0]);
                        decimal decFineAmount = decimal.Parse(s[1]);

                        Contract o = listContract.Find(delegate(Contract c) { return c.Id == nContractId; });
                        if (o == null)
                        {
                            throw new Exception(InnoSoft.LS.Resources.Strings.FindFineContractDataFaild);
                        }
                        o.FineAmount = decFineAmount;
                        listFineContract.Add(o);
                    }
                }
            }

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

            string sortExpression = (sidx ?? "ContractNo") + " " + (sord ?? "ASC");
            var data = listFineContract.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.CarNo,
                              c.TrailerNo,
                              c.DriverName,
                              c.DriverMobileTel,
                              c.CreatorName,
                              c.FineAmount.ToString()
                          }
                      }).ToArray(),
                userdata = new
                {
                    ContractNo = InnoSoft.LS.Resources.Labels.Total,
                    FineAmount = data.Sum(s => s.FineAmount)
                }
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }
Example #2
0
        public JsonResult LoadFineContractsGrid(string sidx, string sord, int page, int rows, string contractNo, string originalContractNo, string transactorId)
        {
            //读取数据
            string strErrText;
            ContractSystem contract = new ContractSystem();
            List<Contract> listContract = contract.LoadFineContractsByConditions(contractNo, originalContractNo, transactorId, 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.CarNo,
                              c.TrailerNo,
                              c.DriverName,
                              c.DriverMobileTel,
                              c.GoodsName,
                              c.TotalTunnages.ToString("#0.######"),
                              c.TotalPiles.ToString("#0.######"),
                              c.TotalOriginalTransportCharges.ToString(),
                              c.TotalApprovedTransportCharges.ToString(),
                              (c.TotalOriginalTransportCharges - c.TotalApprovedTransportCharges).ToString(),
                              c.CreatorName
                          }
                      }).ToArray(),
                userdata = new
                {
                    ContractNo = InnoSoft.LS.Resources.Labels.Total,
                    TotalTransportCharges = data.Sum(s => s.TotalOriginalTransportCharges),
                    TotalApproveTransportCharges = data.Sum(s => s.TotalApprovedTransportCharges),
                    TransportChargesBalance = data.Sum(s => s.TotalOriginalTransportCharges) - data.Sum(s => s.TotalApprovedTransportCharges)
                }
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }