Beispiel #1
0
        // methods

        ////////////////////////// BEGIN YOUR CODE HERE ///////////////////////////////

        /// <summary>
        /// btnAddParticipant_Click(object sender, EventArgs e)
        /// Button event handler to add a participant with the specified data
        /// to the course that is currently selected in the listbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddParticipant_Click(object sender, EventArgs e)
        {
            // To do, assignment 4
            if (lbCourseOverview.SelectedItem != null)
            {
                try
                {
                    int    id   = Convert.ToInt32(tbParticipantId.Text);
                    String name = tbParticipantName.Text.ToString();
                    Course c    = (Course)lbCourseOverview.SelectedItem;
                    c.AddParticipant(id, name);
                    this.ShowAllCourses();
                }
                catch (FormatException exc)
                {
                    MessageBox.Show(exc.Message);
                }
                catch (CourseException exc)
                {
                    MessageBox.Show(exc.Message);
                }
            }
            else
            {
                MessageBox.Show("No course selected in the course overview");
            }
        }
Beispiel #2
0
        /////////////////////////////// BEGIN YOUR CODE HERE /////////////////////////////////////////////////////

        // Assignment 4:
        private void btnAddParticipant_Click(object sender, EventArgs e)
        {
            if (this.lbCourseOverview.SelectedItem != null)
            {
                try
                {
                    Course c               = (Course)this.lbCourseOverview.SelectedItem;
                    int    participantId   = Convert.ToInt32(this.tbParticipantId.Text);
                    String participantName = this.tbParticipantName.Text;
                    c.AddParticipant(participantId, participantName);
                    this.ShowAllCourses();
                }
                catch (FormatException exc)
                {
                    MessageBox.Show(exc.Message);
                }
                catch (CourseException exc)
                {
                    MessageBox.Show(exc.Message);
                }
            }
            else
            {
                MessageBox.Show("No course selected in the course overview");
            }
        }
Beispiel #3
0
        /// <summary>
        /// AddParticipantToCourse(int courseId, int participantId, string name)
        /// Adds a participant to the course with id courseId,
        /// if the course with courseId occurs in the list of courses.
        /// </summary>
        /// <param name="courseId"></param>
        /// <param name="participantId"></param>
        /// <param name="name"></param>
        public void AddParticipantToCourse(int courseId, int participantId, string name)
        {
            Course c = GetCourse(courseId);

            if (c != null)
            {
                c.AddParticipant(participantId, name);
            }
        }