コード例 #1
0
        private void btnDeleteActivity_Click(object sender, EventArgs e)
        {
            SomerenLogic.Activity_Service activity_Service = new Activity_Service();

            // check for empty field
            if (String.IsNullOrEmpty(txtDeleteId.Text))
            {
                MessageBox.Show("No id was given!");
                return; // when field is empty, display message and return
            }

            // get value from textbox
            int id = int.Parse(txtDeleteId.Text);

            // validate the users choice by asking via a messagebox
            string            message = "Are you sure you want to delete this activity?";
            string            caption = "Deleting an activity";
            MessageBoxButtons buttons = MessageBoxButtons.YesNo; // yes and no button
            DialogResult      result;

            // get the result from the messagebox
            result = MessageBox.Show(this, message, caption, buttons);

            // when user says yes, delete the acticvity
            if (result == DialogResult.Yes)
            {
                activity_Service.DeleteActivity(id);
            }
        }
コード例 #2
0
        private void btnRemoveActivity_Click(object sender, EventArgs e)
        {
            if (listViewActivities.SelectedItems.Count < 1)
            {
                MessageBox.Show("select an activity");
            }

            Activity activity = listViewActivities.SelectedItems[0].Tag as Activity;

            activityService.DeleteActivity(activity);
            MessageBox.Show("Record removal is sucessful");

            //page  refresh
            RefreshActivityPanel();
        }
コード例 #3
0
        private void btn_Remove_Activity_Click(object sender, EventArgs e)
        {
            var      selectedItem     = listViewActivities.SelectedItems[0];
            Activity selectedActivity = activities.Where(t => t.countStudents == int.Parse(selectedItem.Text)).FirstOrDefault();

            DialogResult dr = MessageBox.Show("Do you want to remove this activity?", "Removing activity", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                Activity_Service actService = new Activity_Service();
                actService.DeleteActivity(selectedActivity.Id);
            }
            btn_Edit_Activities.Enabled = false;
            btn_Add_Activity.Enabled    = false;
        }
        //Code voor de verwijderknop in en van de activiteiten in de activiteitenlijst
        private void Btnverwijderen_Click(object sender, EventArgs e)
        {
            string message = "Weet u zeker dat u deze activiteit wilt verwijderen?";
            string caption = "Activiteit verwijderen";
            var    result  = MessageBox.Show(message, caption, MessageBoxButtons.YesNo);

            if (result == DialogResult.No)
            {
                ShowPanel("Activities");
            }
            else if (result == DialogResult.Yes)
            {
                Activity_Service activityService = new Activity_Service();

                int activityNumber = int.Parse(Txtactiviteitnr.Text);

                activityService.DeleteActivity(activityNumber);
            }

            ShowPanel("Activities");
        }