当前位置: 首页>>代码示例>>C#>>正文


C# Data.IP2Location方法代码示例

本文整理汇总了C#中Data.IP2Location方法的典型用法代码示例。如果您正苦于以下问题:C# Data.IP2Location方法的具体用法?C# Data.IP2Location怎么用?C# Data.IP2Location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Data的用法示例。


在下文中一共展示了Data.IP2Location方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["User"] == null)
            {
                if (!IsPostBack)
                {
                    HttpCookie cookie = Request.Cookies["BrowserDate"];
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);

                    DateTime isn = DateTime.Now;

                    DateTime.TryParse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"), out isn);

                    Data dat = new Data(isn);

                    if (Session["LocCity"] == null || Session["LocState"] == null || Session["LocCountry"] == null)
                    {
                        LocationLabel.Text = dat.IP2Location().Trim();
                    }
                    else
                    {
                        LocationLabel.Text = Session["LocCity"].ToString().Trim() + ", " +
                            Session["LocState"].ToString().Trim();
                    }
                }
            }
            else
            {
                NotLoggedIn.Visible = false;
            }
        }
        catch (Exception ex)
        {
            LocationLabel.Text = ex.ToString();
        }
    }
开发者ID:aleksczajka,项目名称:Hippo-Code---OLD,代码行数:38,代码来源:LocDetect.ascx.cs

示例2: Page_Load


//.........这里部分代码省略.........
                "' ORDER BY Name1 ASC");

            if (ds4.Tables.Count > 0)
                if (ds4.Tables[0].Rows.Count > 0)
                {
                    Session["LocationVenues"] = ds4;

                    fillVenues(ds4);
                }

            Page.Trace.Write("After Venues Load");

            ////Page.Trace.Write("Started Try");
            try
            {
                if (Session["User"] != null)
                {
                    ////Page.Trace.Write("Location");

                    Page.Trace.Write("Before Location Load");

                    DataView dvUser = dat.GetDataDV("SELECT CatCity, CatState, CatCountry, CatZip, Radius FROM  UserPreferences WHERE UserID=" +
                        Session["User"].ToString());
                    CountryDropDown.SelectedValue = dvUser[0]["CatCountry"].ToString();
                    ChangeState(CountryDropDown, new EventArgs());
                    if (StateTextBoxPanel.Visible)
                        StateTextBox.Text = dvUser[0]["CatState"].ToString();
                    else
                        StateDropDown.Items.FindItemByText(dvUser[0]["CatState"].ToString()).Selected = true;

                    CityTextBox.Text = dvUser[0]["CatCity"].ToString();
                    StateChanged(StateDropDown, new EventArgs());

                    Page.Trace.Write("After Location Load");

                    ////Page.Trace.Write("before zip");

                    if (dvUser[0]["CatZip"] != null)
                    {
                        if (dvUser[0]["CatZip"].ToString().Trim() != "")
                        {

                            char[] delim = { ';' };
                            string[] tokens = dvUser[0]["CatZip"].ToString().Split(delim);

                            if (tokens.Length > 1)
                            {
                                ZipTextBox.Text = tokens[1].Trim();

                                if (dvUser[0]["Radius"] != null)
                                {
                                    if (dvUser[0]["Radius"].ToString().Trim() != "")
                                    {

                                        RadiusDropDown.SelectedValue = dvUser[0]["Radius"].ToString();
                                    }
                                }
                            }
                        }
                    }
                    ////Page.Trace.Write("after zip");
                    Page.Trace.Write("AFter zip");
                }
                else
                {
                    Page.Trace.Write("before get ip");
                    if (Session["LocCountry"] == null || Session["LocState"] == null || Session["LocCity"] == null)
                    {
                        dat.IP2Location();
                    }
                    Page.Trace.Write("after get ip");
                    CountryDropDown.SelectedValue = Session["LocCountry"].ToString().Trim();
                    ChangeState(CountryDropDown, new EventArgs());
                    if (StateTextBoxPanel.Visible)
                        StateTextBox.Text = Session["LocState"].ToString().Trim();
                    else
                        StateDropDown.Items.FindItemByText(Session["LocState"].ToString().Trim()).Selected = true;

                    CityTextBox.Text = Session["LocCity"].ToString();
                    StateChanged(StateDropDown, new EventArgs());
                    Page.Trace.Write("after");
                }
                Page.Trace.Write("before search");
                Search();
                Page.Trace.Write("after search");
            }
            catch (Exception ex)
            {
                ErrorLabel.Text = ex.ToString();
            }
            ////Page.Trace.Write("Ended try");
        }
        else
        {
            if (Session["LocationVenues"] != null)
                fillVenues((DataSet)Session["LocationVenues"]);
        }

        Page.Trace.Write("Ended Page Load");
    }
开发者ID:aleksczajka,项目名称:Hippo-Code---OLD,代码行数:101,代码来源:EventSearch.aspx.cs

示例3: GetEvents


//.........这里部分代码省略.........
            try
            {
                if (Session["User"] != null)
                {
                    if (Session["LocCountry"] == null || Session["LocState"] == null || Session["LocCity"] == null)
                    {
                        DataSet ds1 = dat.GetData("SELECT * FROM Users U, UserPreferences UP WHERE U.User_ID=" +
                            Session["User"].ToString() + " AND U.User_ID=UP.UserID ");

                        country = ds1.Tables[0].Rows[0]["CatCountry"].ToString();
                        countryID = country;

                        state = ds1.Tables[0].Rows[0]["CatState"].ToString();
                        city = ds1.Tables[0].Rows[0]["CatCity"].ToString();
                        stateID = state;
                        cityID = city;
                    }
                    else
                    {
                        country = Session["LocCountry"].ToString().Trim();
                        state = Session["LocState"].ToString().Trim();

                        city = Session["LocCity"].ToString();
                        stateID = state;
                        cityID = city;
                    }

                    fillUserData = true;
                }
                else
                {
                    if (Session["LocCountry"] == null || Session["LocState"] == null || Session["LocCity"] == null)
                    {
                        dat.IP2Location();
                    }

                    country = Session["LocCountry"].ToString().Trim();
                    state = Session["LocState"].ToString().Trim();

                    city = Session["LocCity"].ToString();
                    stateID = state;
                    cityID = city;

                }
            }
            catch (Exception ex)
            {
                ErrorLabel.Text += ex.ToString();
            }

            DataSet ds;

            string realCountry = country;
            string tripCountry = "";
            if (country != "")
            {
                country = " AND E.Country = " + realCountry;
                tripCountry = " AND TDir.Country = " + realCountry;
            }

            string zips = "";

            if (realCountry == "223")
            {
                GetAllZipsInProximity(out zips);
开发者ID:aleksczajka,项目名称:Hippo-Code---OLD,代码行数:66,代码来源:Home.aspx.cs

示例4: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        DateTime today = DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"));
        Data dat = new Data(today);
        DataSet ds;

        if (Request.QueryString["ID"] != null)
        {
            string catID = Request.QueryString["ID"].ToString();
            string location = "";

            //Get the location
            if (Session["User"] != null)
            {
                DataView dvPrefs = dat.GetDataDV("SELECT * FROM UserPreferences WHERE UserID=" + Session["User"].ToString());
                location = " AND A.CatState='" + dvPrefs[0]["CatState"].ToString() + "' AND A.CatCity='" + dvPrefs[0]["CatCity"].ToString() + "' AND A.CatCountry=" + dvPrefs[0]["CatCountry"].ToString();
            }
            else
            {
                if (Session["LocCountry"] == null || Session["LocState"] == null || Session["LocCity"] == null)
                {
                    dat.IP2Location();
                }

                string country = Session["LocCountry"].ToString().Trim();
                string state = Session["LocState"].ToString().Trim();

                string city = Session["LocCity"].ToString();
                location = " AND A.CatState='" + state + "' AND A.CatCity='" + city + "' AND A.CatCountry=" + country;
            }

            string sqlToday = "CONVERT(DATETIME, '" + today.Month.ToString() + "/" +
                today.Day.ToString() + "/" + today.Year.ToString() + "')";
            string timeline = " AND (A.Featured='False' AND AC.DateTimeEnd >= " +
                sqlToday + ")";

            ds = dat.GetData("SELECT ACM.AdID AS VID, A.Featured, C.ID, A.Header, C.Name AS CategoryName, " +
                "ACM.tagSize FROM Ad_Category_Mapping ACM, AdCategories C, Ads A, Ad_Calendar AC WHERE " +
                "ACM.AdID=A.Ad_ID AND AC.AdID=A.Ad_ID AND ACM.CategoryID=C.ID AND A.LIVE = 'True' AND ACM.CategoryID=" +
                catID + location + timeline);
            SearchElements.AD_DS = ds;
            SearchElements.DataBind2();

            NumResultsLabel.Text = "(" + ds.Tables[0].Rows.Count + " Records Found)";

            HtmlHead head = (HtmlHead)Page.Header;

            string theLink = "";

            if (ds.Tables[0].Rows.Count > 0)
            {
                theLink = "http://" + Request.Url.Authority + "/" +
                dat.MakeNiceName(ds.Tables[0].Rows[0]["CategoryName"].ToString()) + "_Ad_Category";
            }
            else
            {
                theLink = "http://" + Request.Url.Authority + "/AdCategorySearch.aspx?ID=" + catID;
            }

            HtmlLink lk = new HtmlLink();
            lk.Href = theLink;
            lk.Attributes.Add("rel", "bookmark");
            head.Controls.AddAt(0, lk);

            HtmlMeta hm = new HtmlMeta();
            HtmlMeta kw = new HtmlMeta();
            HtmlMeta dc = new HtmlMeta();

            kw.Name = "keywords";

            if (ds.Tables[0].Rows.Count > 0)
            {
                kw.Content = ds.Tables[0].Rows[0]["CategoryName"].ToString() + " Ad Category";
            }
            else
            {
                kw.Content = "No Ad Category";
            }

            head.Controls.AddAt(0, kw);

            dc.Name = "description";
            if (ds.Tables[0].Rows.Count > 0)
            {
                dc.Content = "Results for ad category: " + ds.Tables[0].Rows[0]["CategoryName"].ToString();
            }
            else
            {
                dc.Content = "Results for ad category: None";
            }

            head.Controls.AddAt(0, dc);
//.........这里部分代码省略.........
开发者ID:aleksczajka,项目名称:Hippo-Code---OLD,代码行数:101,代码来源:AdCategorySearch.aspx.cs

示例5: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        DataSet ds;

        HtmlHead head = (HtmlHead)Page.Header;

        if (Request.QueryString["ID"] != null)
        {
            string catID = Request.QueryString["ID"].ToString();

            string location = "";

            //Get the location
            if (Session["User"] != null)
            {
                DataView dvPrefs = dat.GetDataDV("SELECT * FROM UserPreferences WHERE UserID=" + Session["User"].ToString());
                location = " AND V.State='" + dvPrefs[0]["CatState"].ToString() + "' AND V.City='" + dvPrefs[0]["CatCity"].ToString() + "'";
            }
            else
            {
                if (Session["LocCountry"] == null || Session["LocState"] == null || Session["LocCity"] == null)
                {
                    dat.IP2Location();
                }

                string country = Session["LocCountry"].ToString().Trim();
                string state = Session["LocState"].ToString().Trim();

                string city = Session["LocCity"].ToString();
                location = " AND V.State='" + state + "' AND V.City='" + city + "' AND V.Country=" + country;
            }

            ds = dat.GetData("SELECT V.Name, V.ID AS VID, V.City, V.State, C.ID, C.Name AS " +
                "CategoryName, VC.tagSize, V.Featured, V.DaysFeatured FROM Venue_Category VC, VenueCategories C, Venues V " +
                "WHERE V.ID=VC.VENUE_ID AND VC.CATEGORY_ID=C.ID AND VC.CATEGORY_ID=" + catID + location);

            SearchElements.VENUE_DS = ds;
            SearchElements.DataBind2();

            NumResultsLabel.Text = "(" + ds.Tables[0].Rows.Count + " Records Found)";

            DataView dvName = dat.GetDataDV("SELECT * FROM VenueCategories WHERE ID=" + catID);

            string theLink = "http://" + Request.Url.Authority + "/" +
            dat.MakeNiceName(dvName[0]["Name"].ToString()) + "_Venue_Category";

            HtmlLink lk = new HtmlLink();
            lk.Href = theLink;
            lk.Attributes.Add("rel", "bookmark");
            head.Controls.AddAt(0, lk);

            HtmlMeta hm = new HtmlMeta();
            HtmlMeta kw = new HtmlMeta();
            HtmlMeta dc = new HtmlMeta();

            kw.Name = "keywords";
            kw.Content = dvName[0]["Name"].ToString() + " Venue Category";

            head.Controls.AddAt(0, kw);

            dc.Name = "description";
            dc.Content = "Results for venue category: " + dvName[0]["Name"].ToString();

            head.Controls.AddAt(0, dc);

            SearchResultsTitleLabel.Text = "<a href=\"" + theLink + "\" style=\"text-decoration: none; color: white;\" ><h1>Venues in '" +
                dvName[0]["Name"].ToString() + "' Category</h1></a>";
        }
        else
        {
            Response.Redirect("home");
        }
    }
开发者ID:aleksczajka,项目名称:Hippo-Code---OLD,代码行数:82,代码来源:VenueCategorySearch.aspx.cs

示例6: Page_Load


//.........这里部分代码省略.........
            head.Controls.AddAt(0, kw);

            hm.Name = "Description";
            hm.Content = "Find local trips and adventures posted by your peers and experience more out of your city.";
            head.Controls.AddAt(0, hm);

            lk = new HtmlLink();
            lk.Href = "http://" + Request.Url.Authority + "/trip-search";
            lk.Attributes.Add("rel", "bookmark");
            head.Controls.AddAt(0, lk);

            EventTitle.Text = "<a style=\"text-decoration: none;\" href=\"" +
                lk.Href + "\"><h1>Search Adventures</h1></a>";

            //Button button = (Button)dat.FindControlRecursive(this, "EventLink");
            //button.CssClass = "NavBarImageEventSelected";
        }

        if (!IsPostBack)
        {
            CountryDropDown.SelectedValue = "223";

            DataSet ds3 = dat.GetData("SELECT * FROM State WHERE country_id=" + CountryDropDown.SelectedValue);

            StateDropDownPanel.Visible = true;
            StateTextBoxPanel.Visible = false;
            StateDropDown.DataSource = ds3;
            StateDropDown.DataTextField = "state_2_code";
            StateDropDown.DataValueField = "state_id";
            StateDropDown.DataBind();

            StateDropDown.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("State", "-1"));

            StateDropDownPanel.Visible = true;
            StateTextBoxPanel.Visible = false;

            try
            {
                if (Session["User"] != null)
                {
                    DataView dvUser = dat.GetDataDV("SELECT CatCity, CatState, CatCountry, CatZip, Radius FROM  UserPreferences WHERE UserID=" +
                        Session["User"].ToString());
                    CountryDropDown.SelectedValue = dvUser[0]["CatCountry"].ToString();
                    ChangeState(CountryDropDown, new EventArgs());
                    if (StateTextBoxPanel.Visible)
                        StateTextBox.Text = dvUser[0]["CatState"].ToString();
                    else
                        StateDropDown.Items.FindItemByText(dvUser[0]["CatState"].ToString()).Selected = true;

                    CityTextBox.Text = dvUser[0]["CatCity"].ToString();

                    if (dvUser[0]["CatZip"] != null)
                    {
                        if (dvUser[0]["CatZip"].ToString().Trim() != "")
                        {

                            char[] delim = { ';' };
                            string[] tokens = dvUser[0]["CatZip"].ToString().Split(delim);

                            if (tokens.Length > 1)
                            {
                                ZipTextBox.Text = tokens[1].Trim();

                                if (dvUser[0]["Radius"] != null)
                                {
                                    if (dvUser[0]["Radius"].ToString().Trim() != "")
                                    {

                                        RadiusDropDown.SelectedValue = dvUser[0]["Radius"].ToString();
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (Session["LocCountry"] == null || Session["LocState"] == null || Session["LocCity"] == null)
                    {
                        dat.IP2Location();
                    }

                    CountryDropDown.SelectedValue = Session["LocCountry"].ToString().Trim();
                    ChangeState(CountryDropDown, new EventArgs());
                    if (StateTextBoxPanel.Visible)
                        StateTextBox.Text = Session["LocState"].ToString().Trim();
                    else
                        StateDropDown.Items.FindItemByText(Session["LocState"].ToString().Trim()).Selected = true;

                    CityTextBox.Text = Session["LocCity"].ToString();
                }

                Search();
            }
            catch (Exception ex)
            {
                ErrorLabel.Text = ex.ToString();
            }
        }
    }
开发者ID:aleksczajka,项目名称:Hippo-Code---OLD,代码行数:101,代码来源:TripSearch.aspx.cs

示例7: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.Date.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }

        bool fillUserData = false;

        DateTime isn = DateTime.Now;

        if (!DateTime.TryParse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"), out isn))
            isn = DateTime.Now;
        DateTime isNow = isn;
        Data dat = new Data(isn);
        if (Session["LocCountry"] == null || Session["LocState"] == null || Session["LocCity"] == null)
            dat.IP2Location();
        DoAds();

        HtmlControl body = (HtmlControl)dat.FindControlRecursive(this.Page, "bodytag");

        //body.Attributes["onload"] = "\r\nif\r\n(\r\ntypeof(window.myFunction) == 'function')\r\n{\r\nStartRotator2();}" + body.Attributes["onload"];

        body.Attributes["onload"] = "StartRotator2();" + body.Attributes["onload"];
    }
开发者ID:aleksczajka,项目名称:Hippo-Code---OLD,代码行数:29,代码来源:Ads.ascx.cs

示例8: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        DateTime today = DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"));
        Data dat = new Data(today);
        DataSet ds;
        if (Request.QueryString["ID"] != null)
        {
            string catID = Request.QueryString["ID"].ToString();

            string location = "";

            //Get the location
            if (Session["User"] != null)
            {
                DataView dvPrefs = dat.GetDataDV("SELECT * FROM UserPreferences WHERE UserID=" + Session["User"].ToString());
                location = " AND TD.State='" + dvPrefs[0]["CatState"].ToString() + "' AND TD.City='" +
                    dvPrefs[0]["CatCity"].ToString() + "' AND TD.Country=" + dvPrefs[0]["CatCountry"].ToString();
            }
            else
            {
                if (Session["LocCountry"] == null || Session["LocState"] == null || Session["LocCity"] == null)
                {
                    dat.IP2Location();
                }

                string country = Session["LocCountry"].ToString().Trim();
                string state = Session["LocState"].ToString().Trim();

                string city = Session["LocCity"].ToString();
                location = " AND TD.State='" + state + "' AND TD.City='" + city + "' AND TD.Country=" + country;
            }

            string command = "SELECT  DISTINCT E.ID AS EID, '$'+CONVERT(NVARCHAR,E.MinPrice)+' - $'+CONVERT(NVARCHAR, E.MaxPrice)" +
                            "AS PriceRange, E.MinPrice AS Price, E.Means, dbo.GetDuration(E.Duration, 0) AS " +
                            "TimeFrame, dbo.GetDuration(E.Duration, 1) AS Duration, E.Header, " +
                            " E.Featured, E.DaysFeatured " +
                "FROM Trip_Category ECM, Trips E, TripDirections TD, TripCategories C " +
                "WHERE C.ID=ECM.CategoryID AND TD.TripID=E.ID AND ECM.TripID=E.ID AND " +
                "ECM.CategoryID=" + catID + location;

            ds = dat.GetData(command);
            SearchElements.EVENTS_DS = ds;
            SearchElements.DataBind2();

            NumResultsLabel.Text = "(" + ds.Tables[0].Rows.Count + " Records Found)";

            DataView dvName = dat.GetDataDV("SELECT * FROM TripCategories WHERE ID=" + catID);

            HtmlHead head = (HtmlHead)Page.Header;

            string theLink = "http://" + Request.Url.Authority + "/" +
               dat.MakeNiceName(dvName[0]["Name"].ToString()) + "_Trip_Category";

            HtmlLink lk = new HtmlLink();
            lk.Href = theLink;
            lk.Attributes.Add("rel", "bookmark");
            head.Controls.AddAt(0, lk);

            HtmlMeta hm = new HtmlMeta();
            HtmlMeta kw = new HtmlMeta();
            HtmlMeta dc = new HtmlMeta();

            kw.Name = "keywords";
            kw.Content = dvName[0]["Name"].ToString() + " trip Category";

            head.Controls.AddAt(0, kw);

            dc.Name = "description";
            dc.Content = "Results for trip category: " + dvName[0]["Name"].ToString();

            head.Controls.AddAt(0, dc);

            SearchResultsTitleLabel.Text = "<a href=\"" + theLink +
                "\" style=\"text-decoration: none;\" ><h1>Trips in '" +
                dvName[0]["Name"].ToString() + "' Category</h1></a>";

        }
        else
        {
            Response.Redirect("home");
        }
    }
开发者ID:aleksczajka,项目名称:Hippo-Code---OLD,代码行数:90,代码来源:TripCategorySearch.aspx.cs

示例9: Page_Load


//.........这里部分代码省略.........
                    CountryDropDown.ClearSelection();
                    CountryDropDown.SelectedValue = dvUser[0]["CatCountry"].ToString();
                    ChangeState(CountryDropDown, new EventArgs());
                    if (StateTextBoxPanel.Visible)
                        StateTextBox.Text = dvUser[0]["CatState"].ToString();
                    else
                    {
                        StateDropDown.ClearSelection();
                        StateDropDown.Items.FindItemByText(dvUser[0]["CatState"].ToString()).Selected = true;
                        ChangeCity(StateDropDown, new EventArgs());
                    }

                    if (dvUser[0]["CatCountry"].ToString() == "223")
                    {
                        if (dvUser[0]["CatCity"] != null)
                        {
                            MajorCityDrop.ClearSelection();
                            MajorCityDrop.Items.FindByValue(dvUser[0]["MajorCity"].ToString()).Selected = true;
                        }
                    }
                    else
                    {
                        if (dvUser[0]["CatCity"] != null)
                        {
                            CityTextBox.Text = dvUser[0]["CatCity"].ToString();
                        }
                    }

                    //if (dvUser[0]["CatZip"] != null)
                    //{
                    //    if (dvUser[0]["CatZip"].ToString().Trim() != "")
                    //    {

                    //        char[] delim = { ';' };
                    //        string[] tokens = dvUser[0]["CatZip"].ToString().Split(delim);

                    //        if (tokens.Length > 1)
                    //        {
                    //            ZipTextBox.Text = tokens[1].Trim();

                    //            if (dvUser[0]["Radius"] != null)
                    //            {
                    //                if (dvUser[0]["Radius"].ToString().Trim() != "")
                    //                {

                    //                    RadiusDropDown.SelectedValue = dvUser[0]["Radius"].ToString();
                    //                }
                    //            }
                    //        }
                    //    }
                    //}
                }
                else
                {
                    if (Session["LocCountry"] == null || Session["LocState"] == null || Session["LocCity"] == null)
                    {
                        dat.IP2Location();
                    }

                    CountryDropDown.SelectedValue = Session["LocCountry"].ToString().Trim();
                    ChangeState(CountryDropDown, new EventArgs());
                    if (StateTextBoxPanel.Visible)
                        StateTextBox.Text = Session["LocState"].ToString().Trim();
                    else
                    {
                        StateDropDown.ClearSelection();
                        StateDropDown.Items.FindItemByText(Session["LocState"].ToString().Trim()).Selected = true;
                    }

                    ChangeCity(StateDropDown, new EventArgs());
                }

            }
            catch (Exception ex)
            {
                ErrorLabel.Text = ex.ToString();
            }
        }

        try
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["search"] != null)
                {
                    FillSavedSearch();
                }
                else
                {
                    Search();
                }
            }
        }
        catch (Exception ex)
        {
            ErrorLabel.Text = ex.ToString();
        }

        MessageRadWindowManager.VisibleOnPageLoad = false;
    }
开发者ID:aleksczajka,项目名称:Hippo-Code---OLD,代码行数:101,代码来源:AdSearch.aspx.cs

示例10: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        DateTime today = DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"));
        Data dat = new Data(today);
        DataSet ds;

        HtmlHead head = (HtmlHead)Page.Header;

        if (Request.QueryString["ID"] != null)
        {
            string catID = Request.QueryString["ID"].ToString();

            string location = "";

            //Get the location
            if (Session["User"] != null)
            {
                DataView dvPrefs = dat.GetDataDV("SELECT * FROM UserPreferences WHERE UserID=" + Session["User"].ToString());
                location = " AND V.State='" + dvPrefs[0]["CatState"].ToString() + "' AND V.City='" + dvPrefs[0]["CatCity"].ToString() + "' AND V.Country = " + dvPrefs[0]["CatCountry"].ToString();
            }
            else
            {
                if (Session["LocCountry"] == null || Session["LocState"] == null || Session["LocCity"] == null)
                {
                    dat.IP2Location();
                }

                string country = Session["LocCountry"].ToString().Trim();
                string state = Session["LocState"].ToString().Trim();

                string city = Session["LocCity"].ToString();
                location = " AND V.State='" + state + "' AND V.City='" + city + "' AND V.Country=" + country;

            }

            //get only events after today, since showing all events might be too much
            string timeline = " AND EO.DateTimeStart >= CONVERT(DATETIME, '" + today.Month.ToString() + "/" + today.Day.ToString() + "/" + today.Year.ToString() + "')";

            string command = "SELECT DISTINCT E.ID  " +
                "FROM Event_Occurance EO, Event_Category_Mapping ECM, Events E, Venues V, EventCategories C " +
                "WHERE EO.EventID=E.ID AND C.ID=ECM.CategoryID  AND ECM.EventID=E.ID AND " +
                "ECM.CategoryID=" + catID + location + timeline;

            DataView dvE = dat.GetDataDV(command);

            ds = new DataSet();
            DataTable dt = new DataTable();
            DataColumn dc = new DataColumn("EID");
            dt.Columns.Add(dc);
            dc = new DataColumn("ReoccurrID");
            dt.Columns.Add(dc);
            dc = new DataColumn("DateTimeStart");
            dt.Columns.Add(dc);
            dc = new DataColumn("VID");
            dt.Columns.Add(dc);
            dc = new DataColumn("Header");
            dt.Columns.Add(dc);
            dc = new DataColumn("Name");
            dt.Columns.Add(dc);

            DataView dv;
            DataRow dr;
            foreach (DataRowView row in dvE)
            {
                dv = dat.GetDataDV("SELECT E.ID AS EID, EO.ID AS ReoccurrID, EO.DateTimeStart, E.Header, "+
                    "V.ID AS VID, V.Name " +
                "FROM Event_Occurance EO, Events E, Venues V " +
                "WHERE EO.EventID=E.ID AND E.Venue=V.ID AND E.ID=" + row["ID"].ToString());

                dr = dt.NewRow();
                dr["EID"] = dv[0]["EID"];
                dr["ReoccurrID"] = dv[0]["ReoccurrID"];
                dr["DateTimeStart"] = dv[0]["DateTimeStart"];
                dr["VID"] = dv[0]["VID"];
                dr["Header"] = dv[0]["Header"];
                dr["Name"] = dv[0]["Name"];
                dt.Rows.Add(dr);
            }

            ds.Tables.Add(dt);
            SearchElements.EVENTS_DS = ds;
            SearchElements.DataBind2();

            NumResultsLabel.Text = "(" + ds.Tables[0].Rows.Count + " Records Found)";

            DataView dvName = dat.GetDataDV("SELECT * FROM EventCategories WHERE ID=" + catID);

            string theLink = "http://" + Request.Url.Authority + "/" +
               dat.MakeNiceName(dvName[0]["Name"].ToString()) + "_Event_Category";

            HtmlLink lk = new HtmlLink();
            lk.Href = theLink;
//.........这里部分代码省略.........
开发者ID:aleksczajka,项目名称:Hippo-Code---OLD,代码行数:101,代码来源:EventCategorySearch.aspx.cs


注:本文中的Data.IP2Location方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。