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 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 btnSaveChanges_Click(object sender, EventArgs e) { StudentMethods stu = new StudentMethods(); string newStatus, fname, lname, phone, email; int id; //assigning changes made to variables fname = txtFName.Text.ToUpper(); lname = txtLName.Text.ToUpper(); phone = txtPhone.Text; email = txtEmail.Text; id = int.Parse(lblIdDisplay.Text); newStatus = txtStatus.Text.ToUpper(); // if statement to ensure status is entered correctly if (newStatus == "POST" || newStatus == "UNDER") { //inputting variables to SaveChanges() which overwrites this item in the list with the new values stu.SaveChanges(fname, lname, phone, email, id, newStatus, index); MessageBox.Show("Changes saved"); } else { MessageBox.Show("Invalid student status entered:\nPlease enter POST or UNDER"); } }
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(); }