示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            enter     obj      = new enter();
            int       userid   = (int)(Session["userid"]);
            string    username = (string)Session["username"];
            DataTable DT       = new DataTable();

            Name.Text  = obj.getName(userid);
            Uname.Text = username;
            int k = obj.GetMsgs(userid);

            if (k > 0)
            {
                notify.Attributes.Add("style", "content:attr(data-badge); position: absolute; font-size:.7em; background: red; color: white; width: 18px; height: 18px; text-align:center; line-height:18px; border-radius:50%; box-shadow:0 0 1px #333;");
                notify.Text += k;
            }

            DataTable p      = new DataTable();
            int       getpic = obj.GetUserImage(userid, ref p);

            if (getpic != -1)
            {
                string imagename = p.Rows[0].Field <string>(0);
                useri.Height   = 100;
                useri.ImageUrl = "userpics/" + imagename;
            }

            upload.Click += (s, ev) =>
            {
                if (F.HasFile)
                {
                    string FileName = F.FileName;
                    F.SaveAs(Server.MapPath("userpics/" + FileName));
                    int x = obj.AddProfilePic(FileName, userid);
                    if (x == -1)
                    {
                        sorry.Text += "image upload error \n";
                    }
                    else
                    {
                        useri.Height   = 100;
                        useri.ImageUrl = "userpics/" + FileName;
                    }
                }
            };

            remove.Click += (s, ev) =>
            {
                int x = obj.RemoveProfilePic(userid);
                if (x == -1)
                {
                    sorry.Text += "image removal error \n";
                }
                useri.ImageUrl = "";
            };

            b1.Click += (se, ev) =>
            {
                Response.Redirect("home.aspx?val=" + userid);
            };
            b2.Click += (se, ev) =>
            {
                Response.Redirect("profile.aspx?val=" + userid);
            };
            b3.Click += (se, ev) =>
            {
                Response.Redirect("notify.aspx?val=" + userid);
            };
            b4.Click += (se, ev) =>
            {
                int x = obj.LastOnline(userid);
                if (x == -1)
                {
                    Error.Text = "Connection Failed. Try Again!";
                }
                else
                {
                    Response.Redirect("message.aspx?val=" + userid);
                }
            };
            b5.Click += (se, ev) =>
            {
                Response.Redirect("about.aspx");
            };
            b6.Click += (se, ev) =>
            {
                Session.Abandon();
                Session.RemoveAll();
                Response.Write("<script language=javascript> { var Backlen=history.length; history.go(-Backlen); window.location.replace(\"logoutpage.aspx\"); } </script>");
                Response.Redirect("loginpage.aspx");
            };
            Button2.Click += (se, ev) =>
            {
                Response.Redirect("friends.aspx");
            };
            int       j      = 0;
            DataTable d1     = new DataTable();
            DataTable d2     = new DataTable();
            bool      flag   = false;
            int       check  = obj.GetNotif(userid, ref d1);
            int       check2 = obj.CheckLastSeen_Notif(userid, ref flag, ref d2);

            if (check > 0 && flag)
            {
                for (int i = 0; i < d1.Rows.Count; i++)
                {
                    if (d2.Rows[0].Field <DateTime>(1).Subtract(d1.Rows[i].Field <DateTime>(2)).TotalMilliseconds < 0)
                    {
                        j++;
                    }
                }
                if (j > 0)
                {
                    un_notif.Text += j;
                    un_notif.Attributes.Add("style", "content:attr(data-badge); position: absolute; font-size:.9em; background: red; color: white; width: 22px; height: 22px; text-align:center; line-height:18px; border-radius:50%; box-shadow:0 0 1px #333;");
                }
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            enter     obj    = new enter();
            DataTable d1     = new DataTable();
            int       userid = (int)Session["userid"];
            int       y      = obj.UpdateLastSeen_Notif(userid);
            int       check  = obj.GetNotif(userid, ref d1);

            if (check <= 0)
            {
                Label l = new Label();
                l.Text = "No Notifications to show" + check;
                l.Attributes.Add("runat", "server");
                p.Controls.Add(l);
            }
            else
            {
                for (int i = 0; i < d1.Rows.Count; i++)
                {
                    Label notify = new Label();
                    notify.ID = notify.UniqueID;
                    int        uid      = d1.Rows[i].Field <int>(0);
                    string     username = obj.GetUser(uid);
                    LinkButton button1  = new LinkButton();
                    button1.ID = button1.UniqueID;
                    button1.Attributes.Add("runat", "server");
                    p.Controls.Add(new LiteralControl("<div style=\"border: solid; border-color: azure; background-color: rgba(255, 216, 0,0.6); color: white; \">"));
                    notify.Attributes.Add("style", "font-size: 30px;");
                    notify.Attributes.Add("runat", "server");
                    //notify.Attributes.Add("Width", "561px");
                    button1.Attributes.Add("style", "font-size: 30px;");
                    //button1.Attributes.Add("Width", "561px");
                    int tid = d1.Rows[i].Field <int>(1);
                    if (d1.Rows[i].Field <string>(3) == "like")
                    {
                        button1.Text   = "@" + username;
                        button1.Click += (se, ev) =>
                        {
                            Session["uid"] = uid;
                            Response.Redirect("user.aspx?val=" + uid);
                        };
                        notify.Text += " liked your ";
                        LinkButton button2 = new LinkButton();
                        button2.ID = button2.UniqueID;
                        button2.Attributes.Add("runat", "server");
                        button2.Attributes.Add("style", "font-size: 30px;");
                        //  button2.Attributes.Add("Width", "561px");
                        button2.Text   = "tweet.";
                        button2.Click += (se, ev) =>
                        {
                            Session["tweetid"] = tid;
                            Response.Redirect("tweet.aspx?val=" + uid);
                        };
                        p.Controls.Add(button1);
                        p.Controls.Add(notify);
                        p.Controls.Add(button2);
                    }
                    else if (d1.Rows[i].Field <string>(3) == "you followed")
                    {
                        button1.Text   = "@" + username;
                        button1.Click += (se, ev) =>
                        {
                            Session["uid"] = uid;
                            Response.Redirect("user.aspx?val=" + uid);
                        };
                        notify.Text = "You started Following ";

                        p.Controls.Add(notify);
                        p.Controls.Add(button1);
                    }
                    else if (d1.Rows[i].Field <string>(3) == "followed you")
                    {
                        button1.Text   = "@" + username;
                        button1.Click += (se, ev) =>
                        {
                            Session["uid"] = uid;
                            Response.Redirect("user.aspx?val=" + uid);
                        };
                        notify.Text = " started Following you.";
                        p.Controls.Add(button1);
                        p.Controls.Add(notify);
                    }
                    else if (d1.Rows[i].Field <string>(3) == "Comment")
                    {
                        button1.Text   = "@" + username;
                        button1.Click += (se, ev) =>
                        {
                            Session["uid"] = uid;
                            Response.Redirect("user.aspx?val=" + uid);
                        };
                        notify.Text = " Commented on your ";
                        LinkButton button2 = new LinkButton();
                        button2.ID = button2.UniqueID;
                        button2.Attributes.Add("runat", "server");
                        button2.Attributes.Add("style", "font-size: 30px;");
                        //  button2.Attributes.Add("Width", "561px");
                        button2.Text   = "tweet.";
                        button2.Click += (se, ev) =>
                        {
                            Session["tweetid"] = tid;
                            Response.Redirect("tweet.aspx?val=" + uid);
                        };
                        p.Controls.Add(button1);
                        p.Controls.Add(notify);
                        p.Controls.Add(button2);
                    }
                    else if (d1.Rows[i].Field <string>(3) == "ReTweet")
                    {
                        button1.Text   = username;
                        button1.Click += (se, ev) =>
                        {
                            Session["uid"] = uid;
                            Response.Redirect("user.aspx?val=" + uid);
                        };
                        notify.Text = " Retweeted your ";
                        LinkButton button2 = new LinkButton();
                        button2.ID = button2.UniqueID;
                        button2.Attributes.Add("runat", "server");
                        button2.Attributes.Add("style", "font-size: 30px;");
                        //  button2.Attributes.Add("Width", "561px");
                        button2.Text   = "tweet.";
                        button2.Click += (se, ev) =>
                        {
                            Session["tweetid"] = tid;
                            Response.Redirect("tweet.aspx?val=" + uid);
                        };
                        p.Controls.Add(button1);
                        p.Controls.Add(notify);
                        p.Controls.Add(button2);
                    }
                    else if (d1.Rows[i].Field <string>(3) == "Tag")
                    {
                        button1.Text   = username;
                        button1.Click += (se, ev) =>
                        {
                            Session["uid"] = uid;
                            Response.Redirect("user.aspx?val=" + uid);
                        };
                        notify.Text = " Tagged you in their ";
                        LinkButton button2 = new LinkButton();
                        button2.ID = button2.UniqueID;
                        button2.Attributes.Add("runat", "server");
                        button2.Attributes.Add("style", "font-size: 30px;");
                        //  button2.Attributes.Add("Width", "561px");
                        button2.Text   = "tweet.";
                        button2.Click += (se, ev) =>
                        {
                            Session["tweetid"] = tid;
                            Response.Redirect("tweet.aspx?val=" + uid);
                        };
                        p.Controls.Add(button1);
                        p.Controls.Add(notify);
                        p.Controls.Add(button2);
                    }
                    else if (d1.Rows[i].Field <string>(3) == "Message")
                    {
                        button1.Text   = username;
                        button1.Click += (se, ev) =>
                        {
                            Session["uid"] = uid;
                            Response.Redirect("user.aspx?val=" + uid);
                        };
                        notify.Text = " sent you a secret Message.";
                        p.Controls.Add(button1);
                        p.Controls.Add(notify);
                    }
                    p.Controls.Add(new LiteralControl("</div>"));
                    p.Controls.Add(new LiteralControl("<br/><br/>"));
                }
            }
        }