//public string FindCoursesBySequence(string name)
 //{
 //}
 //public string GetDepartmentInfo()
 //{
 //}
 public int findCourse(Course course)
 {
     if (courses.ContainsKey(course.getCourseId()))
         return 1;
     else
         return 0;
 }
        //public string FindCoursesBySequence(string name)
        //{

        //}
        //public string GetDepartmentInfo()
        //{

        //}
        public int findCourse(Course course)
        {
            if (courses.ContainsKey(course.getCourseId()))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Пример #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            String error = "";

            if (textBox4.Text.Equals("") || textBox3.Text.Equals("") || textBox5.Text.Equals(""))
            {
                error += "The field can't be empty.\n";
                MessageBox.Show(error);
            }
            else
            {
                foreach (String course in courses.Keys)
                {
                    if (course == textBox4.Text)
                    {
                        error += "Course Id alerady exists\n";
                        MessageBox.Show(error);
                    }
                }
                if (error == "")
                {
                    Course c1 = new Course(Convert.ToInt32(textBox4.Text), textBox3.Text, textBox5.Text);


                    courses.Add(c1.getCourseId(), c1);
                    String text = "Course " + textBox4.Text + " added";
                    MessageBox.Show(text);
                    comboBox2.Items.Add(textBox4.Text);
                    comboBox3.Items.Add(textBox4.Text);
                }
                else
                {
                    MessageBox.Show(error);
                }
            }
        }