Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            enter     obj    = new enter();
            string    search = (string)Session["searchstring"];
            string    myname = (string)Session["Uname"];
            int       myown  = (int)Session["userid"];
            DataTable DT     = new DataTable();
            DataTable DT2    = new DataTable();
            int       found  = obj.search(search, ref DT, ref DT2);

            if (found == -1)
            {
                Error.Text = "Your text did not yield any result";
            }
            else
            {
                foreach (DataRow row in DT2.Rows)
                {
                    if (search[0] == '#')
                    {
                        Label b1 = new Label();
                        b1.ID = b1.UniqueID;
                        b1.Attributes.Add("runat", "server");
                        b1.Attributes.Add("style", "font-family: Broadway;  font-size: 25px; color: #ffffff; background-color: midnightblue;");
                        b1.Text = row.Field <string>(0) + " (" + row.Field <int>(1) + ")";
                        ph.Controls.Add(b1);
                        ph.Controls.Add(new LiteralControl("<br/><br/>"));
                    }
                }
                ph.Controls.Add(new LiteralControl("<br/><br/>"));
                foreach (DataRow row in DT.Rows)
                {
                    if (search[0] == '#')
                    {
                        Label  b2       = new Label();
                        string thetweet = obj.GetATweet(row.Field <int>(0));
                        int    idofuser = obj.GetUserIDfromTweet(row.Field <int>(0));
                        string name     = obj.GetUser(idofuser);
                        Button bu       = new Button();
                        bu.ID = bu.UniqueID;
                        bu.Attributes.Add("style", "font-family: Broadway;  font-size: 25px; color: black; background-color:rgba(18, 12, 85, 0.6);");

                        bu.Attributes.Add("runat", "server");

                        bu.Text = name;
                        if (bu.Text == myname)
                        {
                            bu.Click += (se, ev) =>
                            {
                                Response.Redirect("profile.aspx?val=" + myown);
                            };
                        }
                        else
                        {
                            bu.Click += (se, ev) =>
                            {
                                int u = obj.GetUserID(name);
                                Session["uid"] = u;
                                Response.Redirect("user.aspx?val=" + u);
                            };
                        }
                        ph.Controls.Add(bu);
                        b2.ID = b2.UniqueID;
                        b2.Attributes.Add("style", "font-family: Times New Roman;font-size: 20px; border: solid; border-color: black; background-color: rgba(255, 216, 0,0.6); color: black; text-align: left;width:900px ");

                        b2.Attributes.Add("runat", "server");
                        b2.Text = thetweet;
                        ph.Controls.Add(b2);
                        ph.Controls.Add(new LiteralControl("<br/><br/><br/><br/><br/>"));
                    }
                    else
                    {
                        bool   checkfollow = false;
                        Button b1          = new Button();
                        b1.ID = b1.UniqueID;
                        b1.Attributes.Add("runat", "server");
                        b1.Attributes.Add("style", "font-family: Broadway;  font-size: 25px; color: black; background-color:rgba(18, 12, 85, 0.6);");

                        b1.Text = row.Field <string>(0);
                        int u = obj.GetUserID(b1.Text);
                        if (u == myown)
                        {
                            b1.Click += (ser, eve) =>
                            {
                                Response.Redirect("profile.aspx?val=" + myown);
                            };
                            ph.Controls.Add(b1);
                        }
                        else
                        {
                            ph.Controls.Add(new LiteralControl("<br/>"));
                            ph.Controls.Add(new LiteralControl("<br/>"));

                            b1.Click += (ser, eve) =>
                            {
                                Session["uid"] = u;
                                Response.Redirect("user.aspx?val=" + u);
                            };

                            ph.Controls.Add(b1);
                            ph.Controls.Add(new LiteralControl("&nbsp &nbsp &nbsp"));

                            Button b2 = new Button();
                            b2.ID = b2.UniqueID;
                            b2.Attributes.Add("runat", "server");
                            b2.Attributes.Add("style", "font-family: Times New Roman;font-size: 20px; border: solid; border-color: black; background-color: rgba(255, 216, 0,0.6); color: black; text-align: left;width:130px ");

                            obj.checkifcollowing(myown, u, ref checkfollow);
                            if (checkfollow == false)
                            {
                                b2.Text = "FOLLOW ";
                            }
                            else
                            {
                                b2.Text = "UNFOLLOW ";
                            }

                            b2.Click += (se, ev) =>
                            {
                                bool ret = false;
                                int  f   = obj.enterfollow(myown, u, ref ret);
                                if (f != -1)
                                {
                                    if (!ret)
                                    {
                                        b2.Text = "UNFOLLOW ";
                                    }
                                    else
                                    {
                                        b2.Text = "FOLLOW ";
                                    }
                                }
                            };

                            ph.Controls.Add(b2);
                            ph.Controls.Add(new LiteralControl("<br/>"));
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            enter     obj       = new enter();
            string    username  = (string)(Session["Uname"]);
            int       userid    = obj.GetUserID(username);
            DataTable DT        = new DataTable();
            DataTable DT2       = new DataTable();
            int       following = obj.GetFollowingID(userid, ref DT);
            int       followers = obj.GetFollowerID(userid, ref DT2);

            if (following != -1)
            {
                Label youfollow = new Label();
                youfollow.ID = youfollow.UniqueID;
                youfollow.Attributes.Add("runat", "server");
                youfollow.Attributes.Add("style", "font-family: Times New Roman; font-size: 25px; background-color: #ffffff;");
                youfollow.Text = "You are Following these Users! :D";
                p.Controls.Add(youfollow);
                p.Controls.Add(new LiteralControl("<br/><br/>"));
                foreach (DataRow row in DT.Rows)
                {
                    bool   checkfollow = false;
                    Button b1          = new Button();
                    Button b2          = new Button();
                    b1.ID = b1.UniqueID;
                    b2.ID = b2.UniqueID;
                    b1.Attributes.Add("runat", "server");
                    b1.Attributes.Add("style", "font-family: Broadway;  font-size: 25px; color: #ffffff; background-color: midnightblue;");
                    b2.Attributes.Add("runat", "server");
                    b2.Attributes.Add("style", "height: 35px; width: 100px; font-family: Times New Roman; font-size: 10px; background-color: #ffffff;");
                    string name = obj.GetUser(row.Field <int>(0));
                    b1.Text   = name;
                    b1.Click += (ser, eve) =>
                    {
                        int u = obj.GetUserID(b1.Text);
                        Session["uid"] = u;
                        Response.Redirect("user.aspx?val=" + u);
                    };
                    p.Controls.Add(b1);
                    obj.checkifcollowing(userid, row.Field <int>(0), ref checkfollow);
                    if (checkfollow == false)
                    {
                        b2.Text = "FOLLOW ";
                    }
                    else
                    {
                        b2.Text = "UNFOLLOW ";
                    }

                    b2.Click += (se, ev) =>
                    {
                        bool ret = false;
                        int  f   = obj.enterfollow(userid, row.Field <int>(0), ref ret);
                        if (f != -1)
                        {
                            if (!ret)
                            {
                                b2.Text = "UNFOLLOW ";
                            }
                            else
                            {
                                b2.Text = "FOLLOW ";
                            }
                        }
                    };
                    p.Controls.Add(b2);
                    p.Controls.Add(new LiteralControl("<br/><br/>"));
                }
            }
            else if (following == -1)
            {
                Label youfollow = new Label();
                youfollow.ID = youfollow.UniqueID;
                youfollow.Attributes.Add("runat", "server");
                youfollow.Attributes.Add("style", "font-family: Times New Roman; font-size: 25px; background-color: #ffffff;");
                youfollow.Text = "You are following No User! :(";
                p.Controls.Add(youfollow);
                p.Controls.Add(new LiteralControl("<br/><br/>"));
            }
            if (followers != -1)
            {
                p.Controls.Add(new LiteralControl("<br/><br/>"));
                Label youfollow = new Label();
                youfollow.ID = youfollow.UniqueID;
                youfollow.Attributes.Add("runat", "server");
                youfollow.Attributes.Add("style", "font-family: Times New Roman; font-size: 25px; background-color: #ffffff;");
                youfollow.Text = "These Users are Following You! :D";
                p.Controls.Add(youfollow);
                p.Controls.Add(new LiteralControl("<br/><br/>"));
                foreach (DataRow row in DT2.Rows)
                {
                    bool   checkfollow = false;
                    Button b1          = new Button();
                    Button b2          = new Button();
                    b1.ID = b1.UniqueID;
                    b2.ID = b2.UniqueID;
                    b1.Attributes.Add("runat", "server");
                    b1.Attributes.Add("style", "font-family: Broadway;  font-size: 25px; color: #ffffff; background-color: midnightblue;");
                    b2.Attributes.Add("runat", "server");
                    b2.Attributes.Add("style", "height: 35px; width: 100px; font-family: Times New Roman; font-size: 10px; background-color: #ffffff;");
                    string name = obj.GetUser(row.Field <int>(0));
                    b1.Text   = name;
                    b1.Click += (ser, eve) =>
                    {
                        int u = obj.GetUserID(b1.Text);
                        Session["uid"] = u;
                        Response.Redirect("user.aspx?val=" + u);
                    };
                    p.Controls.Add(b1);
                    obj.checkifcollowing(userid, row.Field <int>(0), ref checkfollow);
                    if (checkfollow == false)
                    {
                        b2.Text = "FOLLOW ";
                    }
                    else
                    {
                        b2.Text = "UNFOLLOW ";
                    }

                    b2.Click += (se, ev) =>
                    {
                        bool ret = false;
                        int  f   = obj.enterfollow(userid, row.Field <int>(0), ref ret);
                        if (f != -1)
                        {
                            if (!ret)
                            {
                                b2.Text = "UNFOLLOW ";
                            }
                            else
                            {
                                b2.Text = "FOLLOW ";
                            }
                        }
                    };
                    p.Controls.Add(b2);
                    p.Controls.Add(new LiteralControl("<br/><br/>"));
                }
            }
            else if (followers == -1)
            {
                Label youfollow = new Label();
                youfollow.ID = youfollow.UniqueID;
                youfollow.Attributes.Add("runat", "server");
                youfollow.Attributes.Add("style", "font-family: Times New Roman; font-size: 25px; background-color: #ffffff;");
                youfollow.Text = "No one is Following you! :(";
                p.Controls.Add(youfollow);
                p.Controls.Add(new LiteralControl("<br/><br/>"));
            }
        }