Пример #1
0
        public JsonResult LoadCarrierCars(string carrierName)
        {
            string strErrText;
            DDSystem dd = new DDSystem();
            List<CarrierCar> listCar = dd.LoadCarrierCars(carrierName, LoginAccountId, LoginStaffName, out strErrText);
            if (listCar == null)
            {
                throw new Exception(strErrText);
            }

            var ret = from c in listCar
                      select new
                      {
                          c.CarNo,
                          c.TrailerNo,
                          c.CarryingCapacity
                      };

            return Json(ret, JsonRequestBehavior.AllowGet);
        }
Пример #2
0
        public JsonResult LoadCarrierCarGrid(string id, string sidx, string sord, int page, int rows)
        {
            //读取全部数据
            string strErrText;
            DDSystem dd = new DDSystem();
            List<CarrierCar> listCar = dd.LoadCarrierCars(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText);
            if (listCar == null)
            {
                throw new Exception(strErrText);
            }

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

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

            //生成表格数据
            var ret = new
            {
                total = nTotalPages,
                page = nPageIndex,
                records = nTotalRows,
                rows = (
                      from p in data
                      select new
                      {
                          id = p.Id,
                          cell = new string[]
                          {
                              p.Id.ToString(),
                              p.CarNo,
                              p.TrailerNo,
                              p.CarryingCapacity.ToString()
                          }
                      }).ToArray()
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }