예제 #1
0
        private void button9_Click(object sender, EventArgs e)
        {
            String error = "";

            if (textBox9.Text.Equals("") || textBox10.Text.Equals("") || textBox11.Text.Equals("") || textBox12.Text.Equals(""))
            {
                error += "The field can't be empty.\n";
            }
            else
            {
                foreach (Student s in students)
                {
                    if (s.getStudentId() == Convert.ToInt32(textBox11.Text))
                    {
                        error += "\n-Student Id Already exists.";
                        break;
                    }
                }
                if (error == "")
                {
                    Student s1 = new Student(Convert.ToInt32(textBox11.Text), textBox10.Text, textBox12.Text, textBox9.Text);
                    students.Add(s1.getStudentId(), s1);
                    String text = "Student " + textBox11.Text + " added";
                    MessageBox.Show(text);
                }
                else
                {
                    MessageBox.Show(error);
                }
            }
        }
예제 #2
0
        public int findStudent(Student p)
        {
            Student s = (Student)students[p.getStudentId()];
            if (s == null)
                return 0;

            return 1;
        }
        public int findStudent(Student p)
        {
            Student s = (Student)students[p.getStudentId()];

            if (s == null)
            {
                return(0);
            }

            return(1);
        }