Beispiel #1
0
        private void button6_Click(object sender, EventArgs e)
        {
            String error = "";

            if (comboBox3.SelectedIndex < 0 || comboBox1.SelectedIndex < 0)
            {
                error += "The field can't be empty.\n";
                MessageBox.Show("Error");
            }


            else
            {
                foreach (Department dept in departments)
                {
                    if (dept.getDepartmentId() == (Convert.ToInt32(comboBox1.SelectedItem.ToString())))
                    {
                        Course c = (Course)courses[(Convert.ToInt32(comboBox3.SelectedItem.ToString()))];
                        if (c == null)
                        {
                            MessageBox.Show("Course not found");
                        }

                        else
                        {
                            if (dept.findCourse(c) == 1)
                            {
                                MessageBox.Show("Course already exists.");
                            }
                            else
                            {
                                dept.AddCourse(c);
                                MessageBox.Show("course: " + c.getCourseName() + " added into department: " + dept.getDepartmentName());
                            }
                        }
                        break;
                    }
                    else
                    {
                        MessageBox.Show("Department not available");
                    }
                }
            }
        }
Beispiel #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            string message = "";

            if (textBox4.Text == "")
            {
                MessageBox.Show("Course ID must be entered");
            }
            else
            {
                if (courses.ContainsKey((Convert.ToInt32(textBox4.Text))))
                {
                    Course c = (Course)courses[(Convert.ToInt32(textBox4.Text))];
                    message += "Name: " + c.getCourseName() + "\n";
                    message += "Sequence: " + c.getCourseSequence() + "\n";

                    MessageBox.Show(message);
                }
                else
                {
                    MessageBox.Show("Course not found");
                }
            }
        }