public void display_assigned_announcements() { html = new StringBuilder(); html.Append("<table border = '1' align='center'>"); html.Append("<tr>"); html.Append("<th>Id ogłoszenia</th><th>Dodane przez</th><th>Data dodania</th><th>Do kiedy</th><th>Typ pomocy</th><th>Status</th><th>Temat</th><th>Zawartość</th><th>od</th><th>do</th><th>Modyfikuj</th>"); html.Append("</tr>"); foreach (DataRow row in dt.Rows) { for (int i = 0; i < list_announcements.Count; i++) { if (list_announcements.ElementAt(i).id.Equals((int)row[1])) { id_a = i; } } html.Append("<tr>"); html.Append("<td>" + row[1] + "</td>"); html.Append("<td>" + db.getNickname_id(list_announcements.ElementAt(id_a).id_user) + "</td>"); html.Append("<td>" + list_announcements.ElementAt(id_a).post_date.ToString("yyyy-MM-dd") + "</td>"); html.Append("<td>"); if (list_announcements.ElementAt(id_a).type_help.Equals("Jednorazowa")) { html.Append("---"); } else { html.Append(list_announcements.ElementAt(id_a).end_date); } html.Append("</td>"); html.Append("<td>" + list_announcements.ElementAt(id_a).type_help + "</td>"); html.Append("<td>" + list_announcements.ElementAt(id_a).current_status + "</td>"); html.Append("<td>" + list_announcements.ElementAt(id_a).title + "</td>"); html.Append("<td>" + list_announcements.ElementAt(id_a).content + "</td>"); html.Append("<td>" + row[3] + "</td>"); html.Append("<td>" + row[4] + "</td>"); html.Append("<td>"); html.Append("<a href=\"Modify.aspx?id_a=" + row[1] + "&r=z\">Zrezygnuj </a>"); html.Append("</td>"); html.Append("</tr>"); } html.Append("</table>"); PlaceHolder1.Controls.Add(new Literal { Text = html.ToString() }); }
/// <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 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(); }
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(); }
/// <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(); }
/// <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(); }
/// <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(); }
/// <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(); }