private void btExcluir_Click(object sender, EventArgs e) { try { DialogResult d = MessageBox.Show("Deseja realmente excluir o grupo - " + txtNome.Text + "?", "Aviso", MessageBoxButtons.YesNo); if (d.ToString() == "Yes") { NomeExclusao = txtNome.Text; DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLGrupo bll = new BLLGrupo(cx); bll.Excluir(Convert.ToInt32(txtId.Text)); MessageBox.Show("Grupo " + NomeExclusao + " excluído com sucesso."); NomeExclusao = ""; this.LimpaCampos(); this.alteraBotoes(1); this.CarregaDados(); } } catch { MessageBox.Show("Impossível excluir o registro. \n O registro está sendo utilizado em outro local."); this.alteraBotoes(3); } }