예제 #1
0
        private void editStudent(int index)
        {
            addStudentForm asf = new addStudentForm();

            asf.EditMode = true;

            Student s = (Student)peopleList[index];

            Console.WriteLine(s.ToString());

            // preload the objects' property value
            asf.FirstName          = s.FirstName;
            asf.LastName           = s.LastName;
            asf.AcademicDepartment = s.AcademicDepartment;
            asf.StudentContact     = new StudentContact(s.Contact.Email, s.Contact.MailAddress);
            asf.GraduationYear     = s.GraduationYear;
            asf.CourseList         = s.CourseList;

            // show the dialog and wait for an OK

            DialogResult result = asf.ShowDialog();

            // if answer was OK update the product inventory with the new values and update display

            if (result != DialogResult.OK)
            {
                return;
            }

            UniversityPeople up = new Student(asf.FirstName,
                                              asf.LastName,
                                              asf.AcademicDepartment,
                                              asf.StudentContact,
                                              "Student",
                                              asf.GraduationYear,
                                              asf.CourseList);

            peopleList[index] = up;
            allContactListBox.Items[index] = up.ToFormattedString();
        }
예제 #2
0
        // create a new student
        private UniversityPeople creatNewStudent()
        {
            addStudentForm asf = new addStudentForm();

            DialogResult result;

            result = asf.ShowDialog();
            if (result != DialogResult.OK)
            {
                return(null);
            }

            UniversityPeople newStudent = new Student(asf.FirstName,
                                                      asf.LastName,
                                                      asf.AcademicDepartment,
                                                      asf.StudentContact,
                                                      "Student",
                                                      asf.GraduationYear,
                                                      asf.CourseList);

            return(newStudent);
        }