Ejemplo n.º 1
0
        public JsonResult LoadTransportLimitedPriceGrid(string sidx, string sord, int page, int rows, string planType, string startCountry, string startProvince, string startCity, string destCountry, string destProvince, string destCity, string modifiedIds)
        {
            //读取全部数据
            string strErrText;
            DDSystem dd = new DDSystem();
            List<TransportLimitedPrice> listPrice = dd.LoadTransportLimitedPricesByConditions(planType, startCountry, startProvince, startCity, destCountry, destProvince, destCity, LoginAccountId, LoginStaffName, out strErrText);
            if (listPrice == null)
            {
                throw new Exception(strErrText);
            }

            //剔除已经修改成功的记录
            listPrice = listPrice.FindAll(delegate(TransportLimitedPrice p) { return modifiedIds.IndexOf(p.Id.ToString()) < 0; });

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

            var data = listPrice.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.PlanType,
                              p.StartCountry,
                              p.StartProvince,
                              p.StartCity,
                              p.DestCountry,
                              p.DestProvince,
                              p.DestCity,
                              p.CarType,
                              p.MinTunnagesOrPiles.ToString("#0.######"),
                              p.MaxTunnagesOrPiles.ToString("#0.######"),
                              p.StartTime.ToString("yyyy-MM-dd"),
                              p.EndTime.ToString("yyyy-MM-dd"),
                              p.TransportPrice.ToString("#0.######"),
                              p.TransportCharges.ToString("#0.######")
                          }
                      }).ToArray()
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }