/// <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); }
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); }
/// <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> /// 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); }
/// <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> /// 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(); }