Ejemplo n.º 1
0
        void buttonDelete_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show("Tem a certeza que quer eliminar esta atividade?",
                                                "Atividade removida!",
                                                MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                object[] values = { ActivityManager.GetCurrentActivity().Id };

                var statement =
                    "DELETE FROM `user_has_activity` WHERE `user_has_activity`.`Activity_id` = @0";
                Db.ExecuteSql(statement, values);

                statement = "DELETE FROM `activity` WHERE `activity`.`id` = @0";
                Db.ExecuteSql(statement, values);

                MessageBox.Show("Atividade eliminada");
                FormManager.GoBack();
            }
        }
Ejemplo n.º 2
0
        void ActivityProfile_form_Load(object sender, EventArgs e)
        {
            var activityId = ActivityManager.GetCurrentActivity().Id;
            var activity   = ActivityManager.CreateActivityId(activityId);

            FillUsersTable(ActivityManager.GetCurrentActivity(), AccountsManager.GetLoggedUser());

            activity_name.Text = activity.Name;
            category.Text      = activity.Category.Name;
            date.Text          = activity.Date.ToString("dd/MM/yyyy HH:mm");

            description.Text          = activity.Description;
            localization.Text         = activity.Location;
            labelActivityCreator.Text = "Criador da atividade\n" + activity.User.Email;

            description.MaximumSize = new Size(400, 0);
            description.AutoSize    = true;

            if (AccountsManager.GetLoggedUser() is Admin)
            {
                buttonParticipate.Visible = false;
            }

            else if (activity.User.Id != AccountsManager.GetLoggedUser().Id)
            {
                buttonDelete.Visible = false;
                buttonEdit.Visible   = false;
            }

            if (ActivityManager.GetCurrentActivity().Date < DateTime.Now)
            {
                buttonParticipate.Visible = false;
                buttonDelete.Visible      = false;
                buttonEdit.Visible        = false;
            }
        }