예제 #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)
        {
            int       userid = (int)Session["userid"];
            int       user2  = (int)Session["msgid"];
            DataTable convo  = (DataTable)Session["convo"];

            enter obj = new enter();
            int   rem = obj.UpdateLastSeen(userid, user2);

            heading.Text   = obj.getName(user2);
            heading.Click += (se, ev) =>
            {
                Session["uid"] = user2;
                Response.Redirect("user.aspx?val=" + user2);
            };

            if (rem == -1)
            {
                msgtxt.Text = "An error occured. Please reload the page!";
            }
            else
            {
                foreach (DataRow row in convo.Rows)
                {
                    Label message = new Label();
                    message.ID   = message.UniqueID;
                    message.Text = row.Field <string>(1);
                    message.Attributes.Add("style", "font-size: 20px;");
                    message.Attributes.Add("runat", "server");
                    Label time = new Label();
                    time.ID = time.UniqueID;
                    time.Attributes.Add("style", "text-align: right;");
                    time.Text = "<sub>" + row.Field <DateTime>(2) + "</sub>";

                    if (row.Field <int>(0) == userid)
                    {
                        p.Controls.Add(new LiteralControl("<div style=\"border: solid; border-color: azure; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left \">"));
                    }
                    else
                    {
                        p.Controls.Add(new LiteralControl("<div style=\"border: solid; border-color: azure; background-color: rgba(255, 216, 0,0.6); color: white; text-align: right \">"));
                    }

                    p.Controls.Add(message);
                    p.Controls.Add(new LiteralControl("<br/>"));
                    p.Controls.Add(time);
                    p.Controls.Add(new LiteralControl("</div>"));
                    p.Controls.Add(new LiteralControl("<br/><br/>"));
                }
            }

            if (IsPostBack)
            {
                for (int i = ControlIds.Count - 1; i >= 0; i--)
                {
                    Label message = new Label();
                    message.ID   = "msg" + ControlIds[i];
                    message.Text = Texts[i];
                    message.Attributes.Add("style", "font-size: 20px;");
                    message.Attributes.Add("runat", "server");
                    Label time = new Label();
                    time.ID = "time" + ControlIds[i];
                    time.Attributes.Add("style", "text-align: right;");
                    time.Text = "<sub>" + Times[i] + "</sub>";
                    place.Controls.Add(new LiteralControl("<div style=\"border: solid; border-color: azure; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left \">"));
                    place.Controls.Add(message);
                    place.Controls.Add(new LiteralControl("<br/>"));
                    place.Controls.Add(time);
                    place.Controls.Add(new LiteralControl("</div>"));
                    place.Controls.Add(new LiteralControl("<br/><br/>"));
                }
            }
        }