Exemplo n.º 1
0
        /*protected void search_ServerClick(object sender, EventArgs e)
         * {
         *  string searchView = "<div class='row'>";
         *  searchView += "<div class='input-field col s12 m9 l10'>";
         *  searchView += "<i class='material-icons prefix'>search</i>";
         *  searchView += "<input id='txtSearch' type='text' class='black-text' runat='server' autofocus/>";
         *  searchView += "<label for='txtSearch'>Click here to search</label>";
         *  searchView += "</div>";
         *  searchView += "<div class='input-field col m2 l2'>";
         *  searchView += "<button id='btnSearch' type='submit' class='btn waves-effect waves-light' runat=\"server\" onserverclick=\"btnSearch_ServerClick\">Search</button>";
         *  searchView += "</div>";
         *  searchView += "</div>";
         *
         *  searchView = "<span class='card-title'>Feature coming soon...</span>";
         *  AdManageView.InnerHtml = searchView;
         * }*/

        /*protected void btnSearch_ServerClick(object sender, EventArgs e)
         * {
         *  AdService.AdCRUDClient adCRUDService = new AdService.AdCRUDClient();
         *  adCRUDService.Open();
         *  Object[][] ads = adCRUDService.searchAdsManagement(txtSearch.Value,"");
         *  adCRUDService.Close();
         *
         *  AdManageView.InnerHtml = createAdManageView(ads, "No ads match your search...", "Search Ads");
         * }*/

        protected void stats_ServerClick(object sender, EventArgs e)
        {
            //AdManageView.InnerHtml = "<span class='card-title'>Feature coming soon...</span>";

            AdService.AdCRUDClient adCRUDService = new AdService.AdCRUDClient();
            adCRUDService.Open();
            DateTime todayIs            = DateTime.Today;
            int      newUsersThisYear   = adCRUDService.numNewAdsYearManagement(todayIs);
            int      newUsersThisMonth  = adCRUDService.numNewAdsMonthManagement(todayIs);
            int      newUsersThisWeek   = adCRUDService.numNewAdsWeekManagement(todayIs);
            int      newUsersToday      = adCRUDService.numNewAdsDayManagement(todayIs);
            int      reportedusersTotal = adCRUDService.numReportedAdsManagement();
            int      flaggedUsersTotal  = adCRUDService.numFlaggedAdsManagement();
            int      premUsersTotal     = adCRUDService.numPremAdsManagement();

            adCRUDService.Close();

            string statsView = "<span class='card-title'>Stats</span>";

            statsView += "<div class='row'>";
            statsView += "<p>New Ads This <b>Year:</b> " + newUsersThisYear.ToString() + "</p>";
            statsView += "<p>New Ads This <b>Month:</b> " + newUsersThisMonth.ToString() + "</p>";
            statsView += "<p>New Ads This <b>Week:</b> " + newUsersThisWeek.ToString() + "</p>";
            statsView += "<p>New Ads <b>Today:</b> " + newUsersToday.ToString() + "</p>";
            statsView += "<br/>";
            statsView += "<p>Number of <b>Premium Ads:</b> " + premUsersTotal.ToString() + "</p>";
            statsView += "<p>Number of <b>Reported Ads:</b> " + reportedusersTotal.ToString() + "</p>";
            statsView += "<p>Number of <b>Flagged Ads:</b> " + flaggedUsersTotal.ToString() + "</p>";
            statsView += "</div>";

            AdManageView.InnerHtml = statsView;
        }
Exemplo n.º 2
0
        protected void viewAll_ServerClick(object sender, EventArgs e)
        {
            AdService.AdCRUDClient adCRUDService = new AdService.AdCRUDClient();
            adCRUDService.Open();
            Object[][] ads = adCRUDService.getAllAdsManagement();
            adCRUDService.Close();

            AdManageView.InnerHtml = createAdManageView(ads, "There seems to be no ads...", "All Ads");
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] != null) //Logged in
            {
                dropDownMenuLoggedIn.Visible  = true;
                dropDownMenuLoggedOut.Visible = false;
                logInSideNav.Visible          = false;
                registerSideNav.Visible       = false;
                postNewAdTopNav.Visible       = true;
                postNewAdSideNav.Visible      = true;
                floatingPostAdButton.Visible  = true;
                signOutSideNav.Visible        = true;

                //----obtain number of users ads and set myads badge
                AdService.AdCRUDClient adServ = new AdService.AdCRUDClient();
                adServ.Open();
                int numUsersAds = adServ.getNumUserAds(((UserData)Session["User"]).getID());
                adServ.Close();
                myAdsBadgeDropDown.InnerHtml = numUsersAds.ToString();

                //----set appropriate admin and mod link visible
                if (((UserData)Session["User"]).isMod() == 1)
                {
                    managementDropDownTrigger.Visible = true;
                    dropDownManagementMenu.Visible    = true;
                    manageAdsDrop.Visible             = true;
                    manageUsersDrop.Visible           = false;
                    //adminSideNav.Visible = true;
                    manageAdsSideNav.Visible    = true;
                    manageUsersSideNav.Visible  = false;
                    adminSideNavDivider.Visible = true;
                }
                else if (((UserData)Session["User"]).isAdmin() == 1)
                {
                    managementDropDownTrigger.Visible = true;
                    dropDownManagementMenu.Visible    = true;
                    manageAdsDrop.Visible             = true;
                    manageUsersDrop.Visible           = true;
                    //adminSideNav.Visible = true;
                    manageAdsSideNav.Visible    = true;
                    manageUsersSideNav.Visible  = true;
                    adminSideNavDivider.Visible = true;
                }
            }
            else
            {
                postNewAdTopNav.Visible       = false;
                postNewAdSideNav.Visible      = false;
                dropDownMenuLoggedIn.Visible  = false;
                dropDownMenuLoggedOut.Visible = true;
                logInSideNav.Visible          = true;
                registerSideNav.Visible       = true;
                myProfileSideNav.Visible      = false;
                myAdsSideNav.Visible          = false;
                signOutSideNav.Visible        = false;
            }
        }
Exemplo n.º 4
0
        protected void btnDeleteAd_ServerClick(object sender, EventArgs e)
        {
            UserData user = (UserData)Session["User"];

            AdService.AdCRUDClient service = new AdService.AdCRUDClient();
            service.Open();

            int success = service.deleteAd(Convert.ToInt32(Request.QueryString.Get("ad")));

            if (success == 1)
            {
                //remember variable in code bellow
                editAdDiv.InnerHtml  = "<div class='col s12 m6 push-m3'>";
                editAdDiv.InnerHtml += "<div class='card white'>";
                editAdDiv.InnerHtml += "<div class='card-content Black-text'>";
                editAdDiv.InnerHtml += "<span class='card-title bold'>Ad Deleted Successfully</span>";
                editAdDiv.InnerHtml += "<p>You have Deleted this ad. To view your other ads, proceeed to the My Ads page.</p>";

                editAdDiv.InnerHtml += "</div>";
                editAdDiv.InnerHtml += "<div class='card-action'>";
                editAdDiv.InnerHtml += "<a href='MyAds.aspx' runat='server' class='btn waves-effect waves-light'>My Ads</a>";
                if (Session["User"] != null)
                {
                    if (((UserData)Session["User"]).isAdmin() == 1 || ((UserData)Session["User"]).isMod() == 1)
                    {
                        editAdDiv.InnerHtml += "<a class='btn right waves-effect waves-light orange lighten-2' href='AdManagement.aspx'>Manage Ads</a>";
                    }
                }
                editAdDiv.InnerHtml += "</div>";
                editAdDiv.InnerHtml += "</div>";
                editAdDiv.InnerHtml += "</div>";
            }
            else
            {
                editAdDiv.InnerHtml  = "<div class='col s12 m6 push-m3'>";
                editAdDiv.InnerHtml += "<div class='card white'>";
                editAdDiv.InnerHtml += "<div class='card-content Black-text'>";
                editAdDiv.InnerHtml += "<span class='card-title bold'>Unable to delete Ad</span>";
                editAdDiv.InnerHtml += "<p>We where unable to delete this ad. Please try again and if the problem persists pleas contact us <a href='ContactUs.aspx'>here</a>.</p>";

                editAdDiv.InnerHtml += "</div>";
                editAdDiv.InnerHtml += "<div class='card-action'>";
                editAdDiv.InnerHtml += "<a href='MyAds.aspx' runat='server' class='btn waves-effect waves-light'>My Ads</a>";
                if (Session["User"] != null)
                {
                    if (((UserData)Session["User"]).isAdmin() == 1 || ((UserData)Session["User"]).isMod() == 1)
                    {
                        editAdDiv.InnerHtml += "<a class='btn right waves-effect waves-light orange lighten-2' href='AdManagement.aspx'>Manage Ads</a>";
                    }
                }
                editAdDiv.InnerHtml += "</div>";
                editAdDiv.InnerHtml += "</div>";
                editAdDiv.InnerHtml += "</div>";
            }
            service.Close();
        }
Exemplo n.º 5
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;
                }
            }
        }
Exemplo n.º 6
0
        protected void btnReplyAd_ServerClick(object sender, EventArgs e)
        {
            AdService.AdCRUDClient adService = new AdService.AdCRUDClient();
            adService.Open();
            String[] userdetails = adService.getUserEmail(adnum);
            adService.Close();

            if (txtName.Value == "" || txtemail.Value == "" || txtMessage.Value == "")
            {
                replysentdiv.InnerHtml = "<p class='red-text'>Please fill in all the appropriate fields</p>";
            }
            else
            {
                NetworkCredential netCred = new NetworkCredential("*****@*****.**", "IFMTYP2016");
                SmtpClient        smtpobj = new SmtpClient("smtp.gmail.com", 587);
                smtpobj.EnableSsl   = true;
                smtpobj.Credentials = netCred;
                //smtpobj.DeliveryMethod = SmtpDeliveryMethod.Network;

                MailMessage mailMessage = new MailMessage();
                mailMessage.From = new MailAddress("*****@*****.**", "twoGames");
                mailMessage.To.Add(new MailAddress(userdetails[0]));
                mailMessage.Subject    = "You have a reply to your ad \"" + (string)adDetails[1] + "\"";
                mailMessage.IsBodyHtml = true;

                mailMessage.Body  = "<h1>Hi " + userdetails[1] + ",</h1><br/>";
                mailMessage.Body += "<b>" + txtName.Value + "</b> has replied to your advert <b>\"" + (string)adDetails[1] + "\"</b>";
                mailMessage.Body += "<br/><br/>";
                mailMessage.Body += "Their message: <br/>";
                mailMessage.Body += "\"<i>" + txtMessage.Value + "</i>\"";
                mailMessage.Body += "<br/><br/><a href='mailto:" + txtemail.Value + "?subject=[twoGames] \"" + (string)adDetails[1] + "\" Advert'><button>Click here to reply</button></a>";
                mailMessage.Body += "<br/><br/>Kind Regards<br/>twoGames";



                try
                {
                    smtpobj.Send(mailMessage);
                    btnReplyAd.Visible     = false;
                    replysentdiv.InnerHtml = "<p>Your message has been sent successfully.</p>";
                }
                catch (SmtpException ex)
                {
                    replysentdiv.InnerHtml = "<p class='red-text'>Failed to send your message. Please try again.</p>";
                }
            }
        }
Exemplo n.º 7
0
        protected void flagAd_ServerClick(object sender, EventArgs e)
        {
            if (Session["User"] != null)
            {
                if (((UserData)Session["User"]).isAdmin() == 1 || ((UserData)Session["User"]).isMod() == 1)
                {
                    AdService.AdCRUDClient adService = new AdService.AdCRUDClient();
                    adService.Open();
                    int flagAdResult = adService.flagAd(Convert.ToInt32((string)this.adDetails[0]));
                    adService.Close();

                    if (flagAdResult == 1)
                    {
                        detailedAdActionResutView.InnerHtml  = "<div class='col s12 m6 l4 push-l4 push-m3'>";
                        detailedAdActionResutView.InnerHtml += "<div class='card'>";
                        detailedAdActionResutView.InnerHtml += "<div class='card-content black-text'>";
                        detailedAdActionResutView.InnerHtml += "<span class='card-title bold'>Ad Flagged Successfully</span>";
                        detailedAdActionResutView.InnerHtml += "<p>You have successfully flagged this ad. Our proficient team of Moderators and Administrators will review the ad and decide its fate.<br/><br/>We personally thank you for making twoGames even better!</p><br/>";
                        detailedAdActionResutView.InnerHtml += "<div class='card-action'>";
                        detailedAdActionResutView.InnerHtml += "<a href='Index.aspx' runat='server' class='btn waves-effect waves-light'>Continue</a>";
                        detailedAdActionResutView.InnerHtml += " <a href='AdManagement.aspx' runat='server' class='btn waves-effect waves-light orange lighten-2'>Manage Ads</a>";
                        detailedAdActionResutView.InnerHtml += "</div></div></div></div>";
                    }
                    else
                    {
                        detailedAdActionResutView.InnerHtml  = "<div class='col s12 m6 l4 push-l4 push-m3'>";
                        detailedAdActionResutView.InnerHtml += "<div class='card'>";
                        detailedAdActionResutView.InnerHtml += "<div class='card-content black-text'>";
                        detailedAdActionResutView.InnerHtml += "<span class='card-title bold'>Ad Flagged Unsuccessfully</span>";
                        detailedAdActionResutView.InnerHtml += "<p>An error occured trying to flag this ad. You can go back and try again.</p><br/>";
                        detailedAdActionResutView.InnerHtml += "<div class='card-action'>";
                        detailedAdActionResutView.InnerHtml += "<a href='DetailedAd.aspx?" + (string)adDetails[0] + "' runat='server' class='btn waves-effect waves-light'>Go Back</a>";
                        detailedAdActionResutView.InnerHtml += " <a href='AdManagement.aspx' runat='server' class='btn waves-effect waves-light orange lighten-2'>Manage Ads</a>";
                        detailedAdActionResutView.InnerHtml += "</div></div></div></div>";
                    }
                }
                else
                {
                    Response.Redirect("Index.aspx");
                }
            }
            else
            {
                Response.Redirect("Index.aspx");
            }
        }
Exemplo n.º 8
0
        protected void unflagAd_ServerClick(object sender, EventArgs e)
        {
            if (Session["User"] != null)
            {
                if (((UserData)Session["User"]).isAdmin() == 1 || ((UserData)Session["User"]).isMod() == 1)
                {
                    AdService.AdCRUDClient adService = new AdService.AdCRUDClient();
                    adService.Open();
                    int unflagAdResult = adService.unflagAd(Convert.ToInt32((string)this.adDetails[0]));
                    adService.Close();

                    if (unflagAdResult == 1)
                    {
                        detailedAdActionResutView.InnerHtml  = "<div class='col s12 m6 l4 push-l4 push-m3'>";
                        detailedAdActionResutView.InnerHtml += "<div class='card'>";
                        detailedAdActionResutView.InnerHtml += "<div class='card-content black-text'>";
                        detailedAdActionResutView.InnerHtml += "<span class='card-title bold'>Ad Unflagged Successfully</span>";
                        detailedAdActionResutView.InnerHtml += "<p>You have successfully unflagged this ad.</p><br/>";
                        detailedAdActionResutView.InnerHtml += "<div class='card-action'>";
                        detailedAdActionResutView.InnerHtml += " <a href='AdManagement.aspx' runat='server' class='btn waves-effect waves-light orange lighten-2'>Manage Ads</a>";
                        detailedAdActionResutView.InnerHtml += "</div></div></div></div>";
                    }
                    else
                    {
                        detailedAdActionResutView.InnerHtml  = "<div class='col s12 m6 l4 push-l4 push-m3'>";
                        detailedAdActionResutView.InnerHtml += "<div class='card'>";
                        detailedAdActionResutView.InnerHtml += "<div class='card-content black-text'>";
                        detailedAdActionResutView.InnerHtml += "<span class='card-title bold'>Ad Unflagged Unsuccessfully</span>";
                        detailedAdActionResutView.InnerHtml += "<p>An error occured trying to unflag this ad. You can go back and try again.</p><br/>";
                        detailedAdActionResutView.InnerHtml += "<div class='card-action'>";
                        detailedAdActionResutView.InnerHtml += "<a href='DetailedAd.aspx?" + (string)adDetails[0] + "' runat='server' class='btn waves-effect waves-light'>Go Back</a>";
                        detailedAdActionResutView.InnerHtml += " <a href='AdManagement.aspx' runat='server' class='btn waves-effect waves-light orange lighten-2'>Manage Ads</a>";
                        detailedAdActionResutView.InnerHtml += "</div></div></div></div>";
                    }
                }
                else
                {
                    Response.Redirect("Index.aspx");
                }
            }
            else
            {
                Response.Redirect("Index.aspx");
            }
        }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Title = "twoGAMES: Search";

                //string searchTerm = Request.QueryString.Get("search");
                searchedAdsDisplay.InnerHtml = "";
                //txtSearch.Value = ""; ----------breaks search when button clicked

                //Retrieve and populate platforms list

                AdService.AdCRUDClient service = new AdService.AdCRUDClient();
                service.Open();
                Object[] platforms = service.getPlatforms();
                if (!(platforms == null))
                {
                    //PlatformDrop.Items.Add(new ListItem("Platform",""));
                    //InnerHtml = "<option value='' disabled selected>Platform</option>";
                    PlatformDrop.Items.Clear();
                    PlatformDrop.Items.Add(new ListItem("All", "default"));
                    for (int i = 0; i <= platforms.Length - 1; i++)
                    {
                        PlatformDrop.Items.Add(new ListItem(Convert.ToString(platforms[i]), Convert.ToString(platforms[i])));
                        //PlatformDrop.InnerHtml += "<option value='"+ Convert.ToString(platforms[i]) + "' disabled selected>" + Convert.ToString(platforms[i]) + "</option>";
                    }
                }
                else
                {
                    PlatformDrop.Items.Add(new ListItem("XBOX ONE", "XBOX ONE"));
                    PlatformDrop.Items.Add(new ListItem("PS4", "PS4"));
                    PlatformDrop.Items.Add(new ListItem("XBOX 360", "XBOX 360"));
                    PlatformDrop.Items.Add(new ListItem("PS3", "PS3"));
                    PlatformDrop.Items.Add(new ListItem("3DS", "3DS"));
                    PlatformDrop.Items.Add(new ListItem("WII U", "WII U"));
                    PlatformDrop.Items.Add(new ListItem("GAMECUBE", "GAMECUBE"));
                }
                service.Close();

                txtSearch.Focus();
            }
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                Title = "twoGAMES: Post Ad";

                //Retrieve and populate platforms list

                AdService.AdCRUDClient service = new AdService.AdCRUDClient();
                service.Open();
                Object[] platforms = service.getPlatforms();
                if (!(platforms == null))
                {
                    //PlatformDrop.Items.Add(new ListItem("Platform",""));
                    //InnerHtml = "<option value='' disabled selected>Platform</option>";
                    for (int i = 0; i <= platforms.Length - 1; i++)
                    {
                        PlatformDrop.Items.Add(new ListItem(Convert.ToString(platforms[i]), Convert.ToString(platforms[i])));
                        //PlatformDrop.InnerHtml += "<option value='"+ Convert.ToString(platforms[i]) + "' disabled selected>" + Convert.ToString(platforms[i]) + "</option>";
                    }
                }
                else
                {
                    PlatformDrop.Items.Add(new ListItem("XBOX ONE", "XBOX ONE"));
                    PlatformDrop.Items.Add(new ListItem("PS4", "PS4"));
                    PlatformDrop.Items.Add(new ListItem("XBOX 360", "XBOX 360"));
                    PlatformDrop.Items.Add(new ListItem("PS3", "PS3"));
                    PlatformDrop.Items.Add(new ListItem("3DS", "3DS"));
                    PlatformDrop.Items.Add(new ListItem("WII U", "WII U"));
                    PlatformDrop.Items.Add(new ListItem("GAMECUBE", "GAMECUBE"));
                }
                service.Close();
            }
        }
Exemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            else if (((UserData)Session["User"]).isAdmin() == 0)
            {
                Response.Redirect("Index.aspx");
            }
            else
            {
                Title = "twoGAMES: Users Ads";

                //Populate with table of users ads
                AdService.AdCRUDClient adCRUDService = new AdService.AdCRUDClient();
                adCRUDService.Open();
                Object[][] ads = adCRUDService.getUsersAdsManagement(Convert.ToInt32(Request.QueryString.Get("id")));
                adCRUDService.Close();

                usersAdsView.InnerHtml = createUsersAdsView(ads, "There are no ads for user \"" + Request.QueryString.Get("user") + "\".", "Viewing " + Request.QueryString.Get("user") + "'s Ads");
            }
        }
Exemplo n.º 12
0
        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;
            }
        }
Exemplo n.º 13
0
        //private string pic1server = "";
        //private string pic2server = "";
        //private string pic3server = "";


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["User"] != null)
                {
                    string adID = Request.QueryString.Get("ad");

                    AdService.AdCRUDClient adService = new AdService.AdCRUDClient();
                    adService.Open();
                    Object[] platforms = adService.getPlatforms();
                    if (!(platforms == null))
                    {
                        //PlatformDrop.Items.Add(new ListItem("Platform",""));
                        //InnerHtml = "<option value='' disabled selected>Platform</option>";
                        for (int i = 0; i <= platforms.Length - 1; i++)
                        {
                            drpGamePlatform.Items.Add(new ListItem(Convert.ToString(platforms[i]), Convert.ToString(platforms[i])));
                            //PlatformDrop.InnerHtml += "<option value='"+ Convert.ToString(platforms[i]) + "' disabled selected>" + Convert.ToString(platforms[i]) + "</option>";
                        }
                    }
                    else
                    {
                        drpGamePlatform.Items.Add(new ListItem("XBOX ONE", "XBOX ONE"));
                        drpGamePlatform.Items.Add(new ListItem("PS4", "PS4"));
                        drpGamePlatform.Items.Add(new ListItem("XBOX 360", "XBOX 360"));
                        drpGamePlatform.Items.Add(new ListItem("PS3", "PS3"));
                        drpGamePlatform.Items.Add(new ListItem("3DS", "3DS"));
                        drpGamePlatform.Items.Add(new ListItem("WII U", "WII U"));
                        drpGamePlatform.Items.Add(new ListItem("GAMECUBE", "GAMECUBE"));
                    }
                    Object[] adDetails = adService.getAdDetails(adID);
                    adService.Close();

                    //----------------TITLE
                    txtGameTile.Value = (string)adDetails[1];
                    Title             = "twoGAMES: " + (string)adDetails[1];

                    txtGamePrice.Value = (string)adDetails[6];
                    if (!((string)adDetails[9]).Equals("NOPIC"))
                    {
                        pic1Thumb.InnerHtml = "<img class='thumb' src='data:image/jpeg;base64," + (string)adDetails[9] + "'/>";
                    }
                    if (!((string)adDetails[10]).Equals("NOPIC"))
                    {
                        pic2Thumb.InnerHtml = "<img class='thumb' src='data:image/jpeg;base64," + (string)adDetails[10] + "'/>";
                    }
                    if (!((string)adDetails[11]).Equals("NOPIC"))
                    {
                        pic3Thumb.InnerHtml = "<img class='thumb' src='data:image/jpeg;base64," + (string)adDetails[11] + "'/>";
                    }
                    drpGamePlatform.Items.FindByText((string)adDetails[2]).Selected = true;
                    txtGameDescription.Value = (string)adDetails[4];
                    txtGameLocation.Value    = (string)adDetails[5];

                    //pic1server = (string)adDetails[9];
                    //pic2server = (string)adDetails[10];
                    //pic3server = (string)adDetails[11];
                    Session["pic1"] = (string)adDetails[9];
                    Session["pic2"] = (string)adDetails[10];
                    Session["pic3"] = (string)adDetails[11];

                    if (Convert.ToBoolean(adDetails[8]))
                    {
                        ShowPhone.Checked = true;
                    }
                    else
                    {
                        ShowPhone.Checked = false;
                    }

                    if (Convert.ToBoolean(adDetails[7]))
                    {
                        NegotiableCheck.Checked = true;
                    }
                    else
                    {
                        NegotiableCheck.Checked = false;
                    }
                }
                else
                {
                    Response.Redirect("Login.aspx");
                }
            }
        }
Exemplo n.º 14
0
        protected void btnUpdateAd_ServerClick(object sender, EventArgs e)
        {
            Boolean postad = true;



            if (txtGameTile.Value.Equals("") || txtGamePrice.Value == null || drpGamePlatform.Items[drpGamePlatform.SelectedIndex].Text.Equals("Platform") || txtGameDescription.Value.Equals(""))
            {
                InvlaidPostAd.InnerHtml = "<p>Please fill in all the fields</p>";
                postad = false;
            }
            else
            {
                try
                {
                    int temp = Int32.Parse(txtGamePrice.Value);
                }
                catch (FormatException ex)
                {
                    txtGamePrice.Value      = "";
                    InvlaidPostAd.InnerHtml = "<p>Please fill in a price</p>";
                    postad = false;
                }
            }



            if (postad)
            {
                int negChecked       = 0;
                int ShowPhoneChecked = 0;
                if (NegotiableCheck.Checked)
                {
                    negChecked = 1;
                }
                if (ShowPhone.Checked)
                {
                    ShowPhoneChecked = 1;
                }


                //**************Check files exist********************
                //string base64String1 = "";
                //string base64String2 = "";
                //string base64String3 = "";

                //Check if there is a file 1
                if (pic1files.PostedFile.ContentLength != 0)
                {
                    string base64String1 = ImageFunctions.validateImage(new BinaryReader(pic1files.PostedFile.InputStream).ReadBytes(pic1files.PostedFile.ContentLength));
                    if (base64String1.Equals("NOPIC"))
                    {
                        InvlaidPostAd.InnerHtml = "<p>Picture 1 is an invalid image. Please attach only the pictures you took of your game.</p>";
                        return;
                    }
                    Session["pic1"] = base64String1;

                    /*
                     * //convert pic 1 to byte[]
                     * byte[] pic1Data = null;
                     * using (var binaryReader = new BinaryReader(pic1files.PostedFile.InputStream))
                     * {
                     *  pic1Data = CompressImage(binaryReader.ReadBytes(pic1files.PostedFile.ContentLength));
                     * }
                     *
                     * /*base64String1 this.pic1server Session["pic1"] = Convert.ToBase64String(pic1Data);*/
                }

                /*else
                 *  base64String1 = "NOPIC";*/

                //Check if there is a file 2
                if (pic2files.PostedFile.ContentLength != 0)
                {
                    string base64String2 = ImageFunctions.validateImage(new BinaryReader(pic2files.PostedFile.InputStream).ReadBytes(pic2files.PostedFile.ContentLength));
                    if (base64String2.Equals("NOPIC"))
                    {
                        InvlaidPostAd.InnerHtml = "<p>Picture 2 is an invalid image. Please attach only the pictures you took of your game.</p>";
                        return;
                    }
                    Session["pic2"] = base64String2;

                    /*
                     * //convert pic 2 to byte[]
                     * byte[] pic2Data = null;
                     * using (var binaryReader = new BinaryReader(pic2files.PostedFile.InputStream))
                     * {
                     *  pic2Data = CompressImage(binaryReader.ReadBytes(pic2files.PostedFile.ContentLength));
                     * }
                     * base64String2 this.pic2server Session["pic2"] = Convert.ToBase64String(pic2Data);*/
                }

                /*else
                 *  base64String2 = "NOPIC";*/

                //Check if there is a file 3
                if (pic3files.PostedFile.ContentLength != 0)
                {
                    string base64String3 = ImageFunctions.validateImage(new BinaryReader(pic3files.PostedFile.InputStream).ReadBytes(pic3files.PostedFile.ContentLength));
                    if (base64String3.Equals("NOPIC"))
                    {
                        InvlaidPostAd.InnerHtml = "<p>Picture 3 is an invalid image. Please attach only the pictures you took of your game.</p>";
                        return;
                    }
                    Session["pic3"] = base64String3;

                    /*
                     * //convert pic 3 to byte[]
                     * byte[] pic3Data = null;
                     * using (var binaryReader = new BinaryReader(pic3files.PostedFile.InputStream))
                     * {
                     *  pic3Data = CompressImage(binaryReader.ReadBytes(pic3files.PostedFile.ContentLength));
                     * }
                     * base64String3 this.pic3server
                     * Session["pic3"] = Convert.ToBase64String(pic3Data);*/
                }

                /*else
                 *  base64String3 = "NOPIC";*/



                /*if (base64String1.Equals("NOPIC"))
                 * {
                 *  if (!pic1server.Equals("NOPIC"))
                 *      base64String1 = pic1server;
                 * }
                 * if (base64String2.Equals("NOPIC"))
                 * {
                 *  if (!pic2server.Equals("NOPIC"))
                 *      base64String2 = pic2server;
                 * }
                 * if (base64String3.Equals("NOPIC"))
                 * {
                 *  if (!pic3server.Equals("NOPIC"))
                 *      base64String3 = pic3server;
                 * }*/



                //byte[][] sendPics = new byte[3][];
                // sendPics[0] = pic1Data;
                // sendPics[1] = pic2Data;
                //sendPics[2] = pic3Data;

                //--------------------------------------------------------------------------

                UserData user = (UserData)Session["User"];
                AdService.AdCRUDClient service = new AdService.AdCRUDClient();
                service.Open();

                string adID = Request.QueryString.Get("ad");

                int success = service.updateAd(Convert.ToInt32(adID), txtGameTile.Value, drpGamePlatform.Items[drpGamePlatform.SelectedIndex].Text, txtGameDescription.Value, txtGameLocation.Value, Convert.ToDouble(txtGamePrice.Value), negChecked, ShowPhoneChecked, /*base64String1 this.pic1server*/ (string)Session["pic1"], /*base64String2 this.pic2server*/ (string)Session["pic2"], /*base64String3 this.pic3server*/ (string)Session["pic3"], user.isPrem());

                if (success == 1)
                {
                    editAdDiv.InnerHtml  = "<div class='col s12 m6 push-m3'>";
                    editAdDiv.InnerHtml += "<div class='card white'>";
                    editAdDiv.InnerHtml += "<div class='card-content Black-text'>";
                    editAdDiv.InnerHtml += "<span class='card-title bold'>Ad Updated Successfully</span>";
                    editAdDiv.InnerHtml += "<p>You have successfully Updated your ad. To view your ad, proceeed to the My Ads page.</p>";

                    editAdDiv.InnerHtml += "</div>";
                    editAdDiv.InnerHtml += "<div class='card-action'>";
                    editAdDiv.InnerHtml += "<a href='MyAds.aspx' runat='server' class='btn waves-effect waves-light'>My Ads</a>";
                    editAdDiv.InnerHtml += "</div>";
                    editAdDiv.InnerHtml += "</div>";
                    editAdDiv.InnerHtml += "</div>";
                }
                else
                {
                    editAdDiv.InnerHtml  = "<div class='col s12 m6 push-m3'>";
                    editAdDiv.InnerHtml += "<div class='card white'>";
                    editAdDiv.InnerHtml += "<div class='card-content Black-text'>";
                    editAdDiv.InnerHtml += "<span class='card-title bold'>Ad Update Unsuccessfully</span>";
                    editAdDiv.InnerHtml += "<p>We where unable to update your add. Please try again and if the problem persists pleas contact us <a href='ContactUs.aspx'>here</a>.</p>";

                    editAdDiv.InnerHtml += "</div>";
                    editAdDiv.InnerHtml += "<div class='card-action'>";
                    editAdDiv.InnerHtml += "<a href='MyAds.aspx' runat='server' class='btn waves-effect waves-light'>Continue</a>";
                    editAdDiv.InnerHtml += "</div>";
                    editAdDiv.InnerHtml += "</div>";
                    editAdDiv.InnerHtml += "</div>";
                }
                service.Close();

                Session["pic1"] = null;
                Session["pic2"] = null;
                Session["pic3"] = null;
            }
        }
Exemplo n.º 15
0
        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>";
            }
        }
Exemplo n.º 16
0
        protected void btnPostAd_ServerClick(object sender, EventArgs e)
        {
            Boolean postad = true;

            //string adultResponse = "NOINFO";
            //string spoofResponse = "NOINFO";


            if (txtGameTitle.Value.Equals("") || txtPrice.Value == null || PlatformDrop.Items[PlatformDrop.SelectedIndex].Text.Equals("Platform") || txtGameDesc.Value.Equals(""))
            {
                InvlaidPostAd.InnerHtml = "<p>Please fill in all the fields</p>";
                postad = false;
                return;
            }
            else
            {
                try
                {
                    int temp = Int32.Parse(txtPrice.Value);
                }
                catch (FormatException ex)
                {
                    txtPrice.Value          = "";
                    InvlaidPostAd.InnerHtml = "<p>Please fill in a price</p>";
                    postad = false;
                    return;
                }
                catch (OverflowException ex)
                {
                    txtPrice.Value          = "";
                    InvlaidPostAd.InnerHtml = "<p>It seems the price you entered is two high.</p>";
                    postad = false;
                    return;
                }
            }

            if (pic1files.PostedFile.ContentLength == 0 && pic2files.PostedFile.ContentLength == 0 && pic3files.PostedFile.ContentLength == 0)
            {
                InvlaidPostAd.InnerHtml = "<p>Please add at least one picture</p>";
                postad = false;
                return;
            }



            if (postad)
            {
                int negChecked       = 0;
                int ShowPhoneChecked = 0;
                if (NegotiableCheck.Checked)
                {
                    negChecked = 1;
                }
                if (ShowPhone.Checked)
                {
                    ShowPhoneChecked = 1;
                }



                //--------------------------------------------------------------------IMAGES

                //create service
                //var visionCredentails = CreateCredentials("C:\\Users\\James McGuire\\Desktop\\IMF third year project-46cd5c28569b.json");
                //var visionService = CreateService("twoGames", visionCredentails);


                //**************Check files exist********************
                string base64String1 = "";
                string base64String2 = "";
                string base64String3 = "";


                //----------------Check if there is PIC 1
                if (pic1files.PostedFile.ContentLength != 0)
                {
                    base64String1 = ImageFunctions.validateImage(new BinaryReader(pic1files.PostedFile.InputStream).ReadBytes(pic1files.PostedFile.ContentLength));
                    if (base64String1.Equals("NOPIC"))
                    {
                        InvlaidPostAd.InnerHtml = "<p>Picture 1 is an invalid image. Please attach only the pictures you took of your game.</p>";
                        return;
                    }
                }
                else
                {
                    base64String1 = "NOPIC";
                }


                //Check if there is a file 2
                if (pic2files.PostedFile.ContentLength != 0)
                {
                    base64String2 = ImageFunctions.validateImage(new BinaryReader(pic2files.PostedFile.InputStream).ReadBytes(pic2files.PostedFile.ContentLength));
                    if (base64String2.Equals("NOPIC"))
                    {
                        InvlaidPostAd.InnerHtml = "<p>Picture 2 is an invalid image. Please attach only the pictures you took of your game.</p>";
                        return;
                    }

                    /*
                     * //convert pic 2 to byte[]
                     * byte[] pic2Data = null;
                     * using (var binaryReader = new BinaryReader(pic2files.PostedFile.InputStream))
                     * {
                     *  pic2Data = binaryReader.ReadBytes(pic2files.PostedFile.ContentLength);
                     *  byte[] temp = pic2Data;
                     *
                     *  if (IsValidImage(pic2Data) && checkVision(pic2Data))
                     *  {
                     *      pic2Data = CompressImage(temp);
                     *      base64String2 = Convert.ToBase64String(pic2Data);
                     *  }
                     *  else
                     *  {
                     *      InvlaidPostAd.InnerHtml = "<p>Picture 2 is invalid</p>";
                     *      return;
                     *  }
                     * }*/
                }
                else
                {
                    base64String2 = "NOPIC";
                }


                //Check if there is a file 3
                if (pic3files.PostedFile.ContentLength != 0)
                {
                    base64String3 = ImageFunctions.validateImage(new BinaryReader(pic3files.PostedFile.InputStream).ReadBytes(pic3files.PostedFile.ContentLength));
                    if (base64String3.Equals("NOPIC"))
                    {
                        InvlaidPostAd.InnerHtml = "<p>Picture 3 is an invalid image. Please attach only the pictures you took of your game.</p>";
                        return;
                    }

                    /*
                     * //convert pic 3 to byte[]
                     * byte[] pic3Data = null;
                     * using (var binaryReader = new BinaryReader(pic3files.PostedFile.InputStream))
                     * {
                     *  pic3Data = binaryReader.ReadBytes(pic3files.PostedFile.ContentLength);
                     *  byte[] temp = pic3Data;
                     *
                     *  if (IsValidImage(pic3Data) && checkVision(pic3Data))
                     *  {
                     *      pic3Data = CompressImage(temp);
                     *      base64String3 = Convert.ToBase64String(pic3Data);
                     *  }
                     *  else
                     *  {
                     *      InvlaidPostAd.InnerHtml = "<p>Picture 3 is invalid</p>";
                     *      return;
                     *  }
                     * }*/
                }
                else
                {
                    base64String3 = "NOPIC";
                }



                //byte[][] sendPics = new byte[3][];
                // sendPics[0] = pic1Data;
                // sendPics[1] = pic2Data;
                //sendPics[2] = pic3Data;

                //--------------------------------------------------------------------------

                UserData user = (UserData)Session["User"];
                AdService.AdCRUDClient service = new AdService.AdCRUDClient();
                service.Open();


                //Inserting ad
                int success = 0;
                success = service.insertAd(txtGameTitle.Value, PlatformDrop.Items[PlatformDrop.SelectedIndex].Text, DateTime.Today, txtGameDesc.Value, txtLocation.Value, Convert.ToDouble(txtPrice.Value), negChecked, ShowPhoneChecked, base64String1, base64String2, base64String3, user.isPrem(), user.getID());
                service.Close();

                //string Title, string Platform, DateTime CreatedDate, string Description, string Location, Double Price, int Negotiable, int ShowNumber, String Pic1Path, String Pic2Path, String Pic3Path, int PremiumAd, int UserID
                if (success == 1)
                {
                    //remember variable in code bellow
                    postAdDiv.InnerHtml  = "<div class='col s12 m6 push-m3'>";
                    postAdDiv.InnerHtml += "<div class='card white'>";
                    postAdDiv.InnerHtml += "<div class='card-content Black-text'>";
                    postAdDiv.InnerHtml += "<span class='card-title bold'>Ad Created Successfully</span>";
                    postAdDiv.InnerHtml += "<p>You have successfully created your ad. To view your ad, proceeed to the My Ads page.</p>";

                    postAdDiv.InnerHtml += "</div>";
                    postAdDiv.InnerHtml += "<div class='card-action'> ";
                    postAdDiv.InnerHtml += "<a href='Index.aspx' class='btn waves-effect waves-light'>Continue</a> ";
                    postAdDiv.InnerHtml += "<a href='MyAds.aspx' class='btn waves-effect waves-light orange lighten-2'>My Ads</a> ";
                    postAdDiv.InnerHtml += "</div>";
                    postAdDiv.InnerHtml += "</div>";
                    postAdDiv.InnerHtml += "</div>";


                    //Object[] temp = service.getAdDetails("25");
                    //byte[][] temp = service.getPictures(1);
                    //string base64String1 = Convert.ToBase64String(temp[0], 0, temp[0].Length);
                    //temp1.Attributes["src"] = "data:image/jpeg;base64," + temp[9];
                    //string base64String2 = Convert.ToBase64String(temp[1], 0, temp[1].Length);
                    //temp2.Attributes["src"] = "data:image/jpeg;base64," + temp[10];
                    //string base64String3 = Convert.ToBase64String(temp[2], 0, temp[2].Length);
                    //temp3.Attributes["src"] = "data:image/jpeg;base64," + temp[11];
                }
                else
                {
                    postAdDiv.InnerHtml  = "<div class='col s12 m6 push-m3'>";
                    postAdDiv.InnerHtml += "<div class='card white'>";
                    postAdDiv.InnerHtml += "<div class='card-content Black-text'>";
                    postAdDiv.InnerHtml += "<span class='card-title bold'>Oh No...An Error Occured</span>";
                    postAdDiv.InnerHtml += "<p>Unfortunately we were unable to create your ad. Please try again or come back later.<br/>To view your current ads, proceeed to the My Ads page.</p>";

                    postAdDiv.InnerHtml += "</div>";
                    postAdDiv.InnerHtml += "<div class='card-action'> ";
                    postAdDiv.InnerHtml += "<a href='Index.aspx' class='btn waves-effect waves-light'>Continue</a> ";
                    postAdDiv.InnerHtml += "<a href='MyAds.aspx' runat='server' class='btn waves-effect waves-light'>My Ads</a> ";
                    postAdDiv.InnerHtml += "</div>";
                    postAdDiv.InnerHtml += "</div>";
                    postAdDiv.InnerHtml += "</div>";
                }
            }
        }
Exemplo n.º 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string adID     = Request.QueryString.Get("ad");
            bool   isnumber = int.TryParse(adID, out adnum);

            if (isnumber)
            {
                AdService.AdCRUDClient adService = new AdService.AdCRUDClient();
                adService.Open();
                this.adDetails = adService.getAdDetails(adID);
                adService.incViewCount(Convert.ToInt32(adID));
                adService.Close();
                if (this.adDetails != null)
                {
                    //--------------TITLE
                    lblGameTitle.InnerHtml = (string)adDetails[1];
                    Title = "twoGAMES: " + (string)adDetails[1];

                    //--------------PRICE
                    lblGamePrice.InnerHtml = "Price: R" + (string)adDetails[6];

                    //--------------NEGOTIABLE
                    if (Convert.ToBoolean(adDetails[7]))
                    {
                        lblGamePrice.InnerHtml += " Negotiable";
                    }

                    //--------------USERNAME + PREMIUM ICON
                    UserService.UserCRUDClient userService = new UserService.UserCRUDClient();
                    userService.Open();
                    string  username    = userService.getUsername(Convert.ToInt32((string)adDetails[13]));
                    Boolean premiumUser = Convert.ToBoolean(userService.isUserPrem(Convert.ToInt32((string)adDetails[13])));
                    userService.Close();

                    editButtonSpan.InnerHtml = "Posted By: " + username;
                    if (premiumUser)
                    {
                        editButtonSpan.InnerHtml += " <i class='material-icons tooltipped' data-position='right' data-tooltip='Premium Member'>star</i>";
                    }

                    //--------------ADMIN MOD BUTTONS
                    //editButtonSpan.InnerHtml = "";
                    if (Session["User"] != null)
                    {
                        if (((UserData)Session["User"]).isAdmin() == 1 || ((UserData)Session["User"]).isMod() == 1)
                        {
                            btnReportAd.Visible = false;
                            if (Convert.ToBoolean((string)adDetails[14]))
                            {
                                btnUnflagAdAdminMod.Visible = true;
                            }
                            else
                            {
                                btnFlagAdAdminMod.Visible = true;
                            }
                            editButtonSpan.InnerHtml += " <a class='btn right waves-effect waves-light orange lighten-2' href='EditAdPage.aspx?ad=" + Request.QueryString.Get("ad") + "'>Edit</a> ";
                        }
                    }

                    //--------------IMAGES
                    if (!((string)adDetails[9]).Equals("NOPIC"))
                    {
                        imgPic1.Src = "data:image/jpeg;base64," + (string)adDetails[9];
                    }
                    else
                    {
                        imgPic1.Visible = false;
                    }
                    if (!((string)adDetails[10]).Equals("NOPIC"))
                    {
                        imgPic2.Src = "data:image/jpeg;base64," + (string)adDetails[10];
                    }
                    else
                    {
                        imgPic2.Visible = false;
                    }
                    if (!((string)adDetails[11]).Equals("NOPIC"))
                    {
                        imgPic3.Src = "data:image/jpeg;base64," + (string)adDetails[11];
                    }
                    else
                    {
                        imgPic3.Visible = false;
                    }

                    //--------------PLATFORM
                    lblGamePlatform.InnerHtml = "Platform: " + (string)adDetails[2];

                    //--------------DESCRIPTION
                    txtGameDescription.Value = (string)adDetails[4];

                    //--------------LOCATION
                    txtGameLocation.Value = (string)adDetails[5];
                    String mapString = (string)adDetails[5];
                    mapString = mapString.Replace(" ", "+");
                    adMap.Src = "https://www.google.com/maps/embed/v1/place?key=AIzaSyB7eq5IZFtbXZitO0yI53upIROFqC5RBcY&q=" + mapString;

                    //--------------YOUTUBE SOURCE
                    adYoutubeFrame.Src = "https://www.youtube.com/embed?listType=search&list=" + (string)adDetails[1] + " ign review?theme=light&color=white";

                    //--------------CELL NUMBER
                    if (Convert.ToBoolean(adDetails[8]))
                    {
                        txtCellNumber.Value = (string)adDetails[16];
                    }
                    else
                    {
                        sellerCellNumberDiv.InnerHtml = "";
                    }
                }
            }
            else
            {
                Response.Redirect("Index.aspx");
            }
        }