コード例 #1
0
ファイル: CidadeDAO.cs プロジェクト: MayconLSilva/Centaurus
        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);
        }
コード例 #2
0
ファイル: MarcaDAO.cs プロジェクト: MayconLSilva/Centaurus
        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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #5
0
 //Método excluir categoria
 public void ExcluirCategoria(CategoriaModelo modCategoria)
 {
     try
     {
         ConexaoBanco conexao = new ConexaoBanco();
         conexao.AbrirConexao();
         string comando = "delete from categoria where id_categoria =" + modCategoria.idCategoria;
         conexao.ExecutarComandoSQL(comando);
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao excluir a categoria: " + ex.Message);
     }
 }
コード例 #6
0
ファイル: MarcaDAO.cs プロジェクト: MayconLSilva/Centaurus
 public void excluirMarca(MarcaModelo modMarca)
 {
     try
     {
         ConexaoBanco conexao = new ConexaoBanco();
         conexao.AbrirConexao();
         string comando = "delete from marca where id_marca =" + modMarca.idMarca;
         conexao.ExecutarComandoSQL(comando);
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao excluir o marca: " + ex.Message);
     }
 }
コード例 #7
0
 //Inicio do código fonte excluir participante
 public void excluirParticipante(ParticipanteModelo modParticipante)
 {
     try
     {
         ConexaoBanco conexao = new ConexaoBanco();
         //conexao.FecharConexao();
         conexao.AbrirConexao();
         string comando = "delete from participante where id_partipante =" + modParticipante.idParticipante;
         conexao.ExecutarComandoSQL(comando);
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao excluir o participante: " + ex.Message);
     }
 }
コード例 #8
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);
        }
コード例 #9
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);
        }
コード例 #10
0
 public void excluirVariacao(ProdutoModelo produtoModelo)
 {
     try
     {
         ConexaoBanco conexao = new ConexaoBanco();
         conexao.AbrirConexao();
         string comando = "delete from produtovariacao where id_produtovariacao=" + produtoModelo.idProdVariacao;
         conexao.ExecutarComandoSQL(comando);
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao excluir produto variação: " + ex.Message);
     }
     finally
     {
         FecharConexao();
     }
 }
コード例 #11
0
 //Método utilizado para excluir um item dalocação
 public void excluirItemLocacao(LocacaoModelo locacaoModelo)
 {
     try
     {
         ConexaoBanco conexao = new ConexaoBanco();
         conexao.AbrirConexao();
         string comando = "delete from locacaoitens where id_locacaoitens=" + locacaoModelo.idProdutoLocacaoItens;
         conexao.ExecutarComandoSQL(comando);
     }
     catch (Exception erro)
     {
         throw new Exception("Erro ao excluir o item da locação, classe DAO: " + erro.Message);
     }
     finally
     {
         FecharConexao();
     }
 }
コード例 #12
0
        //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);
        }
コード例 #13
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);
        }