コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                Title = "twoGAMES: My Ads";
                AdService.AdCRUDClient adCRUDService = new AdService.AdCRUDClient();
                adCRUDService.Open();
                Object[][] ads = adCRUDService.getUserAds(((UserData)Session["User"]).getID());
                adCRUDService.Close();

                if (ads == null)
                {
                    mainMyAdsView.InnerHtml  = "<div class='col s12 m10 l8 push-m1 push-l2'>";
                    mainMyAdsView.InnerHtml += "<div class='card white'>";
                    mainMyAdsView.InnerHtml += "<div class='card-content Black-text'>";
                    mainMyAdsView.InnerHtml += "<span class='card-title bold'>You Don't Have Any Ads</span>";
                    mainMyAdsView.InnerHtml += "<div class='row'>";
                    mainMyAdsView.InnerHtml += "<p>It looks like you haven't posted any ads yet<br/><b/>Let's see if we can help with that...try clicking the \"Post My First Ad\" button bellow to post your first ad</p>";
                    mainMyAdsView.InnerHtml += "</div>";
                    mainMyAdsView.InnerHtml += "<div class='row'>";
                    mainMyAdsView.InnerHtml += "<a href=\"PostAd.aspx\" runat=\"server\" class=\"btn waves-effect waves-light\">Post My First Ad</a> ";
                    mainMyAdsView.InnerHtml += "<a href=\"Index.aspx\" runat=\"server\" class=\"btn waves-effect waves-light red\">Cancel</a>";
                    mainMyAdsView.InnerHtml += "</div>";
                    mainMyAdsView.InnerHtml += "</div>";
                    mainMyAdsView.InnerHtml += "</div>";
                    mainMyAdsView.InnerHtml += "</div>";
                }
                else
                {
                    string userAdsView = "<div class='row'>";

                    for (int k = 0; k < ads.Length; k++)
                    {
                        if ((k % 2) != 0)
                        {
                            userAdsView += AdCard.createAdCard((string)ads[k][0], (string)ads[k][1], (string)ads[k][2], (string)ads[k][3], (string)ads[k][4], (string)ads[k][5], Convert.ToBoolean(ads[k][6]), "EditAdPage.aspx", true);
                            userAdsView += "</div>";
                            userAdsView += "<div class=\"row\">";
                        }
                        else
                        {
                            userAdsView += AdCard.createAdCard((string)ads[k][0], (string)ads[k][1], (string)ads[k][2], (string)ads[k][3], (string)ads[k][4], (string)ads[k][5], Convert.ToBoolean(ads[k][6]), "EditAdPage.aspx", true);
                        }
                    }

                    userAdsView += "</div>";

                    mainMyAdsView.InnerHtml = userAdsView;
                }
            }
        }
コード例 #2
0
ファイル: Index.aspx.cs プロジェクト: szarath/Two_games
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] != null) //Logged in
            {
                indexTitle.InnerHtml = "Welcome " + ((UserData)Session["User"]).getFirstName() + ", here are the latest ads";
            }

            Title = "twoGAMES: Home";

            AdService.AdCRUDClient adCRUDService = new AdService.AdCRUDClient();
            adCRUDService.Open();
            Object[][] ads = adCRUDService.getRecentlyAdded();
            adCRUDService.Close();

            if (ads != null)
            {
                string recentAds = "<div class='row'>";

                for (int k = 0; k < ads.Length; k++)
                {
                    if ((k % 2) != 0)
                    {
                        recentAds += AdCard.createAdCard((string)ads[k][0], (string)ads[k][1], (string)ads[k][2], (string)ads[k][3], (string)ads[k][4], (string)ads[k][5], Convert.ToBoolean(ads[k][6]), "DetailedAd.aspx", false);
                        recentAds += "</div>";
                        recentAds += "<div class=\"row\">";
                    }
                    else
                    {
                        recentAds += AdCard.createAdCard((string)ads[k][0], (string)ads[k][1], (string)ads[k][2], (string)ads[k][3], (string)ads[k][4], (string)ads[k][5], Convert.ToBoolean(ads[k][6]), "DetailedAd.aspx", false);
                    }
                }

                recentAds += "</div>";

                recentlyAddedView.InnerHtml = recentAds;
            }
        }
コード例 #3
0
ファイル: Search.aspx.cs プロジェクト: szarath/Two_games
        protected void btnSearch_ServerClick(object sender, EventArgs e)
        {
            searchedAdsDisplay.InnerHtml = "";

            if (txtSearch.Value.Equals(""))
            {
                searchedAdsDisplay.InnerHtml  = "<div class='col s12 m10 l8 push-m1 push-l2'>";
                searchedAdsDisplay.InnerHtml += "<div class='card white'>";
                searchedAdsDisplay.InnerHtml += "<div class='card-content Black-text'>";
                searchedAdsDisplay.InnerHtml += "<span class='card-title bold'>Ah Ha...Gotcha!</span>";
                searchedAdsDisplay.InnerHtml += "<div class='row'>";
                searchedAdsDisplay.InnerHtml += "<p>See what you did there. Try entering a search term now...who knows what will happen?</p>";
                searchedAdsDisplay.InnerHtml += "</div>";
                searchedAdsDisplay.InnerHtml += "</div>";
                searchedAdsDisplay.InnerHtml += "</div>";
                searchedAdsDisplay.InnerHtml += "</div>";
                txtSearch.Value = "";
                txtSearch.Focus();
                return;
            }

            AdService.AdCRUDClient adCRUDService = new AdService.AdCRUDClient();
            adCRUDService.Open();
            Object[][] ads = null;

            //-------FILTERS
            string strSQLFilters  = "";
            string strSQLOrderBys = "";

            //-------SORT DROP
            if (SortDrop.Items[SortDrop.SelectedIndex].Value.Equals("titleAZ"))
            {
                strSQLOrderBys = "aTitle ASC, ";
            }
            else if (SortDrop.Items[SortDrop.SelectedIndex].Value.Equals("titleZA"))
            {
                strSQLOrderBys = "aTitle DESC, ";
            }
            else if (SortDrop.Items[SortDrop.SelectedIndex].Value.Equals("platformAZ"))
            {
                strSQLOrderBys = "aPlatform ASC, ";
            }
            else if (SortDrop.Items[SortDrop.SelectedIndex].Value.Equals("platformZA"))
            {
                strSQLOrderBys = "aPlatform DESC, ";
            }
            else if (SortDrop.Items[SortDrop.SelectedIndex].Value.Equals("priceHighLow"))
            {
                strSQLOrderBys = "aPrice DESC, ";
            }
            else if (SortDrop.Items[SortDrop.SelectedIndex].Value.Equals("priceLowHigh"))
            {
                strSQLOrderBys = "aPrice ASC, ";
            }

            //-------PLATFORM DROP
            if (!PlatformDrop.Items[PlatformDrop.SelectedIndex].Value.Equals("default"))
            {
                strSQLFilters += "AND (aPlatform='" + PlatformDrop.Items[PlatformDrop.SelectedIndex].Value + "') ";
            }

            //-------LOCATION DROP
            if (!LocationDrop.Items[LocationDrop.SelectedIndex].Value.Equals("default"))
            {
                strSQLFilters += "AND (aLocation LIKE '%" + LocationDrop.Items[LocationDrop.SelectedIndex].Value + "%') ";
            }

            //-------PRICE DROP
            if (PriceDrop.Items[PriceDrop.SelectedIndex].Value.Equals("0-100"))
            {
                strSQLFilters += "AND (aPrice <= 100) ";
            }
            else if (PriceDrop.Items[PriceDrop.SelectedIndex].Value.Equals("100-200"))
            {
                strSQLFilters += "AND (aPrice > 100) AND (aPrice <= 200) ";
            }
            else if (PriceDrop.Items[PriceDrop.SelectedIndex].Value.Equals("200-300"))
            {
                strSQLFilters += "AND (aPrice > 200) AND (aPrice <= 300) ";
            }
            else if (PriceDrop.Items[PriceDrop.SelectedIndex].Value.Equals("300-400"))
            {
                strSQLFilters += "AND (aPrice > 300) AND (aPrice <= 400) ";
            }
            else if (PriceDrop.Items[PriceDrop.SelectedIndex].Value.Equals("400+"))
            {
                strSQLFilters += "AND (aPrice > 400) ";
            }

            /*if (((UserData)Session["User"]).isAdmin() == 0 && ((UserData)Session["User"]).isMod() == 0)
             * {*/
            ads = adCRUDService.searchAds(txtSearch.Value, strSQLFilters, strSQLOrderBys);

            /*}
             * else
             * {
             *  ads = adCRUDService.searchAdsManagement(txtSearch.Value, "");
             * }*/
            adCRUDService.Close();

            if (ads != null)
            {
                string recentAds = "<div class='row'>";

                for (int k = 0; k < ads.Length; k++)
                {
                    if ((k % 2) != 0)
                    {
                        recentAds += AdCard.createAdCard((string)ads[k][0], (string)ads[k][1], (string)ads[k][2], (string)ads[k][3], (string)ads[k][4], (string)ads[k][5], Convert.ToBoolean(ads[k][6]), "DetailedAd.aspx", false);
                        recentAds += "</div>";
                        recentAds += "<div class=\"row\">";
                    }
                    else
                    {
                        recentAds += AdCard.createAdCard((string)ads[k][0], (string)ads[k][1], (string)ads[k][2], (string)ads[k][3], (string)ads[k][4], (string)ads[k][5], Convert.ToBoolean(ads[k][6]), "DetailedAd.aspx", false);
                    }
                }

                recentAds += "</div>";

                searchedAdsDisplay.InnerHtml = recentAds;
                txtSearch.Focus();
            }
            else
            {
                searchedAdsDisplay.InnerHtml  = "<div class='col s12 m10 l8 push-m1 push-l2'>";
                searchedAdsDisplay.InnerHtml += "<div class='card white'>";
                searchedAdsDisplay.InnerHtml += "<div class='card-content Black-text'>";
                searchedAdsDisplay.InnerHtml += "<span class='card-title bold'>Oh No...Where Did They Go?</span>";
                searchedAdsDisplay.InnerHtml += "<div class='row'>";
                searchedAdsDisplay.InnerHtml += "<p>It looks like you've searched for ads which haven't been posted yet<br/><br/>You can help with that by clicking the \"Register\" button bellow to register your account</p>";
                searchedAdsDisplay.InnerHtml += "</div>";
                searchedAdsDisplay.InnerHtml += "<div class='row'>";
                searchedAdsDisplay.InnerHtml += "<a href=\"Registration.aspx\" runat=\"server\" class=\"btn waves-effect waves-light\">Register</a> ";
                //searchedAdsDisplay.InnerHtml += "<a href=\"Index.aspx\" runat=\"server\" class=\"btn waves-effect waves-light red\">Cancel</a>";
                searchedAdsDisplay.InnerHtml += "</div>";
                searchedAdsDisplay.InnerHtml += "</div>";
                searchedAdsDisplay.InnerHtml += "</div>";
                searchedAdsDisplay.InnerHtml += "</div>";
            }
        }