public void ExcluirVenda(Venda venda, List <Produto> produtos, List <int> quantidadeVendida) { using (var contexto = new DBCContext()) { var ven = contexto.Vendas .Include(v => v.Funcionario) .Include(v => v.Cliente) .FirstOrDefault(v => v.Id == venda.Id); var com = contexto.Compras .Where(c => Convert.ToInt32(c.VendaId) == venda.Id); // Vendas contexto.Remove(ven); // Compras int i = 0; foreach (var item in com) { contexto.Remove(item); i++; } contexto.SaveChanges(); } }
public void ExcluirFornecedor(Fornecedor fornecedor) { using (var contexto = new DBCContext()) { var fornec = contexto.Fornecedores .Include(f => f.Contato) .Include(f => f.Endereco) .First(f => f.Id == fornecedor.Id); contexto.Remove(fornec); contexto.Remove(fornec.Endereco); contexto.Remove(fornec.Contato); contexto.SaveChanges(); dialogBox.Show(); } }
public void ExcluirFuncionario(Funcionario funcionario) { using (var contexto = new DBCContext()) { var func = contexto.Vendedores .Include(v => v.Endereco) .Include(v => v.Contato) .Where(v => v.Id == funcionario.Id) .FirstOrDefault(); contexto.Remove(func); contexto.Remove(func.Endereco); contexto.Remove(func.Contato); contexto.SaveChanges(); dialogBox.Show(); } }
public void ExcluirCliente(Cliente cliente) { using (var contexto = new DBCContext()) { var cli = contexto.Clientes .Include(c => c.Contato) .Include(c => c.Endereco) .Where(c => c.Id == cliente.Id) .FirstOrDefault(); contexto.Remove(cli); contexto.Remove(cli.Endereco); contexto.Remove(cli.Contato); contexto.SaveChanges(); dialogBox.Show(); } }
public void ExcluirProduto(Produto produto) { using (var contexto = new DBCContext()) { var prod = contexto.Produtos .First(p => p.Id == produto.Id); contexto.Remove(prod); contexto.SaveChanges(); dialogBox.Show(); } }