Пример #1
0
    public string GenerateCountryLinks(string regionID)
    {
        DataTable     dtCountryList = new DataTable();
        DataTable     dtStateList   = new DataTable();
        StringBuilder sb            = new StringBuilder();

        //----------------------------North America
        //north amer
        dtCountryList = VADBCommander.CountiesByRegionList(regionID);
        //dtCountryList = VADBCommander.CountriesByRegionList(regionID);
        if (dtCountryList.Rows.Count > 0)
        {
            //sb.AppendLine("<ul class=\"TripleListMain\">");
            foreach (DataRow row in dtCountryList.Rows)
            {
                //we list the country first
                sb.AppendLine("<a class=\"mainPgCountry\" href=\"" + CommonFunctions.PrepareURL(row["country"].ToString().ToLower().Replace(" ", "_") + "/default.aspx") + "\"><b>" + row["country"].ToString().ToUpper() + "</b></a>, ");
                bool stateDown = false;

                //we grab all of the states for that country

                dtStateList = VADBCommander.StateProvinceByCountryList(row["id"].ToString());

                if (dtStateList.Rows.Count > 0)
                {
                    if (dtStateList.Rows.Count > 0)
                    {
                        foreach (DataRow rowTemp in dtStateList.Rows)
                        {
                            DataTable dtCityList = VADBCommander.CityStateCountryRegionList(rowTemp["id"].ToString());
                            //add cities to lower
                            if (dtCityList.Rows.Count > 0)
                            {
                                sb.AppendLine("<a class=\"mainState\" href=\"" + CommonFunctions.PrepareURL(row["country"].ToString().ToLower().Replace(" ", "_").Replace(" ", "_").ToLower() + "/" + rowTemp["stateprovince"].ToString().Replace(" ", "_").ToLower() + "/default.aspx") + "\">" + rowTemp["stateprovince"].ToString().Replace(" ", "&nbsp;").Replace("-", "&#8209;") + "</a>");
                                sb.AppendLine(":  ");
                                foreach (DataRow row1 in dtCityList.Rows)
                                {
                                    sb.AppendLine("<a class=\"mainCity\" href=\"" + CommonFunctions.PrepareURL(row["country"].ToString().ToLower().Replace(" ", "_") + "/" + rowTemp["stateProvince"].ToString().Replace(" ", "_").ToLower() + "/" + row1["city"].ToString().ToLower().Replace(" ", "_") + "/default.aspx") + "\" class=\"mainCity\">" + row1["city"].ToString().Replace(" ", "&nbsp;").Replace("-", "&#8209;") + "</a>, ");
                                }
                            }
                            else
                            {
                                sb.AppendLine("<a class=\"mainState\" href=\"" + CommonFunctions.PrepareURL(row["country"].ToString().ToLower().Replace(" ", "_").Replace(" ", "_").ToLower() + "/" + rowTemp["stateprovince"].ToString().Replace(" ", "_").ToLower() + "/default.aspx") + "\">" + rowTemp["stateprovince"].ToString().Replace(" ", "&nbsp;").Replace("-", "&#8209;") + "</a>");
                            }
                        }
                    }
                    else
                    {
                        sb.AppendLine(", ");
                    }
                } /**/
            }
        }
        string str = sb.ToString();

        str = str.Remove(str.Length - 2);
        return(str);
    }