private void btExcluir_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); BLLProduto bll = new BLLProduto(cx); bll.Excluir(Convert.ToInt32(txtCodigo.Text)); this.LimpaTela(); this.alteraBotoes(1); } } catch { MessageBox.Show("Impossível excluir o registro. \n O registro esta sendo utilizado em outro local."); this.alteraBotoes(3); } }
private void btExcluir_Click(object sender, EventArgs e) { try { Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this); DialogResult res = MessageBox.Show("Deseja excluir este Produto ?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (res.ToString() == "Yes") { DALConexao cx = new DALConexao(DadosDaConexao.srtConexao); BLLProduto bll = new BLLProduto(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); } }