示例#1
0
        //this method initiates read only mode
        // and creates the student object to be displayed
        private void showStudentContact(int index)
        {
            AddEditStudent aes = new AddEditStudent();

            aes.ReadOnlyMode = true;

            Student s = (Student)educationPeople[index];

            aes.FirstName      = s.FirstName;
            aes.LastName       = s.LastName;
            aes.Department     = s.Department;
            aes.MailingAddress = s.CI.MailingAddress;
            aes.EmailAddress   = s.CI.EmailAddress;
            aes.GradYear       = s.GraduationYear;
            aes.CourseList     = s.CourseList;

            DialogResult result = aes.ShowDialog();

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

            ContactInformation contact = new ContactInformation();

            contact.EmailAddress   = aes.EmailAddress;
            contact.MailingAddress = aes.MailingAddress;

            EducationPerson person = new Student(aes.FirstName,
                                                 aes.LastName,
                                                 aes.Department,
                                                 contact, aes.GradYear,
                                                 aes.CourseList);
        }
示例#2
0
        //this method creates a student Object reference
        private Student createStudent()
        {
            AddEditStudent aes = new AddEditStudent();

            DialogResult result;

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

            ContactInformation contact = new ContactInformation();

            contact.EmailAddress   = aes.EmailAddress;
            contact.MailingAddress = aes.MailingAddress;

            Student S = new Student(aes.FirstName,
                                    aes.LastName,
                                    aes.Department,
                                    contact,
                                    aes.GradYear, aes.CourseList);

            return(S);
        }
示例#3
0
        //this method is used to edit student individuals or persons
        //pop the student dialogue and populate the contents of the fields
        private void editStudent(int index)
        {
            AddEditStudent aes = new AddEditStudent();

            aes.EditMode = true;

            Student s = (Student)educationPeople[index];

            aes.FirstName      = s.FirstName;
            aes.LastName       = s.LastName;
            aes.Department     = s.Department;
            aes.MailingAddress = s.CI.MailingAddress;
            aes.EmailAddress   = s.CI.EmailAddress;
            aes.GradYear       = s.GraduationYear;
            aes.CourseList     = s.CourseList;

            DialogResult result = aes.ShowDialog(); //show the dialog and anticipate an ok response

            if (result != DialogResult.OK)          //if the user selects an option other than ok, Return
            {
                return;
            }

            ContactInformation contact = new ContactInformation();

            contact.EmailAddress   = aes.EmailAddress;
            contact.MailingAddress = aes.MailingAddress;

            EducationPerson person = new Student(aes.FirstName,
                                                 aes.LastName,
                                                 aes.Department,
                                                 contact, aes.GradYear, aes.CourseList);

            //pop a message box to confirm if the user wishes to change selected details
            result = MessageBox.Show($"Are you sure you like to change {person.FirstName}'s details?",
                                     "Confirmation", MessageBoxButtons.YesNo);
            //if the user selects Yes continue
            if (result == DialogResult.Yes)
            {
                educationPeople[index]             = person;
                ContactDisplayListBoz.Items[index] = person.ToFormattedString();
            }
            else
            {
                return;
            }
        }