Esempio n. 1
0
        public JsonResult LoadCitysByProvince(string strCountryName, string strProvinceName)
        {
            string      strErrText;
            DDSystem    dd       = new DDSystem();
            List <City> listCity = dd.LoadCitysByProvince(strCountryName, strProvinceName, LoginAccountId, LoginStaffName, out strErrText);

            if (listCity == null)
            {
                throw new Exception(strErrText);
            }

            var ret = from c in listCity
                      select c.Name;

            return(Json(ret, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public JsonResult LoadCitysGrid(string country, string province, string sidx, string sord, int page, int rows)
        {
            //读取全部数据
            string      strErrText;
            DDSystem    city     = new DDSystem();
            List <City> listCity = null;

            if (country == null || country == InnoSoft.LS.Resources.Options.SelectCountry)
            {
                listCity = city.LoadCitys(LoginAccountId, LoginStaffName, out strErrText);
            }
            else
            {
                if (province == null || province == InnoSoft.LS.Resources.Options.SelectProvince)
                {
                    listCity = city.LoadCitysByCountry(country, LoginAccountId, LoginStaffName, out strErrText);
                }
                else
                {
                    listCity = city.LoadCitysByProvince(country, province, LoginAccountId, LoginStaffName, out strErrText);
                }
            }
            if (listCity == null)
            {
                throw new Exception(strErrText);
            }

            //提取当前页面数据
            int nTotalRows  = listCity.Count;
            int nPageIndex  = page;
            int nPageSize   = rows;
            int nTotalPages = nTotalRows / nPageSize;

            if (nTotalRows % nPageSize > 0)
            {
                nTotalPages++;
            }

            var data = listCity.OrderBy(c => c.ProvinceName).ThenBy(c => c.Name).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.Name,
                        c.CountryName,
                        c.ProvinceName,
                        c.Remark,
                    }
                }).ToArray()
            };

            return(Json(ret, JsonRequestBehavior.AllowGet));
        }