public bool Excluir(int codigo, out string mensagem) { if (_vendaRepository.PodeExcluir(codigo, out mensagem)) { _vendaRepository.Excluir(codigo); return(true); } return(false); }
public void Excluir(int id) { if (id == 0) { throw new MensagemException(EnumStatusCode.RequisicaoInvalida, "Não foi possivel excluir o Venda. Venda não localizado"); } var Venda = _vendaRepository.PesquisarPorId(id); if (Venda == null || Venda.Id == 0) { throw new MensagemException(EnumStatusCode.RequisicaoInvalida, "Não foi possivel excluir o Venda. Venda não localizado"); } _vendaRepository.Excluir(Venda); }
private void btnExcluir_Click(object sender, EventArgs e) { if (dgPrecos.SelectedRows.Count == 0) { MessageBox.Show("Selecione uma linha"); } else { DialogResult dr = MessageBox.Show("Deseja Excluir?", "Aviso", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); if (dr == DialogResult.Yes) { Venda vendaSelecionada = dgPrecos.SelectedRows[0].DataBoundItem as Venda; try { IProdutoVendaRepository _pvendaRepository = new ProdutoVendaRepository(); foreach (ProdutoVenda pv in vendaSelecionada.ProdutosVenda) { _pvendaRepository.Excluir(pv); } _vendaRepository.Excluir(vendaSelecionada); ExibeGrid(); MessageBox.Show("Operação realizada com sucesso."); } catch (Exception ex) { MessageBox.Show("Não foi possível excluir o produto"); } } } }
public void Exclui(Venda venda) { _vendaRepository.Excluir(venda); }