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");
                }
            }
        }
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            TeacherMethods tea = new TeacherMethods();

            string newSubject, fname, lname, phone, email;

            double salary;

            //assigning changes made to variables
            fname  = txtFName.Text.ToUpper();
            lname  = txtLName.Text.ToUpper();
            phone  = txtPhone.Text;
            email  = txtEmail.Text;
            salary = double.Parse(lblSalaryDisplay.Text);

            newSubject = txtSubject.Text.ToUpper();


            if (newSubject == "MATHS" || newSubject == "SCIENCE" || newSubject == "ENGLISH")
            {
                //saving changes made to the item using the SaveChanges() method
                tea.SaveChanges(fname, lname, phone, email, salary, newSubject, index);
                MessageBox.Show("Changes saved");
            }

            else
            {
                MessageBox.Show("Invalid subject entered:\nPlease enter ENGLISH, MATHS or SCIENCE");
            }
        }
Example #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");
                }
            }
        }
        private void btnAddTeacher_Click(object sender, EventArgs e)
        {
            TeacherMethods teacherMethod = new TeacherMethods();

            double salary = 0;
            //subject assigned based on combo box
            string subject = "", reset = ": Please Select Subject";

            //exception handling for input salary
            try
            {
                salary = double.Parse(txtSalary.Text);
            }
            catch
            {
                MessageBox.Show("Invalid entry for Salary.\n Please enter a numeric value.");
            }

            subject = cboSubject.Text;

            //if statements to prevent blank entries
            if (txtFName.Text != "")
            {
                if (txtLName.Text != "")
                {
                    if (subject != ": Please Select Subject")
                    {
                        //teacher method to add this teacher input to list of teacher
                        teacherMethod.AddTeacher(txtFName.Text.ToUpper(), txtLName.Text.ToUpper(), txtPhone.Text, txtEmail.Text, salary, cboSubject.Text);
                        //clear fields after
                        txtFName.Clear();
                        txtLName.Clear();
                        txtEmail.Clear();
                        txtPhone.Clear();
                        txtSalary.Clear();
                        cboSubject.Text = reset;
                        MessageBox.Show("Teacher Added");
                    }
                    else
                    {
                        MessageBox.Show("Please fill in all the fields");
                    }
                }
                else
                {
                    MessageBox.Show("Please fill in all the fields");
                }
            }

            else
            {
                MessageBox.Show("Please fill in all the fields");
            }
        }
Example #5
0
        public Login()
        {
            InitializeComponent();

            //these below methods are just to populate the list with hardcoded items

            TeacherMethods tea = new TeacherMethods();
            StudentMethods stu = new StudentMethods();

            tea.TestTeachers();
            stu.TestStuds();

            txtUser.Clear();
            txtPass.Clear();
        }