/// <summary> /// The method that supports the registration process. /// It retrieves the data entered by the user from the form, then calls the InsertUser method by sending the downloaded data as method parameters. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Register_User(object sender, EventArgs e) { if (male.Checked) { sex = "male"; } else { sex = "female"; } if (volounteer.Checked) { type = "volounteer"; } else { type = "needy"; } db = new SQLDatabase(); db.Connect(); db.InsertUser(nickname.Value, inputPassword.Value, pesel.Value, inputEmail.Value, telephone.Value, name.Value, surname.Value, birthDate.Value, sex, type); db.Disconnect(); Response.Redirect("Home.aspx"); }
/// <summary> /// A method that displays the invitations the user has received /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (Session["id"] != null) { db = new SQLDatabase(); db.Connect(); list_invitations = db.ListInvitations(); html = new StringBuilder(); html.Append("<table border = '1' align='center'>"); html.Append("<tr>"); html.Append("<th>Data wysłania</th><th>Wysłane przez</th><th>Temat</th><th>Zawartość</th>"); html.Append("</tr>"); for (int i = 0; i < list_invitations.Count; i++) { if (list_invitations.ElementAt(i).id_receiver.Equals(db.getId((string)Session["id"]))) { html.Append("<tr>"); html.Append("<td>" + list_invitations.ElementAt(i).post_date + "</td>"); html.Append("<td>" + db.getNickname_id(list_invitations.ElementAt(i).id_sender) + "</td>"); html.Append("<td>" + list_invitations.ElementAt(i).title + "</td>"); html.Append("<td>" + list_invitations.ElementAt(i).content + "</td>"); html.Append("<td><a href=\"Details.aspx?id_e=" + list_invitations.ElementAt(i).id_event + "\">Szczegóły wydarzenia</a></td>"); html.Append("</tr>"); } } html.Append("</table>"); html.Append("<br/><br/>"); PlaceHolder1.Controls.Add(new Literal { Text = html.ToString() }); db.Disconnect(); } }
protected List <Event_count> count_joined_user() { db = new SQLDatabase(); db.Connect(); list_events = db.ListEvents(); List <Event_count> ranking_amount_events2 = new List <Event_count>(); for (int i = 0; i < list_events.Count; i++) { ranking_amount_events2.Add(new Event_count(list_events.ElementAt(i).id, db.Count_Events(list_event_ranking, list_events.ElementAt(i).id))); } ranking_amount_events2.Sort((Event_count x, Event_count y) => y.amount.CompareTo(x.amount)); /* for (int i = 0; i < ranking_amount_events2.Count; i++) * { * for (int j = i; j < ranking_amount_events2.Count; j++) * { * if (ranking_amount_events2.ElementAt(j).amount > ranking_amount_events2.ElementAt(i).amount) * { * Event_count temp = ranking_amount_events2.ElementAt(i); * ranking_amount_events2.Insert(i, ranking_amount_events2.ElementAt(j)); * ranking_amount_events2.Insert(j, temp); * } * } * } */ // db.Disconnect(); return(ranking_amount_events2); }
public List <int> ListInvitations_User() { List <int> list_events_id = ListEventsFromAnnouncement_User(); db = new SQLDatabase(); db.Connect(); List <Invitation> list_invitations = db.ListInvitations(); List <int> list_invitations_id = new List <int>(); for (int i = 0; i < list_events_id.Count; i++) { for (int j = 0; j < list_invitations.Count; j++) { if (list_events_id.ElementAt(i) == list_invitations.ElementAt(j).id_event) { list_invitations_id.Add(list_invitations.ElementAt(j).id); } } } for (int i = 0; i < list_invitations.Count; i++) { if (id == list_invitations.ElementAt(i).id_sender) { list_invitations_id.Add(list_invitations.ElementAt(i).id); } } db.Disconnect(); return(list_invitations_id); }
/// <summary> /// lista identyfikator wydarzen, ktore powstaly na podstawie ogloszen dodanych przez uzytkownika /// </summary> /// <returns></returns> public List <int> ListEventsFromAnnouncement_User() { List <int> list_announcements_id = ListAnnouncements_User(); List <int> list_events_id2 = ListEvents_User(); //lista identyfikatorow wydarzen, ktore dodal uzytkownik plus list_events_id db = new SQLDatabase(); db.Connect(); List <Event> list_events = db.ListEvents(); List <int> list_events_id = new List <int>(); //lista identyfikatorow wydarzen, ktore powstaly na podstawie ogloszen dodanych przez uzytkownika for (int j = 0; j < list_announcements_id.Count; j++) { for (int i = 0; i < list_events.Count; i++) { if (list_announcements_id.ElementAt(j) == list_events.ElementAt(i).id_announcement) { list_events_id.Add(list_events.ElementAt(i).id); } } } for (int i = 0; i < list_events_id.Count; i++) { list_events_id2.Add(list_events_id.ElementAt(i)); } db.Disconnect(); return(list_events_id2); }
/// <summary> /// Metoda obsługuje dołączenie wolontariuszy do wydarzeń. /// Wywołuje metodę JoinToEvent. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Join_To_Event(object sender, EventArgs e) { db = new SQLDatabase(); db.Connect(); db.JoinToEvent(id_e, db.getId((string)Session["id"])); db.Disconnect(); }
/// <summary> /// Metoda obsługująca zgłaszanie wolontariusza do wykonania ogłoszenia potrzebującego. Wywołuję /// metodę AssignToAnnouncement, przesyła pobrane informacje z formularza wypełnionego /// przez użytkownika oraz numer wybranego ogłoszenia. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Zglos_Sie(object sender, EventArgs e) { db = new SQLDatabase(); db.Connect(); db.AssignToAnnouncement(id_a, db.getId((string)Session["id"]), from.Text, to.Text); db.Disconnect(); }
protected void Reset_Password(int id_u) { db = new SQLDatabase(); db.Connect(); db.ResetPassword(id_u); Send_Email(db.getEmail(id_u), db.getNickname_id(id_u)); db.Disconnect(); }
/// <summary> /// The method is responsible for handling the subsystem of adding advertisements. Retrieves information from the form entered by the user. /// Then it calls the InsertAnnouncement method by sending the previously retrieved information as method parameters. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Add_Announcement(object sender, EventArgs e) { db = new SQLDatabase(); db.Connect(); db.InsertAnnouncement(db.getId((string)Session["id"]), end_date.Value, one.Checked, subject.Value, content.Value); Response.Redirect("MyActivities.aspx"); db.Disconnect(); }
protected void Edit_Data(object sender, EventArgs e) { db = new SQLDatabase(); db.Connect(); list_users = db.ListUsers(); string sex = ""; string type = ""; if (!male.Checked && !female.Checked) { sex = list_users.ElementAt(id_i).sex; } else { if (male.Checked) { sex = "male"; } else { sex = "female"; } } if (!volounteer.Checked && !needy.Checked) { type = list_users.ElementAt(id_i).type; } else { if (volounteer.Checked) { type = "volounteer"; } else { type = "needy"; } } if (birthDate.Value == "") { birthDate.Value = list_users.ElementAt(id_i).birth_date.ToString("yyyy-MM-dd"); } db.EditAccount(id, nickname.Value, pesel.Value, inputEmail.Value, telephone.Value, name.Value, surname.Value, birthDate.Value, sex, type); if (!inputEmail.Value.Equals(email)) { Session.RemoveAll(); Response.Redirect("Login.aspx"); } else { Response.Redirect("MyAccount.aspx"); } db.Disconnect(); }
/// <summary> /// This method is responsible for making a connection to database, trying to put the edited data into the database and returning to the events list. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Edit_Event(object sender, EventArgs e) { db = new SQLDatabase(); db.Connect(); if (Request.QueryString["id_e"] != null) { int id_e = int.Parse(Request.QueryString["id_e"]); db.EditEvent(id_e, due_date.Value, title.Value, content.Value); Response.Redirect("Events.aspx"); } db.Disconnect(); }
/// <summary> /// The method that supports editing the adverts created. /// It retrieves data from the form by the user, then calls the EditAnnouncement method, /// sending these values as method parameters. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Edit_Announcement(object sender, EventArgs e) { db = new SQLDatabase(); db.Connect(); int id_a; if (Request.QueryString["id_a"] != null) { id_a = int.Parse(Request.QueryString["id_a"]); db.EditAnnouncement(id_a, end_date.Value, one.Checked, subject.Value, content.Value); } Response.Redirect("MyActivities.aspx"); db.Disconnect(); }
protected void Page_Load(object sender, EventArgs e) { db = new SQLDatabase(); html = new StringBuilder(); db.Connect(); list_event_ranking = db.RankingEvents(); ranking_amount_events = count_joined_user(); html.Append("<table border = '1' align='center'>"); html.Append("<tr>"); html.Append("<th>Ilość osób biorących udział</th><th>Dodane przez</th><th>Data dodania</th><th>Data wydarzenia</th><th>Powiązane z ogłoszeniem potrzebującego</th><th>Temat</th>"); html.Append("</tr>"); int k = 0; for (int i = 0; i < Math.Min(5, ranking_amount_events.Count); i++) { for (int j = 0; j < list_events.Count; j++) { if (ranking_amount_events.ElementAt(i).id == list_events.ElementAt(j).id) { k = j; } } html.Append("<tr>"); html.Append("<td>" + ranking_amount_events.ElementAt(i).amount + "</td>"); html.Append("<td>" + db.getNickname_id(list_events.ElementAt(k).id_user) + "</td>"); html.Append("<td>" + list_events.ElementAt(k).post_date.ToString("yyyy-MM-dd") + "</td>"); html.Append("<td>" + list_events.ElementAt(k).due_date.ToString("yyyy-MM-dd") + "</td>"); if (list_events.ElementAt(k).id_announcement.Equals(null)) { html.Append("<td>Nie</td>"); } else { html.Append("<td>Tak</td>"); } html.Append("<td>" + list_events.ElementAt(k).title + "</td>"); html.Append("<td>"); html.Append("<a href=\"Details.aspx?id_e=" + list_events.ElementAt(k).id + "\">Szczegóły</a>"); html.Append("</td>"); html.Append("</tr>"); } html.Append("</table>"); html.Append("<br/><br/>"); PlaceHolder.Controls.Add(new Literal { Text = html.ToString() }); db.Disconnect(); }
protected void Form_Data(object sender, EventArgs e) { data_form.Visible = true; password_form.Visible = false; db = new SQLDatabase(); db.Connect(); list_users = db.ListUsers(); nickname.Value = list_users.ElementAt(id_i).nickname; inputEmail.Value = list_users.ElementAt(id_i).email; name.Value = list_users.ElementAt(id_i).name; surname.Value = list_users.ElementAt(id_i).surname; telephone.Value = list_users.ElementAt(id_i).telephone; pesel.Value = list_users.ElementAt(id_i).pesel; db.Disconnect(); }
/// <summary> /// A method that supports the subsystem to invite volunteers to the parish. Invokes the SendInvitation method. /// Parameters that are entered by the user are the subject and contents of the invitation, /// then are sent as parameters of the SendIvitation method /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Send_Invitation(object sender, EventArgs e) { db = new SQLDatabase(); db.Connect(); if (Request.QueryString["id_u"] != null) { id_user = int.Parse(Request.QueryString["id_u"]); } if (Request.QueryString["id_e"] != null) { id_event = int.Parse(Request.QueryString["id_e"]); } db.SendInvitation(id_event, db.getId((string)Session["id"]), id_user, title.Value, content.Value); db.Disconnect(); }
/// <summary> /// The method responsible for handling the subsystem of adding events. Retrieves information from the form entered by the user. /// Then it calls the InsertEvents method to send the downloaded values as method parameters. /// The event can also be created on the basis of the announcement, the method checks if the announcement number is sent using QueryString. /// If so, the value of the advertisement number is sent. If number -1 is not sent. /// In the InsertEvents method there is further support for the value of the advertisement number. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Add_Event(object sender, EventArgs e) { SQLDatabase db = new SQLDatabase(); int id_a = -1;; if (Request.QueryString["id_a"] != null) { id_a = int.Parse(Request.QueryString["id_a"]); } db.Connect(); db.InstertEvents(id_a, db.getId((string)Session["id"]), due_date.Value, title.Value, content.Value); db.Disconnect(); Response.Redirect("Events.aspx"); }
/// <summary> /// This method is responsible for getting data from the database, putting them into a StringBuilder and appending them to the Events.aspx page. /// </summary> /// <param name="sender">Parameter containing references to the control that raised the event</param> /// <param name="e">Parameter responsible for storing event data</param> protected void Page_Load(object sender, EventArgs e) { html = new StringBuilder(); db = new SQLDatabase(); db.Connect(); list_events = db.ListEvents(); if (Session["id"] != null) { if (db.getType_User(db.getId((string)Session["id"])) == "volounteer" || db.getType_User(db.getId((string)Session["id"])) == "administrator") { add_event.Visible = true; } } html.Append("<table border = '1' align='center'>"); html.Append("<tr>"); html.Append("<th>Dodane przez</th><th>Data dodania</th><th>Data wydarzenia</th><th>Powiązane z ogłoszeniem potrzebującego</th><th>Temat</th>"); html.Append("</tr>"); for (int i = 0; i < list_events.Count; i++) { html.Append("<tr>"); html.Append("<td>" + db.getNickname_id(list_events.ElementAt(i).id_user) + "</td>"); html.Append("<td>" + list_events.ElementAt(i).post_date.ToString("yyyy-MM-dd") + "</td>"); html.Append("<td>" + list_events.ElementAt(i).due_date.ToString("yyyy-MM-dd") + "</td>"); if (list_events.ElementAt(i).id_announcement.Equals(null)) { html.Append("<td>Nie</td>"); } else { html.Append("<td>Tak</td>"); } html.Append("<td>" + list_events.ElementAt(i).title + "</td>"); html.Append("<td>"); html.Append("<a href=\"Details.aspx?id_e=" + list_events.ElementAt(i).id + "\">Szczegóły</a>"); html.Append("</td>"); html.Append("</tr>"); } html.Append("</table>"); html.Append("<br/><br/>"); PlaceHolder1.Controls.Add(new Literal { Text = html.ToString() }); db.Disconnect(); }
protected void Edit_Password(object sender, EventArgs e) { password_form.Visible = true; data_form.Visible = false; if (password != null && new_password != null) { db = new SQLDatabase(); db.Connect(); if (pass.Equals(password.Value)) { db.EditPassword(id, new_password.Value); Session.RemoveAll(); Response.Redirect("Login.aspx"); } db.Disconnect(); } }
/// <summary> /// The method that supports the login subsystem. /// It retrieves the entered email and password from the form, then calls the getlogin method, /// which returns a value of type SqlDataReader. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { db = new SQLDatabase(); db.Connect(); if (db.getLogin(inputEmail.Value, inputPassword.Value).Read()) { Session["id"] = inputEmail.Value; Response.Redirect("Home.aspx"); } else { Response.Write("Nieudana próba logowania!!!"); } db.Disconnect(); }
protected void Delete_Account(object sender, EventArgs e) { List <int> list_announcement_id = ListAnnouncements_User(); List <int> list_events_id = ListEventsFromAnnouncement_User(); List <int> list_invitations_id = ListInvitations_User(); db = new SQLDatabase(); db.Connect(); db.Delete_Users_Assigned_Announcement_id_user(id); for (int i = 0; i < list_announcement_id.Count; i++) { db.Delete_Users_Assigned_Announcement(list_announcement_id.ElementAt(i)); } for (int i = 0; i < list_events_id.Count; i++) { db.Delete_Users_Joined_Event(list_events_id.ElementAt(i)); } db.Delete_Users_Joined_Event_id_user(id); for (int i = 0; i < list_events_id.Count; i++) { db.Delete_Users_Joined_Event(list_events_id.ElementAt(i)); } for (int i = 0; i < list_invitations_id.Count; i++) { db.DeleteInvitation_id(list_invitations_id.ElementAt(i)); } for (int i = 0; i < list_events_id.Count; i++) { db.DeleteEvent(list_events_id.ElementAt(i)); } for (int i = 0; i < list_announcement_id.Count; i++) { db.DeleteAnnouncement(list_announcement_id.ElementAt(i)); } db.DeleteUser(id); Session.RemoveAll(); Response.Redirect("Home.aspx"); db.Disconnect(); }
protected void Page_Load(object sender, EventArgs e) { this.countMe(); DataSet tmpDs = new DataSet(); tmpDs.ReadXml(Server.MapPath("~/res/xml/counter.xml")); visitcounter.Text = tmpDs.Tables[0].Rows[0]["hitcounter"].ToString(); //CHECK COOKIES CONSENT if (Request.Cookies["CookieConsent"] != null) { cookieConsent.Visible = false; } if (Session["id"] == null) { login.Visible = true; logout.Visible = false; account.Visible = false; list_users.Visible = false; newsletter.Visible = false; my_activities.Visible = false; invitations.Visible = false; } else { db = new SQLDatabase(); db.Connect(); login.Visible = false; logout.Visible = true; account.Visible = true; reg.Visible = false; list_users.Visible = false; newsletter.Visible = false; my_activities.Visible = true; invitations.Visible = true; hello_user.Text = "Hello " + db.getNickname_email((string)Session["id"]); if (db.getType_User(db.getId((string)Session["id"])).Equals("administrator")) { list_users.Visible = true; newsletter.Visible = true; my_activities.Visible = false; invitations.Visible = false; } db.Disconnect(); } }
/// <summary> /// The method that supports the display of announcements and events that the logged-on user has added and /// the declarations he has declared his help and events he takes part in. /// The method also supports the option of resigning, editing and deleting announcements and events. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { db = new SQLDatabase(); db.Connect(); list_announcements = db.ListAnnouncements(); list_events = db.ListEvents(); dt = db.getMyActivities(db.getId((string)Session["id"])); dt_events = db.getMyActivitiesEvents(db.getId((string)Session["id"])); if (db.getType_User(db.getId((string)Session["id"])) == "volounteer") { display_assigned_announcements(); display_created_events(); display_joined_events(); } display_created_announcements(); db.Disconnect(); }
/// <summary> /// lista identyfikatorow wydarzen, które dodal uzytkownik /// </summary> /// <returns></returns> public List <int> ListEvents_User() { db = new SQLDatabase(); db.Connect(); List <Event> list = db.ListEvents(); List <int> list_id = new List <int>(); for (int i = 0; i < list.Count; i++) { if (id == list.ElementAt(i).id_user) { list_id.Add(list.ElementAt(i).id); } } db.Disconnect(); return(list_id); }
protected void Prepare_Email(object sender, EventArgs e) { db = new SQLDatabase(); db.Connect(); List <String> lists_email = new List <string>(); list_users = db.ListUsers(); if (volounteers.Checked) { for (int i = 0; i < list_users.Count(); i++) { if (list_users.ElementAt(i).type.Equals("volounteer")) { lists_email.Add(list_users.ElementAt(i).email); } } } if (needies.Checked) { for (int i = 0; i < list_users.Count(); i++) { if (list_users.ElementAt(i).type.Equals("needy")) { lists_email.Add(list_users.ElementAt(i).email); } } } if (all.Checked) { for (int i = 0; i < list_users.Count(); i++) { lists_email.Add(list_users.ElementAt(i).email); } } for (int i = 0; i < lists_email.Count(); i++) { Send_Email(lists_email.ElementAt(i), db.getNickname_email(lists_email.ElementAt(i)), subject.Value, TextArea1.Text); } db.Disconnect(); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id_e"] != null) { id_e = int.Parse(Request.QueryString["id_e"]); } db = new SQLDatabase(); html = new StringBuilder(); db.Connect(); list_users = db.ListUsers(); html.Append("<table border = '1' align='center'>"); html.Append("<tr>"); html.Append("<th>Id</th><th>Imię</th><th>Nazwisko</th><th>Nickname</th><th>E-mail</th><th>Płeć</th><th>Telefon</th>"); html.Append("</tr>"); for (int i = 0; i < list_users.Count; i++) { if (list_users.ElementAt(i).type.Equals("volounteer")) { html.Append("<tr>"); html.Append("<td>" + list_users.ElementAt(i).id + "</td>"); html.Append("<td>" + list_users.ElementAt(i).name + "</td>"); html.Append("<td>" + list_users.ElementAt(i).surname + "</td>"); html.Append("<td>" + list_users.ElementAt(i).nickname + "</td>"); html.Append("<td>" + list_users.ElementAt(i).email + "</td>"); html.Append("<td>" + list_users.ElementAt(i).sex + "</td>"); html.Append("<td>" + list_users.ElementAt(i).telephone + "</td>"); html.Append("<td><a href=\"Invite.aspx?id_u=" + list_users.ElementAt(i).id + "&id_e=" + id_e + "\">Zaproś</a></td>"); html.Append("</tr>"); } } html.Append("</table>"); html.Append("<br/><br/>"); PlaceHolder1.Controls.Add(new Literal { Text = html.ToString() }); db.Disconnect(); }
/// <summary> /// The method responsible for displaying all advertisements based on the list of Announcement objects. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { db = new SQLDatabase(); db.Connect(); list_announcements = db.ListAnnouncements(); html = new StringBuilder(); if (Session["id"] == null) { add_announcement.Visible = false; } else { add_announcement.Visible = true; } html.Append("<table border = '1' align='center'> "); html.Append("<tr>"); html.Append("<th>Data dodania</th><th>Stworzone przez</th><th>Dodane przez</th><th>Status</th><th>Temat</th>"); html.Append("</tr>"); for (int i = 0; i < list_announcements.Count; i++) { html.Append("<tr>"); html.Append("<td>" + list_announcements.ElementAt(i).post_date.ToString("yyyy-MM-dd") + "</td>"); html.Append("<td>" + db.getNickname_id(list_announcements.ElementAt(i).id_user) + "</td>"); html.Append("<td>" + db.getType_User(list_announcements.ElementAt(i).id_user).Replace("needy", "Potrzebujący").Replace("volounteer", "Wolontariusz") + "</td>"); html.Append("<td>" + list_announcements.ElementAt(i).current_status + "</td>"); html.Append("<td>" + list_announcements.ElementAt(i).title + "</td>"); html.Append("<td><a href=\"Details.aspx?id_a=" + list_announcements.ElementAt(i).id + "\">Szczegóły</a></td>"); html.Append("</tr>"); } html.Append("</table>"); PlaceHolder1.Controls.Add(new Literal { Text = html.ToString() }); db.Disconnect(); }
protected void Page_Load(object sender, EventArgs e) { db = new SQLDatabase(); html = new StringBuilder(); db.Connect(); list_users = db.ListUsers(); id = db.getId((string)Session["id"]); html.Append("<table border = '1' align='center'>"); for (int i = 0; i < list_users.Count; i++) { if (list_users.ElementAt(i).id.Equals(id)) { html.Append("<tr><td>Id</td> <td>" + list_users.ElementAt(i).id + "</td></tr>"); html.Append("<tr><td>Imię</td> <td>" + list_users.ElementAt(i).name + "</td></tr>"); html.Append("<tr><td>Nazwisko</td> <td>" + list_users.ElementAt(i).surname + "</td></tr>"); html.Append("<tr><td>Nickname</td> <td>" + list_users.ElementAt(i).nickname + "</td></tr>"); html.Append("<tr><td>E-mail</td> <td>" + list_users.ElementAt(i).email + "</td></tr>"); html.Append("<tr><td>Płeć</td> <td>" + list_users.ElementAt(i).sex + "</td></tr>"); html.Append("<tr><td>Telefon</td> <td>" + list_users.ElementAt(i).telephone + "</td></tr>"); html.Append("<tr><td>Data urodzenia</td> <td>" + list_users.ElementAt(i).birth_date.ToString("yyyy-MM-dd") + "</td></tr>"); html.Append("<tr><td>Typ użytkownika</td> <td>" + list_users.ElementAt(i).type + "</td></tr>"); html.Append("<tr><td>Pesel</td> <td>" + list_users.ElementAt(i).pesel + "</td></tr>"); email = list_users.ElementAt(i).email; pass = list_users.ElementAt(i).password; id_i = i; } } html.Append("</table>"); html.Append("<br/><br/>"); PlaceHolder1.Controls.Add(new Literal { Text = html.ToString() }); db.Disconnect(); }
/// <summary> /// The method responsible for displaying the details of the selected event or announcement. /// The number of the selected advertisement or event is sent using QueryString. /// The method also displays an advertisement based on which the event was created (but it did not have to) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { typ = ""; if (Request.QueryString["id_a"] != null) { id_a = int.Parse(Request.QueryString["id_a"]); } if (Request.QueryString["id_e"] != null) { id_e = int.Parse(Request.QueryString["id_e"]); } wielorazowe = false; db = new SQLDatabase(); db.Connect(); list_announcements = db.ListAnnouncements(); list_events = db.ListEvents(); html = new StringBuilder(); if (Request.QueryString["id_a"] != null) { html.Append("<table border = '1' align='center'>"); html.Append("<tr>"); html.Append("<th>Dodane przez</th><th>Nickname</th><th>Data dodania</th><th>Do kiedy</th><th>Typ pomocy</th><th>Status</th><th>Temat</th><th>Zawartość</th>"); html.Append("</tr>"); for (int i = 0; i < list_announcements.Count; i++) { if (id_a == list_announcements.ElementAt(i).id) { typ = db.getType_User(list_announcements.ElementAt(i).id_user); html.Append("<tr>"); html.Append("<td>" + typ + "</td>"); html.Append("<td>" + db.getNickname_id(list_announcements.ElementAt(i).id_user) + "</td>"); html.Append("<td>" + list_announcements.ElementAt(i).post_date.ToString("yyyy-MM-dd") + "</td>"); html.Append("<td>"); if (list_announcements.ElementAt(i).type_help.Equals("Jednorazowa")) { html.Append("---"); } else { wielorazowe = true; html.Append(list_announcements.ElementAt(i).end_date); } html.Append("</td>"); html.Append("<td>" + list_announcements.ElementAt(i).type_help + "</td>"); html.Append("<td>" + list_announcements.ElementAt(i).current_status + "</td>"); html.Append("<td>" + list_announcements.ElementAt(i).title + "</td>"); html.Append("<td>" + list_announcements.ElementAt(i).content + "</td>"); if (db.getType_User(db.getId((string)Session["id"])).Equals("administrator")) { html.Append("<td><a href=\"Modify.aspx?id_a=" + list_announcements.ElementAt(i).id + "&id_u=" + list_announcements.ElementAt(i).id_user + "&r=u" + "\">Usuń</a></td>"); } html.Append("</tr>"); } } html.Append("</table>"); html.Append("<br/><br/>"); } if (Session["id"] != null && Request.QueryString["id_a"] != null) { if (db.getType_User(db.getId((string)Session["id"])) == "volounteer" && typ == "needy") { zglos.Visible = true; html.Append("Zgłoś się do pomocy!"); if (wielorazowe) { html.Append("Potrzebna jest pomoc przez kilka dni, określ godziny, które Ci pasują: "); from.Visible = true; to.Visible = true; } html.Append("Możesz również utworzyć wydarzenie dla tego ogłoszenia: "); create.Visible = true; } } if (Request.QueryString["id_e"] != null) { for (int i = 0; i < list_events.Count; i++) { if (id_e == list_events.ElementAt(i).id) { html.Append("</br>Szczegóły wydarzenia: </br>"); html.Append("<table border = '1' align='center'>"); html.Append("<tr>"); html.Append("<th>Utworzone przez</th><th>Data dodania</th><th>Data wydarzenia</th><th>Powiązanie z ogłoszeniem</th><th>Temat</th><th>Zawartość</th>"); html.Append("</tr>"); typ = db.getType_User(list_events.ElementAt(i).id_user); html.Append("<tr>"); html.Append("<td>" + db.getNickname_id(list_events.ElementAt(i).id_user) + "</td>"); html.Append("<td>" + list_events.ElementAt(i).post_date.ToString("yyyy-MM-dd") + "</td>"); html.Append("<td>" + list_events.ElementAt(i).due_date.ToString("yyyy-MM-dd") + "</td>"); if (list_events.ElementAt(i).id_announcement.Equals(null)) { html.Append("<td>Nie</td>"); } else { html.Append("<td>Tak</td>"); } html.Append("<td>" + list_events.ElementAt(i).title + "</td>"); html.Append("<td>" + list_events.ElementAt(i).content + "</td>"); if (db.getType_User(db.getId((string)Session["id"])).Equals("administrator")) { html.Append("<td><a href=\"Modify.aspx?id_e=" + list_events.ElementAt(i).id + "&id_u=" + list_events.ElementAt(i).id_user + "&r=u" + "\">Usuń</a></td>"); } html.Append("</tr>"); html.Append("</table>"); html.Append("<br/><br/>"); if (!list_events.ElementAt(i).id_announcement.Equals(null)) { int id_anno = db.getIdAnnouncement((int)list_events.ElementAt(i).id_announcement); html.Append("</br>Ogłoszenie, do którego zostało utworzone powyższe wydarzenie: </br>"); html.Append("<table border = '1'>"); html.Append("<tr>"); html.Append("<th>Utworzone przez</th><th>Data dodania</th><th>Do kiedy</th><th>Typ pomocy</th><th>Status</th><th>Temat</th><th>Zawartość</th>"); html.Append("</tr>"); html.Append("<tr>"); html.Append("<td>" + db.getNickname_id(list_announcements.ElementAt(id_anno).id_user) + "</td>"); html.Append("<td>" + list_announcements.ElementAt(id_anno).post_date.ToString("yyyy-MM-dd") + "</td>"); html.Append("<td>"); if (list_announcements.ElementAt(id_anno).type_help.Equals("Jednorazowa")) { html.Append("---"); } else { html.Append(list_announcements.ElementAt(id_anno).end_date); } html.Append("</td>"); html.Append("<td>" + list_announcements.ElementAt(id_anno).type_help + "</td>"); html.Append("<td>" + list_announcements.ElementAt(id_anno).current_status + "</td>"); html.Append("<td>" + list_announcements.ElementAt(id_anno).title + "</td>"); html.Append("<td>" + list_announcements.ElementAt(id_anno).content + "</td>"); html.Append("</tr>"); html.Append("</table>"); } } } } if (Session["id"] != null && Request.QueryString["id_e"] != null) { if (db.getType_User(db.getId((string)Session["id"])) == "volounteer") { html.Append("Możesz dołączyć do wydarzenia:"); join.Visible = true; html.Append("Możesz zaprosić innego wolontariusza do wzięcia udziału w tym wydarzeniu:"); select.Visible = true; } } PlaceHolder.Controls.Add(new Literal { Text = html.ToString() }); db.Disconnect(); }
/// <summary> /// The method that supports the possibility of resignation from the performance of the announcement /// or from taking part in the event. /// It also supports deleting announcements or events that the logged-in user has created. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { db = new SQLDatabase(); db.Connect(); if (Request.QueryString["id_a"] != null) { id_a = int.Parse(Request.QueryString["id_a"]); } if (Request.QueryString["id_e"] != null) { id_e = int.Parse(Request.QueryString["id_e"]); } if (Request.QueryString["id_u"] != null) { id_u = int.Parse(Request.QueryString["id_u"]); } opcja = 0; if (Request.QueryString["r"] != null) { if (Request.QueryString["r"].Equals("z")) { opcja = 1; } if (Request.QueryString["r"].Equals("u")) { opcja = 2; } } if (opcja == 1) { if (Request.QueryString["id_a"] != null) { db.DeclineFromAnnouncement(id_a, db.getId((string)Session["id"])); } if (Request.QueryString["id_e"] != null) { db.DeclineFromEvent(id_e, db.getId((string)Session["id"])); } Response.Redirect("MyActivities.aspx"); } if (opcja == 2) { if (Request.QueryString["id_e"] != null) { if (Request.QueryString["id_u"] != null) { Send_Email(db.getEmail(id_u), db.getNickname_id(id_u), true, db.getTitleEvent(id_e)); } db.Delete_Users_Joined_Event(id_e); db.DeleteInvitation(id_e); db.DeleteEvent(id_e); } if (Request.QueryString["id_a"] != null) { if (Request.QueryString["id_u"] != null) { Send_Email(db.getEmail(id_u), db.getNickname_id(id_u), false, db.getTitleAnnouncement(id_a)); } List <int?> list_events_id = db.getIdEvents(id_a); for (int i = 0; i < list_events_id.Count; i++) { db.Delete_Users_Joined_Event((int)list_events_id.ElementAt(i)); db.DeleteInvitation((int)list_events_id.ElementAt(i)); } db.DeleteEvent_id_a(id_a); db.Delete_Users_Assigned_Announcement(id_a); db.DeleteAnnouncement(id_a); } if (Request.QueryString["id_u"] == null) { Response.Redirect("MyActivities.aspx"); } } db.Disconnect(); }