Example #1
0
        //obter por ID
        public Venda ObterPorId(int idVenda)
        {
            VendaRepository repository = new VendaRepository();

            try
            {
                repository.AbrirConexao();
                Venda venda = repository.ObterPorId(idVenda);

                if (venda != null)                 //se foi encontrado
                {
                    return(venda);                 //retornando venda..
                }
                else
                {
                    throw new Exception("Venda não encontrado.");
                }
            }
            catch (Exception e)
            {
                throw new Exception("Ocorreu um erro: " + e.Message);
            }
            finally
            {
                repository.FecharConexao();
            }
        }
Example #2
0
        //método para atualizar o venda..
        public void Atualizar(Venda venda)
        {
            VendaRepository repository = new VendaRepository();

            try
            {
                repository.AbrirConexao();
                repository.Update(venda);
            }
            catch (Exception e)
            {
                throw new Exception("Ocorreu um erro: " + e.Message);
            }
            finally
            {
                repository.FecharConexao();
            }
        }
Example #3
0
        public List <Venda> ObterTodos()
        {
            VendaRepository repository = new VendaRepository();

            try
            {
                repository.AbrirConexao();
                return(repository.ObterTodos());
            }
            catch (Exception e)
            {
                throw new Exception("Ocorreu um erro: " + e.Message);
            }
            finally
            {
                repository.FecharConexao();
            }
        }
Example #4
0
        //método para excluir o estoque..
        public void Excluir(int idVenda)
        {
            VendaRepository repository = new VendaRepository();

            try
            {
                repository.AbrirConexao();
                repository.Excluir(idVenda);
            }
            catch (Exception e)
            {
                throw new Exception("Ocorreu um erro: " + e.Message);
            }
            finally
            {
                repository.FecharConexao();
            }
        }