예제 #1
0
        private void teachersComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (teachersComboBox.SelectedIndex == -1)
            {
                return;
            }

            Teacher             teacher             = (Teacher)teachersComboBox.SelectedItem;
            Participant_Service participant_Service = new Participant_Service();

            selectedParticipant = null;
            activitiesListView.Items.Clear();

            List <Participant> participantcies = participant_Service.getParticipantsWithActivityByUser(teacher);

            foreach (Participant participantcy in participantcies)
            {
                ListViewItem item = new ListViewItem(participantcy.ParticipatingActivity.ActivityName);
                item.SubItems.Add(participantcy.ParticipancyType == "CNS" ? "Counsellor" : "Participant");
                item.SubItems.Add(participantcy.ParticipatingActivity.ActivityStartDate.ToString("HH:mm dd-MM-yyyy"));

                item.Tag = participantcy;

                activitiesListView.Items.Add(item);
            }
        }
예제 #2
0
        private void btnChangeCounsellor_Click(object sender, EventArgs e)
        {
            if (selectedParticipant == null)
            {
                throw new Exception("Selected participant was null");
            }

            Dictionary <string, object> dataTransferObject = new Dictionary <string, object>();

            // Show popup
            Form popup = new TeacherSelectPopup(dataTransferObject);

            popup.ShowDialog();

            // Checks whether or not the dialog has been force closed or by selecting a teacher
            if (dataTransferObject.ContainsKey("selectedTeacher"))
            {
                Teacher replacementTeacher = (Teacher)dataTransferObject["selectedTeacher"];

                Teacher_Services teacher_Services = new Teacher_Services();

                bool isAvailable = teacher_Services.isAvailableBetween(replacementTeacher, selectedParticipant.ParticipatingActivity.ActivityStartDate, selectedParticipant.ParticipatingActivity.ActivityEndDate);

                if (isAvailable)
                {
                    DialogResult result = MessageBox.Show($"Are you sure you want to replace the selected activity with {replacementTeacher}", "Confirm", MessageBoxButtons.YesNo);

                    if (result == DialogResult.Yes)
                    {
                        Participant_Service participant_Service = new Participant_Service();

                        participant_Service.setNewUserAsParticipant(selectedParticipant, replacementTeacher);

                        MessageBox.Show("Changed have been made");

                        refreshTeachers();
                        teachersComboBox.SelectedIndex = -1;
                    }
                }
                else
                {
                    MessageBox.Show("Selected replacement teacher is not available when the activity takes place.");
                }
            }
        }
예제 #3
0
        public void loadDataViews()
        {
            Activity_Service actService = new Activity_Service();
            List <Activity>  activities = actService.getActivities();

            Participant_Service prtService   = new Participant_Service();
            List <Participant>  participants = prtService.getParticipants();

            DataGridView gridView = new DataGridView();

            foreach (Activity activity in activities)
            {
                switch (activity.ActivityStartDate.DayOfWeek)
                {
                case (DayOfWeek.Monday):
                    gridView = gridViewMon;
                    break;

                case (DayOfWeek.Tuesday):
                    gridView = gridViewTue;
                    break;

                case (DayOfWeek.Wednesday):
                    gridView = gridViewWed;
                    break;

                case (DayOfWeek.Thursday):
                    gridView = gridViewThu;
                    break;

                case (DayOfWeek.Friday):
                    gridView = gridViewFri;
                    break;
                }

                int rowId = gridView.Rows.Add();

                DataGridViewRow row = gridView.Rows[rowId];

                row.Cells[0].Value = activity.ActivityName;

                string counsellorList = "";

                foreach (Participant participant in participants)
                {
                    if (participant.ActivityId == activity.ActivityId && participant.ParticipancyType == "CNS")
                    {
                        counsellorList += participant.UserId.ToString();
                        counsellorList += ", ";
                    }
                }

                if (counsellorList == "")
                {
                    counsellorList = "Onbegeleid";
                }
                else
                {
                    counsellorList = counsellorList.Remove(counsellorList.Length - 2);
                }


                row.Cells[1].Value = counsellorList;
            }
        }