Exemplo n.º 1
0
        // constructor

        public Faculty(string firstName,
                       string lastName,
                       string department,
                       ContactFaculty contactFaculty) : base(firstName, lastName, department)
        {
            this.contactFaculty = contactFaculty;
        }
Exemplo n.º 2
0
        // load file
        public Faculty(string fromFile) : base(fromFile)
        {
            char[] delimiters = { '|', ',' };

            string[] tokens = fromFile.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

            // call constructor to set contact information of faculty staff
            contactFaculty = new ContactFaculty(tokens[3], tokens[4]);
        }
Exemplo n.º 3
0
        // Function - Edit faculty staff contact information
        private void EditFacultyPerson(int index, int mode)
        {
            // create a dialog and configure for edit or only display

            AddEditFacultyDialog adfd = new AddEditFacultyDialog();

            switch (mode)
            {
            case 0:         // 0 - show mode
            case 2:         // 2 - edit mode

                Faculty f = (Faculty)personList[index];

                // assign values in personList to public properties in AddEditFacultyDialog
                adfd.FacultyEditMode     = mode;
                adfd.FacultyFirstName    = f.FirstName;
                adfd.FacultyLastName     = f.LastName;
                adfd.FacultyAcademicDept = f.Department;
                adfd.FacultyEmail        = f.ContactFaculty.Email;
                adfd.FacultyBuilding     = f.ContactFaculty.Building;

                break;

            case 1:         // 1 - add mode
                adfd.FacultyEditMode = mode;
                break;
            }


            // show the dialog and wait for a ok

            DialogResult result = adfd.ShowDialog();

            // if answer was ok update the contact information with the new values and update display

            // update faculty contact information



            if (result == DialogResult.OK)
            {
                ContactFaculty facultyInfo;
                try
                {
                    facultyInfo = new ContactFaculty(adfd.FacultyEmail, adfd.FacultyBuilding);
                }
                catch (Exception excp)
                {
                    MessageBox.Show($"email address error. {excp.Message}");
                    return;
                }

                Person p = new Faculty(adfd.FacultyFirstName,
                                       adfd.FacultyLastName,
                                       adfd.FacultyAcademicDept,
                                       facultyInfo);

                // set mode to public property
                p.Type = "Faculty";

                switch (mode)
                {
                case 0:     // show mode
                    break;

                case 2:     // edit mode

                    // update new values for dispaly and list

                    personList[index] = p;
                    personListListBox.Items[index] = p.ToFormattedString();
                    EditCount++;                        // EditCount add 1 after sucessful edit
                    break;

                case 1:     //add mode

                    // add to list
                    personList.Add(p);

                    // add to list box for display
                    personListListBox.Items.Add(p.ToFormattedString());
                    EditCount++;                        // EditCount add 1 after sucessful add
                    break;

                default:
                    break;
                }
            }
            else if (result == DialogResult.Cancel)
            {
                return;
            }
            else
            {
                MessageBox.Show("AddEditFacultyDialog not return OK ....debug");
                return;
            }
        }