示例#1
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        RegionCountriesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "select distinct Country,Region from Countries inner join Regions on Countries.RegionID=Regions.ID " +
                                                                " inner join StateProvinces on StateProvinces.CountryID=Countries.ID " +
                                                                "where (RegionID=@RegionID)  AND EXISTS (" +
                                                                " SELECT * FROM Properties INNER JOIN Cities ON Properties.CityID = Cities.ID" +
                                                                " WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1)" +
                                                                " AND (Cities.StateProvinceID = StateProvinces.ID) " +
                                                                " AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID)) " +
                                                                "ORDER BY Country", SqlDbType.Int);
        StateProvincesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT StateProvinces.* " +
                                                               "FROM StateProvinces " +
                                                               "WHERE (StateProvinces.CountryID = @CountryID) AND EXISTS (" +
                                                               " SELECT * FROM Properties INNER JOIN Cities ON Properties.CityID = Cities.ID" +
                                                               " WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1)" +
                                                               " AND (Cities.StateProvinceID = StateProvinces.ID) " +
                                                               " AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID)) " +
                                                               "ORDER BY StateProvince", SqlDbType.Int);
        // StateCodeInfo.Text = SqlDbType.Int.
        CitiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), String.Format(STR_SELECTCitiesFROMCitiesWHERECitiesStateProvinceID), SqlDbType.Int);

        const string STR_SELECTPropertiesInfo = "SELECT Properties.Name2 as PropertyName2, Properties.Name, Properties.NumBedrooms, Properties.NumBaths, Properties.NumSleeps, Properties.NumTVs, Properties.NumVCRs, Properties.CityID, Properties.NumCDPlayers, Properties.ID, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Beach Front')) THEN 'Beach Front' ELSE '' END AS BeachFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Seaside')) THEN 'Seaside' ELSE '' END AS Seaside, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Lake Front')) THEN 'Lake Front' ELSE '' END AS LakeFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'River Front')) THEN 'River Front' ELSE '' END AS RiverFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Ski In Ski Out')) THEN 'Ski In Ski Out' ELSE '' END AS Ski, Cities.City, StateProvinces.StateProvince, Countries.Country, Regions.Region, MinimumNightlyRentalTypes.Name AS MinimumNightlyRental, PropertyTypes.Name AS Type FROM Properties INNER JOIN Cities ON Properties.CityID = Cities.ID INNER JOIN StateProvinces ON StateProvinces.ID = Cities.StateProvinceID INNER JOIN Countries ON StateProvinces.CountryID = Countries.ID INNER JOIN Regions ON Countries.RegionID = Regions.ID INNER JOIN Users ON Properties.UserID = Users.ID LEFT OUTER JOIN MinimumNightlyRentalTypes ON Properties.MinimumNightlyRentalID = MinimumNightlyRentalTypes.ID LEFT OUTER JOIN PropertyTypes ON Properties.TypeID = PropertyTypes.ID WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND (StateProvinces.CountryID = @CountryID) AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID) ORDER BY StateProvinces.StateProvince, Cities.City, Type, CASE WHEN EXISTS (SELECT * FROM Invoices WHERE (PropertyID = Properties.ID) AND (PaymentAmount >= InvoiceAmount) AND (GETDATE() <= Invoices.RenewalDate)) THEN 1 ELSE 0 END DESC, Properties.ID";

        PropertiesAdapter  = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), String.Format(STR_SELECTPropertiesInfo), SqlDbType.Int);
        Properties2Adapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "Select * from Properties", SqlDbType.Int);

        AmenitiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT Amenities.ID, Amenity," +
                                                          " PropertiesAmenities.PropertyID " +
                                                          "FROM Amenities INNER JOIN PropertiesAmenities ON Amenities.ID = PropertiesAmenities.AmenityID" +
                                                          " INNER JOIN Properties ON PropertiesAmenities.PropertyID = Properties.ID " +
                                                          " INNER JOIN Cities ON Properties.CityID = Cities.ID INNER JOIN StateProvinces ON StateProvinces.ID = Cities.StateProvinceID " +
                                                          "WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND (StateProvinces.CountryID = @CountryID)" +
                                                          " AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID) AND (Amenities.Amenity NOT IN" +
                                                          " ('Lake Front', 'Beach Front', 'River Front', 'Seaside', 'Ski In Ski Out', 'TV', 'VCR', 'CD Player'))",
                                                          SqlDbType.Int);

        LocationAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT StateProvinces.ID AS StateProvinceID," +
                                                         " StateProvinces.StateProvince, Countries.ID AS CountryID, Countries.Country, Regions.ID AS RegionID," +
                                                         " Regions.Region, Countries.titleoverride, stateprovinces.descriptionoverride " +
                                                         "FROM StateProvinces INNER JOIN Countries ON StateProvinces.CountryID = Countries.ID" +
                                                         " INNER JOIN Regions ON Countries.RegionID = Regions.ID WHERE (Countries.ID = @CountryId)",
                                                         SqlDbType.Int);

        PropertyTypesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT     PropertyTypes.Name,COUNT(*) as Count, PropertyTypes.ID " +
                                                              " FROM         Cities INNER JOIN " +
                                                              " Properties ON Cities.ID = Properties.CityID  " +
                                                              " INNER JOIN " +
                                                              " PropertyTypes ON Properties.TypeID = PropertyTypes.ID INNER JOIN " +
                                                              " StateProvinces ON Cities.StateProvinceID = StateProvinces.ID INNER JOIN " +
                                                              " Countries ON StateProvinces.CountryID = Countries.ID  WHERE (Countries.ID = @CountryId) " +
                                                              "group by PropertyTypes.Name,PropertyTypes.ID",
                                                              SqlDbType.Int);

        if ((Request.Params["CountryID"] != null))
        {
            try
            {
                countryid = Convert.ToInt32(Request.Params["CountryID"]);
            }
            catch (Exception)
            {
            }
        }

        if (countryid == -1)
        {
            Response.Redirect(CommonFunctions.PrepareURL("InternalError1.aspx"));
        }
        CitiesAdapter.SelectCommand.Parameters["@CountryId"].Value        = countryid;
        LocationAdapter.SelectCommand.Parameters["@CountryId"].Value      = countryid;
        PropertiesAdapter.SelectCommand.Parameters["@CountryId"].Value    = countryid;
        AmenitiesAdapter.SelectCommand.Parameters["@CountryId"].Value     = countryid;
        PropertyTypesAdapter.SelectCommand.Parameters["@CountryId"].Value = countryid;

        Session["CountryID"] = countryid;
        if (LocationAdapter.Fill(MainDataSet, "Location") > 0)
        {
            regionid      = (int)MainDataSet.Tables["Location"].Rows[0]["RegionID"];
            countryid     = (int)MainDataSet.Tables["Location"].Rows[0]["CountryID"];
            region        = (string)MainDataSet.Tables["Location"].Rows[0]["Region"];
            country       = (string)MainDataSet.Tables["Location"].Rows[0]["Country"];
            stateprovince = (string)MainDataSet.Tables["Location"].Rows[0]["StateProvince"];
        }
        else
        {
            Response.Redirect(CommonFunctions.PrepareURL("InternalError.aspx"));
        }

        StateProvincesAdapter.SelectCommand.Parameters["@CountryID"].Value = countryid;
        RegionCountriesAdapter.SelectCommand.Parameters["@RegionId"].Value = regionid;
        CitiesAdapter.Fill(MainDataSet, "Cities");
        PropertiesAdapter.Fill(MainDataSet, "Properties");
        Properties2Adapter.Fill(SecondaryDataSet, "Properties");
        AmenitiesAdapter.Fill(MainDataSet, "Amenities");
        StateProvincesAdapter.Fill(MainDataSet, "StateProvinces");
        PropertyTypesAdapter.Fill(MainDataSet, "PropertyTypes");
        RegionCountriesAdapter.Fill(MainDataSet, "CountriesRegion");
        DBConnection objTemp = new DBConnection();

        try
        {
            MainDataSet.Relations.Add("CitiesProperties", MainDataSet.Tables["Cities"].Columns["ID"],
                                      MainDataSet.Tables["Properties"].Columns["CityID"]);
            MainDataSet.Relations.Add("PropertiesAmenities", MainDataSet.Tables["Properties"].Columns["ID"],
                                      MainDataSet.Tables["Amenities"].Columns["PropertyID"]);
        }
        catch (Exception ex) {  }
        finally { objTemp.CloseConnection(); }

        foreach (DataRow datarow in MainDataSet.Tables["Cities"].Rows)
        {
            if (datarow["City"] is string)
            {
                cities += " " + (string)datarow["City"];
            }
        }
        HtmlHead head = Page.Header;

        DataBind();

        /////// common for postback and ! postback
        List <string> vList        = new List <string>();
        DataTable     dt           = new DataTable();
        DataTable     dtCategories = new DataTable();
        DBConnection  obj          = new DBConnection();

        try
        {
            dt = VADBCommander.CityTextInd(cityid.ToString());
        }
        catch (Exception ex) { lblInfo22.Text = ex.Message; }
        finally { obj.CloseConnection(); }

        //NO NEED TO CHECK IF EMPTY FOR BOTTOM, OK TO SHOW NOTHING


        if (!IsPostBack)
        {
            DataTable     dt1  = new DataTable();
            DataFunctions obj1 = new DataFunctions();

            try
            {
                dt1 = obj1.PropertiesByCase(vList, countryid, "Country");
                DataView dv = dt1.DefaultView;
                // dv.Sort = "minNightRate desc";
                dt1 = dv.ToTable();

                FillPropertiesBox(dt1, string.Empty);

                //create rdo items from categories table
                dtCategories = obj1.FindNumCategories(dt1);
                //int vCategoryCount = 0;


                DataView dvMax = dtCategories.DefaultView;
                // dvMax.Sort = "count desc";
                DataTable dtMax          = dvMax.ToTable();
                int       vCategoryCount = 0;
                string    firstCategory  = "";
                string    PropertyName   = "";
                string    subCategory    = "";

                foreach (DataRow row in dtMax.Rows)
                {
                    int index = dtMax.Rows.IndexOf(row);
                    if (index == 0)
                    {
                        firstCategory = row["category"].ToString();
                        subCategory   = dt1.Rows[0]["SubCategory"].ToString();
                    }
                    PropertyName = PropertyName + row["category"].ToString() + "s" + ", ";
                    string vTemp = row["category"].ToString() + " (" + row["count"].ToString() + ")";
                    vTemp = vTemp.Replace(" ", "&nbsp;");
                    //rdoTypes.Items.Add(vTemp + " ");
                    vCategoryCount = vCategoryCount + Convert.ToInt32(row["count"].ToString());
                }

                if (!IsPostBack)
                {
                    Session["t"] = dtCategories;
                }

                Page page = (Page)HttpContext.Current.Handler;

                if (dt1.Rows.Count <= 10)
                {
                    //Implement 404 logic less then 10 property with Prorerty in URL - Develop By Nimesh Sapovadiya
                    if (Request.QueryString["category"] != null)
                    {
                        Response.Clear();
                        Response.StatusCode = 404;
                        Response.End();
                    }
                    string dispString2 = "";
                    string dispString  = "";

                    if (firstCategory.Contains("_"))
                    {
                        string[] strSplit = firstCategory.Split('_');
                        dispString2 = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s";
                    }
                    else
                    {
                        dispString2 = UppercaseFirst(firstCategory) + "s";
                    }

                    Session["dtRecalc"] = dt1;
                    Session["dt"]       = dt1;

                    //City_datagrid.DataSource = dt1;
                    //City_datagrid.DataBind();


                    ltrH11.Text = "Vacation Properties in " + country;


                    hyplnkCountryBackLink.NavigateUrl = "/" + country.ToLower().Replace(" ", "_") + "/default.aspx";
                    ltrCountryBackText.Text           = country + "<<";

                    page.Title = "Vacation Properties in " + country;
                }
                else
                {
                    if (Request.QueryString["category"] != null)
                    {
                        firstCategory = Convert.ToString(Request.QueryString["category"]);

                        string dispString = "";
                        if (firstCategory.Contains("_"))
                        {
                            string[] strSplit = firstCategory.Split('_');
                            dispString = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s";
                            foreach (DataRow dr in dt1.Rows)
                            {
                                if (dr["Category"].ToString().ToLower().Contains(strSplit[0]))
                                {
                                    subCategory = dr["SubCategory"].ToString();
                                    break;
                                }
                            }
                        }
                        else
                        {
                            dispString = UppercaseFirst(firstCategory) + "s";
                            foreach (DataRow dr in dt1.Rows)
                            {
                                if (dr["Category"].ToString().ToLower().Equals(firstCategory))
                                {
                                    subCategory = dr["SubCategory"].ToString();
                                    break;
                                }
                            }
                        }



                        ltrH11.Text = char.ToUpper(city[0]) + city.Substring(1) + " " + dispString;

                        hyplnkCountryBackLink.NavigateUrl = "/" + country.ToLower().Replace(" ", "_") + "/default.aspx";
                        ltrCountryBackText.Text           = country + "<<";

                        page.Title = country + " " + dispString + " " + "and" + " " + char.ToUpper(city[0]) + city.Substring(1) + " " + "Property Rentals | Vacations Abroad";
                    }
                    else
                    {
                        string dispString  = "";
                        string dispString2 = "";

                        if (firstCategory.Contains("_"))
                        {
                            string[] strSplit = firstCategory.Split('_');
                            dispString2 = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s";
                        }
                        else
                        {
                            dispString2 = UppercaseFirst(firstCategory) + "s";
                        }

                        ltrH11.Text = "Vacation Properties in " + country;

                        hyplnkCountryBackLink.NavigateUrl = "/" + country.ToLower().Replace(" ", "_") + "/default.aspx";
                        ltrCountryBackText.Text           = country + "<<";

                        page.Title = "Vacation Properties in " + country;
                    }
                    DataTable dtCategory = dt1.Clone();



                    foreach (DataRow dr in dt1.Rows)
                    {
                        string vTemp = dr["category"].ToString().Replace("&", "and").ToLower(); //+ " (" + dr["count"].ToString() + ")";
                                                                                                // vTemp = vTemp.Replace(" ", "&nbsp;");

                        if (vTemp.ToLower().Replace(" ", "").Trim() == firstCategory.ToLower().Replace("_", " ").Replace(" ", ""))
                        {
                            //subCategory = dr["SubCategory"].ToString();
                            dtCategory.ImportRow(dr);
                        }
                    }
                    Session["dtRecalc"] = dtCategory.DefaultView.Table;
                    Session["dt"]       = dtCategory.DefaultView.Table;

                    DataView dv1 = dtCategory.DefaultView;
                    //   dv1.Sort = "MinNightRate asc";



                    //Session["dt"] = dv1.ToTable();
                    //City_datagrid.DataSource = dv1;
                    //City_datagrid.DataBind();
                }
            }
            catch (Exception ex) { lblInfo22.Text = ex.Message; }
        }

        //add cities to right column
        DBConnection obj3 = new DBConnection();

        try
        {
            #region Cities within State
            SqlDataReader reader3 = obj3.ExecuteRecordSetArtificial("SELECT Cities.* FROM Cities WHERE (Cities.StateProvinceID = " + stateprovinceid + ") AND EXISTS ( SELECT * FROM Properties WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND (Properties.CityID = Cities.ID)  AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID)) ORDER BY City");
            while (reader3.Read())
            {
                if (reader3["City"] is string)
                {
                    string temp = "/" + country + "/" + stateprovince + "/" + reader3["city"].ToString() + "/default.aspx";
                    temp = temp.ToLower();
                    temp = temp.Replace(' ', '_');
                }
            }
            reader3.Close();

            #endregion

            #region States within Country
            DataTable dtCountries = new DataTable();
            dtCountries = obj3.spStateProvByCountries(countryid);
            foreach (DataRow row in dtCountries.Rows)
            {
                if (row["stateprovince"] is string)
                {
                    string temp = CommonFunctions.GetSiteAddress() + "/" + country + "/" + row["stateprovince"].ToString() + "/default.aspx";
                    temp = temp.ToLower();
                    temp = temp.Replace(' ', '_');

                    // divCitiesRt.InnerHtml += "<a  href=\"" + temp + "\">" + row["stateprovince"].ToString().Replace(" ", "&nbsp;") + "</a>, ";
                }
            }
            //divCitiesRt.InnerHtml = divCitiesRt.InnerHtml.Remove(divCitiesRt.InnerHtml.Length - 2, 2);
            #endregion
        }
        catch (Exception ex) { lblInfo22.Text = ex.Message + "22"; }
        finally { obj3.CloseConnection(); }

        Session["state"]   = stateprovince;
        Session["country"] = country;


//        Page.Header.Controls.Add(new LiteralControl("<link href='http://vacations-abroad.com/css/StyleSheetBig4.css' rel='stylesheet' type='text/css' />"));
        //Page.Header.Controls.Add(new LiteralControl("<script src='http://vacations-abroad.com/wz_tooltip.js' type='text/javascript'></script>"));
    }
    protected void Page_Load(object sender, System.EventArgs e)
    {
        StateProvincesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT StateProvinces.* " +
                                                               "FROM StateProvinces " +
                                                               "WHERE (StateProvinces.CountryID = @CountryID) AND EXISTS (" +
                                                               " SELECT * FROM Properties INNER JOIN Cities ON Properties.CityID = Cities.ID" +
                                                               " WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1)" +
                                                               " AND (Cities.StateProvinceID = StateProvinces.ID) " +
                                                               " AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID)) " +
                                                               "ORDER BY StateProvince", SqlDbType.Int);
        CitiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), String.Format(STR_SELECTCitiesFROMCitiesWHERECitiesStateProvinceID), SqlDbType.Int);

        const string STR_SELECTPropertiesInfo = "SELECT Properties.Name, Properties.NumBedrooms, Properties.NumBaths, Properties.NumSleeps, Properties.NumTVs, Properties.NumVCRs, Properties.CityID, Properties.NumCDPlayers, Properties.ID, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Beach Front')) THEN 'Beach Front' ELSE '' END AS BeachFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Seaside')) THEN 'Seaside' ELSE '' END AS Seaside, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Lake Front')) THEN 'Lake Front' ELSE '' END AS LakeFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'River Front')) THEN 'River Front' ELSE '' END AS RiverFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Ski In Ski Out')) THEN 'Ski In Ski Out' ELSE '' END AS Ski, Cities.City, StateProvinces.StateProvince, Countries.Country, Regions.Region, MinimumNightlyRentalTypes.Name AS MinimumNightlyRental, PropertyTypes.Name AS Type FROM Properties INNER JOIN Cities ON Properties.CityID = Cities.ID INNER JOIN StateProvinces ON StateProvinces.ID = Cities.StateProvinceID INNER JOIN Countries ON StateProvinces.CountryID = Countries.ID INNER JOIN Regions ON Countries.RegionID = Regions.ID INNER JOIN Users ON Properties.UserID = Users.ID LEFT OUTER JOIN MinimumNightlyRentalTypes ON Properties.MinimumNightlyRentalID = MinimumNightlyRentalTypes.ID LEFT OUTER JOIN PropertyTypes ON Properties.TypeID = PropertyTypes.ID WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND (Cities.StateProvinceID = @StateProvinceID) AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID) ORDER BY StateProvinces.StateProvince, Cities.City, Type, CASE WHEN EXISTS (SELECT * FROM Invoices WHERE (PropertyID = Properties.ID) AND (PaymentAmount >= InvoiceAmount) AND (GETDATE() <= Invoices.RenewalDate)) THEN 1 ELSE 0 END DESC, Properties.ID";

        PropertiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), String.Format(STR_SELECTPropertiesInfo), SqlDbType.Int);

        AmenitiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT Amenities.ID, Amenity," +
                                                          " PropertiesAmenities.PropertyID " +
                                                          "FROM Amenities INNER JOIN PropertiesAmenities ON Amenities.ID = PropertiesAmenities.AmenityID" +
                                                          " INNER JOIN Properties ON PropertiesAmenities.PropertyID = Properties.ID " +
                                                          " INNER JOIN Cities ON Properties.CityID = Cities.ID " +
                                                          "WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND (Cities.StateProvinceID = @StateProvinceID)" +
                                                          " AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID) AND (Amenities.Amenity NOT IN" +
                                                          " ('Lake Front', 'Beach Front', 'River Front', 'Seaside', 'Ski In Ski Out', 'TV', 'VCR', 'CD Player'))",
                                                          SqlDbType.Int);

        LocationAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT StateProvinces.ID AS StateProvinceID," +
                                                         " StateProvinces.StateProvince, Countries.ID AS CountryID, Countries.Country, Regions.ID AS RegionID," +
                                                         " Regions.Region, stateprovinces.titleoverride, stateprovinces.descriptionoverride " +
                                                         "FROM StateProvinces INNER JOIN Countries ON StateProvinces.CountryID = Countries.ID" +
                                                         " INNER JOIN Regions ON Countries.RegionID = Regions.ID WHERE (StateProvinces.ID = @StateProvinceID)",
                                                         SqlDbType.Int);


        if ((Request.Params["StateProvinceID"] != null) && (Request.Params["StateProvinceID"].Length > 0))
        {
            try
            {
                stateprovinceid = Convert.ToInt32(Request.Params["StateProvinceID"]);
            }
            catch (Exception)
            {
            }
        }
        // IF state is not found throw an error
        if (stateprovinceid == -1)
        {
            Response.Redirect(CommonFunctions.PrepareURL("InternalError.aspx"));
        }

        CitiesAdapter.SelectCommand.Parameters["@StateProvinceID"].Value     = stateprovinceid;
        LocationAdapter.SelectCommand.Parameters["@StateProvinceID"].Value   = stateprovinceid;
        PropertiesAdapter.SelectCommand.Parameters["@StateProvinceID"].Value = stateprovinceid;
        AmenitiesAdapter.SelectCommand.Parameters["@StateProvinceID"].Value  = stateprovinceid;
        if (LocationAdapter.Fill(MainDataSet, "Location") > 0)
        {
            regionid      = (int)MainDataSet.Tables["Location"].Rows[0]["RegionID"];
            countryid     = (int)MainDataSet.Tables["Location"].Rows[0]["CountryID"];
            region        = (string)MainDataSet.Tables["Location"].Rows[0]["Region"];
            country       = (string)MainDataSet.Tables["Location"].Rows[0]["Country"];
            stateprovince = (string)MainDataSet.Tables["Location"].Rows[0]["StateProvince"];
        }
        else
        {
            Response.Redirect(CommonFunctions.PrepareURL("InternalError.aspx"));
        }

        StateProvincesAdapter.SelectCommand.Parameters["@CountryID"].Value = countryid;
        CitiesAdapter.Fill(MainDataSet, "Cities");
        PropertiesAdapter.Fill(MainDataSet, "Properties");
        AmenitiesAdapter.Fill(MainDataSet, "Amenities");
        StateProvincesAdapter.Fill(MainDataSet, "StateProvinces");
        DBConnection objTemp = new DBConnection();
        DataTable    dtTemp  = new DataTable();

        try
        {
            dtTemp = VADBCommander.CountyNamesWithProperties(Request.Params["StateProvinceID"].ToString());
            DataTable dtCopy = dtTemp.Copy();
            dtCopy.TableName = "dtcopy";
            dtCopy.Namespace = "dtcopy";
            MainDataSet.Tables.Add(dtCopy);
            MainDataSet.Relations.Add("CitiesProperties", MainDataSet.Tables["Cities"].Columns["ID"],
                                      MainDataSet.Tables["Properties"].Columns["CityID"]);
            MainDataSet.Relations.Add("PropertiesAmenities", MainDataSet.Tables["Properties"].Columns["ID"],
                                      MainDataSet.Tables["Amenities"].Columns["PropertyID"]);

            MainDataSet.Relations.Add("CountyCities", MainDataSet.Tables["dtcopy"].Columns["ID"],
                                      MainDataSet.Tables["Cities"].Columns["countyID"]);
            LocationAdapterCountry.SelectCommand.Parameters["@CountryID"].Value = countryid;
        }
        catch (Exception ex) { lblInfo22.Text += ex.Message; }
        finally { objTemp.CloseConnection(); }

        foreach (DataRow datarow in MainDataSet.Tables["Cities"].Rows)
        {
            if (datarow["City"] is string)
            {
                cities += " " + (string)datarow["City"];
            }
        }

        HtmlHead head = Page.Header;



        DataBind();

        /////// common for postback and ! postback
        List <string> vList        = new List <string>();
        DataTable     dt           = new DataTable();
        DataFunctions obj          = new DataFunctions();
        DataTable     dtCategories = new DataTable();
        DBConnection  obj1         = new DBConnection();

        try
        {
            Page page = (Page)HttpContext.Current.Handler;
            if (!IsPostBack)
            {
                dt = obj.PropertiesByCase(vList, stateprovinceid, "State");
                DataView dv = dt.DefaultView;
                dv.Sort       = "category asc";
                dt            = dv.ToTable();
                Session["dt"] = dt;

                int[] i = new int[4];
                i = FindNumAmenities(dt);



                //create rdo items from categories table
                dtCategories = obj.FindNumCategories(dt);
                int    vCategoryCount = 0;
                string firstCategory  = "";
                string subCategory    = "";
                foreach (DataRow row in dtCategories.Rows)
                {
                    int index = dtCategories.Rows.IndexOf(row);
                    if (index == 0)
                    {
                        firstCategory = row["category"].ToString();
                        subCategory   = dt.Rows[0]["SubCategory"].ToString();
                    }
                    string vTemp = row["category"].ToString() + " (" + row["count"].ToString() + ")";
                    vTemp          = vTemp.Replace(" ", "&nbsp;");
                    vCategoryCount = vCategoryCount + Convert.ToInt32(row["count"].ToString());
                }
                if (!IsPostBack)
                {
                }        //numbedrooms filter
                dtCategories = obj.FindNumBedrooms(dt);

                int vBedCount = 0;
                foreach (DataRow row in dtCategories.Rows)
                {
                    vBedCount += Convert.ToInt32(row["count"]);
                }

                //Implement 404 logic less then 10 property with Prorerty in URL - Develop By Nimesh Sapovadiya
                if (Request.QueryString["category"] != null)
                {
                    Response.Clear();
                    Response.StatusCode = 404;
                    Response.End();
                }
                string dispString = "";
                if (firstCategory.Contains("_"))
                {
                    string[] strSplit = firstCategory.Split('_');
                    dispString = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s";
                }
                else
                {
                    dispString = UppercaseFirst(firstCategory) + "s";
                }

                statestr           = char.ToUpper(stateprovince[0]) + stateprovince.Substring(1);
                altTag             = char.ToUpper(stateprovince[0]) + stateprovince.Substring(1) + " Vacation Rentals";
                ltrH1.Text         = char.ToUpper(stateprovince[0]) + stateprovince.Substring(1) + " Vacations";// Rentals";// And " +  dispString;
                ltrHeading.Text    = statestr + " Vacation Rentals and " + statestr + " Hotels";
                ltrStateThing.Text = char.ToUpper(stateprovince[0]) + stateprovince.Substring(1);

                hyplinkBackRegion.NavigateUrl = "/" + region.ToLower().ToLower().Replace(" ", "_") + "/" + "default.aspx";
                ltrRegion.Text = region + "<<";

                hyplnkBackLink.NavigateUrl = "/" + country.ToLower().ToLower().Replace(" ", "_") + "/" + "default.aspx";
                ltrBackText.Text           = country + "<<";
                string iframe = "<iframe height='260' width='500' frameborder='0' src='/" + country + "/" + stateprovince + "/Maps.aspx'></iframe>";
                googlemap.InnerHtml = iframe;
                page.Title          = char.ToUpper(stateprovince[0]) + stateprovince.Substring(1) + " Vacation Rentals, Boutique Hotels | Vacations Abroad";

                string tempcountry1 = CommonFunctions.GetSiteAddress() + "/" + country.ToLower().Replace(" ", "_") + "/" + stateprovince.ToLower().Replace(" ", "_") +
                                      "/default.aspx";
            }

            string vText = "Vacations-abroad.com is a " + stateprovince + " accommodation directory of " + stateprovince + " rentals by owner and privately owned " + stateprovince + " holiday accommodation. Our short term " + stateprovince + " rentals include luxury " +
                           stateprovince + " holiday homes, " + stateprovince + " vacation homes and " + stateprovince + " vacation home rentals which are perfect for group or family vacation rentals in " + stateprovince + " " + country;

            //TOP DEFAULT TEXT
            if (!IsPostBack)
            {
                txtCityText.Text = vText;
            }
            lblcityInfo.Text = vText;

            //BOTTOM, NO DEFAULT TEXT
            dt = VADBCommander.CityTextByStateInd(stateprovinceid.ToString());

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["cityText"] != null)
                {
                    if (!IsPostBack)
                    {
                        lblcityInfo.Text = dt.Rows[0]["cityText"].ToString();
                        txtCityText.Text = dt.Rows[0]["cityText"].ToString().Replace("<br />-ipx-", Environment.NewLine);
                    }
                }
                if (dt.Rows[0]["cityText2"] != null)
                {
                    if (!IsPostBack)
                    {
                        lblInfo2.Text = dt.Rows[0]["cityText2"].ToString();

                        if (string.IsNullOrEmpty(dt.Rows[0]["cityText2"].ToString()) || dt.Rows[0]["cityText2"].ToString() == "")
                        {
                            OrangeTitle.Visible = false;
                        }
                        txtCityText2.Text = dt.Rows[0]["cityText2"].ToString().Replace("<br />", Environment.NewLine);
                    }
                }
                else
                {
                    OrangeTitle.Visible   = false;
                    ltrStateThing.Visible = false;
                }
            }
            else
            {
                OrangeTitle.Visible   = false;
                ltrStateThing.Visible = false;
            }

            if (String.IsNullOrEmpty(lblcityInfo.Text))
            {
                //IF EMPTY VALUES OR 'DELETES' FROM ADMIN FOR TOP

                txtCityText.Text = vText;
                lblcityInfo.Text = vText;
            }
            if (Request.QueryString["Category"] != null)
            {
                lblInfo2.Visible    = false;
                OrangeTitle.Visible = false;
                txtCityText.Visible = false;
            }
        }
        catch (Exception ex) { lblInfo.Text = ex.Message; }

        DBConnection  obj3   = new DBConnection();
        SqlDataReader reader = obj3.ExecuteRecordSetArtificial("SELECT Cities.* FROM Cities WHERE (Cities.StateProvinceID = " + stateprovinceid + ") " + "AND EXISTS ( SELECT * FROM Properties WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND " + "(Properties.CityID = Cities.ID)  AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID)) ORDER " + "BY City");

        foreach (DataRow dr in MainDataSet.Tables["StateProvinces"].Rows)
        {
            string temp = CommonFunctions.GetSiteAddress() + "/" + country +
                          "/" + dr["StateProvince"].ToString() + "/default.aspx";
            temp         = temp.ToLower();
            temp         = temp.Replace(' ', '_');
            rtLow3.Text += "<li><a href='" + temp + "'>" + dr["StateProvince"].ToString().Replace(" ", "&nbsp;") + ", </a></li>";
        }
        rtLow3.Text     = rtLow3.Text;
        rtHd3.InnerHtml = country + " Regions: ";

        //add counties to right column
        //add counties within state
        string query = "";

        dt = obj1.spGetRightSideCounties(stateprovinceid);
        if (dt.Rows.Count > 0)
        {
            rtCountiesHd.InnerHtml = stateprovince + " Counties";
            foreach (DataRow datarow in dt.Rows)
            {
                if (datarow["county"] is string)
                {
                    string temp = CommonFunctions.GetSiteAddress() + "/" + stateprovince + "/Holiday-Rentals/" +
                                  datarow["county"].ToString() + "-Vacation_Rentals/default.aspx";
                    temp              = temp.ToLower();
                    temp              = temp.Replace(' ', '_');
                    divCitiesRt.Text += "<li><a href='" + temp + "'>" + datarow["county"].ToString().Replace(" ", "&nbsp;") + "</a></li> ";
                }
            }
            divCitiesRt.Text = divCitiesRt.Text.Remove(divCitiesRt.Text.Length - 2, 2);
        }
        else
        {
        }

        //add counties within state
        DataTable dtCountries = obj1.spStateProvByCountries(countryid);

        foreach (DataRow row in dtCountries.Rows)
        {
            if (row["stateprovince"] is string)
            {
                string temp = CommonFunctions.GetSiteAddress() + "/" + country + "/" + row["stateprovince"].ToString() + "/default.aspx";
                temp = temp.ToLower();
                temp = temp.Replace(' ', '_');
            }
        }
        /////// common for postback and ! postback ////////
        string cities1   = "";
        string citiesNew = "";

        foreach (DataRow dr in MainDataSet.Tables["Cities"].Rows)
        {
            string temp = CommonFunctions.GetSiteAddress() + "/" + country +
                          "/" + stateprovince + "/" + dr["City"].ToString() + "/default.aspx";
            temp     = temp.ToLower();
            temp     = temp.Replace(' ', '_');
            cities1 += "<a href='" + temp + "'><span class=\"tdNoSleeps\" style=\"font-weight:normal;font-style:normal\">" + dr["City"].ToString().Replace(" ", "&nbsp;") + "</span></a>, ";
        }

        string str_cities = "";
        int    ind        = 0;
        // string cls = " class='borderright' ";
        string cls = "border-right:1px solid #0094ff;";
        string li  = "";

        foreach (DataRow dr in MainDataSet.Tables["Cities"].Rows)
        {
            string temp = "/" + country +
                          "/" + stateprovince + "/" + dr["City"].ToString() + "/default.aspx";
            temp = temp.ToLower();
            temp = temp.Replace(' ', '_');

            DataTable dt1 = new DataTable();
            dt1 = obj.PropertiesByCase(vList, Convert.ToInt32(dr["id"]), "City");

            // li = " style='" + ((ind > 4) ? "border-top:0px;" : "") + (((ind++ % 5) == 4) ? cls : "") + "'";

            citiesNew += "<li" + li + ">" +
                         "<a href='" + temp + "' class='StateTitle'>" + dr["City"].ToString() + "</a> <br/>" +
                         "<a href='" + temp + "'>" +
                         "<div class='drop-shadow effect4'><img width='160' height='125' src='/images/" + Convert.ToString(dt1.Rows[0]["PhotoImage"]) + "' alt='" + dr["City"].ToString() + " vacation rentals and boutique hotels' title='" + dr["City"].ToString() + " vacation rentals and boutique hotels' /></a></div>" +
                         "</li>";
            str_cities += dr["City"].ToString() + ",";
        }

        ulManiGrid.InnerHtml = citiesNew;

        string tempcountry2 = CommonFunctions.GetSiteAddress() + "/" + country.ToLower().Replace(" ", "_") + "/" + stateprovince.ToLower().Replace(" ", "_") +
                              "/default.aspx";

        string tempstate = CommonFunctions.GetSiteAddress() + "/" + country.ToLower().Replace(" ", "_") +
                           "/" + stateprovince.ToLower().Replace(" ", "_") + "/default.aspx";
        string tempcountry3 = CommonFunctions.GetSiteAddress() + "/" + country.ToLower().Replace(" ", "_") +
                              "/default.aspx";
        string tempregion = CommonFunctions.GetSiteAddress() + "/" + region.ToLower().Replace(" ", "_") +
                            "/default.aspx";

        Session["tempstate"]   = stateprovince;
        Session["tempcountry"] = country;

        //FillCitiesColumn();
        HtmlMeta description = new HtmlMeta();

        description.Name    = "description";
        description.Content = Description.Text.Replace("%country%", country).Replace("%stateprovince%", stateprovince).
                              Replace("%cities%", cities);
        // Description OVER RIDE area

        string DescripReplacement = MainDataSet.Tables["Location"].Rows[0]["descriptionoverride"].ToString();

        if (DescripReplacement.Length > 0)
        {
            description.Content = DescripReplacement;
        }
        Page page1 = (Page)HttpContext.Current.Handler;

        description.Content = "Plan your next " + stateprovince + " vacation: where to stay and places to visit!";

        head.Controls.Add(description);

        HtmlMeta newdescription = new HtmlMeta();

        string str_meta = "%state% vacation rentals and boutique hotels in %cities% etc.";

        newdescription.Name    = "description";
        newdescription.Content = str_meta.Replace("%state%", stateprovince).Replace("%cities%", str_cities);

        head.Controls.Add(newdescription);



        HtmlMeta keywords = new HtmlMeta();

        keywords.Name    = "keywords";
        keywords.Content = Keywords.Text.Replace("%country%", country).Replace("%stateprovince%", stateprovince).
                           Replace("%cities%", cities);
        keywords.Content = page1.Title;
        head.Controls.Add(keywords);
        // ((System.Web.UI.WebControls.Image)Master.FindControl("Logo")).AlternateText = page1.Title;
        // Page.Header.Controls.Add(new LiteralControl("<link href='http://vacations-abroad.com/css/StyleSheetBig4.css' rel='stylesheet' type='text/css'></script>"));
    }
示例#3
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        RegionCountriesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "select distinct Country,Region from Countries inner join Regions on Countries.RegionID=Regions.ID " +
                                                                " inner join StateProvinces on StateProvinces.CountryID=Countries.ID " +
                                                                "where (RegionID=@RegionID)  AND EXISTS (" +
                                                                " SELECT * FROM Properties INNER JOIN Cities ON Properties.CityID = Cities.ID" +
                                                                " WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1)" +
                                                                " AND (Cities.StateProvinceID = StateProvinces.ID) " +
                                                                " AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID)) " +
                                                                "ORDER BY Country", SqlDbType.Int);
        StateProvincesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT StateProvinces.* " +
                                                               "FROM StateProvinces " +
                                                               "WHERE (StateProvinces.CountryID = @CountryID) AND EXISTS (" +
                                                               " SELECT * FROM Properties INNER JOIN Cities ON Properties.CityID = Cities.ID" +
                                                               " WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1)" +
                                                               " AND (Cities.StateProvinceID = StateProvinces.ID) " +
                                                               " AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID)) " +
                                                               "ORDER BY StateProvince", SqlDbType.Int);
        // StateCodeInfo.Text = SqlDbType.Int.
        CitiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), String.Format(STR_SELECTCitiesFROMCitiesWHERECitiesStateProvinceID), SqlDbType.Int);

        const string STR_SELECTPropertiesInfo = "SELECT Properties.Name2 as PropertyName2, Properties.Name, Properties.NumBedrooms, Properties.NumBaths, Properties.NumSleeps, Properties.NumTVs, Properties.NumVCRs, Properties.CityID, Properties.NumCDPlayers, Properties.ID, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Beach Front')) THEN 'Beach Front' ELSE '' END AS BeachFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Seaside')) THEN 'Seaside' ELSE '' END AS Seaside, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Lake Front')) THEN 'Lake Front' ELSE '' END AS LakeFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'River Front')) THEN 'River Front' ELSE '' END AS RiverFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Ski In Ski Out')) THEN 'Ski In Ski Out' ELSE '' END AS Ski, Cities.City, StateProvinces.StateProvince, Countries.Country, Regions.Region, MinimumNightlyRentalTypes.Name AS MinimumNightlyRental, PropertyTypes.Name AS Type FROM Properties INNER JOIN Cities ON Properties.CityID = Cities.ID INNER JOIN StateProvinces ON StateProvinces.ID = Cities.StateProvinceID INNER JOIN Countries ON StateProvinces.CountryID = Countries.ID INNER JOIN Regions ON Countries.RegionID = Regions.ID INNER JOIN Users ON Properties.UserID = Users.ID LEFT OUTER JOIN MinimumNightlyRentalTypes ON Properties.MinimumNightlyRentalID = MinimumNightlyRentalTypes.ID LEFT OUTER JOIN PropertyTypes ON Properties.TypeID = PropertyTypes.ID WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND (StateProvinces.CountryID = @CountryID) AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID) ORDER BY StateProvinces.StateProvince, Cities.City, Type, CASE WHEN EXISTS (SELECT * FROM Invoices WHERE (PropertyID = Properties.ID) AND (PaymentAmount >= InvoiceAmount) AND (GETDATE() <= Invoices.RenewalDate)) THEN 1 ELSE 0 END DESC, Properties.ID";

        PropertiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), String.Format(STR_SELECTPropertiesInfo), SqlDbType.Int);

        AmenitiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT Amenities.ID, Amenity," +
                                                          " PropertiesAmenities.PropertyID " +
                                                          "FROM Amenities INNER JOIN PropertiesAmenities ON Amenities.ID = PropertiesAmenities.AmenityID" +
                                                          " INNER JOIN Properties ON PropertiesAmenities.PropertyID = Properties.ID " +
                                                          " INNER JOIN Cities ON Properties.CityID = Cities.ID INNER JOIN StateProvinces ON StateProvinces.ID = Cities.StateProvinceID " +
                                                          "WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND (StateProvinces.CountryID = @CountryID)" +
                                                          " AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID) AND (Amenities.Amenity NOT IN" +
                                                          " ('Lake Front', 'Beach Front', 'River Front', 'Seaside', 'Ski In Ski Out', 'TV', 'VCR', 'CD Player'))",
                                                          SqlDbType.Int);

        LocationAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT StateProvinces.ID AS StateProvinceID," +
                                                         " StateProvinces.StateProvince, Countries.ID AS CountryID, Countries.Country, Regions.ID AS RegionID," +
                                                         " Regions.Region, Countries.titleoverride, stateprovinces.descriptionoverride " +
                                                         "FROM StateProvinces INNER JOIN Countries ON StateProvinces.CountryID = Countries.ID" +
                                                         " INNER JOIN Regions ON Countries.RegionID = Regions.ID WHERE (Countries.ID = @CountryId)",
                                                         SqlDbType.Int);

        PropertyTypesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT     PropertyTypes.Name,COUNT(*) as Count, PropertyTypes.ID " +
                                                              " FROM         Cities INNER JOIN " +
                                                              " Properties ON Cities.ID = Properties.CityID  " +
                                                              " INNER JOIN " +
                                                              " PropertyTypes ON Properties.TypeID = PropertyTypes.ID INNER JOIN " +
                                                              " StateProvinces ON Cities.StateProvinceID = StateProvinces.ID INNER JOIN " +
                                                              " Countries ON StateProvinces.CountryID = Countries.ID  WHERE (Countries.ID = @CountryId) " +
                                                              "group by PropertyTypes.Name,PropertyTypes.ID",
                                                              SqlDbType.Int);


        if ((Request.Params["CountryID"] != null) && (Request.Params["CountryID"].Length > 0))
        {
            try
            {
                countryid = Convert.ToInt32(Request.Params["CountryID"]);
            }
            catch (Exception)
            {
            }
        }

        if (countryid == -1)
        {
            Response.Redirect(CommonFunctions.PrepareURL("InternalError.aspx"));
        }
        CitiesAdapter.SelectCommand.Parameters["@CountryId"].Value        = countryid;
        LocationAdapter.SelectCommand.Parameters["@CountryId"].Value      = countryid;
        PropertiesAdapter.SelectCommand.Parameters["@CountryId"].Value    = countryid;
        AmenitiesAdapter.SelectCommand.Parameters["@CountryId"].Value     = countryid;
        PropertyTypesAdapter.SelectCommand.Parameters["@CountryId"].Value = countryid;

        Session["CountryID"] = countryid;
        if (LocationAdapter.Fill(MainDataSet, "Location") > 0)
        {
            regionid      = (int)MainDataSet.Tables["Location"].Rows[0]["RegionID"];
            countryid     = (int)MainDataSet.Tables["Location"].Rows[0]["CountryID"];
            region        = (string)MainDataSet.Tables["Location"].Rows[0]["Region"];
            country       = (string)MainDataSet.Tables["Location"].Rows[0]["Country"];
            stateprovince = (string)MainDataSet.Tables["Location"].Rows[0]["StateProvince"];
        }
        else
        {
            Response.Redirect(CommonFunctions.PrepareURL("InternalError.aspx"));
        }

        StateProvincesAdapter.SelectCommand.Parameters["@CountryID"].Value = countryid;
        RegionCountriesAdapter.SelectCommand.Parameters["@RegionId"].Value = regionid;
        CitiesAdapter.Fill(MainDataSet, "Cities");
        PropertiesAdapter.Fill(MainDataSet, "Properties");
        AmenitiesAdapter.Fill(MainDataSet, "Amenities");
        StateProvincesAdapter.Fill(MainDataSet, "StateProvinces");
        PropertyTypesAdapter.Fill(MainDataSet, "PropertyTypes");
        RegionCountriesAdapter.Fill(MainDataSet, "CountriesRegion");
        DBConnection objTemp = new DBConnection();
        DataTable    dtTemp  = new DataTable();

        try
        {
            dtTemp = VADBCommander.CountyNamesWithProperties(Request.Params["StateProvinceID"].ToString());
            DataTable dtCopy = dtTemp.Copy();
            dtCopy.TableName = "dtcopy";
            dtCopy.Namespace = "dtcopy";
            MainDataSet.Tables.Add(dtCopy);
            MainDataSet.Relations.Add("CitiesProperties", MainDataSet.Tables["Cities"].Columns["ID"],
                                      MainDataSet.Tables["Properties"].Columns["CityID"]);
            MainDataSet.Relations.Add("PropertiesAmenities", MainDataSet.Tables["Properties"].Columns["ID"],
                                      MainDataSet.Tables["Amenities"].Columns["PropertyID"]);

            MainDataSet.Relations.Add("CountyCities", MainDataSet.Tables["dtcopy"].Columns["ID"],
                                      MainDataSet.Tables["Cities"].Columns["countyID"]);
            LocationAdapterCountry.SelectCommand.Parameters["@CountryID"].Value = countryid;
        }
        catch (Exception ex) { lblInfo22.Text += ex.Message; }
        finally { objTemp.CloseConnection(); }

        foreach (DataRow datarow in MainDataSet.Tables["Cities"].Rows)
        {
            if (datarow["City"] is string)
            {
                cities += " " + (string)datarow["City"];
            }
        }
        HtmlHead head = Page.Header;

        DataBind();

        /////// common for postback and ! postback
        List <string> vList        = new List <string>();
        DataTable     dt           = new DataTable();
        DataFunctions obj          = new DataFunctions();
        DataTable     dtCategories = new DataTable();
        DBConnection  obj1         = new DBConnection();

        try
        {
            if (!IsPostBack)
            {
                dt = obj.PropertiesByCase(vList, countryid, "Country");
                DataView dv = dt.DefaultView;
                dv.Sort       = "category asc";
                dt            = dv.ToTable();
                Session["dt"] = dt;
                int[] i = new int[4];
                i = FindNumAmenities(dt);

                dtCategories = obj.FindNumCategories(dt);
                DataView dvMax = dtCategories.DefaultView;
                dvMax.Sort = "count desc";
                DataTable dtMax          = dvMax.ToTable();
                int       vCategoryCount = 0;
                string    firstCategory  = "";
                string    subCategory    = "";
                foreach (DataRow row in dtMax.Rows)
                {
                    int index = dtMax.Rows.IndexOf(row);
                    if (index == 0)
                    {
                        firstCategory = row["category"].ToString();
                        subCategory   = dt.Rows[0]["SubCategory"].ToString();
                    }
                    string vTemp = row["category"].ToString() + " (" + row["count"].ToString() + ")";
                    vTemp          = vTemp.Replace(" ", "&nbsp;");
                    vCategoryCount = vCategoryCount + Convert.ToInt32(row["count"].ToString());
                }

                if (!IsPostBack)
                {
                    //dtlStates.DataSource = dtCategories;
                    //dtlStates.DataBind();
                }
                //numbedrooms filter
                dtCategories = obj.FindNumBedrooms(dt);
                int vBedCount = 0;
                foreach (DataRow row in dtCategories.Rows)
                {
                    vBedCount += Convert.ToInt32(row["count"]);
                }

                Page page = (Page)HttpContext.Current.Handler;
                if (Request.QueryString["category"] != null)
                {
                    Response.Clear();
                    Response.StatusCode = 404;
                    Response.End();
                }
                if (dt.Rows.Count <= 10)
                {
                    //Implement 404 logic less then 10 property with Prorerty in URL - Develop By Nimesh Sapovadiya
                    if (Request.QueryString["category"] != null)
                    {
                        Response.Clear();
                        Response.StatusCode = 404;
                        Response.End();
                    }
                    string dispString  = "";
                    string dispString2 = "";
                    if (subCategory.Contains("_"))
                    {
                        string[] strSplit = subCategory.Split('_');
                        dispString = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s";
                    }
                    else
                    {
                        dispString = UppercaseFirst(subCategory) + "s";
                    }
                    firstCategory = dt.Rows[0]["category"].ToString();
                    if (firstCategory.Contains("_"))
                    {
                        string[] strSplit = firstCategory.Split('_');
                        dispString2 = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s";
                    }
                    else
                    {
                        dispString2 = UppercaseFirst(firstCategory) + "s";
                    }

                    altTag      = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals";
                    ltrH11.Text = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals";
                    hyplnkBackLink.NavigateUrl = "/" + region.ToLower().Replace(" ", "_") + "/default.aspx";
                    ltrBackText.Text           = region + "<<";
                    hyplnkAllProps.NavigateUrl = "/" + country.ToLower().Replace(" ", "_") + "/countryproperties.aspx";
                    ltrAllProps.Text           = " View all " + char.ToUpper(country[0]) + country.Substring(1) + " properties";
                    ltrHeading.Text            = char.ToUpper(country[0]) + country.Substring(1) + " Vacations";
                    string iframe = "<iframe height='260' width='95%' frameborder='0' src='/" + country + "/Maps.aspx'></iframe>";
                    ltrCountryThing.Text       = char.ToUpper(country[0]) + country.Substring(1);
                    googleCountrymap.InnerHtml = iframe;
                    page.Title = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals, Boutique Hotels | Vacations Abroad";

                    string tempcountry1 = CommonFunctions.GetSiteAddress() + "/" + country.ToLower().Replace(" ", "_") +
                                          "/default.aspx";

                    /*  HtmlMeta description = new HtmlMeta();
                     * description.Name = "description";
                     * description.Content = "Plan your next " + char.ToUpper(country[0]) + country.Substring(1) + " vacation: where to stay and places to visit ";
                     * head.Controls.Add(description);
                     */
                }
                else
                {
                    if (Request.QueryString["category"] != null)
                    {
                        firstCategory = Convert.ToString(Request.QueryString["category"]);
                    }
                    {
                        string dispString  = "";
                        string dispString2 = "";
                        if (subCategory.Contains("_"))
                        {
                            string[] strSplit = subCategory.Split('_');
                            dispString = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s";
                        }
                        else
                        {
                            dispString = UppercaseFirst(subCategory) + "s";
                        }
                        if (firstCategory.Contains("_"))
                        {
                            string[] strSplit = firstCategory.Split('_');
                            dispString2 = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s";
                        }
                        else
                        {
                            dispString2 = UppercaseFirst(firstCategory) + "s";
                        }
                        altTag      = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals";
                        ltrH11.Text = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals";
                        hyplnkBackLink.NavigateUrl = "/" + region.ToLower().Replace(" ", "_") + "/default.aspx";
                        ltrBackText.Text           = region + "<<";
                        hyplnkAllProps.NavigateUrl = "/" + country.ToLower().Replace(" ", "_") + "/countryproperties.aspx";
                        ltrAllProps.Text           = " View all " + char.ToUpper(country[0]) + country.Substring(1) + " properties";
                        ltrHeading.Text            = char.ToUpper(country[0]) + country.Substring(1) + " Vacations";

                        string iframe = "<iframe height='260' frameborder='0' width='95%' src='/" + country + "/Maps.aspx'></iframe>";
                        googleCountrymap.InnerHtml = iframe;
                        ltrCountryThing.Text       = char.ToUpper(country[0]) + country.Substring(1);
                        page.Title = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals, Boutique Hotels | Vacations Abroad";
                    }
                    if (firstCategory == "bandb")
                    {
                        firstCategory = "B&B";
                    }


                    DataTable dtCategory = dt.Clone();
                    foreach (DataRow dr in dt.Rows)
                    {
                        string vTemp = dr["Category"].ToString();
                        if (vTemp.ToLower().Replace(" ", "").Trim() == firstCategory.ToLower().Replace("_", " ").Replace(" ", ""))
                        {
                            subCategory = dr["SubCategory"].ToString();
                            dtCategory.ImportRow(dr);
                        }
                    }
                    DataView dv1 = dtCategory.DefaultView;
                    dv1.Sort = "MinNightRate desc";

                    if (Request.QueryString["category"] != null)
                    {
                        string dispString = "";
                        if (firstCategory.Contains("_"))
                        {
                            string[] strSplit = firstCategory.Split('_');
                            dispString = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s";
                        }
                        else
                        {
                            dispString = UppercaseFirst(firstCategory) + "s";
                        }
                        ltrH11.Text = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals";
                        page.Title  = char.ToUpper(country[0]) + country.Substring(1) + "Vacation Rentals, Boutique Hotels | Vacations Abroad";
                        altTag      = subCategory + " in " + country;
                        Label3.Text = altTag;
                    }
                    else
                    {
                        string dispString  = "";
                        string dispString2 = "";
                        if (subCategory.Contains("_"))
                        {
                            string[] strSplit = subCategory.Split('_');
                            dispString = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s";
                        }
                        else
                        {
                            dispString = UppercaseFirst(subCategory) + "s";
                        }
                        if (firstCategory.Contains("_"))
                        {
                            string[] strSplit = firstCategory.Split('_');
                            dispString2 = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s";
                        }
                        else
                        {
                            dispString2 = UppercaseFirst(firstCategory) + "s";
                        }
                        altTag      = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals";
                        ltrH11.Text = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals";
                        page.Title  = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals, Boutique Hotels | Vacations Abroad";
                    }
                    string tempcountry = CommonFunctions.GetSiteAddress() + "/" + country.ToLower().Replace(" ", "_") +
                                         "/default.aspx";

                    /* HtmlMeta description = new HtmlMeta();
                     * description.Name = "description";
                     * description.Content = "Plan your next " + char.ToUpper(country[0]) + country.Substring(1) + " vacation: where to stay and places to visit ";// + char.ToUpper(country[0]) + country.Substring(1) + " Vacations with unique " + char.ToUpper(country[0]) + country.Substring(1) + " vacation rentals.";
                     * head.Controls.Add(description);
                     */
                }

                ViewState["firstCategory"] = firstCategory;
                DataTable dt1 = new DataTable();
                try
                {
                    dt1 = VADBCommander.CountryTextInd(countryid.ToString(), firstCategory);
                }
                catch (Exception ex) { lblInfo.Text = ex.Message; }

                string vText = "Vacations-abroad.com is a " + country + " accommodation directory of " + country + " rentals by owner and privately owned " + country + " holiday accommodation. Our short term " + country + " rentals include luxury " +
                               country + " holiday homes, " + country + " vacation homes and " + country + " vacation home rentals which are perfect for group or family vacation rentals in " + country + " " + region;

                if (dt1.Rows.Count > 0)
                {
                    if (dt1.Rows[0]["countryText"] != null)
                    {
                        if (!IsPostBack)
                        {
                            lblCountryInfo.Text = dt1.Rows[0]["countryText"].ToString();
                            txtCountryText.Text = dt1.Rows[0]["countryText"].ToString().Replace("<br />", Environment.NewLine);
                        }
                        ////Editor.Value = dt.Rows[0]["cityText"].ToString();
                    }
                    else
                    {
                        lblCountryInfo.Text = vText;
                        txtCountryText.Text = vText;
                    }
                    if (dt1.Rows[0]["countryText2"] != null)
                    {
                        if (!IsPostBack)
                        {
                            lblInfo2.Text = dt1.Rows[0]["countryText2"].ToString();
                            if (string.IsNullOrEmpty(lblInfo2.Text) || lblInfo2.Text == "")
                            {
                                OrangeTitle.Visible = false;
                            }
                            txtCountryText2.Text = dt1.Rows[0]["countryText2"].ToString().Replace("<br />", Environment.NewLine);
                        }
                    }
                    else
                    {
                        OrangeTitle.Visible = false;
                    }
                }
                else
                {
                    lblCountryInfo.Text = vText;
                    txtCountryText.Text = vText;
                    OrangeTitle.Visible = false;
                }
            }
        }
        catch (Exception ex) { lblInfo.Text = ex.Message; }

        DBConnection  obj3          = new DBConnection();
        SqlDataReader reader        = obj3.ExecuteRecordSetArtificial("SELECT Cities.* FROM Cities WHERE (Cities.StateProvinceID = " + stateprovinceid + ") " + "AND EXISTS ( SELECT * FROM Properties WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND " + "(Properties.CityID = Cities.ID)  AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID)) ORDER " + "BY City");
        string        states1       = "";
        string        regionCountry = "";

        foreach (DataRow dr in MainDataSet.Tables["CountriesRegion"].Rows)
        {
            string temp = "/" + dr["Country"].ToString().ToLower().Replace(" ", "_") + "/default.aspx";
            temp          = temp.ToLower();
            temp          = temp.Replace(' ', '_');
            rtLow3.Text  += "<li><a href=\"" + temp + "\"><span class=\"tdNoSleeps\">" + dr["Country"].ToString().Replace(" ", "&nbsp;") + ",</span></a></li>";
            states1      += "<a href=\"" + temp + "\"><span class=\"tdNoSleeps\" style=\"font-weight:normal;font-style:normal\">" + dr["Country"].ToString().Replace(" ", "&nbsp;") + "</span></a>, ";
            regionCountry = dr["Region"].ToString();
        }
        states1 = "";
        foreach (DataRow dr in MainDataSet.Tables["StateProvinces"].Rows)
        {
            string temp = "/" + country.ToLower().Replace(" ", "_") + "/" + dr["StateProvince"].ToString().ToLower().Replace(" ", "_") + "/default.aspx";
            states1 += "<a href=\"" + temp + "\"><span class=\"tdNoSleeps\" style=\"font-weight:normal;font-style:normal\">" + dr["StateProvince"].ToString().Replace(" ", "&nbsp;") + "</span></a>, ";
        }

        states1 = "";
        string str_states  = "";
        string str_keyword = "";
        int    ind         = 0;
        // string cls = " class='borderright' ";
        string cls = "border-right:1px solid #0094ff;";
        string li  = "";

        foreach (DataRow dr in MainDataSet.Tables["StateProvinces"].Rows)
        {
            DataFunctions objcate = new DataFunctions();
            DataTable     dt1     = new DataTable();
            dt = obj.PropertiesByCase(vList, Convert.ToInt32(dr["id"]), "State");

            //li =" style='"+ ((ind > 4) ? "border-top:0px;" : "")+ (((ind++ % 5) == 4) ? cls : "")+"'";

            string temp = "/" + country.ToLower().Replace(" ", "_") + "/" + dr["StateProvince"].ToString().ToLower().Replace(" ", "_") + "/default.aspx";
            states1     += "<li" + li + "><a href='" + temp + "' class='StateTitle'>" + dr["StateProvince"].ToString().Replace(" ", "&nbsp;") + "</a><br/> ";
            states1     += "<a href=\"" + temp + "\"><div class='drop-shadow effect4'><img width='160' height='125' src='/images/" + Convert.ToString(dt.Rows[0]["PhotoImage"]) + "' alt='" + Convert.ToString(dr["StateProvince"]) + " vacation rentals and boutique hotels in " + country + " ' title='" + Convert.ToString(dr["StateProvince"]) + " vacation rentals and boutique hotels in " + country + "' /></div></a></li>";
            str_states  += Convert.ToString(dr["StateProvince"]) + ", ";
            str_keyword += Convert.ToString(dr["StateProvince"]) + " " + country + ", ";
        }
        rtLow3.Text     = rtLow3.Text.Remove(rtLow3.Text.Length - 2, 2);
        rtHd3.InnerHtml = regionCountry + " Countries";

        //add counties to right column
        //add counties within state
        string query = "";

        /////// common for postback and ! postback ////////



        string tempstate = "/" + country.ToLower().Replace(" ", "_") + "/default.aspx";

        Session["tempstate"]   = stateprovince;
        Session["tempcountry"] = country;


        Statesul.InnerHtml = states1;
        //Page.Header.Controls.Add(new LiteralControl("<link href='http://vacations-abroad.com/css/StyleSheetBig4.css' rel='stylesheet' type='text/css'></script>"));

        int num_properties = MainDataSet.Tables["Properties"].Rows.Count;


        Page page1 = (Page)HttpContext.Current.Handler;

        HtmlMeta newdescription = new HtmlMeta();

        string str_meta = "(%number%) %country% vacation rentals and boutique hotels in %states% etc.";

        newdescription.Name    = "description";
        newdescription.Content = str_meta.Replace("%country%", country).Replace("%states%", str_states).Replace("%number%", Convert.ToString(num_properties));

        head.Controls.Add(newdescription);

        HtmlMeta keywords = new HtmlMeta();

        keywords.Name = "keywords";
        // keywords.Content = Keywords.Text.Replace("%country%", country).Replace("%stateprovince%", stateprovince).
        //    Replace("%cities%", cities);
        //  keywords.Content = page1.Title;
        keywords.Content = str_keyword + "etc.";
        head.Controls.Add(keywords);
    }
示例#4
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        DBConnection obj = new DBConnection();
        DataTable    dt  = new DataTable();

        if (Request.QueryString["county"] != null)
        {
            try
            {
                countyID = Convert.ToInt32(Request.QueryString["county"]);
            }
            catch (Exception)
            {
            }
        }

        //GET REGION, COUNTRY, STATE
        try
        {
            string vCityID    = "";
            string vCountryID = "";
            string vStateID   = "";

            dt = VADBCommander.CountyStateCountryRegionInd(countyID.ToString());
            if (dt.Rows.Count > 0)
            {
                region        = dt.Rows[0]["region"].ToString();
                country       = dt.Rows[0]["country"].ToString();
                stateprovince = dt.Rows[0]["stateprovince"].ToString();
                county        = dt.Rows[0]["countyName"].ToString();
                stateID       = Convert.ToInt32(dt.Rows[0]["StateID"]);
                countryid     = Convert.ToInt32(dt.Rows[0]["countryid"]);
            }
        }
        catch (Exception ex) { lblInfo.Text = ex.Message; }
        finally { obj.CloseConnection(); }

        //CommonFunctions.Connection.Open ();
        // StateCodeInfo.Text = SqlDbType.Int.
        CitiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), String.Format(STR_SELECTCitiesFROMCitiesWHERECitiesStateProvinceID), SqlDbType.Int);

        //const string STR_SELECTPropertiesInfo = "SELECT Properties.Name, Properties.NumBedrooms, Properties.NumBaths, Properties.NumSleeps, Properties.NumTVs, Properties.NumVCRs, Properties.CityID, Properties.NumCDPlayers, Properties.ID, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Beach Front')) THEN 'Beach Front' ELSE '' END AS BeachFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Seaside')) THEN 'Seaside' ELSE '' END AS Seaside, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Lake Front')) THEN 'Lake Front' ELSE '' END AS LakeFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'River Front')) THEN 'River Front' ELSE '' END AS RiverFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Ski In Ski Out')) THEN 'Ski In Ski Out' ELSE '' END AS Ski, Cities.City, StateProvinces.StateProvince, Countries.Country, Regions.Region, MinimumNightlyRentalTypes.Name AS MinimumNightlyRental, PropertyTypes.Name AS Type FROM Properties INNER JOIN Cities ON Properties.CityID = Cities.ID INNER JOIN StateProvinces ON StateProvinces.ID = Cities.StateProvinceID INNER JOIN Countries ON StateProvinces.CountryID = Countries.ID INNER JOIN Regions ON Countries.RegionID = Regions.ID INNER JOIN Users ON Properties.UserID = Users.ID LEFT OUTER JOIN MinimumNightlyRentalTypes ON Properties.MinimumNightlyRentalID = MinimumNightlyRentalTypes.ID LEFT OUTER JOIN PropertyTypes ON Properties.TypeID = PropertyTypes.ID WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND (Cities.StateProvinceID = @StateProvinceID) AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID) ORDER BY StateProvinces.StateProvince, Cities.City, Type, CASE WHEN EXISTS (SELECT * FROM Invoices WHERE (PropertyID = Properties.ID) AND (PaymentAmount >= InvoiceAmount) AND (GETDATE() <= Invoices.RenewalDate)) THEN 1 ELSE 0 END DESC, Properties.ID";
        string STR_SELECTPropertiesInfo = "SELECT Properties.Name, Properties.NumBedrooms, Properties.Name2, Properties.NumBaths, Properties.NumSleeps, Properties.NumTVs, Properties.NumVCRs, Properties.CityID," +
                                          " Properties.NumCDPlayers, Properties.ID," +
                                          " CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities" +
                                          " ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID)" +
                                          " AND (Amenities.Amenity = 'Beach Front')) THEN 'Beach Front' ELSE '' END AS BeachFront," +
                                          " CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities" +
                                          " ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID)" +
                                          " AND (Amenities.Amenity = 'Seaside')) THEN 'Seaside' ELSE '' END AS Seaside," +
                                          " CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities" +
                                          " ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID)" +
                                          " AND (Amenities.Amenity = 'Lake Front')) THEN 'Lake Front' ELSE '' END AS LakeFront," +
                                          " CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities" +
                                          " ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID)" +
                                          " AND (Amenities.Amenity = 'River Front')) THEN 'River Front' ELSE '' END AS RiverFront," +
                                          " CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities" +
                                          " ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID)" +
                                          " AND (Amenities.Amenity = 'Ski In Ski Out')) THEN 'Ski In Ski Out' ELSE '' END AS Ski," +
                                          " Cities.City, StateProvinces.StateProvince, Countries.Country, Regions.Region," +
                                          " MinimumNightlyRentalTypes.Name AS MinimumNightlyRental, PropertyTypes.Name AS Type " +
                                          "FROM Properties INNER JOIN Cities ON Properties.CityID = Cities.ID" +
                                          " INNER JOIN StateProvinces ON StateProvinces.ID = Cities.StateProvinceID" +
                                          " INNER JOIN Countries ON StateProvinces.CountryID = Countries.ID" +
                                          " INNER JOIN Regions ON Countries.RegionID = Regions.ID" +
                                          " INNER JOIN Users ON Properties.UserID = Users.ID" +
                                          " LEFT OUTER JOIN MinimumNightlyRentalTypes ON Properties.MinimumNightlyRentalID = MinimumNightlyRentalTypes.ID" +
                                          " LEFT OUTER JOIN PropertyTypes ON Properties.TypeID = PropertyTypes.ID, counties " +
                                          "WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) " +
                                          "AND ( counties.county='" + countyID + "' ) " +
                                          "and (cities.id=counties.cityID) " +
                                          " AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID) " +
                                          "ORDER BY StateProvinces.StateProvince, Cities.City, Properties.NumBedrooms, Properties.NumSleeps," +
                                          " CASE WHEN EXISTS (SELECT * FROM Invoices WHERE (PropertyID = Properties.ID)" +
                                          " AND (PaymentAmount >= InvoiceAmount) AND (GETDATE() <= Invoices.RenewalDate))" +
                                          " THEN 1 ELSE 0 END DESC, Properties.ID";

        PropertiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), String.Format(STR_SELECTPropertiesInfo), SqlDbType.Int);

        //Dummyadapter = CommonFunctions.PrepareAdapter()
        AmenitiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT Amenities.ID, Amenity," +
                                                          " PropertiesAmenities.PropertyID " +
                                                          "FROM Amenities INNER JOIN PropertiesAmenities ON Amenities.ID = PropertiesAmenities.AmenityID" +
                                                          " INNER JOIN Properties ON PropertiesAmenities.PropertyID = Properties.ID " +
                                                          " INNER JOIN Cities ON Properties.CityID = Cities.ID " +
                                                          " INNER JOIN Counties ON Cities.ID = Counties.CityID " +
                                                          "WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND (Counties.county = @countyID)" +
                                                          " AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID) AND (Amenities.Amenity NOT IN" +
                                                          " ('Lake Front', 'Beach Front', 'River Front', 'Seaside', 'Ski In Ski Out', 'TV', 'VCR', 'CD Player'))",
                                                          SqlDbType.Int);

        LocationAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT StateProvinces.ID AS StateProvinceID," +
                                                         " StateProvinces.StateProvince, Countries.ID AS CountryID, Countries.Country, Regions.ID AS RegionID," +
                                                         " Regions.Region, stateprovinces.titleoverride, stateprovinces.descriptionoverride " +
                                                         "FROM StateProvinces INNER JOIN Countries ON StateProvinces.CountryID = Countries.ID" +
                                                         " INNER JOIN Regions ON Countries.RegionID = Regions.ID WHERE (counties.county = @countyID)",
                                                         SqlDbType.Int);

        HtmlHead head = Page.Header;

        HtmlMeta keywords    = new HtmlMeta();
        HtmlMeta description = new HtmlMeta();

        DataBind();

        if (!IsPostBack)
        {
            //INDIVIDUAL CITY TEXT INSERT HERE*****
            //DBConnection obj = new DBConnection();
            //DataTable dt = new DataTable();
            string vText = county + " Region on Vacations-abroad.com is a " + county + " Regional directory  of " + county + " Regional rentals by owner and privately owned " +
                           county + " Regional vacation accommodation. Our short term " + county + " Regional rentals include luxury or budget " + county + " Regional vacation homes, " + county + " Regional vacation apartments and " + county + " Regional vacation condos that are perfect for family and group vacations in the " + county + " Region of " + country + " ";

            //TOP DEFAULT TEXT
            txtCityText.Text = vText;
            lblcityInfo.Text = vText;

            //BOTTOM, NO DEFAULT TEXT

            try
            {
                dt = VADBCommander.CityTextByCountyInd(countyID.ToString());
            }
            catch (Exception ex) { lblInfo.Text = ex.Message; }
            finally { obj.CloseConnection(); }

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["cityText"] != null)
                {
                    lblcityInfo.Text = dt.Rows[0]["cityText"].ToString();
                    txtCityText.Text = dt.Rows[0]["cityText"].ToString().Replace("<br />", Environment.NewLine);
                }
                if (dt.Rows[0]["cityText2"] != null)
                {
                    lblInfo2.Text     = dt.Rows[0]["cityText2"].ToString();
                    txtCityText2.Text = dt.Rows[0]["cityText2"].ToString().Replace("<br />", Environment.NewLine);
                }
            }

            if (String.IsNullOrEmpty(lblcityInfo.Text))
            {
                //IF EMPTY VALUES OR 'DELETES' FROM ADMIN FOR TOP
                txtCityText.Text = vText;
                lblcityInfo.Text = vText;
            }
            //NO NEED TO CHECK IF EMPTY FOR BOTTOM, OK TO SHOW NOTHING

            List <string> vList        = new List <string>();
            DataTable     dt1          = new DataTable();
            DataTable     dtCategories = new DataTable();
            try
            {
                DataFunctions objF = new DataFunctions();
                dt1                       = objF.PropertiesByCase(vList, countyID, "Counties");
                Session["dt"]             = dt1;
                State_datagrid.DataSource = dt1;
                State_datagrid.DataBind();

                //add num of properties w/amenities to chk texts
                int[] i = new int[4];
                i = FindNumAmenities(dt1);

                rdoFilter.Items[0].Text += " (" + i[0].ToString() + ") ";
                rdoFilter.Items[1].Text += " (" + i[1].ToString() + ") ";
                rdoFilter.Items[2].Text += " (" + i[2].ToString() + ") ";
                rdoFilter.Items[3].Text += " (" + i[3].ToString() + ") ";
                //rdoFilter.Items[4].Text += " in " + city;
                rdoFilter.Items[4].Text += " (" + dt1.Rows.Count.ToString() + ") ";

                //numbedrooms filter
                dtCategories = objF.FindNumBedrooms(dt1);
                rdoBedrooms.Items[0].Text += " (" + dtCategories.Rows[0]["count"].ToString() + ")  ";
                rdoBedrooms.Items[1].Text += " (" + dtCategories.Rows[1]["count"].ToString() + ")  ";
                rdoBedrooms.Items[2].Text += " (" + dtCategories.Rows[2]["count"].ToString() + ")  ";
                int vBedCount = 0;
                foreach (DataRow row in dtCategories.Rows)
                {
                    vBedCount += Convert.ToInt32(row["count"]);
                }
                rdoBedrooms.Items[3].Text += " (" + vBedCount.ToString() + ") ";
                rdoBedrooms.DataBind();


                //create rdo items from categories table
                dtCategories = objF.FindNumCategories(dt1);
                int vCategoryCount = 0;

                foreach (DataRow row in dtCategories.Rows)
                {
                    string vTemp = row["category"].ToString() + " (" + row["count"].ToString() + ")";
                    vTemp = vTemp.Replace(" ", "&nbsp;");
                    rdoTypes.Items.Add(vTemp + " ");
                    vCategoryCount = vCategoryCount + Convert.ToInt32(row["count"].ToString());
                }
                rdoTypes.Items.Add("Display&nbsp;All&nbsp;(" + vCategoryCount.ToString() + ") ");
                rdoTypes.SelectedIndex = rdoTypes.Items.Count - 1;
                rdoTypes.DataBind();

                //add cities to right column
                dt = VADBCommander.CitiesInCountyList(countyID.ToString());
                foreach (DataRow datarow in dt.Rows)
                {
                    if (datarow["city"] is string)
                    {
                        string temp = CommonFunctions.GetSiteAddress() + "/" + country +
                                      "/" + stateprovince + "/" + datarow["city"].ToString() + "/default.aspx";
                        temp = temp.ToLower();
                        temp = temp.Replace(' ', '_');

                        //divCitiesRt.InnerHtml += "<a href=\"" + temp + "\">" + datarow["city"].ToString().Replace(" ", "&nbsp;") + "&nbsp;Vacation&nbsp;Rentals</a>\n";
                        divCitiesRt.InnerHtml += "<a href=\"" + temp + "\">" + datarow["city"].ToString().Replace(" ", "&nbsp;") + "</a>,  ";
                    }
                }
                divCitiesRt.InnerHtml = divCitiesRt.InnerHtml.Remove(divCitiesRt.InnerHtml.Length - 2, 2);
                //add cities to right column

                //add counties within state
                dt = obj.spGetRightSideCounties(stateID);
                foreach (DataRow datarow in dt.Rows)
                {
                    if (datarow["county"] is string)
                    {
                        string temp = CommonFunctions.GetSiteAddress() + "/" + stateprovince + "/Holiday-Rentals/" +
                                      datarow["county"].ToString() + "-Vacation_Rentals/default.aspx";
                        temp = temp.ToLower();
                        temp = temp.Replace(' ', '_');
                        divCountiesRt.InnerHtml += "<a  href=\"" + temp + "\">" + datarow["county"].ToString().Replace(" ", "&nbsp;").Replace("Province", "").Replace("of", "") + "</a>, ";
                        //divCountiesRt.InnerHtml += "<a href=\"" + temp + "\">" + datarow["county"].ToString().Replace(" ", "&nbsp;") + "&nbsp;Vacation&nbsp;Rentals</a>\n";
                        //  divCountiesRt.InnerHtml += "<a   class='rttextlow' href=\"" + temp + "\">" + datarow["county"].ToString().Replace(" ", "&nbsp;") + "&nbsp;Vacation&nbsp;Rentals</a>  ";
                    }
                }
                divCountiesRt.InnerHtml = divCountiesRt.InnerHtml.Remove(divCountiesRt.InnerHtml.Length - 2, 2);
                //add counties within state

                dt = obj.spStateProvByCountries(countryid);
                foreach (DataRow row in dt.Rows)
                {
                    if (row["stateprovince"] is string)
                    {
                        string temp = CommonFunctions.GetSiteAddress() + "/" + country + "/" + row["stateprovince"].ToString() + "/default.aspx";
                        temp = temp.ToLower();
                        temp = temp.Replace(' ', '_');

                        divStates.InnerHtml += "<a  href=\"" + temp + "\">" + row["stateprovince"].ToString().Replace(" ", "&nbsp;") + "</a>, ";
                    }
                }
                divStates.InnerHtml = divStates.InnerHtml.Remove(divStates.InnerHtml.Length - 2, 2);
            }
            catch (Exception ex) { lblInfo22.Text = ex.Message; }
        }
        //FillCitiesColumn();
        ((System.Web.UI.WebControls.Image)Master.FindControl("Logo")).AlternateText = "Vacation Rentals at Vacations-Abroad.com";
        Page.Header.Controls.Add(new LiteralControl("<link href='/css/StyleSheetBig4.css' rel='stylesheet' type='text/css' />"));
    }