Esempio n. 1
0
        public Faculty(string fromFile) : base(fromFile)
        {
            char[] delimiters = { '|', ',' };

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

            contact = new FacultyContact(tokens[4], tokens[5]);
        }
Esempio n. 2
0
        // add button click event handler
        private void AddButton_Click(object sender, EventArgs e)
        {
            string badFieldName = null; // variable for bad field name
            string adviceString = null; // variable for the advice string

            if (!haveValidFirstName)
            {
                badFieldName = "First Name";
                adviceString = "Enter First Name";
            }
            else if (!haveValidLastName)
            {
                badFieldName = "Last Name";
                adviceString = "Enter Last Name";
            }
            else if (!haveValidAcademicDepartment)
            {
                badFieldName = "Academic Department";
                adviceString = "Enter Academic Department";
            }
            else if (!haveValidEmailAddress)
            {
                badFieldName = "Email Address";
                adviceString = "Enter Email Address";
            }
            else if (!haveValidOfficeBuilding)
            {
                badFieldName = "Office Building";
                adviceString = "Enter Office Building";
            }

            if (badFieldName != null)
            {
                MessageBox.Show($"Invalid {badFieldName}.\n{adviceString}", "Data Entry Error");
                return;
            }

            // assign faculty contact object
            FacultyContact = new FacultyContact(emailAddressTextBox.Text.Trim(),
                                                officeLocationBuildingTextBox.Text.Trim());

            DialogResult = DialogResult.OK;
        }
Esempio n. 3
0
 // function to check if the contact object is null
 public static bool isNull(FacultyContact contact)
 {
     return((contact == null) ? true : false);
 }
Esempio n. 4
0
 // constructors
 public Faculty(string fname, string lname, string department, FacultyContact fc, string type) :
     base(fname, lname, department, type)
 {
     contact = (!FacultyContact.isNull(fc)) ? fc :
               throw new ArgumentException("Null value is unaccepted");
 }