public GerenciadorFinanceiro.Dominio.FormaPagamento BuscarObjetoPorId(int id)
        {
            string sSqlSelect = "select * from TB_Forma_Pagamento where IdFormaPagamento = @Id";

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sSqlSelect, id);
                Dominio.FormaPagamento pagamento = new GerenciadorFinanceiro.Dominio.FormaPagamento();
                while (reader.Read())
                {
                    pagamento.Id        = (int)reader["IdFormaPagamento"];
                    pagamento.Descricao = (string)reader["Descricao"];
                }
                return(pagamento);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível buscar a Forma de pagamento solicitada.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#2
0
        public List <GerenciadorFinanceiro.Dominio.TipoVeiculo> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Tipo_Veiculo where Ativo = 1 order by Descricao";
            List <Dominio.TipoVeiculo> listaTipoVeiculo = new List <GerenciadorFinanceiro.Dominio.TipoVeiculo>();

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sSqlSelect);
                Dominio.TipoVeiculo tipoVeiculo;
                while (reader.Read())
                {
                    tipoVeiculo = new Dominio.TipoVeiculo();
                    tipoVeiculo.IdTipoVeiculo = (int)reader["IdTipoVeiculo"];
                    tipoVeiculo.Descricao     = (string)reader["Descricao"];
                    listaTipoVeiculo.Add(tipoVeiculo);
                    tipoVeiculo = null;
                }
                return(listaTipoVeiculo);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar todos os Tipos de Veículos.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
        public List <GerenciadorFinanceiro.Dominio.FormaPagamento> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Forma_Pagamento where Ativo = 1 order by Descricao";

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sSqlSelect);
                List <Dominio.FormaPagamento> lista = new List <GerenciadorFinanceiro.Dominio.FormaPagamento>();
                while (reader.Read())
                {
                    Dominio.FormaPagamento pagamento = new GerenciadorFinanceiro.Dominio.FormaPagamento();
                    pagamento.Id        = (int)reader["IdFormaPagamento"];
                    pagamento.Descricao = (string)reader["Descricao"];
                    lista.Add(pagamento);
                }
                return(lista);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível buscar as Formas de pagamento solicitadas.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#4
0
        public Dominio.TipoVeiculo BuscarObjetoPorId(int id)
        {
            string sSqlSelect = "select * from TB_Tipo_Veiculo where IdTipoVeiculo = @IdTipoVeiculo";

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sSqlSelect, id);
                Dominio.TipoVeiculo tipoVeiculo = new Dominio.TipoVeiculo();
                while (reader.Read())
                {
                    tipoVeiculo.IdTipoVeiculo = id;
                    tipoVeiculo.Descricao     = (string)reader["Descricao"];
                }
                return(tipoVeiculo);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar o Tipo de Veículo.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
        public GerenciadorFinanceiro.Dominio.CentroCustos BuscarObjetoPorId(int id)
        {
            string sSqlSelect = "select * from TB_Centro_Custos where IdCentroCustos = @Idcusto";

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sSqlSelect, id);
                Dominio.CentroCustos custos = new Dominio.CentroCustos();
                while (reader.Read())
                {
                    custos.Id               = id;
                    custos.Descricao        = (string)reader["Descricao"];
                    custos.ReceitaOuDespesa = (Dominio.CentroCustos.Tipo)reader["DespesaOuReceita"];
                }
                return(custos);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar o Centro de custos.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#6
0
        public List <GerenciadorFinanceiro.Dominio.TipoServico> BuscarTodos()
        {
            string sqlSelect = "select * from TB_TipoServico where Ativo = 1 order by Descricao";

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sqlSelect);
                List <Dominio.TipoServico> lista = new List <GerenciadorFinanceiro.Dominio.TipoServico>();
                while (reader.Read())
                {
                    Dominio.TipoServico tipoServico = new GerenciadorFinanceiro.Dominio.TipoServico();
                    tipoServico.IdTipoServico = (int)reader["IdTipoServico"];
                    tipoServico.Descricao     = (string)reader["Descricao"];
                    lista.Add(tipoServico);
                }
                return(lista);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível buscar os Tipos de serviços.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#7
0
        public List <GerenciadorFinanceiro.Dominio.ModeloVeiculo> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Modelo_Veiculo where Ativo = 1 order by Descricao";
            List <Dominio.ModeloVeiculo> listaModeloVeiculo = new List <GerenciadorFinanceiro.Dominio.ModeloVeiculo>();

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sSqlSelect);
                Dominio.ModeloVeiculo modeloVeiculo;
                while (reader.Read())
                {
                    modeloVeiculo = new Dominio.ModeloVeiculo();
                    modeloVeiculo.IdModeloVeiculo = (int)reader["IdModeloVeiculo"];
                    modeloVeiculo.Descricao       = (string)reader["Descricao"];
                    modeloVeiculo.Fabricante      = new Repositorio.RepositorioFabricanteVeiculo().BuscarObjetoPorId((int)reader["IdFabricanteVeiculo"]);
                    listaModeloVeiculo.Add(modeloVeiculo);
                    modeloVeiculo = null;
                }
                return(listaModeloVeiculo);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar todos os Modelos de Veículos.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
        public List <GerenciadorFinanceiro.Dominio.CentroCustos> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Centro_Custos where Ativo = 1";

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sSqlSelect);
                List <Dominio.CentroCustos> lista = new List <GerenciadorFinanceiro.Dominio.CentroCustos>();
                while (reader.Read())
                {
                    Dominio.CentroCustos custos = new Dominio.CentroCustos();
                    custos.Id               = (int)reader["IdCentroCustos"];
                    custos.Descricao        = (string)reader["Descricao"];
                    custos.ReceitaOuDespesa = (Dominio.CentroCustos.Tipo)reader["DespesaOuReceita"];
                    lista.Add(custos);
                }
                return(lista);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar os Centros de custos.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#9
0
        public GerenciadorFinanceiro.Dominio.Banco BuscarObjetoPorId(int id)
        {
            string sSqlSelect = "select * from TB_Banco where IdBanco = @id";

            Dominio.Banco banco = new Dominio.Banco();
            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sSqlSelect, id);
                while (reader.Read())
                {
                    banco.IdBanco     = (int)reader["IdBanco"];;
                    banco.CodigoBanco = (String)reader["CodigoBanco"];
                    banco.Descricao   = (String)reader["Descricao"];
                }
                return(banco);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar o banco.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#10
0
        public List <GerenciadorFinanceiro.Dominio.Banco> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Banco where Ativo = 1 order by Descricao";
            List <Dominio.Banco> ListBanco = new List <GerenciadorFinanceiro.Dominio.Banco>();

            Dominio.Banco banco;
            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sSqlSelect);

                while (reader.Read())
                {
                    banco             = new Dominio.Banco();
                    banco.IdBanco     = (int)reader["IdBanco"];;
                    banco.CodigoBanco = (String)reader["CodigoBanco"];
                    banco.Descricao   = (String)reader["Descricao"];
                    ListBanco.Add(banco);
                    banco = null;
                }
                return(ListBanco);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar todos os Bancos.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#11
0
        public Dominio.Servico BuscarObjetoPorId(int id)
        {
            string sSqlSelect = "select * from TB_Servico where IdServico = @IdServico";

            try
            {
                Conection.AbrirConexao();
                var             reader  = Conection.ExecuteReader(sSqlSelect, id);
                Dominio.Servico servico = new Dominio.Servico();
                while (reader.Read())
                {
                    servico.IdServico  = id;
                    servico.Descricao  = (string)reader["Descricao"];
                    servico.Valor      = (double)reader["Valor"];
                    servico.Observacao = (string)reader["Observacao"];
                }
                return(servico);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar o Veículo.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#12
0
        public List <GerenciadorFinanceiro.Dominio.Servico> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Servico where Ativo = 1 order by Descricao";
            List <Dominio.Servico> ListServicos = new List <GerenciadorFinanceiro.Dominio.Servico>();

            try
            {
                Conection.AbrirConexao();
                var             reader = Conection.ExecuteReader(sSqlSelect);
                Dominio.Servico servico;
                while (reader.Read())
                {
                    servico            = new Dominio.Servico();
                    servico.IdServico  = (int)reader["IdServico"];
                    servico.Descricao  = (string)reader["Descricao"];
                    servico.Valor      = (double)reader["Valor"];
                    servico.Observacao = (string)reader["Observacao"];
                    ListServicos.Add(servico);
                    servico = null;
                }
                return(ListServicos);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar todos os Serviços.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#13
0
        public Dominio.DespesaCombustivel BuscarUltimaDespesaVeiculo(Dominio.Veiculo veiculo)
        {
            string sqlBusca = "SELECT TOP (1) IdDespesaCombustivel, IdVeiculo, KmInicial, KmFinal,"
                              + "QtdLitros, ValorTotal, TipoCombustivel, DataAbastecimento FROM "
                              + "TB_Despesa_Combustivel WHERE IdVeiculo = @IdVeiculo ORDER BY KmFinal DESC";

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sqlBusca, veiculo.IdVeiculo);
                Dominio.DespesaCombustivel despesa = new GerenciadorFinanceiro.Dominio.DespesaCombustivel();
                while (reader.Read())
                {
                    despesa.IdDespesaCombustivel = (int)reader["IdDespesaCombustivel"];
                    despesa.Veiculo           = veiculo;
                    despesa.KmInicial         = (int)reader["KmInicial"];
                    despesa.KmFinal           = (int)reader["KmFinal"];
                    despesa.QtdLitros         = (int)reader["QtdLitros"];
                    despesa.ValorTotal        = (double)reader["ValorTotal"];
                    despesa.Combustivel       = (TipoCombustivel)reader["TipoCombustivel"];
                    despesa.DataAbastecimento = (DateTime)reader["DataAbastecimento"];
                }
                return(despesa);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível buscar a Ultima quilometragem do Carro.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#14
0
        public List <GerenciadorFinanceiro.Dominio.Estado> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Estado where Ativo = 1 order by NomeEstado";
            List <Dominio.Estado> listaEst = new List <GerenciadorFinanceiro.Dominio.Estado>();

            try
            {
                Conection.AbrirConexao();
                var            reader = Conection.ExecuteReader(sSqlSelect);
                Dominio.Estado Est;
                while (reader.Read())
                {
                    Est             = new Dominio.Estado();
                    Est.IdEstado    = (int)reader["IdEstado"];
                    Est.NomeEstado  = (string)reader["NomeEstado"];
                    Est.SiglaEstado = (string)reader["Sigla"];
                    listaEst.Add(Est);
                    Est = null;
                }
                return(listaEst);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar todos os estados.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#15
0
        public Dominio.Estado BuscarObjetoPorId(int id)
        {
            string sSqlSelect = "select * from TB_Estado where Ativo = 1 and IdEstado = @IdEstado";

            try
            {
                Conection.AbrirConexao();
                var            reader = Conection.ExecuteReader(sSqlSelect, id);
                Dominio.Estado Est    = new Dominio.Estado();
                while (reader.Read())
                {
                    Est.IdEstado    = id;
                    Est.NomeEstado  = (string)reader["NomeEstado"];
                    Est.SiglaEstado = (string)reader["Sigla"];
                }
                return(Est);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar o estado.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#16
0
        public List <GerenciadorFinanceiro.Dominio.Categoria> BuscarTodasPorCentroCusto(int IdCentroCusto)
        {
            string sSqlSelect = "select * from TB_Categoria where IdCentroCusto = @IdCusto and Ativo = 1";

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sSqlSelect, IdCentroCusto);
                List <Dominio.Categoria> lista = new List <GerenciadorFinanceiro.Dominio.Categoria>();
                while (reader.Read())
                {
                    Dominio.Categoria cat = new Dominio.Categoria();
                    cat.Id        = (int)reader["IdCategoria"];
                    cat.Descricao = (string)reader["Descricao"];
                    Dominio.CentroCustos catPai = new Repositorio.RepositorioCentroCustos().BuscarObjetoPorId((int)reader["IdCentroCusto"]);
                    cat.CategoriaPai = catPai;
                    lista.Add(cat);
                }
                return(lista);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar a Categoria.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#17
0
        public GerenciadorFinanceiro.Dominio.Categoria BuscarObjetoPorId(int id)
        {
            string sSqlSelect = "select * from TB_Categoria where IdCategoria = @IdCategoria";

            try
            {
                Conection.AbrirConexao();
                var reader            = Conection.ExecuteReader(sSqlSelect, id);
                Dominio.Categoria cat = new Dominio.Categoria();
                while (reader.Read())
                {
                    cat.Id        = id;
                    cat.Descricao = (string)reader["Descricao"];
                    Dominio.CentroCustos catPai = new Repositorio.RepositorioCentroCustos().BuscarObjetoPorId((int)reader["IdCentroCusto"]);
                    cat.CategoriaPai = catPai;
                }
                return(cat);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar a Categoria.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#18
0
        public GerenciadorFinanceiro.Dominio.ModeloVeiculo BuscarObjetoPorId(int id)
        {
            string sSqlSelect = "select * from TB_Modelo_Veiculo where IdModeloVeiculo = @IdModeloVeiculo";

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sSqlSelect, id);
                Dominio.ModeloVeiculo modeloVeiculo = new Dominio.ModeloVeiculo();
                while (reader.Read())
                {
                    modeloVeiculo.IdModeloVeiculo = id;
                    modeloVeiculo.Descricao       = (string)reader["Descricao"];
                    modeloVeiculo.Fabricante      = new Repositorio.RepositorioFabricanteVeiculo().BuscarObjetoPorId((int)reader["IdFabricanteVeiculo"]);
                }
                return(modeloVeiculo);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar o Modelo de Veículo.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
        public Dominio.Veiculo BuscarObjetoPorId(int id)
        {
            string sSqlSelect = "select * from TB_Veiculo where IdVeiculo = @IdVeiculo";

            try
            {
                Conection.AbrirConexao();
                var             reader  = Conection.ExecuteReader(sSqlSelect, id);
                Dominio.Veiculo veiculo = new Dominio.Veiculo();
                while (reader.Read())
                {
                    veiculo.IdVeiculo     = id;
                    veiculo.Placa         = (string)reader["Placa"];
                    veiculo.Renavam       = (string)reader["Renavam"];
                    veiculo.Chassi        = (string)reader["Chassi"];
                    veiculo.Ano           = (int)reader["Ano"];
                    veiculo.Modelo        = (int)reader["Modelo"];
                    veiculo.Cor           = (string)reader["Cor"];
                    veiculo.Observacao    = (string)reader["Observacao"];
                    veiculo.PathFoto      = (string)reader["PathFoto"];
                    veiculo.Combustivel   = (string)reader["Combustivel"];
                    veiculo.TipoVeiculo   = new Repositorio.RepositorioTipoVeiculo().BuscarObjetoPorId((int)reader["IdTipoVeiculo"]);
                    veiculo.ModeloVeiculo = new RepositorioModeloVeiculo().BuscarObjetoPorId((int)reader["IdModeloVeiculo"]);
                }
                return(veiculo);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar o Veículo.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#20
0
        public GerenciadorFinanceiro.Dominio.TipoServico BuscarObjetoPorId(int id)
        {
            string sqlSelect = "select * from TB_TipoServico where IdTipoServico = @id";

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sqlSelect, id);
                Dominio.TipoServico tipoServico = new GerenciadorFinanceiro.Dominio.TipoServico();
                while (reader.Read())
                {
                    tipoServico.IdTipoServico = (int)reader["IdTipoServico"];
                    tipoServico.Descricao     = (string)reader["Descricao"];
                }
                return(tipoServico);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível buscar o Tipo de serviço solicitado.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
        public List <GerenciadorFinanceiro.Dominio.Cidade> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Cidade where Ativo = 1 order by NomeCidade";
            List <Dominio.Cidade> listaCid = new List <GerenciadorFinanceiro.Dominio.Cidade>();

            try
            {
                Conection.AbrirConexao();
                var               reader = Conection.ExecuteReader(sSqlSelect);
                Dominio.Cidade    Cid;
                RepositorioEstado repEstado = new RepositorioEstado();
                while (reader.Read())
                {
                    Cid            = new Dominio.Cidade();
                    Cid.IdCidade   = (int)reader["IdCidade"];
                    Cid.NomeCidade = (string)reader["NomeCidade"];
                    Cid.Estado     = repEstado.BuscarObjetoPorId((int)reader["IdEstado"]);
                    listaCid.Add(Cid);
                    Cid = null;
                }
                return(listaCid);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar todas as Cidades.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
        public List <Dominio.Cidade> BuscarCidadesPorEstado(Dominio.Estado estado)
        {
            string sSqlSelect = "select * from TB_Cidade where Ativo = 1 and IdEstado = @IdEstado";
            List <Dominio.Cidade> listaCid = new List <GerenciadorFinanceiro.Dominio.Cidade>();

            try
            {
                Conection.AbrirConexao();
                var            reader = Conection.ExecuteReader(sSqlSelect, estado.IdEstado);
                Dominio.Cidade Cid;
                while (reader.Read())
                {
                    Cid            = new Dominio.Cidade();
                    Cid.IdCidade   = (int)reader["IdCidade"];
                    Cid.NomeCidade = (string)reader["NomeCidade"];
                    Cid.Estado     = estado;
                    listaCid.Add(Cid);
                    Cid = null;
                }
                return(listaCid);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível buscar todas as Cidades do estado.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
        public Dominio.Cidade BuscarObjetoPorId(int id)
        {
            string sSqlSelect = "select * from TB_Cidade where IdCidade = @IdCidade";

            try
            {
                Conection.AbrirConexao();
                var            reader = Conection.ExecuteReader(sSqlSelect, id);
                Dominio.Cidade Cid    = new Dominio.Cidade();
                while (reader.Read())
                {
                    Cid.IdCidade   = id;
                    Cid.NomeCidade = (string)reader["NomeCidade"];
                    Cid.Estado     = new RepositorioEstado().BuscarObjetoPorId((int)reader["IdEstado"]);
                }
                return(Cid);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar a Cidade.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
        public Dominio.Usuario BuscarObjetoPorId(int id)
        {
            string sSqlSelect = "select * from TB_Usuario where IdUsuario = @IdUsuario";

            try
            {
                Conection.AbrirConexao();
                var             reader  = Conection.ExecuteReader(sSqlSelect, id);
                Dominio.Usuario usuario = new Dominio.Usuario();
                while (reader.Read())
                {
                    usuario.IdUsuario = id;
                    usuario.Nome      = (string)reader["Nome"];
                    usuario.Email     = (string)reader["Email"];
                    usuario.Telefone  = (string)reader["Telefone"];
                    usuario.Celular   = (string)reader["Celular"];
                    usuario.UserName  = (string)reader["Username"];
                    usuario.Senha     = (string)reader["Senha"];
                }
                return(usuario);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar o Usuário.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
        public List <GerenciadorFinanceiro.Dominio.Usuario> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Usuario where Ativo = 1 and IdUsuario > 1 order by Nome";
            List <Dominio.Usuario> ListUsuarios = new List <GerenciadorFinanceiro.Dominio.Usuario>();

            try
            {
                Conection.AbrirConexao();
                var             reader = Conection.ExecuteReader(sSqlSelect);
                Dominio.Usuario usuario;
                while (reader.Read())
                {
                    usuario           = new Dominio.Usuario();
                    usuario.IdUsuario = (int)reader["IdUsuario"];
                    usuario.Nome      = (string)reader["Nome"];
                    usuario.Email     = (string)reader["Email"];
                    usuario.Telefone  = (string)reader["Telefone"];
                    usuario.Celular   = (string)reader["Celular"];
                    usuario.UserName  = (string)reader["Username"];
                    usuario.Senha     = (string)reader["Senha"];
                    ListUsuarios.Add(usuario);
                    usuario = null;
                }
                return(ListUsuarios);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar todos os Usuários.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#26
0
        public List <GerenciadorFinanceiro.Dominio.Aluno> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Aluno where Ativo = 1 order by Nome";
            List <Dominio.Aluno> listAlunos = new List <GerenciadorFinanceiro.Dominio.Aluno>();

            try
            {
                Conection.AbrirConexao();
                var              reader = Conection.ExecuteReader(sSqlSelect);
                Dominio.Aluno    aluno;
                Dominio.Endereco endereco;
                while (reader.Read())
                {
                    aluno                     = new Dominio.Aluno();
                    aluno.IdAluno             = (int)reader["IdAluno"];;
                    aluno.NomeAluno           = (string)reader["Nome"];
                    aluno.CPF_CNPJ            = (string)reader["CPF_CNPJ"];
                    aluno.RG_InscEstadual     = (string)reader["RG_InscricaoEstadual"];
                    aluno.TelefoneResidencial = (string)reader["TelefoneResidencial"];
                    aluno.TelefoneComercial   = (string)reader["TelefoneComercial"];
                    aluno.TelefoneCelular     = (string)reader["TelefoneCelular"];
                    aluno.DataNascimento      = (DateTime)reader["DataNascimento"];
                    endereco                  = new Dominio.Endereco();
                    endereco.Rua              = (string)reader["Rua"];
                    endereco.Numero           = (int)reader["Numero"];
                    endereco.Complemento      = (string)reader["Complemento"];
                    endereco.Bairro           = (string)reader["Bairro"];
                    endereco.CEP              = (string)reader["CEP"];
                    endereco.Cidade           = new RepositorioCidade().BuscarObjetoPorId((int)reader["IdCidade"]);
                    aluno.Endereco            = endereco;
                    endereco                  = null;
                    aluno.SSP                 = (string)reader["SSP"];
                    aluno.NomePai             = (string)reader["NomePai"];
                    aluno.NomeMae             = (string)reader["NomeMae"];
                    aluno.Referencia          = (string)reader["Referencia"];
                    aluno.Observacao          = (string)reader["Observacao"];
                    aluno.Email               = (string)reader["Email"];
                    listAlunos.Add(aluno);
                    aluno = null;
                }
                return(listAlunos);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar todos os Alunos.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#27
0
        public Dominio.Aluno BuscarObjetoPorId(int id)
        {
            string sSqlSelect = "select * from TB_Aluno where IdAluno = @IdAluno";

            try
            {
                Conection.AbrirConexao();
                var              reader   = Conection.ExecuteReader(sSqlSelect, id);
                Dominio.Aluno    aluno    = new Dominio.Aluno();
                Dominio.Endereco endereco = new Dominio.Endereco();
                while (reader.Read())
                {
                    aluno.IdAluno             = id;
                    aluno.NomeAluno           = (string)reader["Nome"];
                    aluno.CPF_CNPJ            = (string)reader["CPF_CNPJ"];
                    aluno.RG_InscEstadual     = (string)reader["RG_InscEstadual"];
                    aluno.TelefoneResidencial = (string)reader["TelefoneResidencial"];
                    aluno.TelefoneComercial   = (string)reader["TelefoneComercial"];
                    aluno.TelefoneCelular     = (string)reader["TelefoneCelular"];
                    aluno.DataNascimento      = (DateTime)reader["DataNascimento"];
                    endereco.Rua         = (string)reader["Rua"];
                    endereco.Numero      = (int)reader["Numero"];
                    endereco.Complemento = (string)reader["Complemento"];
                    endereco.Bairro      = (string)reader["Bairro"];
                    endereco.CEP         = (string)reader["CEP"];
                    endereco.Cidade      = new RepositorioCidade().BuscarObjetoPorId((int)reader["IdCidade"]);
                    aluno.Endereco       = endereco;
                    aluno.SSP            = (string)reader["SSP"];
                    aluno.NomePai        = (string)reader["NomePai"];
                    aluno.NomeMae        = (string)reader["NomeMae"];
                    aluno.Referencia     = (string)reader["Referencia"];
                    aluno.Observacao     = (string)reader["Observacao"];
                    aluno.Email          = (string)reader["Email"];
                }
                return(aluno);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar o Aluno.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
示例#28
0
        public List <GerenciadorFinanceiro.Dominio.Instrutor> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Instrutor where Ativo = 1 order by Nome";
            List <Dominio.Instrutor> listaInstrutor = new List <GerenciadorFinanceiro.Dominio.Instrutor>();

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sSqlSelect);
                Dominio.Instrutor instrutor;
                while (reader.Read())
                {
                    instrutor                     = new Dominio.Instrutor();
                    instrutor.IdInstrutor         = (int)reader["IdInstrutor"];
                    instrutor.Nome                = (string)reader["Nome"];
                    instrutor.TelefoneResidencial = (string)reader["TelefoneResidencial"];
                    instrutor.TelefoneCelular     = (string)reader["TelefoneCelular"];
                    instrutor.RG                  = (string)reader["RG"];
                    instrutor.CPF                 = (string)reader["CPF"];
                    Dominio.Endereco endereco = new Dominio.Endereco();
                    endereco.Rua         = (string)reader["Rua"];
                    endereco.Numero      = (int)reader["Numero"];
                    endereco.Complemento = (string)reader["Complemento"];
                    endereco.Bairro      = (string)reader["Bairro"];
                    endereco.CEP         = (string)reader["CEP"];
                    endereco.Cidade      = new Repositorio.RepositorioCidade().BuscarObjetoPorId((int)reader["IdCidade"]);
                    instrutor.Endereco   = endereco;
                    instrutor.PathFoto   = (string)reader["PathFoto"];
                    instrutor.Observacao = (string)reader["Observacao"];
                    endereco             = null;
                    listaInstrutor.Add(instrutor);
                    instrutor = null;
                }
                return(listaInstrutor);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível buscar os instrutores.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
        public List <GerenciadorFinanceiro.Dominio.Veiculo> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Veiculo where Ativo = 1";
            List <Dominio.Veiculo> listVeiculos = new List <GerenciadorFinanceiro.Dominio.Veiculo>();

            try
            {
                Conection.AbrirConexao();
                var             reader = Conection.ExecuteReader(sSqlSelect);
                Dominio.Veiculo veiculo;
                while (reader.Read())
                {
                    veiculo               = new Dominio.Veiculo();
                    veiculo.IdVeiculo     = (int)reader["IdVeiculo"];
                    veiculo.Placa         = (string)reader["Placa"];
                    veiculo.Renavam       = (string)reader["Renavam"];
                    veiculo.Chassi        = (string)reader["Chassi"];
                    veiculo.Ano           = (int)reader["Ano"];
                    veiculo.Modelo        = (int)reader["Modelo"];
                    veiculo.Cor           = (string)reader["Cor"];
                    veiculo.Observacao    = (string)reader["Observacao"];
                    veiculo.PathFoto      = (string)reader["PathFoto"];
                    veiculo.Combustivel   = (string)reader["Combustivel"];
                    veiculo.TipoVeiculo   = new Repositorio.RepositorioTipoVeiculo().BuscarObjetoPorId((int)reader["IdTipoVeiculo"]);
                    veiculo.ModeloVeiculo = new RepositorioModeloVeiculo().BuscarObjetoPorId((int)reader["IdModeloVeiculo"]);
                    listVeiculos.Add(veiculo);
                    veiculo = null;
                }
                return(listVeiculos);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar todos os Veículos.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
        internal GerenciadorFinanceiro.Dominio.Usuario ObterUsuarioPorUsernameAndPassword(string username, string password)
        {
            string sqlConsulta = "select * from TB_Usuario where Ativo = 1 and Username = @Username and Senha = @Senha";

            try
            {
                Conection.AbrirConexao();
                var             reader  = Conection.ExecuteReader(sqlConsulta, username, password);
                Dominio.Usuario usuario = new Dominio.Usuario();
                int             flag    = 0;
                while (reader.Read())
                {
                    flag = 1;
                    usuario.IdUsuario = (int)reader["IdUsuario"];
                    usuario.Nome      = (string)reader["Nome"];
                    usuario.Email     = (string)reader["Email"];
                    usuario.Telefone  = (string)reader["Telefone"];
                    usuario.Celular   = (string)reader["Celular"];
                    usuario.UserName  = username;
                    usuario.Senha     = password;
                }
                if (flag == 1)
                {
                    return(usuario);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Nao foi possivel verificar o Usuario e Senha! Tente novamente!", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }