Beispiel #1
0
        public IEnumerable <ChamadoAplicativoViewModel> RetornarDadosAplicativo(string cnpj)
        {
            string novoCnpj;

            if (cnpj.Length == 11)
            {
                novoCnpj = Utils.FormatarCPF(cnpj);
            }
            else
            {
                novoCnpj = Utils.FormatarCNPJ(cnpj);
            }

            // lista 20 chamados independente de quantas
            // ocorrencias tenha
            var sb = new StringBuilder();

            sb.AppendLine("SELECT TOP(20) WITH TIES");
            sb.AppendLine(" Cha_Id as Id,");
            sb.AppendLine(" Cha_DataAbertura as Data,");
            sb.AppendLine(" Cha_HoraAbertura as Hora,");
            sb.AppendLine(" Cha_Contato as Contato,");
            sb.AppendLine(" Cha_Descricao as Descricao,");
            sb.AppendLine(" Sta_Nome as Status, ");
            sb.AppendLine(" ChOco_DescricaoTecnica as DescricaoProblema,");
            sb.AppendLine(" ChOco_DescricaoSolucao as DescricaoSolucao ");
            sb.AppendLine("FROM Chamado");
            sb.AppendLine(" LEFT JOIN Chamado_Ocorrencia ON Cha_Id = ChOco_Chamado");
            sb.AppendLine(" INNER JOIN Status ON Cha_Status = Sta_Id");
            sb.AppendLine(" INNER JOIN Cliente ON Cha_Cliente = Cli_Id");
            sb.AppendLine(" WHERE Cli_Dcto = '" + novoCnpj + "'");
            sb.AppendLine(" ORDER BY Cha_Id DESC");
            return(_repositorioAplicativo.GetAll(sb.ToString()));
        }
Beispiel #2
0
        public IEnumerable <QuadroSolicitacaoViewModel> Quadro(int idUsuario, Usuario usuario, int codParametro)
        {
            var usuarioCliente = new UsuarioEF();

            var sb = new StringBuilder();

            sb.AppendLine(" SELECT");
            sb.AppendLine(" 	Sol_Id as Id,");
            sb.AppendLine(" 	Sol_Titulo as Titulo,");
            sb.AppendLine(" 	Sol_UsuarioAtendeAtual as IdUsuarioAtendeAtual,");
            sb.AppendLine(" 	Cli_Nome as ClienteNome,");
            sb.AppendLine(" 	Usu_Nome as UsuarioNome,");
            sb.AppendLine(" 	Sol_Status as IdStatus");
            sb.AppendLine(" FROM Solicitacao");
            sb.AppendLine(" 	INNER JOIN Cliente ON Sol_Cliente = Cli_Id");
            sb.AppendLine(" 	INNER JOIN Status ON Sol_Status = Sta_Id");
            sb.AppendLine(" 	INNER JOIN Parametros ON Sta_Codigo = COALESCE(Par_Valor, 0)");
            sb.AppendLine("   LEFT JOIN Usuario ON Sol_UsuarioAtendeAtual = Usu_Id");

            sb.AppendLine(" WHERE Par_Codigo = " + codParametro);
            sb.AppendLine(" AND Par_Programa = 3");
            sb.AppendLine(usuarioCliente.PermissaoUsuario(idUsuario));
            //sb.AppendLine(usuarioCliente.UsuarioCliente(idUsuario));
            sb.AppendLine(" ORDER BY Sol_Data");

            var lista = _repositorioDapperQuadro.GetAll(sb.ToString());

            //var lista = _rep.context.Database.SqlQuery<QuadroSolicitacao>(sb.ToString());

            return(lista);
        }
Beispiel #3
0
        public IEnumerable <AgendamentoQuadroViewModel> Quadros(string dataInicial, string dataFinal, int idUsuario, int idRevenda)
        {
            var sb             = new StringBuilder();
            var usuarioCliente = new UsuarioEF();

            sb.AppendLine("SELECT");
            sb.AppendLine("	Age_Id as Id,");
            sb.AppendLine("	Age_Data as Data,");
            sb.AppendLine("	Age_Hora as Hora,");
            sb.AppendLine("  Age_Cliente as ClienteId,");
            sb.AppendLine("	Age_NomeCliente as ClienteNome,");
            sb.AppendLine("	Usu_Nome as UsuarioNome,");
            sb.AppendLine("	Sta_Nome as StatusNome");
            sb.AppendLine(" FROM Agendamento");
            sb.AppendLine(" INNER JOIN Cliente ON  Age_Cliente = Cli_Id");
            sb.AppendLine(" INNER JOIN Usuario ON Age_Usuario = Usu_Id");
            sb.AppendLine(" INNER JOIN Status ON Age_Status = Sta_Id");
            sb.AppendLine(" WHERE Age_Data >=" + Funcoes.DataIngles(dataInicial));
            sb.AppendLine(" AND Age_Data <=" + Funcoes.DataIngles(dataFinal));

            if (idRevenda > 0)
            {
                sb.AppendLine(" AND Cli_Revenda = " + idRevenda);
            }

            sb.AppendLine(usuarioCliente.PermissaoUsuario(idUsuario));

            sb.AppendLine(" ORDER BY Age_Data");

            var lista = _repositorioQuadro.GetAll(sb.ToString());

            return(lista);
        }
Beispiel #4
0
        public IEnumerable <VisitaConsultaViewModelApi> FiltrarAPI(int idUsuario, VisitaFiltroViewModelApi filtro, string campo, string valor)
        {
            var sb = new StringBuilder();

            sb.AppendLine(MontarSql(idUsuario, campo, valor));

            if (filtro.Id > 0)
            {
                sb.AppendLine(" AND Vis_Id = " + filtro.Id);
            }

            if (!string.IsNullOrWhiteSpace(filtro.Perfil))
            {
                sb.AppendLine(" AND Cli_Perfil = '" + filtro.Perfil + "'");
            }

            if (!Funcoes.DataEmBranco(filtro.DataInicial))
            {
                sb.AppendLine(" AND Vis_Data >= '" + filtro.DataInicial + "'");
            }

            if (!Funcoes.DataEmBranco(filtro.DataFinal))
            {
                sb.AppendLine(" AND Vis_Data <= '" + filtro.DataFinal + "'");
            }

            if (!string.IsNullOrWhiteSpace(filtro.ClienteId))
            {
                sb.AppendLine(" AND Vis_Cliente IN (" + filtro.ClienteId + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.RevendaId))
            {
                sb.AppendLine(" AND Cli_Revenda IN (" + filtro.RevendaId + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.StatusId))
            {
                sb.AppendLine(" AND Vis_Status IN (" + filtro.StatusId + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.TipoId))
            {
                sb.AppendLine(" AND Vis_Tipo IN (" + filtro.TipoId + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.UsuarioId))
            {
                sb.AppendLine(" AND Vis_Usuario IN (" + filtro.UsuarioId + ")");
            }

            sb.AppendLine(" ORDER BY " + campo);

            var lista = _repositorioConsulta.GetAll(sb.ToString());

            return(lista.ToList());
        }
Beispiel #5
0
        public IEnumerable <SolicitacaoConsultaViewModel> Filtrar(SolicitacaoFiltroViewModel filtro, string campo, string texto, int usuarioId, bool contem)
        {
            var sb = new StringBuilder();

            string sTexto = "";

            sTexto = "'" + texto + "%'";
            if (contem)
            {
                sTexto = "'%" + texto + "%'";
            }

            sb.AppendLine(" SELECT");
            sb.AppendLine("  Sol_Id as Id,");
            sb.AppendLine("  Sol_Data as Data,");
            sb.AppendLine("  Sol_Hora as Hora,");
            sb.AppendLine("  Sol_Cliente as ClienteId,");
            sb.AppendLine("  Sol_Status as StatusId,");
            sb.AppendLine("  Sol_Titulo as Titulo,");
            sb.AppendLine("  CASE Sol_Nivel");
            sb.AppendLine("    WHEN 1 THEN '1-Baixo'");
            sb.AppendLine("    WHEN 2 THEN '2-Normal'");
            sb.AppendLine("    WHEN 3 THEN '3-Alto'");
            sb.AppendLine("    WHEN 4 THEN '4-Crítico'");
            sb.AppendLine("  END AS Nivel,");
            sb.AppendLine("  Cli_Codigo as ClienteCodigo,");
            sb.AppendLine("  Cli_Nome as RazaoSocial,");
            sb.AppendLine("  Cli_Fantasia as NomeFantasia,");
            sb.AppendLine("  Sta_Nome as StatusNome,");
            sb.AppendLine("  Tip_Nome as TipoNome,");
            sb.AppendLine("  Ver_Versao as Versao");
            sb.AppendLine(" FROM Solicitacao");
            sb.AppendLine("  INNER JOIN Cliente ON Sol_Cliente = Cli_Id");
            sb.AppendLine("  INNER JOIN Status ON Sol_Status = Sta_Id");
            sb.AppendLine("  LEFT JOIN Tipo ON Sol_Tipo = Tip_Id");
            sb.AppendLine("  LEFT JOIN Versao On Sol_VersaoId = Ver_Id");

            if (!string.IsNullOrWhiteSpace(texto))
            {
                sb.AppendLine(" WHERE " + campo + " LIKE " + sTexto);
            }
            else
            {
                sb.AppendLine("WHERE Sol_Id > 0");
            }

            sb.AppendLine(FiltrarDados(usuarioId, filtro));

            //_rep.context.Database.SqlQuery<SolicitacaoConsulta>(sb.ToString());

            var lista = _repositorioConsulta.GetAll(sb.ToString());

            return(lista);
        }
Beispiel #6
0
        public IEnumerable <QuadroViewModelChamado> QuadroChamado(int idUsuario, int idRevenda, EnumChamado tipo)
        {
            var sb = new StringBuilder();

            if (tipo == EnumChamado.Chamado)
            {
                sb.AppendLine(RetornarChamadoQuadro(idUsuario, idRevenda));
            }
            else
            {
                sb.AppendLine(RetornarAtividadeQuadro(idUsuario, idRevenda));
            }

            var lista = _repositorioQuadro.GetAll(sb.ToString());

            return(lista);
        }
Beispiel #7
0
        public IEnumerable <ChamadoConsultaViewModel> Filtrar(ChamadoFiltroViewModel filtro, string campo, string texto, int usuarioId, bool contem, EnumChamado tipo)
        {
            var    usuarioCliente = new UsuarioEF();
            var    sb             = new StringBuilder();
            string sTexto         = "";

            sTexto = "'" + texto + "%'";
            if (contem)
            {
                sTexto = "'" + texto + "%'";
            }

            sb.AppendLine("  SELECT");
            sb.AppendLine(" Cha_Id as Id,");
            sb.AppendLine(" '' as Descricao,");
            sb.AppendLine(" Cha_DataAbertura as DataAbertura,");
            sb.AppendLine(" Cha_HoraAbertura as HoraAbertura,");
            sb.AppendLine(" Sta_Nome as NomeStatus,");
            sb.AppendLine(" Cha_Status as IdStatus,");
            sb.AppendLine(" Tip_Nome as NomeTipo,");
            sb.AppendLine(" Cli_Nome as RazaoSocial,");
            sb.AppendLine(" Cli_Fantasia as Fantasia,");
            sb.AppendLine(" CASE Cha_Nivel");
            sb.AppendLine("   WHEN 1 THEN '1-Baixo'");
            sb.AppendLine("   WHEN 2 THEN '2-Normal'");
            sb.AppendLine("   WHEN 3 THEN '3-Alto'");
            sb.AppendLine("   WHEN 4 THEN '4-Crítico'");
            sb.AppendLine(" END AS Nivel,");
            sb.AppendLine(" Usu_Nome as NomeUsuario");
            sb.AppendLine(" FROM Chamado");
            sb.AppendLine("	INNER JOIN Status  ON Cha_Status = Sta_Id");
            sb.AppendLine("	INNER JOIN Tipo    ON Cha_Tipo = Tip_Id");
            sb.AppendLine(" INNER JOIN Cliente ON Cha_Cliente = Cli_Id");
            sb.AppendLine("	INNER JOIN Usuario ON Cha_UsuarioAbertura = Usu_Id");
            sb.AppendLine(" LEFT JOIN Revenda ON Cli_Revenda = Rev_Id");

            if (!string.IsNullOrWhiteSpace(texto))
            {
                sb.AppendLine(" WHERE " + campo + " LIKE " + sTexto);
            }
            else
            {
                sb.AppendLine("WHERE Cha_Id > 0");
            }

            if (filtro.Id > 0)
            {
                sb.AppendLine(" AND Cha_Id = " + filtro.Id);
            }

            if (tipo == EnumChamado.Chamado)
            {
                sb.AppendLine(" AND Cha_TipoMovimento = 1");
            }
            else
            {
                sb.AppendLine(" AND Cha_TipoMovimento = 2");
            }

            sb.AppendLine(usuarioCliente.PermissaoUsuario(usuarioId));

            if ((!string.IsNullOrWhiteSpace(filtro.DataInicial)) && (filtro.DataInicial.Trim() != "/  /"))
            {
                sb.AppendLine(" AND Cha_DataAbertura >=" + Funcoes.DataIngles(filtro.DataInicial));
            }

            if ((!string.IsNullOrWhiteSpace(filtro.DataFinal)) && (filtro.DataFinal.Trim() != "/  /"))
            {
                sb.AppendLine(" AND Cha_DataAbertura <=" + Funcoes.DataIngles(filtro.DataFinal));
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdCliente))
            {
                sb.AppendLine(" AND Cha_Cliente IN " + filtro.IdCliente);
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdTipo))
            {
                sb.AppendLine(" AND Cha_Tipo IN " + filtro.IdTipo);
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdStatus))
            {
                sb.AppendLine(" AND Cha_Status IN " + filtro.IdStatus);
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdModulo))
            {
                sb.AppendLine(" AND Cha_Modulo IN " + filtro.IdModulo);
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdRevenda))
            {
                sb.AppendLine(" AND Cha_Revenda IN " + filtro.IdRevenda);
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdUsuarioAbertura))
            {
                sb.AppendLine(" AND Cha_UsuarioAbertura IN " + filtro.IdUsuarioAbertura);
            }

            if (filtro.ClienteFiltro.UsuarioId > 0)
            {
                sb.AppendLine(" AND Cli_Usuario IN " + filtro.ClienteFiltro.UsuarioId);
            }
            sb.AppendLine(" ORDER BY " + campo);

            var lista = _repositorioConsulta.GetAll(sb.ToString());

            return(lista);
        }
Beispiel #8
0
        public IEnumerable <ClienteConsultaViewModelApi> Filtrar(int idUsuario, ClienteFiltroViewModelApi filtro, int modelo, string campo, string valor, bool contem = true)
        {
            string sTexto = "";

            sTexto = "'" + valor + "%'";
            if (contem)
            {
                sTexto = "'%" + valor + "%'";
            }

            var sb = new StringBuilder();

            sb.AppendLine(" SELECT");
            sb.AppendLine(" Cli_Codigo as Codigo");
            sb.AppendLine(",Cli_Perfil as Perfil");
            sb.AppendLine(",Cli_Versao as Versao");
            sb.AppendLine(",Cli_Id as Id");
            sb.AppendLine(",cli_Fantasia as Fantasia");
            sb.AppendLine(",cli_Nome as Razao");
            sb.AppendLine(",cli_Dcto as Documento");
            sb.AppendLine(",Cli_Fone1 as Telefone");
            sb.AppendLine(",Cli_Enquadramento as Enquadramento");
            sb.AppendLine(",Usu_Nome as NomeConsultor, Rev_Nome");
            sb.AppendLine(",Rev_Nome as NomeRevenda");
            sb.AppendLine(" FROM Cliente");
            sb.AppendLine(" INNER JOIN Revenda ON Cli_Revenda = Rev_Id");
            sb.AppendLine(" LEFT JOIN Usuario ON Cli_Usuario = Usu_Id");
            sb.AppendLine(" WHERE Cli_Id IS NOT NULL");
            sb.AppendLine(" AND " + campo + " LIKE " + sTexto);

            sb.AppendLine(" AND EXISTS(");
            sb.AppendLine(" 	SELECT 1 FROM Usuario WHERE ((Cli_Revenda = Usu_Revenda) OR (Usu_Revenda IS NULL))");
            sb.AppendLine(" 	AND Usu_Id = "+ idUsuario + ")");

            sb.AppendLine(" AND EXISTS(");
            sb.AppendLine(" 	SELECT 1 FROM Usuario WHERE ((Cli_Id = Usu_Cliente) OR (Usu_Cliente IS NULL))");
            sb.AppendLine(" 	AND Usu_Id = "+ idUsuario + ")");

            if (filtro.Ativo != "T")
            {
                if (filtro.Ativo == "A")
                {
                    sb.AppendLine(" AND Cli_Ativo = 1");
                }
                else
                {
                    sb.AppendLine(" AND Cli_Ativo = 0");
                }
            }

            if (filtro.UsuarioId > 0)
            {
                sb.AppendLine("  AND Cli_Usuario =" + filtro.UsuarioId);
            }

            if (filtro.RevendaId > 0)
            {
                sb.AppendLine("  AND Cli_Revenda =" + filtro.RevendaId);
            }

            if (!string.IsNullOrEmpty(filtro.FiltroIdUsuario))
            {
                sb.AppendLine("  AND Cli_Usuario in (" + filtro.FiltroIdUsuario + ")");
            }

            if (filtro.Restricao < 2)
            {
                if (filtro.Restricao == 0)
                {
                    sb.AppendLine("  AND Cli_Restricao = 1");
                }

                if (filtro.Restricao == 1)
                {
                    sb.AppendLine("  AND Cli_Restricao = 0");
                }
            }

            if (filtro.Id > 0)
            {
                sb.AppendLine("  AND Cli_Id =" + filtro.Id);
            }

            if (!string.IsNullOrWhiteSpace(filtro.Enquadramento))
            {
                sb.AppendLine("  AND Cli_Enquadramento = '" + filtro.Enquadramento + "'");
            }

            if (filtro.CidadeId > 0)
            {
                sb.AppendLine("  AND Cli_Cidade =" + filtro.CidadeId);
            }

            if (!string.IsNullOrEmpty(filtro.FiltroIdCidade))
            {
                sb.AppendLine("  AND Cli_Cidade in (" + filtro.FiltroIdCidade + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.Versao))
            {
                sb.AppendLine("  AND Cli_Versao = '" + filtro.Versao + "'");
            }

            if (filtro.EmpresaVinculada == "S")
            {
                sb.AppendLine("  AND Cli_EmpresaVinculada > 0");
            }

            if (filtro.EmpresaVinculada == "N")
            {
                sb.AppendLine(" AND ((Cli_EmpresaVinculada = 0) OR (Cli_EmpresaVinculada IS NULL))");
            }

            if (!string.IsNullOrWhiteSpace(filtro.Perfil))
            {
                sb.AppendLine(" AND Cli_Perfil = '" + filtro.Perfil + "'");
            }

            if (modelo == 2)
            {
                if (filtro.ModuloId > 0)
                {
                    sb.AppendLine(" AND CliMod_Modulo = " + filtro.ModuloId);
                }

                if (!string.IsNullOrEmpty(filtro.filtroIdModulo))
                {
                    sb.AppendLine("  AND CliMod_Modulo in (" + filtro.filtroIdModulo + ")");
                }

                if (filtro.ProdutoId > 0)
                {
                    sb.AppendLine(" AND CliMod_Produto = " + filtro.ProdutoId);
                }

                if (!string.IsNullOrEmpty(filtro.FiltroIdProduto))
                {
                    sb.AppendLine("  AND CliMod_Produto in (" + filtro.FiltroIdProduto + ")");
                }
            }
            else
            {
                if (filtro.ModuloId > 0)
                {
                    sb.AppendLine(" AND EXISTS(SELECT 1 FROM Cliente_Modulo ");
                    sb.AppendLine(" WHERE Cli_Id = CliMod_Cliente ");
                    sb.AppendLine("  AND CliMod_Modulo = " + filtro.ModuloId + ")");
                }

                if (!string.IsNullOrEmpty(filtro.filtroIdModulo))
                {
                    sb.AppendLine(" AND EXISTS(SELECT 1 FROM Cliente_Modulo ");
                    sb.AppendLine(" WHERE Cli_Id = CliMod_Cliente ");
                    sb.AppendLine("  AND CliMod_Modulo IN (" + filtro.filtroIdModulo + "))");
                }

                if (filtro.ProdutoId > 0)
                {
                    sb.AppendLine(" AND EXISTS(SELECT 1 FROM Cliente_Modulo ");
                    sb.AppendLine(" WHERE Cli_Id = CliMod_Cliente ");
                    sb.AppendLine("  AND CliMod_Produto = " + filtro.ProdutoId + ")");
                }

                if (!string.IsNullOrEmpty(filtro.FiltroIdProduto))
                {
                    sb.AppendLine(" AND EXISTS(SELECT 1 FROM Cliente_Modulo ");
                    sb.AppendLine(" WHERE Cli_Id = CliMod_Cliente ");
                    sb.AppendLine("  AND CliMod_Produto in (" + filtro.FiltroIdProduto + "))");
                }
            }
            sb.AppendLine(" ORDER BY " + campo);

            return(_repositorioConsulta.GetAll(sb.ToString()));
        }
        public IEnumerable <RecadoConsultaViewModel> Filtrar(RecadoFiltroViewModel filtro)
        {
            string sTexto;

            sTexto = "'" + filtro.Texto + "%'";
            if (filtro.Contem)
            {
                sTexto = "'%" + filtro.Texto + "%'";
            }

            var sb = new StringBuilder();

            sb.AppendLine("SELECT");
            sb.AppendLine(" Rec_Id as Id,");
            sb.AppendLine(" Rec_Data as Data,");
            sb.AppendLine(" Rec_Nivel as Nivel,");
            sb.AppendLine(" Rec_RazaoSocial as RazaoSocial,");
            sb.AppendLine(" Rec_Telefone as Telefone,");
            sb.AppendLine(" Lcto.Usu_Nome as NomeUsuarioLancamento,");
            sb.AppendLine(" Dest.Usu_Nome as NomeUsuarioDestino,");
            sb.AppendLine(" Sta_Nome as NomeStatus");
            sb.AppendLine(" FROM Recado");
            sb.AppendLine(" INNER JOIN Usuario Lcto ON Rec_UsuarioLcto = Lcto.Usu_Id");
            sb.AppendLine(" LEFT JOIN Usuario Dest ON Rec_UsuarioDestino = Dest.Usu_Id");
            sb.AppendLine(" LEFT JOIN Status ON Rec_Status = Sta_Id");

            if (!string.IsNullOrEmpty(filtro.Texto))
            {
                if (filtro.Campo == "Rec_Data")
                {
                    sb.AppendLine(" WHERE " + filtro.Campo + " = '" + filtro.Texto + "'");
                }
                else
                {
                    sb.AppendLine(" WHERE " + filtro.Campo + " LIKE " + sTexto);
                }
            }
            else
            {
                sb.AppendLine(" WHERE Rec_Id > 0");
            }

            if (!Funcoes.DataEmBranco(filtro.DataInicial))
            {
                sb.AppendLine(" AND Rec_Data >= " + Funcoes.DataIngles(filtro.DataInicial));
            }
            if (!Funcoes.DataEmBranco(filtro.DataFinal))
            {
                sb.AppendLine(" AND Rec_Data <= " + Funcoes.DataIngles(filtro.DataFinal));
            }

            if (!Funcoes.DataEmBranco(filtro.DataInicialDest))
            {
                sb.AppendLine(" AND Rec_Final >= " + Funcoes.DataIngles(filtro.DataInicialDest));
            }
            if (!Funcoes.DataEmBranco(filtro.DataFinal))
            {
                sb.AppendLine(" AND Rec_Final <= " + Funcoes.DataIngles(filtro.DataFinalDest));
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdUsuarioLcto))
            {
                sb.AppendLine(" AND Rec_UsuarioLcto in " + filtro.IdUsuarioLcto);
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdUsuarioDestino))
            {
                sb.AppendLine(" AND Rec_UsuarioDestino in " + filtro.IdUsuarioDestino);
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdStatus))
            {
                sb.AppendLine(" AND Rec_Status in " + filtro.IdStatus);
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdCliente))
            {
                sb.AppendLine(" AND Rec_Cliente in " + filtro.IdCliente);
            }

            return(_repositorioConsulta.GetAll(sb.ToString()));
        }
Beispiel #10
0
        public IEnumerable <VersaoConsultaViewModel> Filtrar(VersaoFiltroViewModel filtro, string campo, string texto, bool contem)
        {
            string consulta = " SELECT"
                              + "  Ver_DataInicio as DataInicio,"
                              + "  Ver_DataLiberacao as DataLiberacao,"
                              + "  Ver_Descricao as Descricao,"
                              + "  Ver_Id as Id,"
                              + "  Ver_Versao as VersaoStr,"
                              + "  Sta_Nome as NomeStatus,"
                              + "  Tip_Nome as NomeTipo,"
                              + "  Usu_Nome as NomeUsuario"
                              + " FROM Versao"
                              + " 	INNER JOIN Status ON Ver_Status = Sta_Id"
                              + " 	INNER JOIN Tipo ON Ver_Tipo = Tip_Id"
                              + " 	INNER JOIN Usuario ON Ver_Usuario = Usu_Id";

            string sTexto = "";

            sTexto = "'" + texto + "%'";
            if (contem)
            {
                sTexto = "'%" + texto + "%'";
            }

            var sb = new StringBuilder();

            sb.AppendLine(consulta);

            if (!string.IsNullOrWhiteSpace(texto))
            {
                sb.AppendLine(" WHERE " + campo + " LIKE " + sTexto);
            }
            else
            {
                sb.AppendLine(" WHERE Ver_Id > 0");
            }

            if (filtro.Id > 0)
            {
                sb.AppendLine(" AND Ver_Id = " + filtro.Id);
            }

            if (!Funcoes.DataEmBranco(filtro.DataInicial))
            {
                sb.AppendLine(" AND Ver_DataInicio >= " + Funcoes.DataIngles(filtro.DataInicial));
            }
            if (!Funcoes.DataEmBranco(filtro.DataFinal))
            {
                sb.AppendLine(" AND Ver_DataInicio <= " + Funcoes.DataIngles(filtro.DataFinal));
            }

            if (!Funcoes.DataEmBranco(filtro.DataLiberacaoInicial))
            {
                sb.AppendLine(" AND Ver_DataLiberacao >= " + Funcoes.DataIngles(filtro.DataLiberacaoInicial));
            }
            if (!Funcoes.DataEmBranco(filtro.DataLiberacaoFinal))
            {
                sb.AppendLine(" AND Ver_DataLiberacao <= " + Funcoes.DataIngles(filtro.DataLiberacaoFinal));
            }

            if (!string.IsNullOrWhiteSpace(filtro.UsuarioId))
            {
                sb.AppendLine(" AND Ver_Usuario IN (" + filtro.UsuarioId + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.StatusId))
            {
                sb.AppendLine(" AND Ver_Status IN (" + filtro.StatusId + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.TipoId))
            {
                sb.AppendLine(" AND Ver_Tipo IN (" + filtro.TipoId + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.ProdutoId))
            {
                sb.AppendLine(" AND Ver_Produto IN (" + filtro.ProdutoId + ")");
            }

            sb.AppendLine(" ORDER BY " + campo);
            var lista = _repositorioConsulta.GetAll(sb.ToString());

            return(lista);
        }
Beispiel #11
0
        public IEnumerable <AgendamentoConsultaViewModel> Filtrar(AgendamentoFiltroViewModel filtro, string campo, string texto, int idUsuario, bool contem = true)

        {
            string sTexto = "";

            sTexto = "'" + texto + "%'";
            if (contem)
            {
                sTexto = "'%" + texto + "%'";
            }

            var sb             = new StringBuilder();
            var usuarioCliente = new UsuarioEF();

            sb.AppendLine(" SELECT");
            sb.AppendLine(" Age_Id as Id,");
            sb.AppendLine("	Age_Data as Data,");
            sb.AppendLine("	Age_Hora as Hora,");
            sb.AppendLine(" Age_Cliente as ClienteId,");
            sb.AppendLine(" Age_NomeCliente as NomeCliente,");
            sb.AppendLine(" Tip_Nome as TipoNome,");
            sb.AppendLine(" Usu_Nome as UsuarioNome,");
            sb.AppendLine(" Sta_Nome as StatusNome");
            sb.AppendLine(" FROM Agendamento");
            sb.AppendLine("     INNER JOIN Cliente ON Age_Cliente = Cli_Id");
            sb.AppendLine(" 	INNER JOIN Tipo ON Age_Tipo = Tip_Id");
            sb.AppendLine(" 	INNER JOIN Usuario ON Age_Usuario = Usu_Id");
            sb.AppendLine(" 	INNER JOIN Status ON Age_Status = Status.Sta_Id");

            if (!string.IsNullOrWhiteSpace(texto))
            {
                sb.AppendLine(" WHERE " + campo + " LIKE " + sTexto);
            }
            else
            {
                sb.AppendLine("WHERE Age_Id > 0");
            }

            sb.AppendLine(usuarioCliente.PermissaoUsuario(idUsuario));

            if ((!string.IsNullOrWhiteSpace(filtro.DataInicial)) && (filtro.DataInicial.Trim() != "/  /"))
            {
                sb.AppendLine(" AND Age_Data >=" + Funcoes.DataIngles(filtro.DataInicial));
            }

            if ((!string.IsNullOrWhiteSpace(filtro.DataFinal)) && (filtro.DataFinal.Trim() != "/  /"))
            {
                sb.AppendLine(" AND Age_Data <=" + Funcoes.DataIngles(filtro.DataFinal));
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdCliente))
            {
                sb.AppendLine(" AND Age_Cliente IN (" + filtro.IdCliente + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdTipo))
            {
                sb.AppendLine(" AND Age_Tipo IN (" + filtro.IdTipo + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdStatus))
            {
                sb.AppendLine(" AND Age_Status IN (" + filtro.IdStatus + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.IdUsuario))
            {
                sb.AppendLine(" AND Age_Usuario IN (" + filtro.IdUsuario + ")");
            }

            var lista = _repositorioConsulta.GetAll(sb.ToString());

            return(lista);
        }
        public IEnumerable <BaseConhConsultaViewModel> Filtrar(BaseConhecimentoFiltroViewModel filtro, string campo, string texto, int usuarioId, bool contem = true)
        {
            string sTexto = "";

            sTexto = "'" + texto + "%'";
            if (contem)
            {
                sTexto = "'%" + texto + "%'";
            }

            var sb = new StringBuilder();

            sb.AppendLine(" SELECT");
            sb.AppendLine(" Bas_Id as Id, ");
            sb.AppendLine(" Bas_Data as Data, ");
            sb.AppendLine(" Bas_Nome as Nome, ");
            sb.AppendLine(" Usu_Nome as NomeUsuario, ");
            sb.AppendLine(" Tip_Nome as NomeTipo, ");
            sb.AppendLine(" Sta_Nome as NomeStatus ");
            sb.AppendLine(" FROM Base");
            sb.AppendLine(" INNER JOIN Usuario ON Bas_Usuario = Usu_id");
            sb.AppendLine(" INNER JOIN Tipo ON Bas_Tipo = Tip_id");
            sb.AppendLine(" INNER JOIN Status ON Bas_Status = Sta_Id");

            if (!string.IsNullOrWhiteSpace(texto))
            {
                sb.AppendLine(" WHERE " + campo + " LIKE " + sTexto);
            }
            else
            {
                sb.AppendLine(" WHERE Bas_Id > 0");
            }

            if (!Comun.Funcoes.DataEmBranco(filtro.DataInicial))
            {
                sb.AppendLine(" AND Bas_Data >= " + Comun.Funcoes.DataIngles(filtro.DataInicial));
            }

            if (!Comun.Funcoes.DataEmBranco(filtro.DataFinal))
            {
                sb.AppendLine(" AND Bas_Data <= " + Comun.Funcoes.DataIngles(filtro.DataFinal));
            }

            if (!string.IsNullOrWhiteSpace(filtro.ModuloId))
            {
                sb.AppendLine(" AND Bas_Modulo IN (" + filtro.ModuloId + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.ProdutoId))
            {
                sb.AppendLine(" AND Bas_Produto IN (" + filtro.ModuloId + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.StatusId))
            {
                sb.AppendLine(" AND Bas_Status IN (" + filtro.StatusId + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.TipoId))
            {
                sb.AppendLine(" AND Bas_Tipo IN (" + filtro.TipoId + ")");
            }

            if (!string.IsNullOrWhiteSpace(filtro.UsuarioId))
            {
                sb.AppendLine(" AND Bas_Usuario IN (" + filtro.UsuarioId + ")");
            }

            sb.AppendLine(" ORDER BY " + campo);

            var lista = _repositorioConsulta.GetAll(sb.ToString());

            return(lista);
        }