//Code voor de wijzigingsknop in en van de activiteiten in de activiteitenlijst
        private void Btnwijzigen_Click(object sender, EventArgs e)
        {
            Activity_Service activityService = new Activity_Service();

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

            string NewDescription = Txtactiviteitomschrijving.Text;

            DateTime NewStartTime = EditOrDeleteCalendar.SelectionRange.Start;

            int NewNumberofStudents = int.Parse(Txtaantalstudenten.Text);

            int NewNumberofLecturers = int.Parse(Txtaantaldocenten.Text);

            if (NewDescription != "" && NewStartTime != null && NewNumberofStudents != 0 && NewNumberofLecturers != 0)
            {
                activityService.EditActivity(activityNumber, NewDescription, NewStartTime, NewNumberofStudents, NewNumberofLecturers);
            }
            else
            {
                lbl_ActivityErrorMessage.Text = "Niet alle velden zijn volledig of correct ingevuld!";
            }

            ShowPanel("Activities");
        }
Beispiel #2
0
        private void buttonActivitySave_Click(object sender, EventArgs e)
        {
            if (textBoxActivityDescription.Text != null && textBoxActivityName.Text != null && textBoxActivityStudents.Text != null && textBoxActivitySupervisors.Text != null)
            {
                Activity_Service activitydb = new Activity_Service();
                if (groupBoxEdit.Text == "Add")
                {
                    if (listViewActivities.Items.Contains(listViewActivities.FindItemWithText(textBoxActivityName.Text)))
                    {
                        MessageBox.Show("This Activity Already Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    Activity a = new Activity
                    {
                        ID                  = -1,
                        Name                = textBoxActivityName.Text,
                        Description         = textBoxActivityDescription.Text,
                        NumberOfStudents    = int.Parse(textBoxActivityStudents.Text),
                        NumberOfSupervisors = int.Parse(textBoxActivitySupervisors.Text),
                    };
                    activitydb.AddActivity(a);
                }
                else if (groupBoxEdit.Text == "Edit")
                {
                    ListViewItem item = listViewActivities.SelectedItems[0];
                    Activity     a    = new Activity
                    {
                        ID                  = int.Parse(item.SubItems[0].Text),
                        Name                = textBoxActivityName.Text,
                        Description         = textBoxActivityDescription.Text,
                        NumberOfStudents    = int.Parse(textBoxActivityStudents.Text),
                        NumberOfSupervisors = int.Parse(textBoxActivitySupervisors.Text),
                    };
                    activitydb.EditActivity(a);
                }

                showPanel("Activities");
            }
            else
            {
                MessageBox.Show("Fields cannot be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btn_edit_Click(object sender, EventArgs e)
        {
            SomerenLogic.Activity_Service activity_Service = new Activity_Service();

            Activity activity = new Activity()
            {
                activity_id         = int.Parse(txt_activity_id.Text),
                name                = txtname.Text,
                numberofstudents    = int.Parse(txtnrstud.Text),
                numberofsupervisors = int.Parse(txtnrsup.Text)
            };


            activity_Service.EditActivity(activity);

            showPanel("Activities");

            txtname.Clear();
            txtnrstud.Clear();
            txtnrsup.Clear();
        }