Beispiel #1
0
        public JsonResult LoadSubmitDispatchBillsGrid(string sidx, string sord, int page, int rows)
        {
            //读取数据
            string strErrText;
            DispatchSystem dispatch = new DispatchSystem();
            List<DispatchBill> listDispatchBill = dispatch.LoadSubmitDispatchBills(LoginAccountId, LoginStaffName, out strErrText);
            if (listDispatchBill == null)
            {
                throw new Exception(strErrText);
            }

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

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

            //生成表格数据
            var ret = new
            {
                total = nTotalPages,
                page = nPageIndex,
                records = nTotalRows,
                rows = (
                      from b in data
                      select new
                      {
                          id = b.Id,
                          cell = new string[] {
                              b.Id.ToString(),
                              b.DispatchBillNo,
                              b.CarNo,
                              b.TrailerNo,
                              b.CarType,
                              b.DriverName,
                              b.DriverMobileTel,
                              b.CarryingCapacity.ToString(),
                              b.TotalTunnages.ToString("#0.######"),
                              b.TotalPiles.ToString("#0.######"),
                              b.TotalTransportCharges.ToString()
                          }
                      }).ToArray()
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }