Exemplo n.º 1
0
 // to find course
 public String findCourse(Course course)
 {
     Course c;
     try
     {
          c = (Course)this.courses[course.getCourseId()];
     } catch (NullReferenceException e) {
         c = null;
     }
        if (c != null)
        {
        return c.getCourseId();
        }
        else {
        return "";
        }
 }
Exemplo n.º 2
0
        private void btnCreateCourse_Click(object sender, EventArgs e)
        {
            String errors = "";
            if (txtCourseId.Text.Equals(""))
            {
                errors += "\n-Course ID required.";
            }

            if (txtCourseName.Text.Equals(""))
            {
                errors += "\n-Course Name required.";
            }
            if (txtCourseSequence.Text.Equals("")) {
                errors += "\n-Course Sequence required.";
            }

            //check if course already exist or not
            foreach (String course in courses.Keys) {
                if (course == txtCourseId.Text) {
                    errors += "\n-Course Id alerady exist";
                 }
            }

            if (errors == "")
            {

                //create a course
                Course newCourse = new Course(txtCourseId.Text, txtCourseName.Text, txtCourseSequence.Text);
                courses.Add(newCourse.getCourseId(), newCourse);
                String message = "Course added";
                MessageBox.Show(message);

            }
            else
            {
                MessageBox.Show(errors);
            }
        }
Exemplo n.º 3
0
 // add course into department
 public void AddCourse(Course course)
 {
     courses.Add(course.getCourseId(), course);
 }