// create a new faculty private UniversityPeople createNewFaculty() { addFacultyForm aff = new addFacultyForm(); DialogResult result; result = aff.ShowDialog(); if (result != DialogResult.OK) { return(null); } UniversityPeople newFaculty = new Faculty(aff.FirstName, aff.LastName, aff.AcademicDepartment, aff.FacultyContact, "Faculty"); return(newFaculty); }
private void editFaculty(int index) { addFacultyForm aff = new addFacultyForm(); aff.EditMode = true; // cast the university people object to faculty Faculty f = (Faculty)peopleList[index]; // assign the faculty object's property values to the form aff.FirstName = f.FirstName; aff.LastName = f.LastName; aff.AcademicDepartment = f.AcademicDepartment; aff.FacultyContact = new FacultyContact(f.Contact.Email, f.Contact.OfficeBuilding); // show the dialog and wait for an OK DialogResult result = aff.ShowDialog(); // if answer was OK update the product inventory with the new values and update display if (result != DialogResult.OK) { return; } // save the changes back to list UniversityPeople up = new Faculty(aff.FirstName, aff.LastName, aff.AcademicDepartment, aff.FacultyContact, "Faculty"); peopleList[index] = up; allContactListBox.Items[index] = up.ToFormattedString(); }