private void ex_Click(object sender, RoutedEventArgs e) { enter enter = new enter(); Close(); enter.ShowDialog(); }
protected void User_RowUpdate_Click(Object sender, GridViewUpdateEventArgs e) { // Retrieve the row that raised the event from the Rows GridViewRow row = modifyUser.Rows[e.RowIndex]; //retrieve roll number from that row (key-non editable) int Userid = Convert.ToInt32(row.Cells[1].Text.ToString()); //get the new values from that row string NewUsername = e.NewValues["username"].ToString(); string NewPassword = e.NewValues["password"].ToString(); string NewName = e.NewValues["name"].ToString(); string NewEmail = e.NewValues["email"].ToString(); string NewBdate = e.NewValues["bdate"].ToString(); string NewCountry = e.NewValues["country"].ToString(); string NewCellno = e.NewValues["cellno"].ToString(); Message.Text = Userid + NewUsername + NewPassword + NewEmail + NewBdate + NewCountry + NewCellno; //=====updating the newly entered values in database==== enter obj = new enter(); int result = obj.UpdateUsers(Userid, NewUsername, NewPassword, NewName, NewEmail, NewBdate, NewCountry, NewCellno); //reload the page====================================================== modifyUser.EditIndex = -1; loadGrid(); Message.Text = "UserID = " + Userid + "'s info updated"; }
public void loadGrid() { //this function will load the data into grid enter obj = new enter(); modifyUser.DataSource = obj.GetAllUsers(); modifyUser.DataBind(); modifyTweet.DataSource = obj.GetAllTweets(); modifyTweet.DataBind(); }
public void RecieveMsg() { enter obj = new enter(); DataTable d = new DataTable(); int suc = obj.GetLatest((int)Session["msgid"], (int)Session["userid"], ref d); string msg = d.Rows[0].Field <string>(0); DateTime time = d.Rows[0].Field <DateTime>(1); var cis = ControlIds; int id = ControlIds.Count + 1; cis.Add(id); ControlIds = cis; var ts = Texts; ts.Add(msg); Texts = ts; var dts = Times; dts.Add(time); Times = dts; Label message = new Label(); message.ID = "msg" + id; message.Text = msg; message.Attributes.Add("style", "font-size: 20px;"); message.Attributes.Add("runat", "server"); Label t = new Label(); t.ID = "time" + id; t.Attributes.Add("style", "text-align: right;"); t.Text = "<sub>" + time + "</sub>"; news.Controls.Add(new LiteralControl("<div style=\"border: solid; border-color: azure; background-color: rgba(255, 216, 0, 0.6); color: white; text-align: right \">")); news.Controls.Add(message); news.Controls.Add(new LiteralControl("<br/>")); news.Controls.Add(t); news.Controls.Add(new LiteralControl("</div>")); news.Controls.Add(new LiteralControl("<br/><br/>")); t.Text = ""; }
protected void CreateMsgs(object sender, EventArgs e) { enter obj = new enter(); int success = obj.InsertMessage((int)Session["userid"], (int)Session["msgid"], t.Text); if (success == -1) { msgtxt.Text = "Connection Failure! Try Again!"; } else { var cis = ControlIds; int id = ControlIds.Count + 1; cis.Add(id); ControlIds = cis; var ts = Texts; ts.Add(t.Text); Texts = ts; var dts = Times; var now = DateTime.Now; dts.Add(now); Times = dts; Label message = new Label(); message.ID = "msg" + id; message.Text = t.Text; message.Attributes.Add("style", "font-size: 20px;"); message.Attributes.Add("runat", "server"); Label time = new Label(); time.ID = "time" + id; time.Attributes.Add("style", "text-align: right;"); time.Text = "<sub>" + now + "</sub>"; news.Controls.Add(new LiteralControl("<div style=\"border: solid; border-color: azure; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left \">")); news.Controls.Add(message); news.Controls.Add(new LiteralControl("<br/>")); news.Controls.Add(time); news.Controls.Add(new LiteralControl("</div>")); news.Controls.Add(new LiteralControl("<br/><br/>")); t.Text = ""; } }
protected void SearchUserButton(object sender, EventArgs e) { enter obj = new enter(); String Name = Textbox1.Text; String Password = Textbox2.Text; int found; found = obj.SearchUser(Name, Password); if (found == -1) { Error.Text = "Username or Password is incorrect. Try again."; } else { Session["userid"] = found; Session["username"] = '******' + Name; Session["Uname"] = Name; Response.Redirect("home.aspx?val=" + found); } }
protected void User_RowDelete_Click(Object sender, GridViewDeleteEventArgs e) { // Retrieve the row that raised the event from the Rows // collection of the GridView control. GridViewRow row = modifyUser.Rows[e.RowIndex]; //get roll number from that row String userid = row.Cells[1].Text; //Call the DAL function to delete the student with this roll number enter obj = new enter(); if (obj.DeleteUser(userid) == 1) { Message.Text = "UserID =" + userid + " was Deleted"; loadGrid(); //reload the grid to show the modifications in table } else { Message.Text = "there was some error"; } }
protected void Tweet_RowUpdate_Click(Object sender, GridViewUpdateEventArgs e) { // Retrieve the row that raised the event from the Rows GridViewRow row = modifyTweet.Rows[e.RowIndex]; //retrieve roll number from that row (key-non editable) int Tweetid = Convert.ToInt32(row.Cells[1].Text.ToString()); //get the new values from that row string NewTweetstr = e.NewValues["tweetstr"].ToString(); string NewTime = e.NewValues["time"].ToString(); Message.Text = Tweetid + NewTweetstr + NewTime; //=====updating the newly entered values in database==== enter obj = new enter(); int result = obj.UpdateTweet(Tweetid, NewTweetstr, NewTime); //reload the page====================================================== modifyUser.EditIndex = -1; loadGrid(); Message.Text = "TweetID = " + Tweetid + "'s info updated"; }
protected void Page_Load(object sender, EventArgs e) { enter obj = new enter(); int userid = (int)Session["userid"]; int tweetid = (int)Session["retweetid"]; ret.Attributes.Add("value", Convert.ToString(Session["retweetstr"])); btnSave.Text = "Post ReTweet"; btnSave.Click += (se, ev) => { int found = obj.InsertReTweet(tweetid, userid, ret.Text); if (found == -1) { Label t = new Label(); t.ID = t.UniqueID; t.Attributes.Add("style", "font-family: Times New Roman; font-size: 25px; background-color: #ffffff;"); t.BorderStyle = BorderStyle.Solid; t.Text = "An error occured. Please Go Back to Previous Page and Try Again"; ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(t); ph.Controls.Add(new LiteralControl("<br /><br /><br />")); } else { Label t = new Label(); t.ID = t.UniqueID; t.Attributes.Add("style", "font-family: Times New Roman; font-size: 25px; background-color: #ffffff;"); t.BorderStyle = BorderStyle.Solid; t.Text = "Your Retweet was posted successfully!"; ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(t); ph.Controls.Add(new LiteralControl("<br /><br /><br />")); Response.Redirect("home.aspx?val=" + userid); } }; }
protected void Page_Load(object sender, EventArgs e) { enter obj = new enter(); DataTable d1 = new DataTable(); int userid = (int)Session["userid"]; int check = obj.MsgPreview(userid, ref d1); if (check <= 0) { Label l = new Label(); l.Text = "No messages to show yet"; l.Attributes.Add("runat", "server"); p.Controls.Add(l); } else { for (int i = 0; i < d1.Rows.Count; i++) { DataTable temp = new DataTable(); int x = obj.Convo(userid, d1.Rows[i].Field <int>(0), ref temp); if (x > 0) { LinkButton button = new LinkButton(); button.ID = button.UniqueID; button.Attributes.Add("style", "font-size: 23px; color: white;"); int user2 = d1.Rows[i].Field <int>(0); button.Text = obj.GetUser(user2); DataTable convo = new DataTable(); convo = temp; button.Click += (se, ev) => { Session["msgid"] = user2; Session["Convo"] = convo; Response.Redirect("talk.aspx?val=" + user2); }; button.Attributes.Add("runat", "server"); int j = 0; while (temp.Rows[j].Field <DateTime>(2).Subtract(d1.Rows[i].Field <DateTime>(1)).TotalMilliseconds > 0) { if (temp.Rows[j].Field <int>(0) == userid) { break; } j++; } Label notify = new Label(); notify.ID = notify.UniqueID; Label message = new Label(); message.ID = message.UniqueID; message.Text = temp.Rows[0].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>" + temp.Rows[0].Field <DateTime>(2) + "</sub>"; if (j > 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 += j; p.Controls.Add(new LiteralControl("<div style=\"border: solid; border-color: azure; background-color: rgba(255, 216, 0,0.6); color: white; \">")); } else { p.Controls.Add(new LiteralControl("<div style=\"border: solid; border-color: azure; background-color: rgba(18, 12, 85, 0.6); color: white; \">")); } p.Controls.Add(button); p.Controls.Add(notify); p.Controls.Add(new LiteralControl("<br/>")); 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/>")); } } } }
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/>")); } } }
protected void Page_Load(object sender, EventArgs e) { enter obj = new enter(); int id = (int)(Session["aboutid"]); int userid = (int)(Session["userid"]); DataTable DT = new DataTable(); int check = obj.GetInformation(id, ref DT); if (check != -1) { string name = DT.Rows[0].Field <string>(0); string uname = DT.Rows[0].Field <string>(1); string email = DT.Rows[0].Field <string>(2); DateTime date = DT.Rows[0].Field <DateTime>(3); string country = DT.Rows[0].Field <string>(4); string cellno = DT.Rows[0].Field <string>(5); string password = DT.Rows[0].Field <string>(6); TextBox about = new TextBox(); about.ID = about.UniqueID; about.TextMode = TextBoxMode.MultiLine; about.Rows = 1; about.Attributes.Add("runat", "server"); about.Attributes.Add("style", "font-family: Broadway;font-size: 30px; border-color: black; background-color: rgba(255, 216, 0,0.6); color: black; text-align: left;width:900px "); about.Text = "ABOUT @" + uname; about.ReadOnly = true; //-------------------NAME---------------- TextBox t1 = new TextBox(); t1.ID = t1.UniqueID; t1.TextMode = TextBoxMode.MultiLine; t1.Rows = 1; t1.Attributes.Add("runat", "server"); t1.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left;width:200px "); t1.Text = "Name"; t1.ReadOnly = true; TextBox l1 = new TextBox(); l1.ID = l1.UniqueID; l1.TextMode = TextBoxMode.MultiLine; l1.Rows = 1; l1.Attributes.Add("runat", "server"); l1.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(255, 216, 0,0.6); color: black; text-align: left;width:900px "); l1.Text = name; l1.ReadOnly = true; //------------USERNAME---------- TextBox t2 = new TextBox(); t2.ID = t2.UniqueID; t2.TextMode = TextBoxMode.MultiLine; t2.Rows = 1; t2.Attributes.Add("runat", "server"); t2.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left;width:200px "); t2.Text = "Username"; t2.ReadOnly = true; TextBox l2 = new TextBox(); l2.ID = l2.UniqueID; l2.TextMode = TextBoxMode.MultiLine; l2.Rows = 1; l2.Attributes.Add("runat", "server"); l2.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(255, 216, 0,0.6); color: black; text-align: left;width:900px "); l2.Text = "@" + uname; l2.ReadOnly = true; //----------------EMAIL----------- TextBox t3 = new TextBox(); t3.ID = t3.UniqueID; t3.TextMode = TextBoxMode.MultiLine; t3.Rows = 1; t3.Attributes.Add("runat", "server"); t3.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left;width:200px "); t3.Text = "Email"; t3.ReadOnly = true; TextBox l3 = new TextBox(); l3.ID = l3.UniqueID; l3.TextMode = TextBoxMode.MultiLine; l3.Rows = 1; l3.Attributes.Add("runat", "server"); l3.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(255, 216, 0,0.6); color: black; text-align: left;width:900px "); l3.Text = email; l3.ReadOnly = true; //----------------BIRTHDATE-------- TextBox t4 = new TextBox(); t4.ID = t4.UniqueID; t4.TextMode = TextBoxMode.MultiLine; t4.Rows = 1; t4.Attributes.Add("runat", "server"); t4.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left;width:200px "); t4.Text = "Birthdate"; t4.ReadOnly = true; TextBox l4 = new TextBox(); l4.ID = l4.UniqueID; l4.TextMode = TextBoxMode.MultiLine; l4.Rows = 1; l4.Attributes.Add("runat", "server"); l4.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(255, 216, 0,0.6); color: black; text-align: left;width:900px "); l4.Text += date; l4.ReadOnly = true; //-------------------COUNTRY--------------- TextBox t5 = new TextBox(); t5.ID = t5.UniqueID; t5.TextMode = TextBoxMode.MultiLine; t5.Rows = 1; t5.Attributes.Add("runat", "server"); t5.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left;width:200px "); t5.Text = "Country"; t5.ReadOnly = true; TextBox l5 = new TextBox(); l5.ID = l5.UniqueID; l5.TextMode = TextBoxMode.MultiLine; l5.Rows = 1; l5.Attributes.Add("runat", "server"); l5.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(255, 216, 0,0.6); color: black; text-align: left;width:900px "); l5.Text = country; l5.ReadOnly = true; //---------------CEll NO----------------- TextBox t6 = new TextBox(); t6.ID = t6.UniqueID; t6.TextMode = TextBoxMode.MultiLine; t6.Rows = 1; t6.Attributes.Add("runat", "server"); t6.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left;width:200px "); t6.Text = "Cell No"; t6.ReadOnly = true; TextBox l6 = new TextBox(); l6.ID = l6.UniqueID; l6.TextMode = TextBoxMode.MultiLine; l6.Rows = 1; l6.Attributes.Add("runat", "server"); l6.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(255, 216, 0,0.6); color: black; text-align: left;width:900px "); l6.Text = cellno; l6.ReadOnly = true; ph.Controls.Add(about); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(t1); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(l1); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(t2); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(l2); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(t3); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(l3); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(t4); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(l4); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(t5); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(l5); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(t6); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(l6); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); if (id == userid) { TextBox t7 = new TextBox(); t7.ID = t6.UniqueID; t7.TextMode = TextBoxMode.MultiLine; t7.Rows = 1; t7.Attributes.Add("runat", "server"); t7.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left;width:200px "); t7.Text = "Password"; t7.ReadOnly = true; TextBox l7 = new TextBox(); l7.ID = l6.UniqueID; l7.Rows = 1; l7.Attributes.Add("runat", "server"); l7.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(255, 216, 0,0.6); color: black; text-align: left;width:900px "); l7.Text = password; l7.ReadOnly = true; l7.TextMode = TextBoxMode.Password; Button edit = new Button(); edit.ID = edit.UniqueID; edit.Attributes.Add("runat", "server"); edit.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left;width:200px "); edit.Text = "EDIT INFO"; Label error = new Label(); error.ID = error.UniqueID; error.Attributes.Add("runat", "server"); edit.Click += (s, ev) => { if (edit.Text == "EDIT INFO") { l1.ReadOnly = false; l2.ReadOnly = false; l3.ReadOnly = false; l4.ReadOnly = false; l5.ReadOnly = false; l6.ReadOnly = false; l7.ReadOnly = false; edit.Text = "SAVE CHANGES"; } else { if (l1.Text == "" || l2.Text == "" || l3.Text == "" || l4.Text == "" || l5.Text == "" || l7.Text == "") { error.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left;width:200px "); error.Text = "A Field cannot be left empty"; } else { int x = obj.EditUser(userid, l1.Text, l2.Text, l3.Text, l4.Text, l5.Text, l6.Text, l7.Text); if (x != -1) { l1.ReadOnly = true; l2.ReadOnly = true; l3.ReadOnly = true; l4.ReadOnly = true; l5.ReadOnly = true; l6.ReadOnly = true; l7.ReadOnly = true; edit.Text = "EDIT INFO"; } else { error.Attributes.Add("style", "font-family: Times New Roman;font-size: 25px; border-color: black; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left;width:200px "); error.Text = "Invalid Username or Password! Try Again!"; } } } }; ph.Controls.Add(t7); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(l7); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(edit); ph.Controls.Add(new LiteralControl("<br />")); ph.Controls.Add(new LiteralControl("<br />")); } } else { Label error = new Label(); error.ID = error.UniqueID; error.Attributes.Add("runat", "server"); error.Attributes.Add("style", "font-family: Times New Roman; font-size: 25px; background-color: #ffffff;"); error.Text = "There was some error"; ph.Controls.Add(error); ph.Controls.Add(new LiteralControl("<br />")); } }
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("     ")); 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/>")); } } } } }
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/>")); } }
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/>")); } } }
protected void EnterUserButton(object sender, EventArgs e) { enter obj = new enter(); String uname = Textbox1.Text; if (string.IsNullOrEmpty(uname)) { Error1.Text = "Username cannot be null."; return; } String password = Textbox7.Text; bool check1 = false; bool check2 = false; if (string.IsNullOrEmpty(password)) { Error2.Text = "Password cannot be null."; return; } else { for (int i = 0; i < password.Length; i++) { if (password[i] >= '0' && password[i] <= '9') { check1 = true; } else if (password[i] >= 'A' && password[i] <= 'Z') { check2 = true; } } if (check1 == false || check2 == false) { Error2.Text = "You have given an invalid Password. Try again."; return; } } String name = Textbox2.Text; if (string.IsNullOrEmpty(name)) { Error3.Text = "Name cannot be null."; return; } String email = Textbox3.Text; if (string.IsNullOrEmpty(email)) { Error4.Text = "Email cannot be null."; return; } String country = Textbox4.Text; if (string.IsNullOrEmpty(country)) { Error5.Text = "Country cannot be null."; return; } String cellno = Textbox5.Text; String bdate = Textbox6.Text; if (string.IsNullOrEmpty(bdate)) { Error6.Text = "Birth-date cannot be null."; return; } DataTable DT = new DataTable(); int found; found = obj.EnterUser(uname, password, name, email, bdate, country, cellno, ref DT); if (found == -1) { Error1.Text = "Sorry! Username already exists. Try again."; } else { Response.Redirect("loginpage.aspx"); } }
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;"); } } }
protected PlaceHolder MakeDraft(DataTable DT) { PlaceHolder p = new PlaceHolder(); enter obj = new enter(); int userid = (int)(Session["userid"]); foreach (DataRow row in DT.Rows) { DataTable t1 = new DataTable(); int tweetid = row.Field <int>(0); bool checklike = false; int get1 = obj.readTweet(tweetid, ref t1); int get2 = obj.numOfLikes(userid, tweetid, ref checklike); int get3 = obj.numOfcomments(tweetid); int get4 = obj.numOfretweets(tweetid); if (get1 != -1 && get2 != -1 && get3 != -1 && get4 != -1) { PlaceHolder np = new PlaceHolder(); np.ID = np.UniqueID; Label t = new Label(); t.ID = t.UniqueID; t.Attributes.Add("style", "font-family: Times New Roman; font-size: 25px; background-color: #ffffff;"); t.BorderStyle = BorderStyle.Solid; t.Text = t1.Rows[0].Field <string>(0); t.Attributes.Add("runat", "server"); Button b1 = new Button(); b1.ID = b1.UniqueID; b1.Attributes.Add("runat", "server"); b1.Attributes.Add("style", "height: 35px; width: 100px; font-family: Times New Roman; font-size: 10px; background-color: #ffffff;"); if (checklike == false) { b1.Text = "LIKE "; } else { b1.Text = "UNLIKE "; } b1.Text += get2; b1.Click += (se, ev) => { bool ret = false; int found = obj.EnterLike(userid, tweetid, ref ret); if (found != -1) { if (!ret) { b1.Text = "UNLIKE "; b1.Text += found; } else { b1.Text = "LIKE "; b1.Text += found; } } }; //b1.OnClientClick = "return false;"; Button b2 = new Button(); b2.ID = b2.UniqueID; b2.Attributes.Add("runat", "server"); b2.Attributes.Add("style", "height: 35px; width: 100px; font-family: Times New Roman; font-size: 10px; background-color: #ffffff;"); b2.Text = "COMMENT "; b2.Text += get3; Button b3 = new Button(); b3.ID = b3.UniqueID; b3.Attributes.Add("runat", "server"); b3.Attributes.Add("style", "height: 35px; width: 100px; font-family: Times New Roman; font-size: 10px; background-color: #ffffff;"); b3.Text = "RETWEET "; b3.Text += get4; b2.Click += (se, ev) => { DataTable d = new DataTable(); int f1 = obj.GetComments(tweetid, ref d); if (f1 == -1) { TextBox tb = new TextBox(); tb.ID = tb.UniqueID; tb.Attributes.Add("style", "font-size: 20px;"); tb.BorderStyle = BorderStyle.Solid; tb.Attributes.Add("runat", "server"); Button b4 = new Button(); b4.ID = b4.UniqueID; b4.Attributes.Add("runat", "server"); b4.Attributes.Add("style", "height: 35px; width: 100px; font-family: Times New Roman; font-size: 10px; background-color: #ffffff;"); b4.Text = "~Tweet"; b4.Click += (ser, eve) => { int cmnt = obj.InsertComment(userid, tweetid, tb.Text); }; np.Controls.Add(tb); np.Controls.Add(new LiteralControl(" ")); np.Controls.Add(b4); } else { np.Controls.Add(MakeDraft(d)); TextBox tb = new TextBox(); tb.ID = tb.UniqueID; tb.Attributes.Add("style", "font-size: 20px;"); tb.BorderStyle = BorderStyle.Solid; tb.Attributes.Add("runat", "server"); Button b4 = new Button(); b4.ID = b4.UniqueID; b4.Attributes.Add("runat", "server"); b4.Attributes.Add("style", "height: 35px; width: 100px; font-family: Times New Roman; font-size: 10px; background-color: #ffffff;"); b4.Text = "~Tweet"; b4.Click += (ser, eve) => { int cmnt = obj.InsertComment(userid, tweetid, tb.Text); }; np.Controls.Add(tb); np.Controls.Add(new LiteralControl(" ")); np.Controls.Add(b4); } }; np.Controls.Add(t); np.Controls.Add(new LiteralControl("<br />")); np.Controls.Add(b1); np.Controls.Add(new LiteralControl(" ")); np.Controls.Add(b2); np.Controls.Add(new LiteralControl(" ")); np.Controls.Add(b3); np.Controls.Add(new LiteralControl("<br />")); p.Controls.Add(np); p.Controls.Add(new LiteralControl("<br /><br /><br />")); } else { Label t = new Label(); t.ID = t.UniqueID; t.Attributes.Add("style", "font-family: Times New Roman; font-size: 25px; background-color: #ffffff;"); t.BorderStyle = BorderStyle.Solid; t.Text = "An error occured. Please reload!"; p.Controls.Add(new LiteralControl("<br />")); p.Controls.Add(t); p.Controls.Add(new LiteralControl("<br /><br /><br />")); } } return(p); }