Exemplo n.º 1
0
        public IEnumerable <ParametroConsulta> Filtrar(string campo, string texto, bool contem = true)
        {
            string sTexto = "";

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

            var sb = new StringBuilder();

            sb.AppendLine("  SELECT");
            sb.AppendLine(" Par_Id as Id,");
            sb.AppendLine(" Par_Codigo as Codigo,");
            sb.AppendLine(" Par_Nome as Nome,");
            sb.AppendLine(" Par_Programa as Programa,");
            sb.AppendLine(" Par_Valor as Valor");
            sb.AppendLine(" FROM Parametros");

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

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

            return(_repositoryReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 2
0
        public IEnumerable <ChamadoAplicativoViewModel> RetornarDadosAplicativo(string cnpj)
        {
            string novoCnpj;

            if (cnpj.Length == 11)
            {
                novoCnpj = Funcoes.Utils.FormatarCPF(cnpj);
            }
            else
            {
                novoCnpj = Funcoes.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_Contato as Contato,");
            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(_repositoryAplicativoReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 3
0
        public IEnumerable <RamalConsulta> Filtrar(string campo, string texto, bool contem = true)
        {
            string sTexto = "";

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

            var sb = new StringBuilder();

            sb.AppendLine("  SELECT");
            sb.AppendLine(" Ram_Id as Id,");
            sb.AppendLine(" Ram_Departamento as Departamento");
            sb.AppendLine(" FROM Ramal");

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

            sb.AppendLine(" ORDER BY " + campo);
            return(_repositoryReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 4
0
        public IEnumerable <AgendamentoQuadroViewModel> Quadros(string dataInicial, string dataFinal, int idUsuario, int idRevenda)
        {
            var sb = new StringBuilder();

            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.Utils.DataIngles(dataInicial));
            sb.AppendLine(" AND Age_Data <=" + Funcoes.Utils.DataIngles(dataFinal));

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

            sb.AppendLine(_uow.RepositorioUsuario.PermissaoUsuario((idUsuario)));

            sb.AppendLine(" ORDER BY Age_Data");

            return(_repositorioReadOnlyQuadro.GetAll(sb.ToString()));
        }
Exemplo n.º 5
0
        public IEnumerable <Feriado> Filtrar(string campo, string texto)
        {
            string sTexto = "";

            sTexto = "'%" + texto + "%'";

            var sb = new StringBuilder();

            sb.AppendLine("  SELECT");
            sb.AppendLine(" Fer_Id as Id,");
            sb.AppendLine(" Fer_Descricao as Descricao,");
            sb.AppendLine(" Fer_Data as Data");
            sb.AppendLine(" FROM Feriado");

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

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

            return(_repositoryReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 6
0
        public IEnumerable <VisitaConsultaViewModelApi> Filtrar(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.Utils.DataEmBranco(filtro.DataInicial))
            {
                sb.AppendLine(" AND Vis_Data >= '" + filtro.DataInicial + "'");
            }

            if (!Funcoes.Utils.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);

            return(_repositoryReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 7
0
        public IEnumerable <ModuloConsulta> Filtrar(string campo, string texto, string ativo = "A", bool contem = true, int idCliente = 0)
        {
            string sTexto = "";

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

            var sb = new StringBuilder();

            sb.AppendLine("  SELECT");
            sb.AppendLine(" Mod_Id as Id,");
            sb.AppendLine(" Mod_Codigo as Codigo,");
            sb.AppendLine(" Mod_Nome as Nome");
            sb.AppendLine(" FROM Modulo");

            if (idCliente > 0)
            {
                sb.AppendLine("INNER JOIN Cliente_Modulo ON CliMod_Modulo = Mod_Id");
            }

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

            if (idCliente > 0)
            {
                sb.AppendLine(" AND CliMod_Cliente = " + idCliente);
            }

            if (ativo == "A")
            {
                sb.AppendLine(" AND Mod_Ativo = 1");
            }

            if (ativo == "I")
            {
                sb.AppendLine(" AND Mod_Ativo = 0");
            }

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

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

            return(lista);
        }
Exemplo n.º 8
0
        public IEnumerable <TipoConsulta> Filtrar(string campo, string texto, EnTipos enTipos, string ativo = "A", bool contem = true)
        {
            int tipo = (int)enTipos;

            string sTexto = "";

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

            var sb = new StringBuilder();

            sb.AppendLine("  SELECT");
            sb.AppendLine(" Tip_Id as Id,");
            sb.AppendLine(" Tip_Codigo as Codigo,");
            sb.AppendLine(" Tip_Nome as Nome,");
            sb.AppendLine(" Tip_Programa as Programa");
            sb.AppendLine(" FROM Tipo");

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

            if (ativo == "A")
            {
                sb.AppendLine(" AND Tip_Ativo = 1");
            }

            if (ativo == "I")
            {
                sb.AppendLine(" AND Tip_Ativo = 0");
            }

            if (enTipos != EnTipos.Todos)
            {
                sb.AppendLine(" AND Tip_Programa = " + tipo);
            }

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

            return(_repositoryReadOnly.GetAll(sb.ToString()));
        }
        private 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 = _repositoryQuadroReadOnly.GetAll(sb.ToString());

            return(lista);
        }
Exemplo n.º 10
0
        public IEnumerable <ProdutoConsulta> Filtrar(string campo, string texto, string ativo = "A", bool contem = true)
        {
            string sTexto = "";

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

            var sb = new StringBuilder();

            sb.AppendLine("  SELECT");
            sb.AppendLine(" Prod_Id as Id,");
            sb.AppendLine(" Prod_Codigo as Codigo,");
            sb.AppendLine(" Prod_Nome as Nome,");
            sb.AppendLine(" Prod_Ativo as Ativo");
            sb.AppendLine(" FROM Produto");

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

            if (ativo == "A")
            {
                sb.AppendLine(" AND Prod_Ativo = 1");
            }

            if (ativo == "I")
            {
                sb.AppendLine(" AND Prod_Ativo = 0");
            }

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

            return(_repositoryReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 11
0
        public IEnumerable <CategoriaConsulta> Filtrar(string campo, string texto, string ativo = "A", bool contem = true, int idCliente = 0)
        {
            string sTexto = "";

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

            var sb = new StringBuilder();

            sb.AppendLine("  SELECT");
            sb.AppendLine(" Cat_Id as Id,");
            sb.AppendLine(" Cat_Codigo as Codigo,");
            sb.AppendLine(" Cat_Nome as Nome");
            sb.AppendLine(" FROM Categoria");

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

            if (ativo == "A")
            {
                sb.AppendLine(" AND Cat_Ativo = 1");
            }

            if (ativo == "I")
            {
                sb.AppendLine(" AND Cat_Ativo = 0");
            }

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

            return(_repositoryReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 12
0
        public IEnumerable <ChamadoAnexo> RetornarAnexos(int chamadoId)
        {
            var sb = new StringBuilder();

            sb.AppendLine(" SELECT");
            sb.AppendLine(" Cha_Id as Id,");
            sb.AppendLine(" Cha_DataAbertura as DataAbertura,");
            sb.AppendLine(" Cha_HoraAbertura as HoraAbertura,");
            sb.AppendLine(" Cha_Contato as Contato,");
            sb.AppendLine(" Cli_Nome as NomeCliente,");
            sb.AppendLine(" ChOco_Docto as DoctoOcorrencia,");
            sb.AppendLine(" ChOco_Data as DataOcorrencia, ");
            sb.AppendLine(" ChOco_Anexo as NomeAnexo ");
            sb.AppendLine("FROM Chamado");
            sb.AppendLine(" INNER JOIN Chamado_Ocorrencia ON Cha_Id = ChOco_Chamado");
            sb.AppendLine(" INNER JOIN Cliente ON Cha_Cliente = Cli_Id");
            sb.AppendLine(" WHERE Cha_Id = " + chamadoId);
            sb.AppendLine(" ORDER BY ChOco_Data");

            return(_repositoryAnexoReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 13
0
        public IEnumerable <ChamadoOcorrencia> ListarProblemaSolucao(ChamadoFiltro filtro, string texto, int idUsuario, EnumChamado tipo)
        {
            string sConsulta = _uow.RepositorioUsuario.PermissaoUsuario(idUsuario);

            var sb = new StringBuilder();

            sb.AppendLine(" SELECT ");
            sb.AppendLine("   ChOco_Chamado,");
            sb.AppendLine("   ChOco_Data,");
            sb.AppendLine("   ChOco_HoraInicio,");
            sb.AppendLine("   ChOco_HoraFim,");
            sb.AppendLine("   ChOco_DescricaoSolucao,");
            sb.AppendLine("   ChOco_DescricaoTecnica,");
            sb.AppendLine("   Usu_Nome");
            sb.AppendLine(" FROM Chamado_Ocorrencia");
            sb.AppendLine("   INNER JOIN Chamado ON ChOco_Chamado = Cha_Id");
            sb.AppendLine("   INNER JOIN Cliente ON Cha_Cliente = Cli_Id");
            sb.AppendLine("   INNER JOIN Usuario ON ChOco_Usuario = Usu_Id	");
            sb.AppendLine(" WHERE ((ChOco_DescricaoTecnica LIKE " + texto + ") OR (ChOco_DescricaoSolucao LIKE " + texto + "))");
            sb.AppendLine(sConsulta);

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

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

            sb.AppendLine(" ORDER BY ChOco_Data");

            return(_repositoryProbemaSolucaoReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 14
0
        public IEnumerable <CidadeConsulta> Filtrar(string campo, string texto, bool?ativo, bool contem = true)
        {
            string sTexto = "";

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

            var sb = new StringBuilder();

            sb.AppendLine("SELECT Cid_Id as Id, Cid_Codigo as Codigo, Cid_Nome as Nome, Cid_UF as UF FROM Cidade");

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

            if (ativo == true)
            {
                sb.AppendLine(" AND Cid_Ativo = 1");
            }
            if (ativo == false)
            {
                sb.AppendLine(" AND Cid_Ativo = 0");
            }

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

            return(_repositoryReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 15
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(_repositoryReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 16
0
        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.Utils.DataEmBranco(filtro.DataInicial))
            {
                sb.AppendLine(" AND Rec_Data >= " + Funcoes.Utils.DataIngles(filtro.DataInicial));
            }
            if (!Funcoes.Utils.DataEmBranco(filtro.DataFinal))
            {
                sb.AppendLine(" AND Rec_Data <= " + Funcoes.Utils.DataIngles(filtro.DataFinal));
            }

            if (!Funcoes.Utils.DataEmBranco(filtro.DataInicialDest))
            {
                sb.AppendLine(" AND Rec_DataFinal >= " + Funcoes.Utils.DataIngles(filtro.DataInicialDest));
            }
            if (!Funcoes.Utils.DataEmBranco(filtro.DataFinalDest))
            {
                sb.AppendLine(" AND Rec_DataFinal <= " + Funcoes.Utils.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);
            }

            try
            {
                return(_repositoryReadOnly.GetAll(sb.ToString()));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 17
0
 public IEnumerable <Customer> GetAllCustomers()
 {
     return(_customerRepository.GetAll());
 }
Exemplo n.º 18
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 (filtro.Id > 0)
            {
                sb.AppendLine(" WHERE Ver_Id = " + filtro.Id);
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(texto))
                {
                    sb.AppendLine(" WHERE " + campo + " LIKE " + sTexto);
                }
                else
                {
                    sb.AppendLine(" WHERE Ver_Id > 0");
                }
            }

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

            if (!Funcoes.Utils.DataEmBranco(filtro.DataLiberacaoInicial))
            {
                sb.AppendLine(" AND Ver_DataLiberacao >= " + Funcoes.Utils.DataIngles(filtro.DataLiberacaoInicial));
            }
            if (!Funcoes.Utils.DataEmBranco(filtro.DataLiberacaoFinal))
            {
                sb.AppendLine(" AND Ver_DataLiberacao <= " + Funcoes.Utils.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);

            return(_repositoryReadOnly.GetAll(sb.ToString()));
        }
        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 (!Funcoes.Utils.DataEmBranco(filtro.DataInicial))
            {
                sb.AppendLine(" AND Bas_Data >= " + Funcoes.Utils.DataIngles(filtro.DataInicial));
            }

            if (!Funcoes.Utils.DataEmBranco(filtro.DataFinal))
            {
                sb.AppendLine(" AND Bas_Data <= " + Funcoes.Utils.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);

            return(_repositoryReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 20
0
        public IEnumerable <ChamadoConsultaViewModel> Filtrar(ChamadoFiltroViewModel filtro, string campo, string texto, int usuarioId, bool contem, EnumChamado tipo)
        {
            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(_uow.RepositorioUsuario.PermissaoUsuario(usuarioId));

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

            if ((!string.IsNullOrWhiteSpace(filtro.DataFinal)) && (filtro.DataFinal.Trim() != "/  /"))
            {
                sb.AppendLine(" AND Cha_DataAbertura <=" + Funcoes.Utils.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);

            return(_repositoryReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 21
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 usuarioPermissao = _uow.RepositorioUsuario.PermissaoUsuario(idUsuario);

            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(usuarioPermissao);

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

            if ((!string.IsNullOrWhiteSpace(filtro.DataFinal)) && (!Funcoes.Utils.DataEmBranco(filtro.DataFinal)))
            {
                sb.AppendLine(" AND Age_Data <=" + Funcoes.Utils.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 + ")");
            }

            return(_repositoryReadOnly.GetAll(sb.ToString()));
        }
Exemplo n.º 22
0
        public IEnumerable <UsuarioConsulta> Filtrar(string campo, string texto, string ativo = "A", bool contem = true)
        {
            string sql = _uow.RepositorioUsuario.Filtrar(campo, texto, ativo, contem);

            return(_repositoryReadOnly.GetAll(sql));
        }