private void btnRemove_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure to delete this user?", "Confirm", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { switch (user.Role) { case "Worker": Worker worker = Worker.GetByUserId(user.Id); worker.Delete(dpEndDate.Value); break; case "Supervisor": Supervisor supervisor = Supervisor.GetByUserId(user.Id); supervisor.Delete(dpEndDate.Value); break; case "Administrator": Administrator admin = Administrator.GetByUserId(user.Id); admin.Delete(dpEndDate.Value); break; case "Manager": Manager manager = Manager.GetByUserId(user.Id); manager.Delete(dpEndDate.Value); break; } mainForm.ShowUsers(User.GetAll()); this.Close(); } }