public static int GetAddressID(string ParentName, string AddressName) { int aid = 0; if (!string.IsNullOrEmpty(AddressName)) { Bll_Region BRegion = new Bll_Region(); DataSet ds = BRegion.GetList(0, " RegionName='" + AddressName + "' ", " RegionPath asc "); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int Grade = int.Parse(ds.Tables[0].Rows[i]["RegionGrade"].ToString()); if (Grade > 1) { if (ds.Tables[0].Rows[i]["RegionPath"] != null && ds.Tables[0].Rows[i]["RegionPath"].ToString().Length > 1) { string path = ds.Tables[0].Rows[i]["RegionPath"].ToString().Substring(1, ds.Tables[0].Rows[i]["RegionPath"].ToString().Length - 2);; string[] array = path.Split(','); Mod_Region MRegion = BRegion.GetModel(int.Parse(array[Grade - 2])); if (MRegion != null && MRegion.RegionName == ParentName) { aid = int.Parse(ds.Tables[0].Rows[i]["ID"].ToString()); } } } else { aid = int.Parse(ds.Tables[0].Rows[i]["ID"].ToString()); } } } } return(aid); }
public static string SetAddressToRegion(string Region) { string txtstr = "0,0,0"; if (!string.IsNullOrEmpty(Region)) { Bll_Region BRegion = new Bll_Region(); DataSet ds = BRegion.GetList(" RegionName='" + Region + "' "); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { int RegionID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); Mod_Region dto = BRegion.GetModel(RegionID); if (dto != null) { txtstr = dto.RegionPath.Substring(1, dto.RegionPath.Length - 2); } } } return(txtstr); }
private void Bind() { Bll_Region BRegion = new Bll_Region(); string[] arraySelcetValue = SelectValue.Split(','); if (arraySelcetValue != null && arraySelcetValue.Length == 3) { string ProvinceID = arraySelcetValue[0]; string CityID = arraySelcetValue[1]; string TownID = arraySelcetValue[2]; StringBuilder sb = new StringBuilder(); DataSet ds = BRegion.GetList(0, " RegionGrade=1 and ParentID=0 and WebSiteID=" + WebSiteID + " ", " OrderBy desc,RegionPath asc "); if (ds.Tables.Count > 0) { DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { //一级地区 sb.Append("<select name=\"" + Provinces + "\" id=\"" + Provinces + "\" class=\"" + CssClass + "\" datatype=\"no0\" onchange=\"ProvinceChanged('" + Provinces + "','" + Citys + "','" + Towns + "','" + WebSiteID + "');\">"); sb.Append("<option value=\"0\">请选择</option>"); for (int i = 0; i < dt.Rows.Count; i++) { if (ProvinceID == dt.Rows[i]["ID"].ToString()) { sb.Append("<option value=\"" + dt.Rows[i]["ID"].ToString() + "\" selected=\"selected\">" + dt.Rows[i]["RegionName"].ToString() + "</option>"); } else { sb.Append("<option value=\"" + dt.Rows[i]["ID"].ToString() + "\" >" + dt.Rows[i]["RegionName"].ToString() + "</option>"); } } sb.Append("</select> "); //二级地区 ds.Clear(); dt.Clear(); sb.Append("<select name=\"" + Citys + "\" id=\"" + Citys + "\" class=\"" + CssClass + "\" datatype=\"no0\" onchange=\"CityChanged('" + Provinces + "','" + Citys + "','" + Towns + "','" + WebSiteID + "');\">"); sb.Append("<option value=\"0\">请选择</option>"); if (ProvinceID != "0") { ds = BRegion.GetList(0, " RegionGrade=2 and ParentID=" + ProvinceID + " and WebSiteID=" + WebSiteID + " ", " OrderBy desc,RegionPath asc "); if (ds.Tables.Count > 0) { dt = ds.Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { if (CityID == dt.Rows[i]["ID"].ToString()) { sb.Append("<option value=\"" + dt.Rows[i]["ID"].ToString() + "\" selected=\"selected\">" + dt.Rows[i]["RegionName"].ToString() + "</option>"); } else { sb.Append("<option value=\"" + dt.Rows[i]["ID"].ToString() + "\" >" + dt.Rows[i]["RegionName"].ToString() + "</option>"); } } } } sb.Append("</select> "); //三级地区 ds.Clear(); dt.Clear(); sb.Append("<select name=\"" + Towns + "\" id=\"" + Towns + "\" class=\"" + CssClass + "\" datatype=\"no0\" onchange=\"TownsChanged('" + Provinces + "','" + Citys + "','" + Towns + "','" + WebSiteID + "');\">"); sb.Append("<option value=\"0\">请选择</option>"); if (CityID != "0") { ds = BRegion.GetList(0, " RegionGrade=3 and ParentID=" + CityID + " and WebSiteID=" + WebSiteID + " ", " OrderBy desc,RegionPath asc "); if (ds.Tables.Count > 0) { dt = ds.Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { if (TownID == dt.Rows[i]["ID"].ToString()) { sb.Append("<option value=\"" + dt.Rows[i]["ID"].ToString() + "\" selected=\"selected\">" + dt.Rows[i]["RegionName"].ToString() + "</option>"); } else { sb.Append("<option value=\"" + dt.Rows[i]["ID"].ToString() + "\" >" + dt.Rows[i]["RegionName"].ToString() + "</option>"); } } } } sb.Append("</select>"); } AddressHtml = sb.ToString(); } } }