Beispiel #1
0
 public String findStudent(Student p)
 {
     Student c;
     try
     {
         c = (Student)this.students[p.getStudentId()];
     }
     catch (NullReferenceException e)
     {
         c = null;
     }
     if (c != null)
     {
         return c.getStudentId();
     }
     else
     {
         return "";
     }
 }
Beispiel #2
0
        private void btnCreateStudent_Click(object sender, EventArgs e)
        {
            String errors = "";
            if (txtStudentId.Text.Equals(""))
            {
                errors += "\n-Stuent ID required.";
            }

            if (txtFirstName.Text.Equals(""))
            {
                errors += "\n-First Name required.";
            }

            if (txtLastName.Text.Equals(""))
            {
                errors += "\n-Last Name required.";
            }

            if (txtEmail.Text.Equals(""))
            {
                errors += "\n-Email required.";
            }

            //check if  already exist or not
            foreach (Student s in students)
            {
                if (s.getStudentId() == txtStudentId.Text)
                {
                    errors += "\n-Student Id Already exists.";
                    break;
                }

            }

            if (errors == "")
            {

                //create a dept
                Student newStudent = new Student(txtStudentId.Text, txtFirstName.Text, txtLastName.Text, txtEmail.Text);
                students.Add(newStudent.getStudentId(), newStudent);
                String message = "Student added";
                MessageBox.Show(message);

            }
            else
            {
                MessageBox.Show(errors);
            }
        }
Beispiel #3
0
 // to add student to the course
 public void AddStudent(Student student)
 {
     this.students.Add(student.getStudentId(), student);
 }