private void btnExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult d = MessageBox.Show("Deseja excluir o registro?", "Aviso", MessageBoxButtons.YesNo);
         if (d.ToString() == "Yes")
         {
             DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);
             BLLUnidadeDeMedida bll = new BLLUnidadeDeMedida(cx);
             bll.Excluir(Convert.ToInt32(txtCod.Text));
             this.LimpaTela();
             this.alterarBotoes(1);
         }
     }
     catch
     {
         MessageBox.Show("Impossível excluir o registro. \n O Registro Está sendo Utilizado em outro Local.");
         this.alterarBotoes(3);
     }
 }
 private void btExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
         DialogResult res = MessageBox.Show("Deseja excluir esta unidade de Medida ?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
         if (res.ToString() == "Yes")
         {
             DALConexao cx = new DALConexao(DadosDaConexao.srtConexao);
             BLLUnidadeDeMedida bll = new BLLUnidadeDeMedida(cx);
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
             MessageBox.Show("Registro excluido com sucesso", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.LimpaCampos();
             this.AlteraBotoes(1);
         }
     }
     catch (Exception erro)
     {
         Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
         MessageBox.Show("Impossivel excluir este registro \n O Registro está sendo utilizado \n" + erro.Message, "Erro", MessageBoxButtons.OK,MessageBoxIcon.Error);
         AlteraBotoes(3);
     }
 }