Beispiel #1
0
        private void studentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            contactsInformation cis = new contactsInformation();

            cis.LoadStudentForm = true;
            DialogResult result;

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

            try
            {
                SI = new Student(cis.FirstName,
                                 cis.LastName,
                                 cis.AcademicDepartment,
                                 cis.EmailAddress,
                                 cis.SnailMailAndOfficeLocation,
                                 cis.GraduationYear,
                                 cis.CourseList);
            }
            catch
            {
                throw new ArgumentException("Unable to Create a New Faculty Entery. Invalid Entery");
            }
            ContactsDataList.Add(SI);
            contactListDiplayListBox.Items.Add(SI.ToFormattedString());  // this is in the main form
            alreadySaved = false;
        }
Beispiel #2
0
        private void facultyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            contactsInformation cif = new contactsInformation();

            cif.LoadFacultyForm = true;
            cif.LoadStudentForm = false;
            DialogResult result;

            // Show the Dialog and Wait for OK
            result = cif.ShowDialog();
            if (result != DialogResult.OK)
            {
                return;
            }


            try
            {
                FI = new Faculty(cif.FirstName,
                                 cif.LastName,
                                 cif.AcademicDepartment,
                                 cif.EmailAddress,
                                 cif.SnailMailAndOfficeLocation);
            }
            catch
            {
                throw new ArgumentException("Unable to Create a New Faculty Entery. Invalid Entery");
            }
            ContactsDataList.Add(FI);
            contactListDiplayListBox.Items.Add(FI.ToFormattedString());
            alreadySaved = false;
        }
Beispiel #3
0
        private void editStudentContact(int index)
        {
            // Create Dialog and Configure for eidit
            contactsInformation cis = new contactsInformation();

            cis.EditMode        = true;
            cis.LoadStudentForm = true;
            Student S = (Student)ContactsDataList[index];

            cis.FirstName                  = S.FirstName;
            cis.LastName                   = S.LastName;
            cis.AcademicDepartment         = S.AcademicDepartment;
            cis.EmailAddress               = S.EmailAddress;
            cis.SnailMailAndOfficeLocation = S.SnailMailAddress;
            cis.GraduationYear             = S.GraduationYear;
            cis.CourseList                 = S.CourseList;


            // Show the Dialog and Wait for OK
            DialogResult result = cis.ShowDialog();

            // If Answer was OK update the ContactList with the new values

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

            ContactsMain CM = new Student(cis.FirstName,
                                          cis.LastName,
                                          cis.AcademicDepartment,
                                          cis.EmailAddress,
                                          cis.SnailMailAndOfficeLocation,
                                          cis.GraduationYear,
                                          cis.CourseList);


            ContactsDataList[index] = CM;

            result = MessageBox.Show($"Are you sure to update {CM.FirstName}?", "Confirmation", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                ContactsDataList[index] = CM;

                contactListDiplayListBox.Items[index] = CM.ToFormattedString();
            }
            alreadySaved = false;
        }
Beispiel #4
0
        private void editFacultyContact(int index)
        {
            // Create Dialog and Configure for eidit
            contactsInformation cif = new contactsInformation();

            cif.EditMode        = true;
            cif.LoadFacultyForm = true;

            Faculty f = (Faculty)ContactsDataList[index];

            cif.FirstName                  = f.FirstName;
            cif.LastName                   = f.LastName;
            cif.AcademicDepartment         = f.AcademicDepartment;
            cif.EmailAddress               = f.EmailAddress;
            cif.SnailMailAndOfficeLocation = f.OfficeLocationBuilding;

            // Show the Dialog and Wait for OK
            DialogResult result = cif.ShowDialog();

            // If Answer was OK update the ContactList with the new values

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

            ContactsMain CM = new Faculty(cif.FirstName,
                                          cif.LastName,
                                          cif.AcademicDepartment,
                                          cif.EmailAddress,
                                          cif.SnailMailAndOfficeLocation);


            ContactsDataList[index] = CM;

            result = MessageBox.Show($"Are you sure to update {CM.FirstName}?", "Confirmation", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                ContactsDataList[index] = CM;

                contactListDiplayListBox.Items[index] = CM.ToFormattedString();
            }
            alreadySaved = false;
        }
Beispiel #5
0
        private void contactDetailToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int index = contactListDiplayListBox.SelectedIndex;

            if (index == -1)
            {
                MessageBox.Show("Please Select an Item First");
                return;
            }

            // Create the edit Dialog, have it prepopulate the contents of the field and
            // Show the Dialog

            ContactsMain CM = ContactsDataList[index];

            if (CM is Student)
            {
                // Create Dialog and Configure for edit
                contactsInformation ci = new contactsInformation();
                ci.ContactDetialMode = true;
                ci.EditMode          = true;
                ci.LoadStudentForm   = true;
                Student S = (Student)ContactsDataList[index];

                ci.FirstName                  = S.FirstName;
                ci.LastName                   = S.LastName;
                ci.AcademicDepartment         = S.AcademicDepartment;
                ci.EmailAddress               = S.EmailAddress;
                ci.SnailMailAndOfficeLocation = S.SnailMailAddress;
                ci.GraduationYear             = S.GraduationYear;
                ci.CourseList                 = S.CourseList;

                // Show the Dialog and Wait for OK
                DialogResult result = ci.ShowDialog();

                // If Answer was OK update the ContactList with the new values

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

                CM = new Student(ci.FirstName,
                                 ci.LastName,
                                 ci.AcademicDepartment,
                                 ci.EmailAddress,
                                 ci.SnailMailAndOfficeLocation,
                                 ci.GraduationYear,
                                 ci.CourseList);


                ContactsDataList[index] = CM;
            }
            else if (CM is Faculty)
            {
                // Create Dialog and Configure for eidit
                contactsInformation cif = new contactsInformation();
                cif.EditMode          = true;
                cif.LoadFacultyForm   = true;
                cif.ContactDetialMode = true;

                Faculty f = (Faculty)ContactsDataList[index];

                cif.FirstName                  = f.FirstName;
                cif.LastName                   = f.LastName;
                cif.AcademicDepartment         = f.AcademicDepartment;
                cif.EmailAddress               = f.EmailAddress;
                cif.SnailMailAndOfficeLocation = f.OfficeLocationBuilding;

                // Show the Dialog and Wait for OK
                DialogResult result = cif.ShowDialog();

                // If Answer was OK update the ContactList with the new values

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

                CM = new Faculty(cif.FirstName,
                                 cif.LastName,
                                 cif.AcademicDepartment,
                                 cif.EmailAddress,
                                 cif.SnailMailAndOfficeLocation);


                ContactsDataList[index] = CM;
            }
            else
            {
                MessageBox.Show("Unknow Product");
            }
        }