Пример #1
0
        private void button8_Click(object sender, EventArgs e)
        {
            string message = "";
            string id      = (textBox11.Text);

            if (id == "")
            {
                MessageBox.Show("Enter student ID ");
            }
            else
            {
                if (students.ContainsKey((Convert.ToInt32(textBox11.Text))))
                {
                    Student s = (Student)students[(Convert.ToInt32(textBox11.Text))];
                    message += "First Name: " + s.getFirstName() + "\n";
                    message += "Last Name: " + s.getLastName() + "\n";
                    message += "Email: " + s.getEmail() + "\n";
                    MessageBox.Show(message);
                }
                else
                {
                    MessageBox.Show("Course not found");
                }
            }
        }
Пример #2
0
        private void button7_Click(object sender, EventArgs e)
        {
            String error = "";

            if (textBox6.Text.Equals("") || comboBox2.SelectedIndex < 0)
            {
                error += "The field can't be empty.\n";
            }


            if (error == "")
            {
                foreach (Course c in courses.Values)
                {
                    if (c.getCourseId() == Convert.ToInt32(comboBox2.SelectedItem.ToString()))
                    {
                        Student s = (Student)students[Convert.ToInt32(textBox6.Text)];
                        if (s == null)
                        {
                            MessageBox.Show("Student not found.");
                            break;
                        }

                        if (c.findStudent(s) == 1)
                        {
                            MessageBox.Show("Student already exists.");
                        }

                        if (c.findStudent(s) == 0)
                        {
                            c.AddStudent(s);
                            MessageBox.Show("Student: " + s.getFirstName() + " " + s.getLastName() + " added into course: " + c.getCourseName());
                        }
                    }
                }
            }
        }