/// <summary> /// 初始化编辑时地址下拉框 /// </summary> /// <param name="user"></param> public void InitialEditAddress(DataOfUserDetial user) { CountryList.Clear(); ProvinceList.Clear(); CityList.Clear(); AreaList.Clear(); var countryList = new Areas() { parent_id = 0, type = 1 }.GetChildrenList(); var provinceList = new Areas() { parent_id = 1 /*user.countryId*/, type = 2 }.GetChildrenList(); var cityList = new Areas() { parent_id = user.provinceId, type = 3 }.GetChildrenList(); var areaList = new Areas() { parent_id = user.cityId, type = 4 }.GetChildrenList(); CountryList.AddRange(countryList.ToObservableCollection()); ProvinceList.AddRange(provinceList.ToObservableCollection()); CityList.AddRange(cityList.ToObservableCollection()); AreaList.AddRange(areaList.ToObservableCollection()); CountryIndex = 1; //user.countryId; ProvinceIndex = user.provinceId; CityIndex = user.cityId; AreaIndex = user.areaId; }
public void Refresh(bool refr_1 = true, bool refr_2 = true, bool refr_3 = true, bool refr_4 = true) { if (refr_1) { AreaList.Clear(); AreaList.AddRange(PubMaster.Mod.AreaSql.QueryAreaList()); } if (refr_2) { AreaDevList.Clear(); AreaDevList.AddRange(PubMaster.Mod.AreaSql.QueryAreaDeviceList()); } if (refr_3) { AreaTraList.Clear(); AreaTraList.AddRange(PubMaster.Mod.AreaSql.QueryAreaTrackList()); } if (refr_4) { AreaDevTraList.Clear(); AreaDevTraList.AddRange(PubMaster.Mod.AreaSql.QueryAreaDeviceTrackList()); } }
/// <summary> /// 初始化地址 /// </summary> /// <param name="user">对应的用户</param> public void InitialViewAddress(DataOfUserDetial user) { MyDetialPage = 0; CountryList.Clear(); ProvinceList.Clear(); CityList.Clear(); AreaList.Clear(); var countryList = new Areas() { parent_id = 0, type = 1 }.GetChildrenList(); CountryList.AddRange(countryList.ToObservableCollection()); var currentCoun = countryList.FirstOrDefault(c => c.id == user.countryId); DCountry = (currentCoun == null) ? "" : currentCoun.name;//设置国家名称 var provinceList = new Areas() { parent_id = user.countryId == 0 ? (1) : (user.countryId), type = 2 }.GetChildrenList(); //如果未选择国家则默认为中国 ProvinceList.AddRange(provinceList.ToObservableCollection()); var currentProvin = provinceList.FirstOrDefault(c => c.id == user.provinceId); DProvince = (currentProvin == null) ? "" : currentProvin.name;//设置省份名称 var cityList = new Areas() { parent_id = user.provinceId, type = 3 }.GetChildrenList(); CityList.AddRange(cityList.ToObservableCollection()); var cuttentCity = cityList.FirstOrDefault(c => c.id == user.cityId); DCity = cuttentCity == null ? "" : cuttentCity.name;//设置城市名称 var areaList = new Areas() { parent_id = user.cityId, type = 4 }.GetChildrenList(); AreaList.AddRange(areaList.ToObservableCollection()); var currentArea = areaList.FirstOrDefault(c => c.id == user.areaId); DArea = currentArea == null ? "" : currentArea.name;//设置区域名称 }