/// <summary> /// Handle the Remove selected user Button press event. Removes the user from the db /// </summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">The event arguments</param> /// <history> /// <Created 18 April 2014>Arun Gopinath && Jeff Bunce</Created> /// <Modified 18 April 2014></Modified> /// </history> private void ButtonPressEvent_RemoveSelectedUser(object sender, EventArgs e) { List <Student> SelectedStudents = new List <Student> (); foreach (DataGridViewRow row in dtgRemoveUsers.SelectedRows) { Student s = ( Student )row.DataBoundItem; SelectedStudents.Add(( Student )row.DataBoundItem); } if (SelectedStudents.Count > 0) { DialogResult result = MessageBox.Show("You are a about to remove " + SelectedStudents.Count.ToString() + " Sudents and their assignments from the system.\n\n Do you wish to continue?", "Remove Students", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { mmControl.RemoveStudents(SelectedStudents); //REFACTOR dtgRemoveUsers.DataSource = null; dtgRemoveUsers.Refresh(); dtgRemoveUsers.DataSource = mmControl.StudentList; dtgRemoveUsers.Refresh(); MessageBox.Show(SelectedStudents.Count + " Students Deleted.", "Students Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }