Пример #1
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");
                }
            }
        }
Пример #2
0
 private void btnDisplayStud_Click(object sender, EventArgs e)
 {
     //display/refresh items in the list box
     lstDisplayBox.Items.Clear();
     foreach (Student s in stu.GetStudentList())
     {
         lstDisplayBox.Items.Add(s.Display());
     }
 }
        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");
                }
            }
        }