/// <summary> /// 得到地区配置 /// </summary> /// <returns></returns> public string GetCityRegion(string city) { CityCodeDao cityDao = new CityCodeDao(); IList<CityCode> list = cityDao.FindAll(); string checkbox = "<input type=\"" + "checkbox\""; StringBuilder sb = new StringBuilder(); string[] cities = city.Split('-').Where(p => p != "").ToArray(); //地区选项 List<string> regions = (from re in list select re.Region).Distinct().ToList(); int identi = 0; bool allregion = true; bool allprovince = true; foreach (string region in regions) { List<CityCode> CityList = (from c in list where c.Region == region select c).ToList(); bool chooseAll = true; StringBuilder child = new StringBuilder(); for (int i = 0; i < CityList.Count; i++) { if (cities.Contains(CityList[i].Value.ToString())) { child.Append(checkbox + " class=\"ckc_" + identi.ToString() + "\" id=\"" + identi + "_" + CityList[i].Value + "\" checked='checked'/>" + CityList[i].Name); } else { child.Append(checkbox + " class=\"ckc_" + identi.ToString() + "\" id=\"" + identi + "_" + CityList[i].Value + "\" />" + CityList[i].Name); chooseAll = false; } } if (chooseAll) { sb.Append("<b>" + checkbox + " id=\"ckc_" + identi.ToString() + "\" checked='checked'/>" + region + "</b>"); } else { sb.Append("<b>" + checkbox + " id=\"ckc_" + identi.ToString() + "\"/>" + region + "</b>"); allregion = false; if (identi < 7) { allprovince = false; } } sb.Append(child.ToString()); sb.Append("<br />"); identi++; } if (allregion) { ViewData["allregion"] = "checked='checked'"; } if (allprovince) { ViewData["allprovince"] = "checked='checked'"; } return sb.ToString(); }
/// <summary> /// 查询 /// </summary> /// <returns></returns> public JsonResult GetCityCode() { CityCodeDao cityDao = new CityCodeDao(); IList<CityCode> list = cityDao.FindAll(); var s =( from m in list select new { CodeValue = m.ID, CodeName = m.Name }).ToList(); JavaScriptSerializer serializer = new JavaScriptSerializer(); string jsonresult = Newtonsoft.Json.JsonConvert.SerializeObject(s); return Json(jsonresult, JsonRequestBehavior.AllowGet); }
public static string GetRegionName(int Id) { string RegionName = new CityCodeDao().Find(Id).Name; return RegionName; }
private string GetRegionSelect() { CityCodeDao cityDao = new CityCodeDao(); IList<CityCode> list = cityDao.FindAll(); StringBuilder sb = new StringBuilder(); sb.Append("<option value=\"all\">——无——</option>"); foreach (CityCode Region in list) { sb.Append("<option value=\"" + Region.ID + "\">" + Region.Name + "</option>"); } return sb.ToString(); }
/// <summary> /// 得到地区配置 /// </summary> /// <returns></returns> public string GetCityRegion() { CityCodeDao cityDao = new CityCodeDao(); IList<CityCode> list = cityDao.FindAll(); string checkbox = "<input type=\"" + "checkbox\""; StringBuilder sb = new StringBuilder(); //地区选项 List<string> regions = (from re in list select re.Region).Distinct().ToList(); int identi = 0; foreach (string region in regions) { List<CityCode> CityList = (from c in list where c.Region == region select c).ToList(); bool chooseAll = true; StringBuilder child = new StringBuilder(); for (int i = 0; i < CityList.Count; i++) { child.Append(checkbox + " class=\"ckc_" + identi.ToString() + "\" id=\"" + identi + "_" + CityList[i].Value + "\" value='"+CityList[i].Value+"' />" + CityList[i].Name); chooseAll = false; } if (chooseAll) { sb.Append("<b>" + checkbox + " id=\"ckc_" + identi.ToString() + "\" checked='checked'/>" + region + "</b>"); } else { sb.Append("<b>" + checkbox + " id=\"ckc_" + identi.ToString() + "\"/>" + region + "</b>"); } sb.Append(child.ToString()); sb.Append("<br />"); identi++; } return sb.ToString(); }