/// <summary> /// Removes a employee when the Remove button is clicked. /// It then updates the user interface. /// </summary> /// <param name="sender">The button that is clicked.</param> /// <param name="e">Additional event information.</param> private void btnRemove_Click(object sender, EventArgs e) { if (lvwEmployees.SelectedIndices.Count == 0) { MessageBox.Show("No employee was selected.", "Remove Employee", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { int index = lvwEmployees.SelectedIndices[0]; DialogResult answer = MessageBox.Show("Are you sure you want to remove?", "Remove Employee", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (answer == DialogResult.Yes) { string employeeId = lvwEmployees.Items[index].SubItems[0].Text; Employee employee = employeeDA.GetEmployeeByEmployeeId(employeeId); employeeDA.RemoveEmployee(employee); this.FillEmployeeListView(); } else { lvwEmployees.Items[index].Selected = false; } } lvwEmployees.Focus(); }