protected void newEvent(object sender, EventArgs e) { HttpCookie userCookie; userCookie = Request.Cookies["UserID"]; User_Class myUser = new User_Class(); myUser = myUser.getUser(userCookie.Value); myUser.getFriends(); Events_Class events = new Events_Class(); //events.Date = TextBoxDate.Text; //TextBoxDate.Text = "disabled"; events.Date = Calendar1.SelectedDate.ToString(); events.Location = TextBoxLocation.Text; events.Description = TextBoxDescription.Text; int indice = 0; events.Users.Add(myUser); foreach (ListItem li in ListBox2.Items) { indice = Int32.Parse(li.Value); events.Users.Add(myUser.Friends[indice]); } events.addEvent(); Response.Redirect("Events.aspx", true); }
public bool addUser(User_Class userm, int eventID) { bool añadido; SqlConnection con = new SqlConnection(connection); try { con.Open(); string sql = "INSERT INTO US_EV_REL (UID,EID) VALUES (" + userm.Id + "," + eventID + ")"; SqlCommand cmd = new SqlCommand(sql, con); cmd.ExecuteNonQuery(); añadido = true; } catch (Exception ex) { añadido = false; } finally { con.Close(); } return añadido; }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { if (!IsPostBack) { ListBox1.Items.Clear(); ListBox2.Items.Clear(); ListBox3.Items.Clear(); ListBox1.Width = 100; ListBox1.Height = 60; ListBox2.Width = 150; ListBox3.Width = 150; user = new User_Class(); user = user.getUser(userCookie.Value); user.getFriends(); int i = 0; ListItem l = new ListItem(); while (i < user.Friends.Count) { l = new ListItem(); l.Text = user.Friends[i].Nick; l.Value = i.ToString(); ListBox2.Items.Add(l); i++; } ListItem o = new ListItem("Public", "0"); ListItem p = new ListItem("Private", "1"); ListBox1.Items.Add(o); ListBox1.Items.Add(p); } } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { usuario_sesion.deleteFriend(int.Parse(Request.QueryString["id"])); Response.Redirect("../Asp_forms/Friends.aspx"); } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { Image1.ImageUrl = usuario_sesion.Image_url; Label1.Text = usuario_sesion.Nick; Label2.Text = usuario_sesion.Name; Label3.Text = usuario_sesion.Surname; Label4.Text = usuario_sesion.Email; Label5.Text = usuario_sesion.Gender.ToString(); Label6.Text = usuario_sesion.Entry_date; Label7.Text = usuario_sesion.Birth_date; } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { CompareValidator pass = new CompareValidator(); pass.ID = "CorrectPasswordCompare"; pass.ValueToCompare = usuario_sesion.Pass; pass.ControlToValidate = "CurrentPassword"; pass.CssClass = "failureNotification"; pass.ErrorMessage = "*</br>The passwords is not correct."; CurrentPasswordRequired.Controls.Add(pass); } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { //When the page reloads keeps the cursor on the same position Page.MaintainScrollPositionOnPostBack = true; HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { if (!IsPostBack) { User_Class myUser = new User_Class(); myUser = myUser.getUser(userCookie.Value); Events_Class events = new Events_Class(); myUser.getFriends(); ListBox1.Items.Clear(); ListBox1.Width = 100; ListBox2.Width = 100; int i = 0; ListItem l = new ListItem(); while (i < myUser.Friends.Count) { l = new ListItem(); l.Text = myUser.Friends[i].Name; l.Value = i.ToString(); ListBox1.Items.Add(l); i++; } } } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void SignUp_Click(object sender, EventArgs e) { User_Class newUser = new User_Class(); newUser.Name = Name.Text; newUser.Surname = Surname.Text; newUser.Pass = Password.Text; newUser.Nick = UserName.Text; newUser.Email = Email.Text; foreach (ListItem li in ListBox1.Items) { if (li.Selected == true) { if (Int32.Parse(li.Value) == 0) { newUser.Gender = 'F'; } else if (Int32.Parse(li.Value) == 1) { newUser.Gender = 'M'; } } } newUser.Entry_date = DateTime.Now.ToShortDateString(); newUser.Birth_date = Calendar1.SelectedDate.ToString(); newUser.Image_url = "../Images/no_image.jpeg"; if (!newUser.existeUsuario(newUser.Nick)) { newUser.addUser(); string subject = "[Thanks for signing up Sticky Notes]"; MailMessage mail = new MailMessage(); mail.To.Add(Email.Text); mail.From = new MailAddress("*****@*****.**"); mail.Subject = subject; mail.Body = "Thanks by have been registered in Sticky Notes.\n\nYour User information is:\nUser: "******"\nPass: "******"\n\nI hope you enjoy our social network.\nSticky Notes’ team."; mail.IsBodyHtml = false; mail.Priority = MailPriority.Normal; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; smtp.Credentials = new NetworkCredential("*****@*****.**", "projecthada"); smtp.Send(mail); Response.Redirect("..//Account/Login.aspx"); } else { SameUserfailure.Text = "This UserName already exists."; } }
protected void Page_Load(object sender, EventArgs e) { Panel p = new Panel(); Panel psub = new Panel(); Label t = new Label(); Label a = new Label(); Note_CAD notaTemp = new Note_CAD(); List<Note_Class> notes = new List<Note_Class>(); User_Class user = new User_Class(); notes = notaTemp.notesOpen(); int i = notes.Count() - 1; int j = i-12; while (i >= 0 && i > j) { p = new Panel(); t = new Label(); a = new Label(); psub = new Panel(); string id = notes[i].Id.ToString(); psub.CssClass = "default_panel"; psub.HorizontalAlign = HorizontalAlign.Right; p.ID = "p" + id; p.CssClass = "postitnotes"; t.ID = "t" + id; a.Text = "a" + id; t.Text = notes[i].Text.ToString() + "<BR>"; a.Text = user.getUser(notes[i].Author).Nick; a.CssClass = "noteauthor"; psub.Controls.Add(a); p.Controls.Add(t); p.Controls.Add(psub); Panel1.Controls.Add(p); i--; } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { List<Category_Class> lista = new List<Category_Class>(); Category_Class category = new Category_Class(); if (Request.QueryString["cadena"] != null) lista = filterCategories(Request.QueryString["cadena"], category.Categories()); else lista = category.Categories(); if (lista.Count() == 0) { Label label = new Label(); label.ID = "LabelX"; label.Text = "<h2> No categories found! </h2>"; Panel2.Controls.Add(label); } for (int j = 0; j < lista.Count(); j++) { Panel2.Controls.Add(createNotesButton(lista.ElementAt(j).Id, lista.ElementAt(j).Nombre)); } } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { String s; s = Request.QueryString["ID"]; if (s != null) { int id = Int32.Parse(s); Note_Class note = new Note_Class(); note.Id = id; if (note.deleteNote()) Response.Redirect("..//Asp_forms/Notes.aspx"); else { Label l = new Label(); l.Text = "An error has occurred, please try again later."; Panel1.Controls.Add(l); } } } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; userCookie = Request.Cookies["UserID"]; if (userCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { Party_Class party = new Party_Class(); List<Party_Class> partyList = new List<Party_Class>(); User_Class myUser = new User_Class(); myUser = myUser.getUser(userCookie.Value); partyList = party.userGroups(myUser.Id); HyperLink link = new HyperLink(); Panel p = new Panel(); int i = partyList.Count() - 1; while(i>=0) { string id = partyList[i].Id.ToString(); link = new HyperLink(); link.CssClass = "button white"; link.Width=300; link.Height = 30; p = new Panel(); link.ID = "link" + id; p.ID = "panel" + id; link.Text = partyList[i].Name; link.NavigateUrl = "~/Asp_forms/Groups_Notes.aspx?ID=" + id; p.Controls.Add(link); Panel2.Controls.Add(p); i--; } } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { String s; s = Request.QueryString["ID"]; if (s != null) { int id = Int32.Parse(s); User_Class myUser = new User_Class(); myUser = myUser.getUser(userCookie.Value); Events_Class events = new Events_Class(); events = events.getEvent(id); events.addUser(myUser); Label1.Text = events.ToString(); Response.Redirect("..//Asp_forms/Events.aspx"); } } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void Change_Pass(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); usuario_sesion.Pass = NewPassword.Text; usuario_sesion.changePass(NewPassword.Text); passCookie.Expires = DateTime.Now.AddMonths(-1); Response.Cookies.Add(userCookie); passCookie.Value = NewPassword.Text; passCookie.Expires = DateTime.Now.AddMonths(1); Response.Cookies.Add(passCookie); Response.Redirect("./ChangePasswordSuccess.aspx"); }
protected void Search(object sender, EventArgs e) { HttpCookie userCookie; userCookie = Request.Cookies["UserID"]; User_Class myUser = new User_Class(); myUser = myUser.getUser(userCookie.Value); Events_Class events = new Events_Class(); List<Events_Class> eventsList = new List<Events_Class>(); eventsList = events.searchEvents(TextBox1.Text, myUser.Id); int totalEvents = eventsList.Count(); int counter = 0; Panel p = new Panel(); Label t = new Label(); HyperLink le = new HyperLink(); while (counter < totalEvents) { string id = eventsList[counter].Id.ToString(); p = new Panel(); t = new Label(); le = new HyperLink(); p.ID = "panel" + id; t.ID = "t" + id; le.ID = "le" + id; t.Text = eventsList[counter].ToString()+ "<BR>"; le.Text = "ADD"; le.NavigateUrl = "~/Asp_forms/AddToEvents.aspx?ID=" + eventsList[counter].Id; p.Controls.Add(t); p.Controls.Add(le); Panel2.Controls.Add(p); counter++; } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { String s; s = Request.QueryString["ID"]; if (s != null) { int id = Int32.Parse(s); note.Id = id; note = note.getNote(id); Label2.Text = note.Text; } } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { if (!usuario_sesion.isFriend(int.Parse(Request.QueryString["id"]))) { Response.Redirect("../Asp_forms/Friends.aspx?all=yes"); } User_Class usuario_friend = new User_Class(); usuario_friend = usuario_friend.getUser(int.Parse(Request.QueryString["id"])); Image1.ImageUrl = usuario_friend.Image_url; Label1.Text = usuario_friend.Nick; Label2.Text = usuario_friend.Name; Label3.Text = usuario_friend.Surname; Label4.Text = usuario_friend.Email; Label5.Text = usuario_friend.Gender.ToString(); Label6.Text = usuario_friend.Entry_date; Label7.Text = usuario_friend.Birth_date; } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { if (usuario_sesion.addFriend(int.Parse(Request.QueryString["id"]))) { LabelHecho.Text = "<h2> User Added </h2>"; System.Threading.Thread.Sleep(5000); Response.Redirect("../Asp_forms/Friends.aspx"); } else { LabelHecho.Text = "<h2> Fail Adding User </h2>"; System.Threading.Thread.Sleep(5000); Response.Redirect("../Asp_forms/Friends.aspx"); } } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { Page.MaintainScrollPositionOnPostBack = true; HttpCookie userCookie; userCookie = Request.Cookies["UserID"]; if (userCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { if (!IsPostBack) { ListBox1.Items.Clear(); ListBox1.Width = 150; ListBox1.Height = 200; ListBox2.Width = 150; ListBox2.Height = 200; user = new User_Class(); user = user.getUser(userCookie.Value); user.getFriends(); int i = 0; ListItem l = new ListItem(); while (i < user.Friends.Count) { l = new ListItem(); l.Text = user.Friends[i].Nick; l.Value = i.ToString(); ListBox1.Items.Add(l); i++; } } } }
protected void ChangeData(object sender, EventArgs e) { HttpCookie userCookie; userCookie = Request.Cookies["UserID"]; User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (Email.Text != "") usuario_sesion.Email = Email.Text; if (Name.Text != "") usuario_sesion.Name = Name.Text; if (Surname.Text != "") usuario_sesion.Surname = Surname.Text; if (RadioButtonList1.Items[0].Selected) usuario_sesion.Gender = 'F'; else if(RadioButtonList1.Items[1].Selected) usuario_sesion.Gender = 'M'; if (ImageUrl.Text != "") usuario_sesion.Image_url = ImageUrl.Text; userCookie = new HttpCookie("UserID", usuario_sesion.Nick); userCookie.Expires = DateTime.Now.AddMonths(1); Response.Cookies.Add(userCookie); if(usuario_sesion.updateUser()) Label1.Text = "Done!"; }
protected void Create_Note(object sender, EventArgs e) { HttpCookie userCookie; userCookie = Request.Cookies["UserID"]; if (userCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { string s = Request.QueryString["ID"]; if (s != null) { Party_Class party = new Party_Class(); party.Id = Int32.Parse(s); User_Class user = new User_Class(); user = user.getUser(userCookie.Value); Note_Class note = new Note_Class(); note.Text = DescripcionNota.Text; note.Date = DateTime.Now.ToShortDateString(); if (party.addNote(note, user.Id)) { Page.MaintainScrollPositionOnPostBack = true; Response.Redirect("~/Asp_forms/Groups_Notes.aspx?ID=" + party.Id); } else Label2.Text = "An error has occurred"; } } /* Create note with the button 'New Note' */ }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { User_Class myUser = new User_Class(); myUser = myUser.getUser(userCookie.Value); Events_Class events = new Events_Class(); List<Events_Class> eventsList = new List<Events_Class>(); eventsList = events.userEvents(myUser.Id); int totalEvents = eventsList.Count(); int counter = 0; Panel p = new Panel(); Label t = new Label(); HyperLink le = new HyperLink(); Panel header = new Panel(); Panel content = new Panel(); Panel footer = new Panel(); Panel cal = new Panel(); Panel textcontent = new Panel(); Label texto2 = new Label(); while (counter < totalEvents) { string id = eventsList[counter].Id.ToString(); p = new Panel(); t = new Label(); Label t2 = new Label(); Label t3 = new Label(); le = new HyperLink(); ImageButton removeButton = new ImageButton(); p.ID = "panel" + id; t.ID = "t" + id; le.ID = "le" + id; t3.Text = "<BR><BR>" + eventsList[counter].Date.ToString(); t2.Text = "<BR>" + eventsList[counter].Description.ToString() + "<BR><BR>"; t.Text = eventsList[counter].Location.ToString() + "<BR>"; t.CssClass = "cal_location"; t2.CssClass = "cal_description"; t3.CssClass = "cal_date"; removeButton.ToolTip = "Remove"; removeButton.ImageUrl = "../Images/deleteButton.png"; removeButton.PostBackUrl = "~/Asp_forms/RemoveUserFromEvents.aspx?ID=" + eventsList[counter].Id; removeButton.Width = 20; header = new Panel(); content = new Panel(); footer = new Panel(); cal = new Panel(); textcontent = new Panel(); texto2 = new Label(); header.ID = "header" + id; content.ID = "content" + id; footer.ID = "footer" + id; cal.ID = "cal" + id; footer.CssClass = "calfooter"; header.CssClass = "calheader"; header.HorizontalAlign = HorizontalAlign.Center; content.CssClass = "calcontent"; textcontent.CssClass = "caldefault"; cal.CssClass = "cal"; content.BackColor = System.Drawing.Color.White; header.Height = 82; header.Width = 300; footer.Height = 50; header.Controls.Add(t3); textcontent.Controls.Add(t); textcontent.Controls.Add(t2); textcontent.Controls.Add(le); textcontent.Controls.Add(removeButton); content.Controls.Add(textcontent); cal.Controls.Add(header); cal.Controls.Add(content); cal.Controls.Add(footer); cal.Width = 300; Panel2.Controls.Add(cal); counter++; } } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { Page.MaintainScrollPositionOnPostBack = true; HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { Panel p = new Panel(); Label t = new Label(); Label f = new Label(); Image ie = new Image(); ie.ImageUrl = "../Images/editButton.png"; ImageButton imgbuttone = new ImageButton(); ImageButton imgbuttonb = new ImageButton(); User_Class userNote = new User_Class(); Label a = new Label(); Panel psub = new Panel(); Note_CAD notaTemp = new Note_CAD(); List<Note_Class> notes = new List<Note_Class>(); User_Class userTemp = new User_Class(); userTemp = userTemp.getUser(userCookie.Value); notes = notaTemp.notesUser(userTemp.Id); int i = notes.Count() - 1; while (i >= 0) { p = new Panel(); psub = new Panel(); t = new Label(); f = new Label(); a = new Label(); userNote = new User_Class(); imgbuttone = new ImageButton(); imgbuttonb = new ImageButton(); imgbuttone.ImageUrl = "../Images/editButton.png"; imgbuttone.PostBackUrl = "~/Asp_forms/Editnotes.aspx?ID=" + notes[i].Id.ToString(); imgbuttone.Width = 30; imgbuttone.ToolTip = "Edit"; imgbuttonb.ImageUrl = "../Images/deleteButton.png"; imgbuttonb.PostBackUrl = "~/Asp_forms/Deletenote.aspx?ID=" + notes[i].Id.ToString(); imgbuttonb.Width = 30; imgbuttonb.ToolTip = "Delete"; psub.CssClass = "default_panel"; psub.HorizontalAlign = HorizontalAlign.Right; a.Text = "<br/>" +userNote.getUser(notes[i].Author).Nick; a.CssClass = "noteauthor"; psub.Controls.Add(imgbuttonb); psub.Controls.Add(imgbuttone); psub.Controls.Add(a); string id = notes[i].Id.ToString(); p.ID = "p" + id; if (notes[i].Type == 'O') p.CssClass = "postitnotes"; else if (notes[i].Type == 'P') p.CssClass = "postitnotespink"; t.ID = "t" + id; f.ID = "f" + id; t.Text = notes[i].Text.ToString() + "<BR>"; p.Controls.Add(t); p.Controls.Add(f); p.Controls.Add(psub); Panel1.Controls.Add(p); i--; } } else { Response.Redirect("../Account/Login.aspx"); } } }
//Destructor //Añadir usuario public void addUser(User_Class myUser, int id) { users.Add(myUser); this.update(); }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { if (Request.QueryString["all"] == "yes") RadioButtonList1.Items[1].Selected = true; else RadioButtonList1.Items[0].Selected = true; if (RadioButtonList1.Text == "Only my friends") { List<User_Class> lista = new List<User_Class>(); usuario_sesion.getFriends(); if (Request.QueryString["cadena"] != null) { lista = filterFriends(Request.QueryString["cadena"], usuario_sesion.Friends); } else { lista = usuario_sesion.Friends; } if (lista.Count() == 0) { Label label = new Label(); label.Attributes.Add("style", "float:center; margin-left:50px;"); label.ID = "LabelX"; label.Text = "<h2> No friends found! </h2>"; Panel2.Controls.Add(label); } HyperLink link = new HyperLink(); for (int j = 0; j < lista.Count(); j++) { link=new HyperLink(); link.Text=lista.ElementAt(j).Name; link.NavigateUrl="~//Asp_forms/UserTable.aspx/?ID="+lista.ElementAt(j).Id.ToString(); link.Attributes.Add("style", "clear:both; margin-left:50px;"); Panel p = createPanel(); Panel2.Controls.Add(p); p.Controls.Add(createImage(lista.ElementAt(j).Image_url)); p.Controls.Add(link); p.Controls.Add(createPrfButton(lista.ElementAt(j).Id)); p.Controls.Add(createDelButton(lista.ElementAt(j).Id)); } } else if (RadioButtonList1.Text == "All Users") { List<User_Class> lista = new List<User_Class>(); if (Request.QueryString["cadena"] != null) { lista = filterFriends(Request.QueryString["cadena"], usuario_sesion.getAllUser()); } else { lista = usuario_sesion.getAllUser(); } HyperLink link = new HyperLink(); for (int j = 0; j < lista.Count(); j++) { link = new HyperLink(); link.Text = lista.ElementAt(j).Name; link.NavigateUrl = "~//Asp_forms/UserTable.aspx/?ID=" + lista.ElementAt(j).Id.ToString(); link.Attributes.Add("style", "clear:both; margin-left:50px;"); Panel p = createPanel(); Panel2.Controls.Add(p); p.Controls.Add(createImage(lista.ElementAt(j).Image_url)); p.Controls.Add(link); if (usuario_sesion.isFriend(lista.ElementAt(j).Id)) { p.Controls.Add(createPrfButton(lista.ElementAt(j).Id)); } if (!usuario_sesion.isFriend(lista.ElementAt(j).Id)) { p.Controls.Add(createAddButton(lista.ElementAt(j).Id)); } else { p.Controls.Add(createDelButton(lista.ElementAt(j).Id)); } } } } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void SendGroup(object sender, EventArgs e) { HttpCookie userCookie; userCookie = Request.Cookies["UserID"]; user = new User_Class(); user = user.getUser(userCookie.Value); user.getFriends(); Party_Class newParty = new Party_Class(); newParty.Name = TextBox1.Text; Label3.Text = ListBox2.Items.Count.ToString(); int indice=0; newParty.Users.Add(user); foreach (ListItem li in ListBox2.Items) { indice = Int32.Parse(li.Value); newParty.Users.Add(user.Friends[indice]); } if (ListBox2.Items.Count == 0 || TextBox1.Text == "") { Label3.Text = "Add users and set Name."; } else { if (newParty.createParty()) Response.Redirect("..//Asp_forms/Groups.aspx"); else Label3.Text = "error"; } }
public bool deleteUser(User_Class userm, int eventID) { bool deleted; SqlConnection con = new SqlConnection(connection); try { con.Open(); string sql = "DELETE FROM US_EV_REL WHERE UID = " + userm.Id + "AND EID=" + eventID; SqlCommand cmd = new SqlCommand(sql, con); cmd.ExecuteNonQuery(); deleted = true; } catch (Exception ex) { deleted = false; } finally { con.Close(); } return deleted; }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { int categoryid = int.Parse(Request.QueryString["id"]); Category_Class category = new Category_Class(); category = category.getCategoria(categoryid); CategoryLabel.Text = category.Nombre + " Notes"; Panel p = new Panel(); Label t = new Label(); Label f = new Label(); Image ie = new Image(); ie.ImageUrl = "../Images/editButton.png"; ImageButton imgbuttone = new ImageButton(); ImageButton imgbuttonb = new ImageButton(); Panel psub = new Panel(); Note_CAD notaTemp = new Note_CAD(); List<Note_Class> notes = new List<Note_Class>(); User_Class userTemp = new User_Class(); userTemp = userTemp.getUser(userCookie.Value); notes = notaTemp.notesCategory(userTemp.Id, category.Id); int i = notes.Count() - 1; if (notes.Count() == 0) { noCategories.Text = "No " + category.Nombre + " notes found. Start creating one up here!"; } else { while (i >= 0) { p = new Panel(); psub = new Panel(); t = new Label(); f = new Label(); imgbuttone = new ImageButton(); imgbuttonb = new ImageButton(); imgbuttone.ImageUrl = "../Images/editButton.png"; imgbuttone.PostBackUrl = "~/Asp_forms/Editnotes.aspx?ID=" + notes[i].Id.ToString(); imgbuttone.Width = 30; imgbuttone.ToolTip = "Edit"; imgbuttonb.ImageUrl = "../Images/deleteButton.png"; imgbuttonb.PostBackUrl = "~/Asp_forms/Deletenote.aspx?ID=" + notes[i].Id.ToString(); imgbuttonb.Width = 30; imgbuttonb.ToolTip = "Delete"; psub.CssClass = "default_panel"; psub.HorizontalAlign = HorizontalAlign.Right; psub.Controls.Add(imgbuttonb); psub.Controls.Add(imgbuttone); string id = notes[i].Id.ToString(); p.ID = "p" + id; p.CssClass = "postitnotes"; t.ID = "t" + id; f.ID = "f" + id; t.Text = notes[i].Text.ToString() + "<BR>"; p.Controls.Add(t); p.Controls.Add(f); p.Controls.Add(psub); Panelnota.Controls.Add(p); i--; } } } else { Response.Redirect("../Account/Login.aspx"); } } }
public List<User_Class> obtainUsers(int party_id) { SqlConnection con = new SqlConnection(connection); try { con.Open(); string sql = "SELECT * FROM US_PA_REL WHERE PID =" + party_id + ")"; SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { User_Class userTemp = new User_Class(); userTemp.Id = int.Parse(reader["ID"].ToString()); userTemp.Nick = reader["NICK"].ToString(); userTemp.Email = reader["EMAIL"].ToString(); userTemp.Name = reader["NAME"].ToString(); userTemp.Surname = reader["SURNAME"].ToString(); userTemp.Pass = reader["PASS"].ToString(); userTemp.Gender = char.Parse(reader["GENDER"].ToString()); userTemp.Entry_date = reader["ENTRY_DATE"].ToString(); userTemp.Birth_date = reader["BIRTH_DATE"].ToString(); userTemp.Image_url = reader["IMAGE_URL"].ToString(); myUsers.Add(userTemp); } } catch (Exception ex) { } finally { con.Close(); } return myUsers; }