private void btnExcluir_Click(object sender, EventArgs e) { bool resposta; if (lblIdProduto.Text.Length == 0) { lblMensagem.Text = "UIm produto de ser selecionado para exclusão"; } else { try { produto.IdProdutos = int.Parse(lblIdProduto.Text); resposta = objProdutoBLL.Excluir(produto); lblMensagem.Text = objProdutoBLL.Mensagem; AtualizaGrid(); if (resposta == true) { lblMensagem.Text = objProdutoBLL.Mensagem; } else { lblMensagem.Text = "Deu B.O na exclusão"; } } catch { lblIdProduto.Text = ""; txtProduto.Text = ""; txtPreco.Text = ""; txtEstoque.Text = ""; } } }
private void excluirButton_Click(object sender, EventArgs e) { if (codigoTextBox.Text.Length == 0) { MessageBox.Show("Um produto deve ser selecionado antes da exclusão."); } else { try { int codigo = Convert.ToInt32(codigoTextBox.Text); ProdutosBLL obj = new ProdutosBLL(); obj.Excluir(codigo); MessageBox.Show("O produto foi excluído com sucesso!"); AtualizaGrid(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void btnExcluir_Click(object sender, EventArgs e) { if (txtCod.Text.Trim().Length == 0) { MessageBox.Show("Um produto deve ser selecionado para exclusão"); } else { try { int codigo = Convert.ToInt32(txtCod.Text); ProdutosBLL obj = new ProdutosBLL(); obj.Excluir(codigo); MessageBox.Show("O produto foi excluido com sucesso!"); AtualizaGrid(); } catch (Exception ex) { MessageBox.Show("Erro: " + ex.Message); } } }