コード例 #1
0
        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();
        }
コード例 #2
0
ファイル: Modify.aspx.cs プロジェクト: Surewen/Wolontariat
        /// <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();
        }