private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e) { try { if (!ValidateFields()) { return; } profesoreBindingSource.EndEdit(); var selectedProfe = commB.SetEntity <Profesore>(profesoreBindingSource.Current); if (selectedProfe != null) { var ce = commB.FindCursoProfesorByIdProfesor(selectedProfe.IdProfesor); if (ce != null) { MessageBox.Show("No se pueden borrar profesores que están relacionados en la tabla de CursosProfesores", "Borrar", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); //base. return; } else { commB.DeleteEntity <Profesore>(selectedProfe); commB.SaveBitacora(this.Name + "Profesor borrado: " + selectedProfe.IdProfesor, false, Tools.UserCredentials.UserId); lblInfoMessage.Text = "Profesor borrado satisfactoriamente"; //horarioBindingSource.RemoveCurrent(); } } profesoreBindingSource.ResetBindings(true); } catch (Exception ex) { CursosBusiness.BusinessHelpers.General.LogInfo(ex, "Control", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }