public ActionResult NewProvince() { string strErrText; //生成国家下拉列表项 DDSystem dd = new DDSystem(); List <Country> listCountry = dd.LoadCountrys(LoginAccountId, LoginStaffName, out strErrText); if (listCountry == null) { throw new Exception(strErrText); } List <SelectListItem> selectListCountry = new List <SelectListItem>(); selectListCountry.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListCountry.AddRange(from c in listCountry select new SelectListItem { Text = c.Name, Value = c.Name }); ViewData["Countries"] = new SelectList(selectListCountry, "Value", "Text"); //创建空的Model ProvinceViewModel model = new ProvinceViewModel(); return(View(model)); }
public JsonResult LoadCountrysGrid(string sidx, string sord, int page, int rows) { //读取全部数据 string strErrText; DDSystem country = new DDSystem(); List <Country> listCountry = country.LoadCountrys(LoginAccountId, LoginStaffName, out strErrText); if (listCountry == null) { throw new Exception(strErrText); } //提取当前页面数据 int nTotalRows = listCountry.Count; int nPageIndex = page; int nPageSize = rows; int nTotalPages = nTotalRows / nPageSize; if (nTotalRows % nPageSize > 0) { nTotalPages++; } string sortExpression = (sidx ?? "Id") + " " + (sord ?? "ASC"); var data = listCountry.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.Name, c.Remark, } }).ToArray() }; return(Json(ret, JsonRequestBehavior.AllowGet)); }
public JsonResult LoadCountrys() { string strErrText; DDSystem dd = new DDSystem(); List <Country> listCountry = dd.LoadCountrys(LoginAccountId, LoginStaffName, out strErrText); if (listCountry == null) { throw new Exception(strErrText); } var ret = from c in listCountry select c.Name; return(Json(ret, JsonRequestBehavior.AllowGet)); }
public ActionResult ModifyProvince(string id) { string strErrText; //生成Model数据 DDSystem province = new DDSystem(); Province data = province.LoadProvince(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText); if (data == null) { throw new Exception(strErrText); } ProvinceViewModel model = new ProvinceViewModel(); model.Id = data.Id; model.Name = data.Name; model.CountryName = data.CountryName; model.Remark = data.Remark; //生成国家下拉列表项 DDSystem dd = new DDSystem(); List <Country> listCountry = dd.LoadCountrys(LoginAccountId, LoginStaffName, out strErrText); if (listCountry == null) { throw new Exception(strErrText); } List <SelectListItem> selectListCountry = new List <SelectListItem>(); selectListCountry.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListCountry.AddRange(from c in listCountry select new SelectListItem { Text = c.Name, Value = c.Name }); ViewData["Countries"] = new SelectList(selectListCountry, "Value", "Text", model.CountryName); return(View(model)); }
public ActionResult ModifyCity(string id) { string strErrText; //生成Model数据 DDSystem city = new DDSystem(); City data = city.LoadCity(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText); if (data == null) { throw new Exception(strErrText); } CityViewModel model = new CityViewModel(); model.Id = data.Id; model.Name = data.Name; model.CountryName = data.CountryName; model.ProvinceName = data.ProvinceName; model.Remark = data.Remark; //生成国家下拉列表项 DDSystem dd = new DDSystem(); List <Country> listCountry = dd.LoadCountrys(LoginAccountId, LoginStaffName, out strErrText); if (listCountry == null) { throw new Exception(strErrText); } List <SelectListItem> selectListCountry = new List <SelectListItem>(); selectListCountry.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListCountry.AddRange(from c in listCountry select new SelectListItem { Text = c.Name, Value = c.Name }); ViewData["Countries"] = new SelectList(selectListCountry, "Value", "Text", model.CountryName); //生成空的省份下拉列表项 List <Province> listState = null; if (!string.IsNullOrEmpty(model.CountryName)) { listState = dd.LoadProvincesByCountry(model.CountryName, LoginAccountId, LoginStaffName, out strErrText); if (listState == null) { throw new Exception(strErrText); } } else { listState = new List <Province>(); } List <SelectListItem> selectListState = new List <SelectListItem>(); selectListState.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListState.AddRange(from s in listState select new SelectListItem { Text = s.Name, Value = s.Name }); ViewData["States"] = new SelectList(selectListState, "Value", "Text", model.ProvinceName); return(View(model)); }