示例#1
0
        protected void myEventBtn_Click(object sender, EventArgs e)
        {
            allEventsBtn.Enabled = true;
            myEventBtn.Enabled   = false;

            string accountID    = Cookies.ReadCookie(this.Request, this.Response);
            var    involvements = HelloWorldQueryMethods.GetAllInvolvements(accountID);

            if (involvements.Length > 0)
            {
                string cmdBase = String.Format("WHERE PostID = '{0}'", involvements[0].Posts_PostID);
                for (int x = 1; x < involvements.Length; x++)
                {
                    string postID = involvements[x].Posts_PostID;
                    cmdBase += String.Format(" || PostID = '{0}'", postID);
                }
                cmdBase += ";";

                var output = HelloWorldQueryMethods.GetAllPosts(cmdBase);

                MainPageGlobals.Posts = output;
                SetCards(-2);
            }
            else
            {
                MainPageGlobals.Posts = new HelloWorldQueryMethods.Posts[0];
                SetCards(-2);
            }
        }
示例#2
0
        private void UnSubscribeFromEvent(int cardNo)
        {
            string postID    = MainPageGlobals.Posts[cardNo].PostID;
            string accountID = Cookies.ReadCookie(this.Request, this.Response);

            HelloWorldQueryMethods.DeleteInvolvement(postID, accountID);
            SetCards(-1);
        }
示例#3
0
        private void SetCards(int index = -1)
        {
            if (index == -1)
            {
                MainPageGlobals.Posts = HelloWorldQueryMethods.GetAllPosts();
            }

            string AccountID = Cookies.ReadCookie(this.Request, this.Response);

            string[] involvementsForAccount = HelloWorldQueryMethods.GetAllInvolvementsForAccount(AccountID);

            int total = MainPageGlobals.Posts.Length;
            int count = total;

            if (total > 10)
            {
                count = 10;
            }

            switch (count - 1)
            {
            case 9:
                host_name9 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[9].Posts_Name;
                host_name8 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[8].Posts_Name;
                host_name7 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[7].Posts_Name;
                host_name6 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[6].Posts_Name;
                host_name5 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[5].Posts_Name;
                host_name4 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[4].Posts_Name;
                host_name3 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[3].Posts_Name;
                host_name2 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[2].Posts_Name;
                host_name1 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[1].Posts_Name;
                host_name0 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[0].Posts_Name;
                break;

            case 8:
                host_name8 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[8].Posts_Name;
                host_name7 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[7].Posts_Name;
                host_name6 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[6].Posts_Name;
                host_name5 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[5].Posts_Name;
                host_name4 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[4].Posts_Name;
                host_name3 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[3].Posts_Name;
                host_name2 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[2].Posts_Name;
                host_name1 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[1].Posts_Name;
                host_name0 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[0].Posts_Name;
                break;

            case 7:
                host_name7 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[7].Posts_Name;
                host_name6 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[6].Posts_Name;
                host_name5 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[5].Posts_Name;
                host_name4 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[4].Posts_Name;
                host_name3 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[3].Posts_Name;
                host_name2 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[2].Posts_Name;
                host_name1 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[1].Posts_Name;
                host_name0 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[0].Posts_Name;
                break;

            case 6:
                host_name6 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[6].Posts_Name;
                host_name5 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[5].Posts_Name;
                host_name4 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[4].Posts_Name;
                host_name3 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[3].Posts_Name;
                host_name2 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[2].Posts_Name;
                host_name1 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[1].Posts_Name;
                host_name0 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[0].Posts_Name;
                break;

            case 5:
                host_name5 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[5].Posts_Name;
                host_name4 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[4].Posts_Name;
                host_name3 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[3].Posts_Name;
                host_name2 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[2].Posts_Name;
                host_name1 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[1].Posts_Name;
                host_name0 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[0].Posts_Name;
                break;

            case 4:
                host_name4 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[4].Posts_Name;
                host_name3 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[3].Posts_Name;
                host_name2 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[2].Posts_Name;
                host_name1 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[1].Posts_Name;
                host_name0 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[0].Posts_Name;
                break;

            case 3:
                host_name3 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[3].Posts_Name;
                host_name2 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[2].Posts_Name;
                host_name1 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[1].Posts_Name;
                host_name0 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[0].Posts_Name;
                break;

            case 2:
                host_name2 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[2].Posts_Name;
                host_name1 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[1].Posts_Name;
                host_name0 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[0].Posts_Name;
                break;

            case 1:
                host_name1 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[1].Posts_Name;
                host_name0 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[0].Posts_Name;
                break;

            case 0:
                host_name0 = "DisplayProfile.aspx?name=" + MainPageGlobals.Posts[0].Posts_Name;
                break;

            default:
                break;
            }
            for (int x = 0; x < 10; x++)
            {
                ((System.Web.UI.HtmlControls.HtmlGenericControl) this.FindControl("card" + x)).Visible = false;
                ((System.Web.UI.HtmlControls.HtmlButton) this.FindControl("button1" + x)).Visible      = false;
            }
            for (int x = 0; x < count; x++)
            {
                int postCounter = (MainPageGlobals.CurrentPage * 10) + x;
                if (postCounter < MainPageGlobals.Posts.Length)
                {
                    ((System.Web.UI.HtmlControls.HtmlGenericControl) this.FindControl("card" + x)).Visible = true;

                    string peopleText;
                    int    totalNumberOfPeopleNeeded = MainPageGlobals.Posts[postCounter].NumberNeeded;
                    int    currentNumber             = HelloWorldQueryMethods.GetNumberOfPeopleInEvent(MainPageGlobals.Posts[postCounter].PostID);


                    if (currentNumber == 0)
                    {
                        ((System.Web.UI.HtmlControls.HtmlGenericControl) this.FindControl("card" + x)).Visible = false;
                    }


                    if (index == x)
                    {
                        peopleText = String.Format("People Commited: {0}/{1}", currentNumber + 1, totalNumberOfPeopleNeeded);
                        HelloWorldQueryMethods.Involvement involvement = new HelloWorldQueryMethods.Involvement
                        {
                            AccountsID   = AccountID,
                            IsHost       = false,
                            Posts_PostID = MainPageGlobals.Posts[postCounter].PostID
                        };
                        HelloWorldQueryMethods.InsertInvolvement(involvement);
                        ((System.Web.UI.HtmlControls.HtmlButton) this.FindControl("button" + x)).Disabled  = true;
                        ((System.Web.UI.HtmlControls.HtmlButton) this.FindControl("button" + x)).InnerText = "Currently Joined";
                        ((System.Web.UI.HtmlControls.HtmlButton) this.FindControl("button1" + x)).Visible  = true;
                    }
                    else
                    {
                        peopleText = String.Format("People Commited: {0}/{1}", currentNumber, totalNumberOfPeopleNeeded);
                    }

                    ((System.Web.UI.HtmlControls.HtmlGenericControl) this.FindControl("DatePrint" + x)).InnerText   = MainPageGlobals.Posts[x].DateTime.ToString("MM/dd/yyyy hh:mm tt");
                    ((System.Web.UI.HtmlControls.HtmlGenericControl) this.FindControl("Location" + x)).InnerText    = MainPageGlobals.Posts[x].Location;
                    ((System.Web.UI.HtmlControls.HtmlGenericControl) this.FindControl("Proficiency" + x)).InnerText = MainPageGlobals.Posts[x].Proficiency;
                    ((System.Web.UI.HtmlControls.HtmlGenericControl) this.FindControl("People" + x)).InnerText      = peopleText;
                    ((System.Web.UI.HtmlControls.HtmlGenericControl) this.FindControl("Description" + x)).InnerText = MainPageGlobals.Posts[postCounter].Desc;
                    ((System.Web.UI.HtmlControls.HtmlGenericControl) this.FindControl("Gender" + x)).InnerText      = "Gender: " + MainPageGlobals.Posts[postCounter].Gender;
                    ((System.Web.UI.HtmlControls.HtmlGenericControl) this.FindControl("CardTitle" + x)).InnerText   = MainPageGlobals.Posts[postCounter].Title;

                    //UpdateMainPageGlobals
                    if (involvementsForAccount.Contains(MainPageGlobals.Posts[x].PostID))
                    {
                        ((System.Web.UI.HtmlControls.HtmlButton) this.FindControl("button" + x)).Disabled  = true;
                        ((System.Web.UI.HtmlControls.HtmlButton) this.FindControl("button" + x)).InnerText = "Currently Joined";
                        ((System.Web.UI.HtmlControls.HtmlButton) this.FindControl("button1" + x)).Visible  = true;
                    }
                    else if (currentNumber >= totalNumberOfPeopleNeeded)
                    {
                        ((System.Web.UI.HtmlControls.HtmlButton) this.FindControl("button" + x)).Disabled  = true;
                        ((System.Web.UI.HtmlControls.HtmlButton) this.FindControl("button" + x)).InnerText = "Event Full";
                    }
                    else if (index != x)
                    {
                        ((System.Web.UI.HtmlControls.HtmlButton) this.FindControl("button" + x)).Disabled  = false;
                        ((System.Web.UI.HtmlControls.HtmlButton) this.FindControl("button" + x)).InnerText = "Join Event";
                    }
                }
            }
        }