private void btnCompare_Click(object sender, EventArgs e)
        {
            StudentMethods stu = new StudentMethods();
            TeacherMethods tea = new TeacherMethods();

            //compare checks all the students in the student list against the selected  teacher instance
            foreach (Student s in stu.GetStudentList())
            {
                // if a match is found
                if (tea.GetTeacherList()[index] == s)
                {
                    //option presented to overwrite the matching student item with the current teacher details of phone and email
                    DialogResult dialogResult = MessageBox.Show("A Student of the same name has been found.\nDo you wish to overwrite their contact details with the current details?", "Possible duplication", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        s.Phone = tea.GetTeacherList()[index].Phone;
                        s.Email = tea.GetTeacherList()[index].Email;
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                        break;
                    }

                    break;
                }
                else
                {
                    MessageBox.Show("No matches found");
                }
            }
        }
Exemplo n.º 2
0
        private void btnDisplayTeacher_Click(object sender, EventArgs e)
        {
            //refreshes/updates list box display

            //clear list box to prevent duplication
            lstDisplayBox.Items.Clear();

            //displays each teacher in the teacher list
            foreach (Teacher t in tea.GetTeacherList())
            {
                lstDisplayBox.Items.Add(t.Display());
            }
        }
Exemplo n.º 3
0
        private void btnCompare_Click(object sender, EventArgs e)
        {
            StudentMethods stu = new StudentMethods();
            TeacherMethods tea = new TeacherMethods();

            //compare checks all the teachers in the teachers list against the selected student instance

            foreach (Teacher t in tea.GetTeacherList())
            {
                // if a match is found
                if (stu.GetStudentList()[index] == t)
                {
                    //an option presented to overwrite the details with the current details or leave as is

                    DialogResult dialogResult = MessageBox.Show("A Teacher of the same name has been found.\nDo you wish to overwrite their contact details with the current details?", "Possible duplication", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        t.Phone = stu.GetStudentList()[index].Phone;
                        t.Email = stu.GetStudentList()[index].Email;
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("No matches found");
                }
            }
        }