Beispiel #1
0
        public DataTable listarCidades(string tipoFiltro, string filtro)
        {
            DataTable dt = new DataTable();

            try
            {
                ConexaoBanco conexao = new ConexaoBanco();
                conexao.AbrirConexao();
                if (tipoFiltro == "TODAS")
                {
                    dt = conexao.RetDataTable("select *from cidade");
                }
                else if (tipoFiltro == "CIDADE")
                {
                    dt = conexao.RetDataTable("select *from cidade where nome_cidade like '%" + filtro + "'");
                }
                else if (tipoFiltro == "UF")
                {
                    dt = conexao.RetDataTable("select *from cidade where uf_cidade = '" + filtro + "'");
                }
            }
            catch (Exception erro)
            {
                throw new Exception("Erro ao listar cidades, classe DAO " + erro.Message);
            }
            finally
            {
                FecharConexao();
            }
            return(dt);
        }
Beispiel #2
0
        public DataTable listarMarcas(string tipoFiltro, string filtro)
        {
            DataTable dt = new DataTable();

            try
            {
                AbrirConexao();
                ConexaoBanco conexao = new ConexaoBanco();
                conexao.AbrirConexao();
                if (tipoFiltro == "TODAS")
                {
                    dt = conexao.RetDataTable("select *from marca");
                }
                else if (tipoFiltro == "MARCA")
                {
                    dt = conexao.RetDataTable("select *from marca where descricao_marca = '" + filtro + "'");
                }
            }
            catch (Exception erro)
            {
                throw new Exception("Erro ao listar marcar, classe DAO " + erro.Message);
            }
            finally
            {
                FecharConexao();
            }
            return(dt);
        }
Beispiel #3
0
        //Método lista as categorias e/ou sub-categorias
        public DataTable listarCategoriaSubCategoria(string tipoConsultaCatSub, string filtroUtilizado, string informacao)
        {
            DataTable dt = new DataTable();

            try
            {
                ConexaoBanco conexao = new ConexaoBanco();
                conexao.AbrirConexao();
                //Validando para puxar categoria e sub-categoria
                if (tipoConsultaCatSub == "T" && filtroUtilizado == "TODOS")
                {
                    dt = conexao.RetDataTable("select *from categoria");
                }
                else if (tipoConsultaCatSub == "T" && filtroUtilizado == "NOME")
                {
                    dt = conexao.RetDataTable("select *from categoria where descricao_categoria = '" + informacao + "'");
                }
                else if (tipoConsultaCatSub == "T" && filtroUtilizado == "INTELIGENTE")
                {
                    dt = conexao.RetDataTable("select *from categoria where descricao_categoria like '%" + informacao + "%'");
                }
                //Validação para puxar somente por categoria
                if (tipoConsultaCatSub == "C" && filtroUtilizado == "TODOS")
                {
                    dt = conexao.RetDataTable("select *from categoria where tipo_categoria = 'C'");
                }
                else if (tipoConsultaCatSub == "C" && filtroUtilizado == "NOME")
                {
                    dt = conexao.RetDataTable("select *from categoria where descricao_categoria = '" + informacao + "' and tipo_categoria = 'C'");
                }
                else if (tipoConsultaCatSub == "C" && filtroUtilizado == "INTELIGENTE")
                {
                    dt = conexao.RetDataTable("select *from categoria where descricao_categoria like '%" + informacao + "%' and tipo_categoria = 'C'");
                }
                //Validando para puxar somente por sub-categoria
                if (tipoConsultaCatSub == "S" && filtroUtilizado == "TODOS")
                {
                    dt = conexao.RetDataTable("select *from categoria where tipo_categoria = 'S'");
                }
                else if (tipoConsultaCatSub == "S" && filtroUtilizado == "NOME")
                {
                    dt = conexao.RetDataTable("select *from categoria where descricao_categoria = '" + informacao + "' and tipo_categoria = 'S'");
                }
                else if (tipoConsultaCatSub == "S" && filtroUtilizado == "INTELIGENTE")
                {
                    dt = conexao.RetDataTable("select *from categoria where descricao_categoria like '%" + informacao + "%' and tipo_categoria = 'S'");
                }
            }
            catch (Exception erro)
            {
                throw new Exception("Erro ao pesquisar as categorias e/ou sub-categorias!" + erro.Message);
            }
            return(dt);
        }
Beispiel #4
0
        //Metodo de lista de produtos com variações e seus respectivos filtros
        public DataTable listarProdutosVariacoes(string tipoPesquisa, string filtro1, string tipoProdutoDAO, string tipoServicoDAO)
        {
            DataTable dt = new DataTable();

            try
            {
                ConexaoBanco conexao = new ConexaoBanco();
                conexao.AbrirConexao();
                if (tipoPesquisa == "TODOS")
                {
                    dt = conexao.RetDataTable("select *from viewlistarprodutocomvariacao where categoria = '' and tipoitem in ('', '') or subcategoria = '' and tipoitem in ('', '') or fornecedor = '' and tipoitem in ('', '') or id_produto = '' and tipoitem in ('', '') or descricao_marca = '' and tipoitem in ('', '') or descricao_produto = '' and tipoitem in ('', '') or categoria like '' or subcategoria like '' or descricao_produto like '' or descricao_marca like '' or fornecedor like '' and tipoitem in ('', '') or tipoitem in ('" + tipoProdutoDAO + "', '" + tipoServicoDAO + "')");
                }
                else if (tipoPesquisa == "CÓDIGO")
                {
                    dt = conexao.RetDataTable("select *from viewlistarprodutocomvariacao where categoria = '' and tipoitem in ('', '') or subcategoria = '' and tipoitem in ('', '') or fornecedor = '' and tipoitem in ('', '') or id_produto = '" + filtro1 + "' and tipoitem in ('" + tipoProdutoDAO + "', '" + tipoServicoDAO + "') or descricao_marca = '' and tipoitem in ('', '') or descricao_produto = '' and tipoitem in ('', '') or categoria like '' or subcategoria like '' or descricao_produto like '' or descricao_marca like '' or fornecedor like '' and tipoitem in ('', '') or tipoitem in ('', '')");
                }
                else if (tipoPesquisa == "NOME")
                {
                    dt = conexao.RetDataTable("select *from viewlistarprodutocomvariacao where categoria = '' and tipoitem in ('', '') or subcategoria = '' and tipoitem in ('', '') or fornecedor = '' and tipoitem in ('', '') or id_produto = '' and tipoitem in ('', '') or descricao_marca = '' and tipoitem in ('', '') or descricao_produto = '" + filtro1 + "' and tipoitem in ('" + tipoProdutoDAO + "', '" + tipoServicoDAO + "') or categoria like '' or subcategoria like '' or descricao_produto like '' or descricao_marca like '' or fornecedor like '' and tipoitem in ('', '') or tipoitem in ('', '')");
                }
                else if (tipoPesquisa == "CATEGORIA")
                {
                    dt = conexao.RetDataTable("select *from viewlistarprodutocomvariacao where categoria = '" + filtro1 + "' and tipoitem in ('" + tipoProdutoDAO + "', '" + tipoServicoDAO + "') or subcategoria = '' and tipoitem in ('', '') or fornecedor = '' and tipoitem in ('', '') or id_produto = '' and tipoitem in ('', '') or descricao_marca = '' and tipoitem in ('', '') or descricao_produto = '' and tipoitem in ('', '') or categoria like '' or subcategoria like '' or descricao_produto like '' or descricao_marca like '' or fornecedor like '' and tipoitem in ('', '') or tipoitem in ('', '')");
                }
                else if (tipoPesquisa == "SUB-CATEGORIA")
                {
                    dt = conexao.RetDataTable("select *from viewlistarprodutocomvariacao where categoria = '' and tipoitem in ('', '') or subcategoria = '" + filtro1 + "' and tipoitem in ('" + tipoProdutoDAO + "', '" + tipoServicoDAO + "') or fornecedor = '' and tipoitem in ('', '') or id_produto = '' and tipoitem in ('', '') or descricao_marca = '' and tipoitem in ('', '') or descricao_produto = '' and tipoitem in ('', '') or categoria like '' or subcategoria like '' or descricao_produto like '' or descricao_marca like '' or fornecedor like '' and tipoitem in ('', '') or tipoitem in ('', '')");
                }
                else if (tipoPesquisa == "MARCA")
                {
                    dt = conexao.RetDataTable("select *from viewlistarprodutocomvariacao where categoria = '' and tipoitem in ('', '') or subcategoria = '' and tipoitem in ('', '') or fornecedor = '' and tipoitem in ('', '') or id_produto = '' and tipoitem in ('', '') or descricao_marca = '" + filtro1 + "' and tipoitem in ('" + tipoProdutoDAO + "', '" + tipoServicoDAO + "') or descricao_produto = '' and tipoitem in ('', '') or categoria like '' or subcategoria like '' or descricao_produto like '' or descricao_marca like '' or fornecedor like '' and tipoitem in ('', '') or tipoitem in ('', '')");
                }
                else if (tipoPesquisa == "FORNECEDOR")
                {
                    dt = conexao.RetDataTable("select *from viewlistarprodutocomvariacao where categoria = '' and tipoitem in ('', '') or subcategoria = '' and tipoitem in ('', '') or fornecedor = '" + filtro1 + "' and tipoitem in ('" + tipoProdutoDAO + "', '" + tipoServicoDAO + "') or id_produto = '' and tipoitem in ('', '') or descricao_marca = '' and tipoitem in ('', '') or descricao_produto = '' and tipoitem in ('', '') or categoria like '' or subcategoria like '' or descricao_produto like '' or descricao_marca like '' or fornecedor like '' and tipoitem in ('', '') or tipoitem in ('', '')");
                }
                else if (tipoPesquisa == "TIPO")
                {
                    dt = conexao.RetDataTable("select *from viewlistarprodutocomvariacao where categoria = '' and tipoitem in ('', '') or subcategoria = '' and tipoitem in ('', '') or fornecedor = '' and tipoitem in ('', '') or id_produto = '' and tipoitem in ('', '') or descricao_marca = '' and tipoitem in ('', '') or descricao_produto = '' and tipoitem in ('', '') or categoria like '' or subcategoria like '' or descricao_produto like '' or descricao_marca like '' or fornecedor like '' and tipoitem in ('', '') or tipoitem in ('" + tipoProdutoDAO + "', '" + tipoServicoDAO + "')");
                }
                else if (tipoPesquisa == "INTELIGENTE")
                {
                    dt = conexao.RetDataTable("select *from viewlistarprodutocomvariacao where categoria = '' and tipoitem in ('', '') or subcategoria = '' and tipoitem in ('', '') or fornecedor = '' and tipoitem in ('', '') or id_produto = '' and tipoitem in ('', '') or descricao_marca = '' and tipoitem in ('', '') or descricao_produto = '' and tipoitem in ('', '') or categoria like '%" + filtro1 + "%' or subcategoria like '%" + filtro1 + "%' or descricao_produto like '%" + filtro1 + "%' or descricao_marca like '%" + filtro1 + "%' or fornecedor like '%" + filtro1 + "%' and tipoitem in ('" + tipoProdutoDAO + "', '" + tipoServicoDAO + "') or tipoitem in ('', '')");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao pesquisar produtos: " + ex.Message);
            }
            return(dt);
        }
Beispiel #5
0
        //Método listar itens locação na tabela
        public DataTable listarItensLocacao(string filtro)
        {
            DataTable dt = new DataTable();

            try
            {
                ConexaoBanco conexao = new ConexaoBanco();
                conexao.AbrirConexao();
                dt = conexao.RetDataTable("select *from viewlocacaoitens where idLocacao_locacaoitens = '" + filtro + "'");
            }catch (Exception erro)
            {
                throw new Exception("Erro ao consultar itens " + erro.Message);
            }
            return(dt);
        }
Beispiel #6
0
        //Método lista os produtos variações do produto informado pelo código
        public DataTable listarVariacaoProduto(string filtro)
        {
            DataTable dt = new DataTable();

            try
            {
                ConexaoBanco conexao = new ConexaoBanco();
                conexao.AbrirConexao();
                dt = conexao.RetDataTable("select *from viewlistarvariacao where idProduto ='" + filtro + "'");
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao pesquisar variacoes do produto: " + ex.Message);
            }
            return(dt);
        }
        //Método lista todos participantes e caso informe irá filtrar
        public DataTable listarParticipantes(string tipoConsulta, string tipoFiltro, string filtroConsulta)
        {
            DataTable dt = new DataTable();

            try
            {
                ConexaoBanco conexao = new ConexaoBanco();
                conexao.AbrirConexao();
                //Pesquisa particpante cliente e seus respectivos filtros
                if (tipoConsulta == "CLIENTE")
                {
                    if (tipoFiltro == "TODOS")
                    {
                        dt = conexao.RetDataTable("select * from participante where tipocliente_participante = 1");
                    }
                    else if (tipoFiltro == "NOME")
                    {
                        dt = conexao.RetDataTable("select * from participante where nome_fantasia_participante = '" + filtroConsulta + "' and tipocliente_participante = 1");
                    }
                    else if (tipoFiltro == "CPF/CNPJ")
                    {
                        string valor    = filtroConsulta;
                        int    contador = valor.Length;

                        //Chama CPF SEM PONTUAÇÃO
                        if (contador == 11)
                        {
                            string filtroCPFCNPJ = valor.Substring(0, 3) + "." + valor.Substring(3, 3) + "." + valor.Substring(6, 3) + "-" + valor.Substring(9, 2);
                            dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroCPFCNPJ + "' and tipocliente_participante = 1");
                        }
                        else if (contador == 14)
                        {
                            //Chama CNPJ SEM PONTUAÇÃO
                            decimal num;
                            if (decimal.TryParse(valor, out num))
                            {
                                string filtroCPFCNPJ = valor.Substring(0, 2) + "." + valor.Substring(2, 3) + "." + valor.Substring(5, 3) + "/" + valor.Substring(8, 4) + "-" + valor.Substring(12, 2);
                                dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroCPFCNPJ + "' and tipocliente_participante = 1");
                            }
                            //Chama CPF COM PONTUAÇÃO
                            else
                            {
                                dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroConsulta + "' and tipocliente_participante = 1");
                            }
                        }
                        //Chama CNPJ COM PONTUAÇÃO
                        else if (contador == 18)
                        {
                            dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroConsulta + "' and tipocliente_participante = 1");
                        }
                    }
                    else if (tipoFiltro == "TELEFONE/CELULAR")
                    {
                        dt = conexao.RetDataTable("select * from participante where telefone_participante = '" + filtroConsulta + "' or celular_participante = '" + filtroConsulta + "' and tipocliente_participante = 1");
                    }
                    else if (tipoFiltro == "INTELIGENTE")
                    {
                        dt = conexao.RetDataTable("select *from participante where telefone_participante like '%" + filtroConsulta + "%' or celular_participante like '%" + filtroConsulta + "%' or cpf_cnpj_participante like  '%" + filtroConsulta + "%' or nome_fantasia_participante like  '%" + filtroConsulta + "%' and tipocliente_participante = 1");
                    }
                }

                //Pesquisa particpante fornecedor e seus respectivos filtros
                else if (tipoConsulta == "FORNECEDOR")
                {
                    if (tipoFiltro == "NOME")
                    {
                        dt = conexao.RetDataTable("select * from participante where nome_fantasia_participante = '" + filtroConsulta + "' and tipofornecedor_participante = 1");
                    }
                    else if (tipoFiltro == "CPF/CNPJ")
                    {
                        string valor    = filtroConsulta;
                        int    contador = valor.Length;

                        //Chama CPF SEM PONTUAÇÃO
                        if (contador == 11)
                        {
                            string filtroCPFCNPJ = valor.Substring(0, 3) + "." + valor.Substring(3, 3) + "." + valor.Substring(6, 3) + "-" + valor.Substring(9, 2);
                            dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroCPFCNPJ + "' and tipofornecedor_participante = 1");
                        }
                        else if (contador == 14)
                        {
                            //Chama CNPJ SEM PONTUAÇÃO
                            decimal num;
                            if (decimal.TryParse(valor, out num))
                            {
                                string filtroCPFCNPJ = valor.Substring(0, 2) + "." + valor.Substring(2, 3) + "." + valor.Substring(5, 3) + "/" + valor.Substring(8, 4) + "-" + valor.Substring(12, 2);
                                dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroCPFCNPJ + "' and tipofornecedor_participante = 1");
                            }
                            //Chama CPF COM PONTUAÇÃO
                            else
                            {
                                dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroConsulta + "' and tipofornecedor_participante = 1");
                            }
                        }
                        //Chama CNPJ COM PONTUAÇÃO
                        else if (contador == 18)
                        {
                            dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroConsulta + "' and tipofornecedor_participante = 1");
                        }
                    }
                    else if (tipoFiltro == "TELEFONE/CELULAR")
                    {
                        dt = conexao.RetDataTable("select * from participante where telefone_participante = '" + filtroConsulta + "' or celular_participante = '" + filtroConsulta + "' and tipofornecedor_participante = 1");
                    }
                    else if (tipoFiltro == "INTELIGENTE")
                    {
                        dt = conexao.RetDataTable("select *from participante where telefone_participante like '%" + filtroConsulta + "%' or celular_participante like '%" + filtroConsulta + "%' or cpf_cnpj_participante like  '%" + filtroConsulta + "%' or nome_fantasia_participante like  '%" + filtroConsulta + "%' and tipofornecedor_participante = 1");
                    }
                    else if (tipoFiltro == "TODOS")
                    {
                        dt = conexao.RetDataTable("select * from participante where tipofornecedor_participante = 1");
                    }
                }

                //Pesquisa participante funcionário e seus respectivos filtros
                else if (tipoConsulta == "FUNCIONARIO")
                {
                    if (tipoFiltro == "TODOS")
                    {
                        dt = conexao.RetDataTable("select * from participante where tipofuncionario_participante = 1");
                    }
                    else if (tipoFiltro == "NOME")
                    {
                        dt = conexao.RetDataTable("select * from participante where nome_fantasia_participante = '" + filtroConsulta + "' and tipofuncionario_participante = 1");
                    }
                    else if (tipoFiltro == "CPF/CNPJ")
                    {
                        string valor    = filtroConsulta;
                        int    contador = valor.Length;

                        //Chama CPF SEM PONTUAÇÃO
                        if (contador == 11)
                        {
                            string filtroCPFCNPJ = valor.Substring(0, 3) + "." + valor.Substring(3, 3) + "." + valor.Substring(6, 3) + "-" + valor.Substring(9, 2);
                            dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroCPFCNPJ + "' and tipofuncionario_participante = 1");
                        }
                        else if (contador == 14)
                        {
                            //Chama CNPJ SEM PONTUAÇÃO
                            decimal num;
                            if (decimal.TryParse(valor, out num))
                            {
                                string filtroCPFCNPJ = valor.Substring(0, 2) + "." + valor.Substring(2, 3) + "." + valor.Substring(5, 3) + "/" + valor.Substring(8, 4) + "-" + valor.Substring(12, 2);
                                dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroCPFCNPJ + "' and tipofuncionario_participante = 1");
                            }
                            //Chama CPF COM PONTUAÇÃO
                            else
                            {
                                dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroConsulta + "' and tipofuncionario_participante = 1");
                            }
                        }
                        //Chama CNPJ COM PONTUAÇÃO
                        else if (contador == 18)
                        {
                            dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroConsulta + "' and tipofuncionario_participante = 1");
                        }
                    }
                    else if (tipoFiltro == "TELEFONE/CELULAR")
                    {
                        dt = conexao.RetDataTable("select * from participante where telefone_participante = '" + filtroConsulta + "' or celular_participante = '" + filtroConsulta + "' and tipofuncionario_participante = 1");
                    }
                    else if (tipoFiltro == "INTELIGENTE")
                    {
                        dt = conexao.RetDataTable("select *from participante where telefone_participante like '%" + filtroConsulta + "%' or celular_participante like '%" + filtroConsulta + "%' or cpf_cnpj_participante like  '%" + filtroConsulta + "%' or nome_fantasia_participante like  '%" + filtroConsulta + "%' and tipofuncionario_participante = 1");
                    }
                }

                //Pesquisa todos participantes e seus respectivos filtros
                else if (tipoConsulta == "TODOS")
                {
                    if (tipoFiltro == "TODOS")
                    {
                        dt = conexao.RetDataTable("select * from participante");
                    }
                    else if (tipoFiltro == "NOME")
                    {
                        dt = conexao.RetDataTable("select * from participante where nome_fantasia_participante = '" + filtroConsulta + "'");
                    }
                    else if (tipoFiltro == "CPF/CNPJ")
                    {
                        string valor    = filtroConsulta;
                        int    contador = valor.Length;

                        //Chama CPF SEM PONTUAÇÃO
                        if (contador == 11)
                        {
                            string filtroCPFCNPJ = valor.Substring(0, 3) + "." + valor.Substring(3, 3) + "." + valor.Substring(6, 3) + "-" + valor.Substring(9, 2);
                            dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroCPFCNPJ + "'");
                        }
                        else if (contador == 14)
                        {
                            //Chama CNPJ SEM PONTUAÇÃO
                            decimal num;
                            if (decimal.TryParse(valor, out num))
                            {
                                string filtroCPFCNPJ = valor.Substring(0, 2) + "." + valor.Substring(2, 3) + "." + valor.Substring(5, 3) + "/" + valor.Substring(8, 4) + "-" + valor.Substring(12, 2);
                                dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroCPFCNPJ + "' ");
                            }
                            //Chama CPF COM PONTUAÇÃO
                            else
                            {
                                dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroConsulta + "'");
                            }
                        }
                        //Chama CNPJ COM PONTUAÇÃO
                        else if (contador == 18)
                        {
                            dt = conexao.RetDataTable("select * from participante where cpf_cnpj_participante = '" + filtroConsulta + "'");
                        }
                    }
                    else if (tipoFiltro == "TELEFONE/CELULAR")
                    {
                        dt = conexao.RetDataTable("select * from participante where telefone_participante = '" + filtroConsulta + "' or celular_participante = '" + filtroConsulta + "'");
                    }
                    else if (tipoFiltro == "INTELIGENTE")
                    {
                        dt = conexao.RetDataTable("select *from participante where telefone_participante like '%" + filtroConsulta + "%' or celular_participante like '%" + filtroConsulta + "%' or cpf_cnpj_participante like  '%" + filtroConsulta + "%' or nome_fantasia_participante like  '%" + filtroConsulta + "%'");
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao pesquisar os participante: " + ex.Message);
            }
            return(dt);
        }
Beispiel #8
0
        //Método listar locação na pesquisa
        public DataTable listarLocacao(string tipoFiltro, string filtro)
        {
            DataTable dt = new DataTable();

            try
            {
                ConexaoBanco conexao = new ConexaoBanco();
                conexao.AbrirConexao();
                if (tipoFiltro == "TODOS")
                {
                    dt = conexao.RetDataTable("select *from viewlocacao " +
                                              " where NomeCliente like '' and TipoLocacao = '' " +
                                              " or cast(DataLancamento as DATE) = '' and TipoLocacao = '' " +
                                              " or cast(DataPrevisaoEntrega as DATE) = '' and TipoLocacao = '' " +
                                              " or UsuarioLocacao = '' and TipoLocacao = '' " +
                                              " or TipoLocacao = 'L' order by codigo");
                }
                else if (tipoFiltro == "CLIENTE")
                {
                    dt = conexao.RetDataTable("select *from viewlocacao " +
                                              " where NomeCliente like '%" + filtro + "%' and TipoLocacao = 'L' " +
                                              " or cast(DataLancamento as DATE) = '' and TipoLocacao = '' " +
                                              " or cast(DataPrevisaoEntrega as DATE) = '' and TipoLocacao = '' " +
                                              " or UsuarioLocacao = '' and TipoLocacao = ''" +
                                              " or TipoLocacao = '' order by codigo");
                }
                else if (tipoFiltro == "DATA LANÇAMENTO")
                {
                    //Método chama o ultimo registro
                    var dataConvertida = DateTime.Parse(filtro).ToString("yyyy-MM-dd HH:mm:ss");

                    dt = conexao.RetDataTable("select *from viewlocacao " +
                                              " where NomeCliente like '' and TipoLocacao = '' " +
                                              " or cast(DataLancamento as DATE) = '" + dataConvertida + "' and TipoLocacao = 'L' " +
                                              " or cast(DataPrevisaoEntrega as DATE) = '' and TipoLocacao = '' " +
                                              " or UsuarioLocacao = '' and TipoLocacao = ''" +
                                              " or TipoLocacao = '' order by codigo");
                }
                else if (tipoFiltro == "DATA DEVOLUÇÃO")
                {
                    //Método chama o ultimo registro
                    var dataConvertida = DateTime.Parse(filtro).ToString("yyyy-MM-dd HH:mm:ss");

                    dt = conexao.RetDataTable("select *from viewlocacao " +
                                              " where NomeCliente like '' and TipoLocacao = '' " +
                                              " or cast(DataLancamento as DATE) = '' and TipoLocacao = '' " +
                                              " or cast(DataPrevisaoEntrega as DATE) = '" + dataConvertida + "' and TipoLocacao = 'L' " +
                                              " or UsuarioLocacao = '' and TipoLocacao = ''" +
                                              " or TipoLocacao = '' order by codigo");
                }
                else if (tipoFiltro == "USUÁRIO")
                {
                    dt = conexao.RetDataTable("select *from viewlocacao " +
                                              " where NomeCliente like '' and TipoLocacao = '' " +
                                              " or cast(DataLancamento as DATE) = '' and TipoLocacao = '' " +
                                              " or cast(DataPrevisaoEntrega as DATE) = '' and TipoLocacao = '' " +
                                              " or UsuarioLocacao = '" + filtro + "' and TipoLocacao = 'L'" +
                                              " or TipoLocacao = '' order by codigo");
                }
            }
            catch (Exception erro)
            {
                throw new Exception("Erro ao consultar locação, classe DAO " + erro.Message);
            }
            return(dt);
        }