/// <summary>
        /// Get TB_UNIVERSIDADE_TAG/TB_UNIVERSIDADE_TAG
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <TB_UNIVERSIDADE_TAG> getQuery(ModelApiUnes _db, int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            _db.Configuration.ProxyCreationEnabled = false;
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.TB_UNIVERSIDADE_TAG.AsQueryable <TB_UNIVERSIDADE_TAG>();// .AsQueryable<TB_UNIVERSIDADE_TAG>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.UNT_ID_TAG:
                    Int32 UNT_ID_TAG = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.UNT_ID_TAG.Equals(UNT_ID_TAG)).AsQueryable <TB_UNIVERSIDADE_TAG>();
                    break;

                case CAMPOS.UNT_TX_NOME:
                    string UNT_TX_NOME = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.UNT_TX_NOME.Equals(UNT_TX_NOME)).AsQueryable <TB_UNIVERSIDADE_TAG>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.UNT_ID_TAG:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.UNT_ID_TAG).AsQueryable <TB_UNIVERSIDADE_TAG>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.UNT_ID_TAG).AsQueryable <TB_UNIVERSIDADE_TAG>();
                }
                break;

            case CAMPOS.UNT_TX_NOME:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.UNT_TX_NOME).AsQueryable <TB_UNIVERSIDADE_TAG>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.UNT_TX_NOME).AsQueryable <TB_UNIVERSIDADE_TAG>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            CAMPOS cAMPOS = db.CAMPOS.Find(id);

            db.CAMPOS.Remove(cAMPOS);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
        /// <summary>
        /// Get TbModoEntradaTef/TbModoEntradaTef
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <tbModoEntradaTef> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.tbModoEntradaTefs.AsQueryable <tbModoEntradaTef>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.CDMODOENTRADATEF:
                    short cdModoEntradaTef = short.Parse(item.Value);
                    entity = entity.Where(e => e.cdModoEntradaTef.Equals(cdModoEntradaTef)).AsQueryable <tbModoEntradaTef>();
                    break;

                case CAMPOS.DSMODOENTRADATEF:
                    string dsModoEntradaTef = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsModoEntradaTef.Equals(dsModoEntradaTef)).AsQueryable <tbModoEntradaTef>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.CDMODOENTRADATEF:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdModoEntradaTef).AsQueryable <tbModoEntradaTef>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdModoEntradaTef).AsQueryable <tbModoEntradaTef>();
                }
                break;

            case CAMPOS.DSMODOENTRADATEF:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsModoEntradaTef).AsQueryable <tbModoEntradaTef>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsModoEntradaTef).AsQueryable <tbModoEntradaTef>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #4
0
        /// <summary>
        /// Get Webpages_UsersInRoles/Webpages_UsersInRoles
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <webpages_UsersInRoles> getQuery(painel_taxservices_dbContext _db, int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.webpages_UsersInRoles.AsQueryable <webpages_UsersInRoles>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.USERID:
                    Int32 UserId = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.UserId.Equals(UserId)).AsQueryable <webpages_UsersInRoles>();
                    break;

                case CAMPOS.ROLEID:
                    Int32 RoleId = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.RoleId.Equals(RoleId)).AsQueryable <webpages_UsersInRoles>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.USERID:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.UserId).AsQueryable <webpages_UsersInRoles>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.UserId).AsQueryable <webpages_UsersInRoles>();
                }
                break;

            case CAMPOS.ROLEID:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.RoleId).AsQueryable <webpages_UsersInRoles>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.RoleId).AsQueryable <webpages_UsersInRoles>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #5
0
        /// <summary>
        /// Get TbAssinante/TbAssinante
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <tbAssinante> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.tbAssinantes.AsQueryable();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.CDCATALOGO:
                    short cdCatalogo = short.Parse(item.Value);
                    entity = entity.Where(e => e.cdCatalogo.Equals(cdCatalogo)).AsQueryable <tbAssinante>();
                    break;

                case CAMPOS.ID_USERS:
                    Int32 id_users = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id_users.Equals(id_users)).AsQueryable <tbAssinante>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.CDCATALOGO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdCatalogo).AsQueryable <tbAssinante>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdCatalogo).AsQueryable <tbAssinante>();
                }
                break;

            case CAMPOS.ID_USERS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id_users).AsQueryable <tbAssinante>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id_users).AsQueryable <tbAssinante>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #6
0
 public ActionResult Edit([Bind(Include = "PAGINA_ID,ID,DESCRIPCION,TIPO")] CAMPOS cAMPOS)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cAMPOS).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PAGINA_ID = new SelectList(db.PAGINAs, "ID", "URL", cAMPOS.PAGINA_ID);
     return(View(cAMPOS));
 }
예제 #7
0
        /// <summary>
        /// Retorna Utils
        /// </summary>
        /// <returns></returns>
        public static Retorno Get(string token, int colecao = 0, int campo = 0, int orderBy = 0, int pageSize = 0, int pageNumber = 0, Dictionary <string, string> queryString = null, ModelApiUnes _dbContext = null)
        {
            Retorno retorno = new Retorno();
            string  CODIGO  = null;
            string  CNPJCPF = null;
            string  CPF     = null;
            string  CNPJ    = null;

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.USUARIO:
                    CODIGO = item.Value;
                    break;

                case CAMPOS.CPF:
                    CPF = item.Value;
                    break;

                case CAMPOS.CNPJ:
                    CNPJ = item.Value;
                    break;
                }
            }

            if (!string.IsNullOrEmpty(CPF))
            {
                CNPJCPF = CPF;
            }
            if (!string.IsNullOrEmpty(CNPJ))
            {
                CNPJCPF = CNPJ;
            }

            if ((!string.IsNullOrEmpty(CNPJCPF)) && (!string.IsNullOrEmpty(CODIGO)))
            {
                retorno = Gateways.Dbo.GatewayTbUsuarioAlias.ValidaCpfCnpjUsuario(token, CODIGO, CNPJCPF);
            }
            if ((!string.IsNullOrEmpty(CNPJCPF)) && (string.IsNullOrEmpty(CODIGO)))
            {
                retorno = Gateways.Dbo.GatewayTbUsuarioAlias.ValidaCpfCnpj(CNPJCPF);
            }
            if ((string.IsNullOrEmpty(CNPJCPF)) && (!string.IsNullOrEmpty(CODIGO)))
            {
                retorno = Gateways.Dbo.GatewayTbUsuarioAlias.ValidaUsuario(CODIGO);
            }

            return(retorno);
        }
예제 #8
0
        // GET: Mensajes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CAMPOS cAMPOS = db.CAMPOS.Find(id);

            if (cAMPOS == null)
            {
                return(HttpNotFound());
            }
            return(View(cAMPOS));
        }
예제 #9
0
        // GET: Mensajes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CAMPOS cAMPOS = db.CAMPOS.Find(id);

            if (cAMPOS == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PAGINA_ID = new SelectList(db.PAGINAs, "ID", "URL", cAMPOS.PAGINA_ID);
            return(View(cAMPOS));
        }
예제 #10
0
        /// <summary>
        /// Get LogExecutionException/LogExecutionException
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <LogExecutionException> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.LogExecutionExceptions.AsQueryable <LogExecutionException>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.ID:
                    Int32 id = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id.Equals(id)).AsQueryable <LogExecutionException>();
                    break;

                case CAMPOS.IDLOGEXECUTION:
                    Int32 idLogExecution = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idLogExecution.Equals(idLogExecution)).AsQueryable <LogExecutionException>();
                    break;

                case CAMPOS.TEXTERROR:
                    string textError = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.textError.Equals(textError)).AsQueryable <LogExecutionException>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.ID:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id).AsQueryable <LogExecutionException>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id).AsQueryable <LogExecutionException>();
                }
                break;

            case CAMPOS.IDLOGEXECUTION:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idLogExecution).AsQueryable <LogExecutionException>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idLogExecution).AsQueryable <LogExecutionException>();
                }
                break;

            case CAMPOS.TEXTERROR:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.textError).AsQueryable <LogExecutionException>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.textError).AsQueryable <LogExecutionException>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #11
0
        /// <summary>
        /// Get TbBancoParametro/TbBancoParametro
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <tbBancoParametro> getQuery(painel_taxservices_dbContext _db, int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.tbBancoParametros.AsQueryable <tbBancoParametro>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.CDBANCO:
                    string cdBanco = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cdBanco.Equals(cdBanco)).AsQueryable <tbBancoParametro>();
                    break;

                case CAMPOS.DSMEMO:
                    string dsMemo = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsMemo.Equals(dsMemo)).AsQueryable <tbBancoParametro>();
                    break;

                case CAMPOS.CDADQUIRENTE:
                    Int32 cdAdquirente = Convert.ToInt32(item.Value);
                    if (cdAdquirente == -1)
                    {
                        // Somente os registros sem adquirentes associados
                        entity = entity.Where(e => e.cdAdquirente == null).AsQueryable <tbBancoParametro>();
                    }
                    else
                    {
                        entity = entity.Where(e => e.cdAdquirente == cdAdquirente).AsQueryable <tbBancoParametro>();
                    }
                    break;

                case CAMPOS.DSTIPO:
                    string dsTipo = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsTipo.Equals(dsTipo)).AsQueryable <tbBancoParametro>();
                    break;

                case CAMPOS.FLVISIVEL:
                    bool flVisivel = Convert.ToBoolean(item.Value);
                    entity = entity.Where(e => e.flVisivel == flVisivel).AsQueryable <tbBancoParametro>();
                    break;

                case CAMPOS.NRCNPJ:
                    string nrCnpj = Convert.ToString(item.Value);
                    if (nrCnpj.Equals(""))
                    {
                        entity = entity.Where(e => e.nrCnpj == null).AsQueryable <tbBancoParametro>();
                    }
                    else
                    {
                        entity = entity.Where(e => e.nrCnpj != null && e.nrCnpj.Equals(nrCnpj)).AsQueryable <tbBancoParametro>();
                    }
                    break;

                case CAMPOS.DSTIPOCARTAO:
                    string dsTipoCartao = Convert.ToString(item.Value);
                    if (dsTipoCartao.Equals(""))
                    {
                        entity = entity.Where(e => e.dsTipoCartao == null).AsQueryable <tbBancoParametro>();
                    }
                    else
                    {
                        entity = entity.Where(e => e.dsTipoCartao != null && e.dsTipoCartao.TrimEnd().Equals(dsTipoCartao)).AsQueryable <tbBancoParametro>();
                    }
                    break;

                case CAMPOS.CDBANDEIRA:
                    Int32 cdBandeira = Convert.ToInt32(item.Value);
                    if (cdBandeira == -1)
                    {
                        // Somente os registros sem adquirentes associados
                        entity = entity.Where(e => e.cdBandeira == null).AsQueryable <tbBancoParametro>();
                    }
                    else
                    {
                        entity = entity.Where(e => e.cdBandeira == cdBandeira).AsQueryable <tbBancoParametro>();
                    }
                    break;


                // PERSONALIZADO
                case CAMPOS.DSADQUIRENTE:
                    string nome = Convert.ToString(item.Value);
                    if (nome.Contains("%"))     // usa LIKE
                    {
                        string busca = nome.Replace("%", "").ToString();
                        entity = entity.Where(e => e.tbAdquirente.dsAdquirente.Contains(busca)).AsQueryable <tbBancoParametro>();
                    }
                    else
                    {
                        entity = entity.Where(e => e.tbAdquirente.dsAdquirente.Equals(nome)).AsQueryable <tbBancoParametro>();
                    }
                    break;

                case CAMPOS.ID_GRUPO:
                    Int32 id_grupo = Convert.ToInt32(item.Value);

                    /*grupo_empresa grupo = _db.grupo_empresa.Where(g => g.id_grupo == id_grupo).FirstOrDefault();
                     * if (grupo == null) continue;
                     * // Armazena todos os parâmetros existentes para o grupo, baseado nos extratos "upados"
                     * //List<ParametroBancario> parametros = new List<ParametroBancario>();
                     * List<string> memos = new List<string>();
                     * foreach (tbContaCorrente tbContaCorrente in grupo.tbContaCorrentes) {
                     *  foreach (tbExtrato tbExtrato in tbContaCorrente.tbExtratos)
                     *  {
                     *      if(!memos.Contains(tbExtrato.dsDocumento))
                     *      {
                     *          memos.Add(tbExtrato.dsDocumento);
                     *      }
                     *  }
                     * }
                     * // Para os parâmetros que não estão associados à uma filial, só são exibidos os que constam nos extratos bancários associados ao grupo
                     * entity = entity.Where(e => (e.cdGrupo != 0 && e.cdGrupo == id_grupo) ||
                     *                         (e.nrCnpj == null && memos.Contains(e.dsMemo))//grupo.tbContaCorrentes.Where(c => c.tbExtratos.Where(x => x.tbContaCorrente.cdBanco.Equals(e.cdBanco) && x.dsDocumento.Equals(e.dsMemo)).Count() > 0).Count() > 0)
                     || (e.nrCnpj != null && e.empresa.id_grupo == id_grupo)).AsQueryable<tbBancoParametro>();
                     */
                    entity = entity.Where(e => e.cdGrupo == id_grupo).AsQueryable <tbBancoParametro>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.CDBANCO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdBanco).ThenBy(e => e.dsMemo).AsQueryable <tbBancoParametro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdBanco).ThenByDescending(e => e.dsMemo).AsQueryable <tbBancoParametro>();
                }
                break;

            case CAMPOS.DSMEMO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsMemo).AsQueryable <tbBancoParametro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsMemo).AsQueryable <tbBancoParametro>();
                }
                break;

            case CAMPOS.CDADQUIRENTE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdAdquirente).AsQueryable <tbBancoParametro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdAdquirente).AsQueryable <tbBancoParametro>();
                }
                break;

            case CAMPOS.DSTIPO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsTipo).AsQueryable <tbBancoParametro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsTipo).AsQueryable <tbBancoParametro>();
                }
                break;

            case CAMPOS.FLVISIVEL:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.flVisivel).AsQueryable <tbBancoParametro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.flVisivel).AsQueryable <tbBancoParametro>();
                }
                break;

            case CAMPOS.NRCNPJ:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nrCnpj).AsQueryable <tbBancoParametro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nrCnpj).AsQueryable <tbBancoParametro>();
                }
                break;

            case CAMPOS.DSTIPOCARTAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsTipoCartao).AsQueryable <tbBancoParametro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsTipoCartao).AsQueryable <tbBancoParametro>();
                }
                break;

            case CAMPOS.CDBANDEIRA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdBandeira).AsQueryable <tbBancoParametro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdBandeira).AsQueryable <tbBancoParametro>();
                }
                break;

            // PERSONALIZADO
            case CAMPOS.DSADQUIRENTE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.tbAdquirente.dsAdquirente).AsQueryable <tbBancoParametro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.tbAdquirente.dsAdquirente).AsQueryable <tbBancoParametro>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #12
0
        /// <summary>
        /// Get TbRecebimentoVenda/TbRecebimentoVenda
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <tbRecebimentoVenda> getQuery(painel_taxservices_dbContext _db, int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.tbRecebimentoVendas.AsQueryable <tbRecebimentoVenda>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.IDRECEBIMENTOVENDA:
                    Int32 idRecebimentoVenda = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idRecebimentoVenda.Equals(idRecebimentoVenda)).AsQueryable <tbRecebimentoVenda>();
                    break;

                case CAMPOS.NRCNPJ:
                    string nrCNPJ = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nrCNPJ.Equals(nrCNPJ)).AsQueryable <tbRecebimentoVenda>();
                    break;

                case CAMPOS.NRNSU:
                    string nrNSU = Convert.ToString(item.Value);
                    if (nrNSU.Contains("%"))     // usa LIKE => ENDS WITH
                    {
                        string busca = nrNSU.Replace("%", "").ToString();
                        entity = entity.Where(e => e.nrNSU.EndsWith(busca)).AsQueryable <tbRecebimentoVenda>();
                    }
                    else
                    {
                        entity = entity.Where(e => e.nrNSU.Equals(nrNSU)).AsQueryable <tbRecebimentoVenda>();
                    }
                    break;

                case CAMPOS.DTVENDA:
                    if (item.Value.Contains("|"))     // BETWEEN
                    {
                        string[] busca  = item.Value.Split('|');
                        DateTime dtaIni = DateTime.ParseExact(busca[0] + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        DateTime dtaFim = DateTime.ParseExact(busca[1] + " 23:59:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        entity = entity.Where(e => e.dtVenda >= dtaIni && e.dtVenda <= dtaFim).AsQueryable <tbRecebimentoVenda>();
                    }
                    else     // IGUAL
                    {
                        string   busca  = item.Value;
                        DateTime dtaIni = DateTime.ParseExact(busca + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        entity = entity.Where(e => e.dtVenda.Year == dtaIni.Year && e.dtVenda.Month == dtaIni.Month && e.dtVenda.Day == dtaIni.Day).AsQueryable <tbRecebimentoVenda>();
                    }
                    break;

                case CAMPOS.CDADQUIRENTE:
                    Int32 cdAdquirente = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.cdAdquirente == cdAdquirente).AsQueryable <tbRecebimentoVenda>();
                    break;

                case CAMPOS.DSBANDEIRA:
                    string dsBandeira = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsBandeira.Equals(dsBandeira)).AsQueryable <tbRecebimentoVenda>();
                    break;

                case CAMPOS.VLVENDA:
                    decimal vlVenda = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.vlVenda.Equals(vlVenda)).AsQueryable <tbRecebimentoVenda>();
                    break;

                case CAMPOS.QTPARCELAS:
                    byte qtParcelas = Convert.ToByte(item.Value);
                    entity = entity.Where(e => e.qtParcelas.Equals(qtParcelas)).AsQueryable <tbRecebimentoVenda>();
                    break;

                case CAMPOS.CDERP:
                    string cdERP = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cdERP.Equals(cdERP)).AsQueryable <tbRecebimentoVenda>();
                    break;

                case CAMPOS.CDSACADO:
                    string cdSacado = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cdSacado.Equals(cdSacado)).AsQueryable <tbRecebimentoVenda>();
                    break;

                case CAMPOS.DTAJUSTE:
                    if (item.Value.Contains("|"))     // BETWEEN
                    {
                        string[] busca  = item.Value.Split('|');
                        DateTime dtaIni = DateTime.ParseExact(busca[0] + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        DateTime dtaFim = DateTime.ParseExact(busca[1] + " 23:59:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        entity = entity.Where(e => e.dtAjuste != null && e.dtAjuste >= dtaIni && e.dtAjuste <= dtaFim).AsQueryable <tbRecebimentoVenda>();
                    }
                    else     // IGUAL
                    {
                        string   busca  = item.Value;
                        DateTime dtaIni = DateTime.ParseExact(busca + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        entity = entity.Where(e => e.dtAjuste != null && e.dtAjuste.Value.Year == dtaIni.Year && e.dtAjuste.Value.Month == dtaIni.Month && e.dtAjuste.Value.Day == dtaIni.Day).AsQueryable <tbRecebimentoVenda>();
                    }
                    break;

                case CAMPOS.DSMENSAGEM:
                    string dsMensagem = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsMensagem.Equals(dsMensagem)).AsQueryable <tbRecebimentoVenda>();
                    break;

                case CAMPOS.DSDETALHE:
                    string dsDetalhe = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsDetalhe.Equals(dsDetalhe)).AsQueryable <tbRecebimentoVenda>();
                    break;

                // RELACIONAMENTOS
                case CAMPOS.ID_GRUPO:
                    Int32 id_grupo = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.empresa.id_grupo == id_grupo).AsQueryable <tbRecebimentoVenda>();
                    break;
                }
            }
            #endregion

            string outValue = null;
            if (queryString.TryGetValue("" + (int)CAMPOS.TIPO, out outValue))
            {
                string      script = String.Empty;
                TIPO_FILTRO tipo   = (TIPO_FILTRO)Convert.ToInt32(queryString["" + (int)CAMPOS.TIPO]);
                switch (tipo)
                {
                case TIPO_FILTRO.CONCILIADO:
                    // entity = entity.Where(e =>  e.Recebimentos.Count > 0).AsQueryable<tbRecebimentoVenda>();
                    script = "SELECT DISTINCT V.idRecebimentoVenda" +
                             " FROM card.tbRecebimentoVenda V (NOLOCK)" +
                             " LEFT JOIN pos.Recebimento R (NOLOCK) ON R.idRecebimentoVenda = V.idRecebimentoVenda" +
                             " WHERE R.idRecebimentoVenda IS NOT NULL" +
                             " AND V.idRecebimentoVenda IN (" + string.Join(", ", entity.Select(e => e.idRecebimentoVenda)) + ")";
                    int[] vendasConciliadas = _db.Database.SqlQuery <int>(script).ToArray();
                    entity = entity.Where(e => vendasConciliadas.Contains(e.idRecebimentoVenda)).AsQueryable <tbRecebimentoVenda>();
                    break;

                case TIPO_FILTRO.NAO_CONCILIADO:
                    // entity = entity.Where(e =>  e.Recebimentos.Count == 0).AsQueryable<tbRecebimentoVenda>();
                    script = "SELECT V.idRecebimentoVenda" +
                             " FROM card.tbRecebimentoVenda V (NOLOCK)" +
                             " LEFT JOIN pos.Recebimento R (NOLOCK) ON R.idRecebimentoVenda = V.idRecebimentoVenda" +
                             " WHERE R.idRecebimentoVenda IS NULL" +
                             " AND V.idRecebimentoVenda IN (" + string.Join(", ", entity.Select(e => e.idRecebimentoVenda)) + ")";
                    int[] vendasNaoConciliadas = _db.Database.SqlQuery <int>(script).ToArray();
                    entity = entity.Where(e => vendasNaoConciliadas.Contains(e.idRecebimentoVenda)).AsQueryable <tbRecebimentoVenda>();
                    break;

                case TIPO_FILTRO.CORRIGIDO:
                    entity = entity.Where(e => e.dtAjuste != null).AsQueryable <tbRecebimentoVenda>();
                    break;

                case TIPO_FILTRO.CORRECAO_MANUAL:
                    entity = entity.Where(e => e.dtAjuste != null && e.dsMensagem != null).AsQueryable <tbRecebimentoVenda>();
                    break;
                }
            }

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.IDRECEBIMENTOVENDA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idRecebimentoVenda).AsQueryable <tbRecebimentoVenda>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idRecebimentoVenda).AsQueryable <tbRecebimentoVenda>();
                }
                break;

            case CAMPOS.NRCNPJ:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nrCNPJ).AsQueryable <tbRecebimentoVenda>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nrCNPJ).AsQueryable <tbRecebimentoVenda>();
                }
                break;

            case CAMPOS.NRNSU:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nrNSU).AsQueryable <tbRecebimentoVenda>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nrNSU).AsQueryable <tbRecebimentoVenda>();
                }
                break;

            case CAMPOS.DTVENDA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtVenda).AsQueryable <tbRecebimentoVenda>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtVenda).AsQueryable <tbRecebimentoVenda>();
                }
                break;

            case CAMPOS.CDADQUIRENTE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdAdquirente).AsQueryable <tbRecebimentoVenda>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdAdquirente).AsQueryable <tbRecebimentoVenda>();
                }
                break;

            case CAMPOS.DSBANDEIRA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsBandeira).AsQueryable <tbRecebimentoVenda>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsBandeira).AsQueryable <tbRecebimentoVenda>();
                }
                break;

            case CAMPOS.VLVENDA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.vlVenda).AsQueryable <tbRecebimentoVenda>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.vlVenda).AsQueryable <tbRecebimentoVenda>();
                }
                break;

            case CAMPOS.QTPARCELAS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.qtParcelas).AsQueryable <tbRecebimentoVenda>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.qtParcelas).AsQueryable <tbRecebimentoVenda>();
                }
                break;

            case CAMPOS.CDERP:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdERP).AsQueryable <tbRecebimentoVenda>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdERP).AsQueryable <tbRecebimentoVenda>();
                }
                break;

            case CAMPOS.CDSACADO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdSacado).AsQueryable <tbRecebimentoVenda>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdSacado).AsQueryable <tbRecebimentoVenda>();
                }
                break;

            case CAMPOS.DTAJUSTE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtAjuste).AsQueryable <tbRecebimentoVenda>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtAjuste).AsQueryable <tbRecebimentoVenda>();
                }
                break;

            case CAMPOS.DSMENSAGEM:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsMensagem).AsQueryable <tbRecebimentoVenda>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsMensagem).AsQueryable <tbRecebimentoVenda>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #13
0
        /// <summary>
        /// Get Bandeiras/Bandeiras
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <Bandeira> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.Bandeiras.AsQueryable <Bandeira>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.IDBANDEIRA:
                    Int32 IdBandeira = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.IdBandeira.Equals(IdBandeira)).AsQueryable <Bandeira>();
                    break;

                case CAMPOS.DESCRICAOBANDEIRA:
                    string DescricaoBandeira = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.DescricaoBandeira.Equals(DescricaoBandeira)).AsQueryable <Bandeira>();
                    break;

                case CAMPOS.IDGRUPO:
                    Int32 IdGrupo = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.IdGrupo.Equals(IdGrupo)).AsQueryable <Bandeira>();
                    break;

                case CAMPOS.CODBANDEIRAERP:
                    string CodBandeiraERP = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.CodBandeiraERP.Equals(CodBandeiraERP)).AsQueryable <Bandeira>();
                    break;

                case CAMPOS.CODBANDEIRAHOSTPAGAMENTO:
                    decimal CodBandeiraHostPagamento = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.CodBandeiraHostPagamento.Equals(CodBandeiraHostPagamento)).AsQueryable <Bandeira>();
                    break;

                case CAMPOS.TAXAADMINISTRACAO:
                    decimal TaxaAdministracao = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.TaxaAdministracao.Equals(TaxaAdministracao)).AsQueryable <Bandeira>();
                    break;

                case CAMPOS.IDTIPOPAGAMENTO:
                    Int32 IdTipoPagamento = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.IdTipoPagamento.Equals(IdTipoPagamento)).AsQueryable <Bandeira>();
                    break;

                case CAMPOS.SACADO:
                    string Sacado = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.Sacado.Equals(Sacado)).AsQueryable <Bandeira>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.IDBANDEIRA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.IdBandeira).AsQueryable <Bandeira>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.IdBandeira).AsQueryable <Bandeira>();
                }
                break;

            case CAMPOS.DESCRICAOBANDEIRA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.DescricaoBandeira).AsQueryable <Bandeira>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.DescricaoBandeira).AsQueryable <Bandeira>();
                }
                break;

            case CAMPOS.IDGRUPO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.IdGrupo).AsQueryable <Bandeira>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.IdGrupo).AsQueryable <Bandeira>();
                }
                break;

            case CAMPOS.CODBANDEIRAERP:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.CodBandeiraERP).AsQueryable <Bandeira>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.CodBandeiraERP).AsQueryable <Bandeira>();
                }
                break;

            case CAMPOS.CODBANDEIRAHOSTPAGAMENTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.CodBandeiraHostPagamento).AsQueryable <Bandeira>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.CodBandeiraHostPagamento).AsQueryable <Bandeira>();
                }
                break;

            case CAMPOS.TAXAADMINISTRACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.TaxaAdministracao).AsQueryable <Bandeira>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.TaxaAdministracao).AsQueryable <Bandeira>();
                }
                break;

            case CAMPOS.IDTIPOPAGAMENTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.IdTipoPagamento).AsQueryable <Bandeira>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.IdTipoPagamento).AsQueryable <Bandeira>();
                }
                break;

            case CAMPOS.SACADO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.Sacado).AsQueryable <Bandeira>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.Sacado).AsQueryable <Bandeira>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #14
0
        /// <summary>
        /// Get TicketCar/TicketCar
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <TicketCar> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.TicketCars.AsQueryable <TicketCar>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.ID:
                    Int32 id = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id.Equals(id)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.DTATRANSACAO:
                    DateTime dtaTransacao = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtaTransacao.Equals(dtaTransacao)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.DESCRICAO:
                    string descricao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.descricao.Equals(descricao)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.TIPOTRANSACAO:
                    string tipoTransacao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.tipoTransacao.Equals(tipoTransacao)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.REEMBOLSO:
                    string reembolso = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.reembolso.Equals(reembolso)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.NUMCARTAO:
                    string numCartao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.numCartao.Equals(numCartao)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.NUMOS:
                    string numOS = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.numOS.Equals(numOS)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.MERCADORIA:
                    string mercadoria = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.mercadoria.Equals(mercadoria)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.QTDE:
                    string qtde = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.qtde.Equals(qtde)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.VALORUNITARIO:
                    decimal valorUnitario = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valorUnitario.Equals(valorUnitario)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.VALORDESCONTO:
                    decimal valorDesconto = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valorDesconto.Equals(valorDesconto)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.VALORBRUTO:
                    decimal valorBruto = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valorBruto.Equals(valorBruto)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.EMPRESA:
                    string empresa = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.empresa.Equals(empresa)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.CNPJ:
                    string cnpj = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cnpj.Equals(cnpj)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.IDOPERADORA:
                    Int32 idOperadora = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idOperadora.Equals(idOperadora)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.IDBANDEIRA:
                    Int32 idBandeira = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idBandeira.Equals(idBandeira)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.DTARECEBIMENTO:
                    DateTime dtaRecebimento = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtaRecebimento.Equals(dtaRecebimento)).AsQueryable <TicketCar>();
                    break;

                case CAMPOS.IDTERMINALLOGICO:
                    Int32 idTerminalLogico = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idTerminalLogico.Equals(idTerminalLogico)).AsQueryable <TicketCar>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.ID:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.DTATRANSACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtaTransacao).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtaTransacao).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.DESCRICAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.descricao).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.descricao).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.TIPOTRANSACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.tipoTransacao).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.tipoTransacao).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.REEMBOLSO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.reembolso).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.reembolso).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.NUMCARTAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.numCartao).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.numCartao).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.NUMOS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.numOS).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.numOS).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.MERCADORIA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.mercadoria).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.mercadoria).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.QTDE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.qtde).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.qtde).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.VALORUNITARIO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valorUnitario).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valorUnitario).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.VALORDESCONTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valorDesconto).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valorDesconto).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.VALORBRUTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valorBruto).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valorBruto).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.EMPRESA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.empresa).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.empresa).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.CNPJ:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cnpj).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cnpj).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.IDOPERADORA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idOperadora).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idOperadora).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.IDBANDEIRA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idBandeira).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idBandeira).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.DTARECEBIMENTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtaRecebimento).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtaRecebimento).AsQueryable <TicketCar>();
                }
                break;

            case CAMPOS.IDTERMINALLOGICO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idTerminalLogico).AsQueryable <TicketCar>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idTerminalLogico).AsQueryable <TicketCar>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #15
0
        /// <summary>
        /// Get RedeCard/RedeCard
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <RedeCard> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.RedeCards.AsQueryable <RedeCard>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.ID:
                    Int32 id = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id.Equals(id)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.NSU:
                    string nsu = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nsu.Equals(nsu)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.NUMCARTAO:
                    string numCartao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.numCartao.Equals(numCartao)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.DTAVENDA:
                    DateTime dtaVenda = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtaVenda.Equals(dtaVenda)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.VALORBRUTO:
                    decimal valorBruto = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valorBruto.Equals(valorBruto)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.TOTALPARCELAS:
                    Int32 totalParcelas = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.totalParcelas.Equals(totalParcelas)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.ESTABELECIMENTO:
                    string estabelecimento = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.estabelecimento.Equals(estabelecimento)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.TIPOCAPTURA:
                    string tipoCaptura = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.tipoCaptura.Equals(tipoCaptura)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.VENDACANCELADA:
                    string vendaCancelada = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.vendaCancelada.Equals(vendaCancelada)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.CNPJ:
                    string cnpj = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cnpj.Equals(cnpj)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.IDOPERADORA:
                    Int32 idOperadora = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idOperadora.Equals(idOperadora)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.IDBANDEIRA:
                    Int32 idBandeira = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idBandeira.Equals(idBandeira)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.DTARECEBIMENTO:
                    DateTime dtaRecebimento = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtaRecebimento.Equals(dtaRecebimento)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.IDLOGICOTERMINAL:
                    Int32 idLogicoTerminal = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idLogicoTerminal.Equals(idLogicoTerminal)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.TIPOVENDA:
                    string tipoVenda = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.tipoVenda.Equals(tipoVenda)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.TAXAADMINISTRACAO:
                    decimal taxaAdministracao = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.taxaAdministracao.Equals(taxaAdministracao)).AsQueryable <RedeCard>();
                    break;

                case CAMPOS.CODRESUMOVENDA:
                    string codResumoVenda = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.codResumoVenda.Equals(codResumoVenda)).AsQueryable <RedeCard>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.ID:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.NSU:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nsu).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nsu).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.NUMCARTAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.numCartao).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.numCartao).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.DTAVENDA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtaVenda).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtaVenda).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.VALORBRUTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valorBruto).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valorBruto).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.TOTALPARCELAS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.totalParcelas).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.totalParcelas).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.ESTABELECIMENTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.estabelecimento).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.estabelecimento).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.TIPOCAPTURA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.tipoCaptura).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.tipoCaptura).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.VENDACANCELADA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.vendaCancelada).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.vendaCancelada).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.CNPJ:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cnpj).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cnpj).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.IDOPERADORA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idOperadora).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idOperadora).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.IDBANDEIRA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idBandeira).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idBandeira).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.DTARECEBIMENTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtaRecebimento).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtaRecebimento).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.IDLOGICOTERMINAL:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idLogicoTerminal).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idLogicoTerminal).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.TIPOVENDA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.tipoVenda).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.tipoVenda).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.TAXAADMINISTRACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.taxaAdministracao).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.taxaAdministracao).AsQueryable <RedeCard>();
                }
                break;

            case CAMPOS.CODRESUMOVENDA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.codResumoVenda).AsQueryable <RedeCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.codResumoVenda).AsQueryable <RedeCard>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #16
0
        /// <summary>
        /// Get tbLogErro/tbLogErro
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <tbLogErro> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.tbLogErros.AsQueryable();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.IDLOGERRO:
                    Int32 idLogErro = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idLogErro.Equals(idLogErro)).AsQueryable <tbLogErro>();
                    break;

                case CAMPOS.DSAPLICACAO:
                    string dsAplicacao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsAplicacao.Equals(dsAplicacao)).AsQueryable <tbLogErro>();
                    break;

                case CAMPOS.DSVERSAO:
                    string dsVersao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsVersao.Equals(dsVersao)).AsQueryable <tbLogErro>();
                    break;

                case CAMPOS.DTERRO:
                    DateTime dtErro = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtErro.Equals(dtErro)).AsQueryable <tbLogErro>();
                    break;

                case CAMPOS.DSNOMECOMPUTADOR:
                    string dsNomeComputador = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsNomeComputador.Equals(dsNomeComputador)).AsQueryable <tbLogErro>();
                    break;

                case CAMPOS.DSNOMEUSUARIO:
                    string dsNomeUsuario = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsNomeUsuario.Equals(dsNomeUsuario)).AsQueryable <tbLogErro>();
                    break;

                case CAMPOS.DSVERSAOSO:
                    string dsVersaoSO = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsVersaoSO.Equals(dsVersaoSO)).AsQueryable <tbLogErro>();
                    break;

                case CAMPOS.DSCULTURA:
                    string dsCultura = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsCultura.Equals(dsCultura)).AsQueryable <tbLogErro>();
                    break;

                case CAMPOS.DSMENSAGEM:
                    string dsMensagem = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsMensagem.Equals(dsMensagem)).AsQueryable <tbLogErro>();
                    break;

                case CAMPOS.DSSTACKTRACE:
                    string dsStackTrace = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsStackTrace.Equals(dsStackTrace)).AsQueryable <tbLogErro>();
                    break;

                case CAMPOS.DSXMLENTRADA:
                    string dsXmlEntrada = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsXmlEntrada.Equals(dsXmlEntrada)).AsQueryable <tbLogErro>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.IDLOGERRO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idLogErro).AsQueryable <tbLogErro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idLogErro).AsQueryable <tbLogErro>();
                }
                break;

            case CAMPOS.DSAPLICACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsAplicacao).AsQueryable <tbLogErro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsAplicacao).AsQueryable <tbLogErro>();
                }
                break;

            case CAMPOS.DSVERSAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsVersao).AsQueryable <tbLogErro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsVersao).AsQueryable <tbLogErro>();
                }
                break;

            case CAMPOS.DTERRO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtErro).AsQueryable <tbLogErro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtErro).AsQueryable <tbLogErro>();
                }
                break;

            case CAMPOS.DSNOMECOMPUTADOR:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsNomeComputador).AsQueryable <tbLogErro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsNomeComputador).AsQueryable <tbLogErro>();
                }
                break;

            case CAMPOS.DSNOMEUSUARIO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsNomeUsuario).AsQueryable <tbLogErro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsNomeUsuario).AsQueryable <tbLogErro>();
                }
                break;

            case CAMPOS.DSVERSAOSO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsVersaoSO).AsQueryable <tbLogErro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsVersaoSO).AsQueryable <tbLogErro>();
                }
                break;

            case CAMPOS.DSCULTURA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsCultura).AsQueryable <tbLogErro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsCultura).AsQueryable <tbLogErro>();
                }
                break;

            case CAMPOS.DSMENSAGEM:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsMensagem).AsQueryable <tbLogErro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsMensagem).AsQueryable <tbLogErro>();
                }
                break;

            case CAMPOS.DSSTACKTRACE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsStackTrace).AsQueryable <tbLogErro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsStackTrace).AsQueryable <tbLogErro>();
                }
                break;

            case CAMPOS.DSXMLENTRADA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsXmlEntrada).AsQueryable <tbLogErro>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsXmlEntrada).AsQueryable <tbLogErro>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #17
0
        /// <summary>
        /// Get TbLogCargaDetalhe/TbLogCargaDetalhe
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <tbLogCargaDetalhe> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.tbLogCargaDetalhes.AsQueryable();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.IDLOGCARGADETALHE:
                    Int32 idLogCargaDetalhe = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idLogCargaDetalhe.Equals(idLogCargaDetalhe)).AsQueryable <tbLogCargaDetalhe>();
                    break;

                case CAMPOS.IDLOGCARGA:
                    Int32 idLogCarga = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idLogCarga.Equals(idLogCarga)).AsQueryable <tbLogCargaDetalhe>();
                    break;

                case CAMPOS.DTEXECUCAOINI:
                    DateTime dtExecucaoIni = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtExecucaoIni.Equals(dtExecucaoIni)).AsQueryable <tbLogCargaDetalhe>();
                    break;

                case CAMPOS.DTEXECUCAOFIM:
                    DateTime dtExecucaoFim = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtExecucaoFim.Equals(dtExecucaoFim)).AsQueryable <tbLogCargaDetalhe>();
                    break;

                case CAMPOS.FLSTATUS:
                    byte flStatus = Convert.ToByte(item.Value);
                    entity = entity.Where(e => e.flStatus.Equals(flStatus)).AsQueryable <tbLogCargaDetalhe>();
                    break;

                case CAMPOS.DSMENSAGEM:
                    string dsMensagem = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsMensagem.Equals(dsMensagem)).AsQueryable <tbLogCargaDetalhe>();
                    break;

                case CAMPOS.DSMODALIDADE:
                    string dsModalidade = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsModalidade.Equals(dsModalidade)).AsQueryable <tbLogCargaDetalhe>();
                    break;

                case CAMPOS.QTTRANSACOES:
                    Int32 qtTransacoes = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.qtTransacoes.Equals(qtTransacoes)).AsQueryable <tbLogCargaDetalhe>();
                    break;

                case CAMPOS.VLTOTALPROCESSADO:
                    decimal vlTotalProcessado = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.vlTotalProcessado.Equals(vlTotalProcessado)).AsQueryable <tbLogCargaDetalhe>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.IDLOGCARGADETALHE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idLogCargaDetalhe).AsQueryable <tbLogCargaDetalhe>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idLogCargaDetalhe).AsQueryable <tbLogCargaDetalhe>();
                }
                break;

            case CAMPOS.IDLOGCARGA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idLogCarga).AsQueryable <tbLogCargaDetalhe>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idLogCarga).AsQueryable <tbLogCargaDetalhe>();
                }
                break;

            case CAMPOS.DTEXECUCAOINI:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtExecucaoIni).AsQueryable <tbLogCargaDetalhe>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtExecucaoIni).AsQueryable <tbLogCargaDetalhe>();
                }
                break;

            case CAMPOS.DTEXECUCAOFIM:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtExecucaoFim).AsQueryable <tbLogCargaDetalhe>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtExecucaoFim).AsQueryable <tbLogCargaDetalhe>();
                }
                break;

            case CAMPOS.FLSTATUS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.flStatus).AsQueryable <tbLogCargaDetalhe>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.flStatus).AsQueryable <tbLogCargaDetalhe>();
                }
                break;

            case CAMPOS.DSMENSAGEM:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsMensagem).AsQueryable <tbLogCargaDetalhe>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsMensagem).AsQueryable <tbLogCargaDetalhe>();
                }
                break;

            case CAMPOS.DSMODALIDADE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsModalidade).AsQueryable <tbLogCargaDetalhe>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsModalidade).AsQueryable <tbLogCargaDetalhe>();
                }
                break;

            case CAMPOS.QTTRANSACOES:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.qtTransacoes).AsQueryable <tbLogCargaDetalhe>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.qtTransacoes).AsQueryable <tbLogCargaDetalhe>();
                }
                break;

            case CAMPOS.VLTOTALPROCESSADO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.vlTotalProcessado).AsQueryable <tbLogCargaDetalhe>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.vlTotalProcessado).AsQueryable <tbLogCargaDetalhe>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #18
0
        /// <summary>
        /// Get ConciliacaoRecebimento/ConciliacaoRecebimento
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <ConciliacaoRecebimento> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.ConciliacaoRecebimentoes.AsQueryable <ConciliacaoRecebimento>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.ID:
                    Int32 id = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id.Equals(id)).AsQueryable <ConciliacaoRecebimento>();
                    break;

                case CAMPOS.ID_USERS:
                    Int32 id_users = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id_users.Equals(id_users)).AsQueryable <ConciliacaoRecebimento>();
                    break;

                case CAMPOS.IDGRUPO:
                    Int32 idGrupo = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idGrupo.Equals(idGrupo)).AsQueryable <ConciliacaoRecebimento>();
                    break;

                case CAMPOS.MES:
                    byte mes = Convert.ToByte(item.Value);
                    entity = entity.Where(e => e.mes.Equals(mes)).AsQueryable <ConciliacaoRecebimento>();
                    break;

                case CAMPOS.ANO:
                    Int32 ano = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.ano.Equals(ano)).AsQueryable <ConciliacaoRecebimento>();
                    break;

                case CAMPOS.DATA:
                    DateTime data = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.data.Equals(data)).AsQueryable <ConciliacaoRecebimento>();
                    break;

                case CAMPOS.QUANTIDADE:
                    Int32 quantidade = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.quantidade.Equals(quantidade)).AsQueryable <ConciliacaoRecebimento>();
                    break;

                case CAMPOS.VALOR:
                    decimal valor = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valor.Equals(valor)).AsQueryable <ConciliacaoRecebimento>();
                    break;

                case CAMPOS.OBSERVACAO:
                    string observacao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.observacao.Equals(observacao)).AsQueryable <ConciliacaoRecebimento>();
                    break;

                case CAMPOS.STATUS:
                    byte status = Convert.ToByte(item.Value);
                    entity = entity.Where(e => e.status.Equals(status)).AsQueryable <ConciliacaoRecebimento>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.ID:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id).AsQueryable <ConciliacaoRecebimento>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id).AsQueryable <ConciliacaoRecebimento>();
                }
                break;

            case CAMPOS.ID_USERS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id_users).AsQueryable <ConciliacaoRecebimento>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id_users).AsQueryable <ConciliacaoRecebimento>();
                }
                break;

            case CAMPOS.IDGRUPO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idGrupo).AsQueryable <ConciliacaoRecebimento>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idGrupo).AsQueryable <ConciliacaoRecebimento>();
                }
                break;

            case CAMPOS.MES:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.mes).AsQueryable <ConciliacaoRecebimento>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.mes).AsQueryable <ConciliacaoRecebimento>();
                }
                break;

            case CAMPOS.ANO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.ano).AsQueryable <ConciliacaoRecebimento>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.ano).AsQueryable <ConciliacaoRecebimento>();
                }
                break;

            case CAMPOS.DATA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.data).AsQueryable <ConciliacaoRecebimento>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.data).AsQueryable <ConciliacaoRecebimento>();
                }
                break;

            case CAMPOS.QUANTIDADE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.quantidade).AsQueryable <ConciliacaoRecebimento>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.quantidade).AsQueryable <ConciliacaoRecebimento>();
                }
                break;

            case CAMPOS.VALOR:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valor).AsQueryable <ConciliacaoRecebimento>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valor).AsQueryable <ConciliacaoRecebimento>();
                }
                break;

            case CAMPOS.OBSERVACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.observacao).AsQueryable <ConciliacaoRecebimento>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.observacao).AsQueryable <ConciliacaoRecebimento>();
                }
                break;

            case CAMPOS.STATUS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.status).AsQueryable <ConciliacaoRecebimento>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.status).AsQueryable <ConciliacaoRecebimento>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #19
0
        /// <summary>
        /// Get TbAdquirente/TbAdquirente
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <tbAdquirente> getQuery(painel_taxservices_dbContext _db, int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.tbAdquirentes.AsQueryable <tbAdquirente>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.CDADQUIRENTE:
                    Int32 cdAdquirente = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.cdAdquirente.Equals(cdAdquirente)).AsQueryable <tbAdquirente>();
                    break;

                case CAMPOS.NMADQUIRENTE:
                    string nmAdquirente = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nmAdquirente.Equals(nmAdquirente)).AsQueryable <tbAdquirente>();
                    break;

                case CAMPOS.DSADQUIRENTE:
                    string dsAdquirente = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsAdquirente.Equals(dsAdquirente)).AsQueryable <tbAdquirente>();
                    break;

                case CAMPOS.STADQUIRENTE:
                    byte stAdquirente = Convert.ToByte(item.Value);
                    entity = entity.Where(e => e.stAdquirente.Equals(stAdquirente)).AsQueryable <tbAdquirente>();
                    break;

                case CAMPOS.HREXECUCAO:
                    DateTime hrExecucao = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.hrExecucao.Equals(hrExecucao)).AsQueryable <tbAdquirente>();
                    break;

                // Relacionamento
                case CAMPOS.CNPJ:
                    string        cnpj         = Convert.ToString(item.Value);
                    List <string> nmOperadoras = _db.Operadoras.Where(o => o.LoginOperadoras.Where(l => l.cnpj.Equals(cnpj)).Count() > 0).Select(o => o.nmOperadora).ToList <string>();
                    entity = entity.Where(e => nmOperadoras.Contains(e.nmAdquirente)).AsQueryable <tbAdquirente>();
                    break;

                case CAMPOS.ID_GRUPO:
                    int           id_grupo      = Convert.ToInt32(item.Value);
                    List <string> nmOperadorasG = _db.Operadoras.Where(o => o.LoginOperadoras.Where(l => l.empresa.id_grupo == id_grupo).Count() > 0).Select(o => o.nmOperadora).ToList <string>();
                    entity = entity.Where(e => nmOperadorasG.Contains(e.nmAdquirente)).AsQueryable <tbAdquirente>();
                    break;

                case CAMPOS.DATA:
                    /*
                     * if (item.Value.Contains("|")) // BETWEEN
                     * {
                     *  string[] busca = item.Value.Split('|');
                     *  DateTime dtaIni = DateTime.ParseExact(busca[0] + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                     *  DateTime dtaFim = DateTime.ParseExact(busca[1] + " 23:59:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                     *
                     * }
                     * else if (item.Value.Contains(">")) // MAIOR IGUAL
                     * {
                     *  string busca = item.Value.Replace(">", "");
                     *  DateTime dta = DateTime.ParseExact(busca + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                     *  entity = entity.Where(e => e.dtaRecebimento >= dta && e.dtaRecebimentoEfetivo == null);
                     * }
                     * else if (item.Value.Contains("<")) // MENOR IGUAL
                     * {
                     *  string busca = item.Value.Replace("<", "");
                     *  DateTime dta = DateTime.ParseExact(busca + " 23:59:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                     *  entity = entity.Where(e => e.dtaRecebimento <= dta);
                     * }
                     * else if (item.Value.Length == 4)
                     * {
                     *  string busca = item.Value + "0101";
                     *  DateTime dtaIni = DateTime.ParseExact(busca + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                     *  entity = entity.Where(e => e.dtaRecebimento.Year == dtaIni.Year);
                     * }
                     * else if (item.Value.Length == 6)
                     * {
                     *  string busca = item.Value + "01";
                     *  DateTime dtaIni = DateTime.ParseExact(busca + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                     *  entity = entity.Where(e => e.dtaRecebimento.Year == dtaIni.Year && e.dtaRecebimento.Month == dtaIni.Month);
                     * }
                     * else // IGUAL
                     * {
                     *  string busca = item.Value;
                     *  DateTime dtaIni = DateTime.ParseExact(busca + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                     *  entity = entity.Where(e => e.dtaRecebimento.Year == dtaIni.Year && e.dtaRecebimento.Month == dtaIni.Month && e.dtaRecebimento.Day == dtaIni.Day);
                     * }
                     */
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.CDADQUIRENTE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdAdquirente).AsQueryable <tbAdquirente>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdAdquirente).AsQueryable <tbAdquirente>();
                }
                break;

            case CAMPOS.NMADQUIRENTE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nmAdquirente).AsQueryable <tbAdquirente>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nmAdquirente).AsQueryable <tbAdquirente>();
                }
                break;

            case CAMPOS.DSADQUIRENTE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsAdquirente).AsQueryable <tbAdquirente>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsAdquirente).AsQueryable <tbAdquirente>();
                }
                break;

            case CAMPOS.STADQUIRENTE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.stAdquirente).AsQueryable <tbAdquirente>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.stAdquirente).AsQueryable <tbAdquirente>();
                }
                break;

            case CAMPOS.HREXECUCAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.hrExecucao).AsQueryable <tbAdquirente>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.hrExecucao).AsQueryable <tbAdquirente>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #20
0
        /// <summary>
        /// Get TbContaCorrente/TbContaCorrente
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <tbContaCorrente> getQuery(painel_taxservices_dbContext _db, int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.tbContaCorrentes.AsQueryable <tbContaCorrente>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.CDCONTACORRENTE:
                    Int32 cdContaCorrente = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.cdContaCorrente == cdContaCorrente).AsQueryable <tbContaCorrente>();
                    break;

                case CAMPOS.CDGRUPO:
                    Int32 cdGrupo = Convert.ToInt32(item.Value);
                    //entity = entity.Where(e => e.cdGrupo == cdGrupo).AsQueryable<tbContaCorrente>();
                    entity = entity.Where(e => e.empresa.id_grupo == cdGrupo).AsQueryable <tbContaCorrente>();
                    break;

                case CAMPOS.NRCNPJ:
                    string nrCnpj = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nrCnpj.Equals(nrCnpj)).AsQueryable <tbContaCorrente>();
                    break;

                case CAMPOS.CDBANCO:
                    string cdBanco = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cdBanco.Equals(cdBanco)).AsQueryable <tbContaCorrente>();
                    break;

                case CAMPOS.NRAGENCIA:
                    string nrAgencia = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nrAgencia.Equals(nrAgencia)).AsQueryable <tbContaCorrente>();
                    break;

                case CAMPOS.NRCONTA:
                    string nrConta = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nrConta.Equals(nrConta)).AsQueryable <tbContaCorrente>();
                    break;

                case CAMPOS.FLATIVO:
                    Boolean fl_cardservices = Convert.ToBoolean(item.Value);
                    entity = entity.Where(e => e.flAtivo.Equals(fl_cardservices)).AsQueryable <tbContaCorrente>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.CDCONTACORRENTE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdContaCorrente).AsQueryable <tbContaCorrente>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdContaCorrente).AsQueryable <tbContaCorrente>();
                }
                break;

            case CAMPOS.CDGRUPO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdGrupo).ThenBy(e => e.nrAgencia).ThenBy(e => e.nrConta).ThenBy(e => e.nrCnpj).AsQueryable <tbContaCorrente>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdGrupo).ThenByDescending(e => e.nrAgencia).ThenByDescending(e => e.nrConta).ThenByDescending(e => e.nrCnpj).AsQueryable <tbContaCorrente>();
                }
                break;

            case CAMPOS.NRCNPJ:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nrCnpj).AsQueryable <tbContaCorrente>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nrCnpj).AsQueryable <tbContaCorrente>();
                }
                break;

            case CAMPOS.CDBANCO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdBanco).AsQueryable <tbContaCorrente>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdBanco).AsQueryable <tbContaCorrente>();
                }
                break;

            case CAMPOS.NRAGENCIA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nrAgencia).AsQueryable <tbContaCorrente>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nrAgencia).AsQueryable <tbContaCorrente>();
                }
                break;

            case CAMPOS.NRCONTA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nrConta).AsQueryable <tbContaCorrente>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nrConta).AsQueryable <tbContaCorrente>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #21
0
        /// <summary>
        /// Get BaneseCard/BaneseCard
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <BaneseCard> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.BaneseCards.AsQueryable <BaneseCard>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.ID:
                    Int32 id = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id.Equals(id)).AsQueryable <BaneseCard>();
                    break;

                case CAMPOS.OPERACAO:
                    string operacao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.operacao.Equals(operacao)).AsQueryable <BaneseCard>();
                    break;

                case CAMPOS.DTAVENDA:
                    DateTime dtaVenda = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtaVenda.Equals(dtaVenda)).AsQueryable <BaneseCard>();
                    break;

                case CAMPOS.NSU:
                    string nsu = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nsu.Equals(nsu)).AsQueryable <BaneseCard>();
                    break;

                case CAMPOS.MODALIDADE:
                    string modalidade = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.modalidade.Equals(modalidade)).AsQueryable <BaneseCard>();
                    break;

                case CAMPOS.TOTALPARCELAS:
                    Int32 totalParcelas = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.totalParcelas.Equals(totalParcelas)).AsQueryable <BaneseCard>();
                    break;

                case CAMPOS.VALORBRUTO:
                    decimal valorBruto = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valorBruto.Equals(valorBruto)).AsQueryable <BaneseCard>();
                    break;

                case CAMPOS.VALORLIQUIDO:
                    decimal valorLiquido = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valorLiquido.Equals(valorLiquido)).AsQueryable <BaneseCard>();
                    break;

                case CAMPOS.CNPJ:
                    string cnpj = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cnpj.Equals(cnpj)).AsQueryable <BaneseCard>();
                    break;

                case CAMPOS.IDOPERADORA:
                    Int32 idOperadora = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idOperadora.Equals(idOperadora)).AsQueryable <BaneseCard>();
                    break;

                case CAMPOS.IDBANDEIRA:
                    Int32 idBandeira = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idBandeira.Equals(idBandeira)).AsQueryable <BaneseCard>();
                    break;

                case CAMPOS.DTARECEBIMENTO:
                    DateTime dtaRecebimento = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtaRecebimento.Equals(dtaRecebimento)).AsQueryable <BaneseCard>();
                    break;

                case CAMPOS.IDTERMINALLOGICO:
                    Int32 idTerminalLogico = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idTerminalLogico.Equals(idTerminalLogico)).AsQueryable <BaneseCard>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.ID:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id).AsQueryable <BaneseCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id).AsQueryable <BaneseCard>();
                }
                break;

            case CAMPOS.OPERACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.operacao).AsQueryable <BaneseCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.operacao).AsQueryable <BaneseCard>();
                }
                break;

            case CAMPOS.DTAVENDA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtaVenda).AsQueryable <BaneseCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtaVenda).AsQueryable <BaneseCard>();
                }
                break;

            case CAMPOS.NSU:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nsu).AsQueryable <BaneseCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nsu).AsQueryable <BaneseCard>();
                }
                break;

            case CAMPOS.MODALIDADE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.modalidade).AsQueryable <BaneseCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.modalidade).AsQueryable <BaneseCard>();
                }
                break;

            case CAMPOS.TOTALPARCELAS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.totalParcelas).AsQueryable <BaneseCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.totalParcelas).AsQueryable <BaneseCard>();
                }
                break;

            case CAMPOS.VALORBRUTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valorBruto).AsQueryable <BaneseCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valorBruto).AsQueryable <BaneseCard>();
                }
                break;

            case CAMPOS.VALORLIQUIDO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valorLiquido).AsQueryable <BaneseCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valorLiquido).AsQueryable <BaneseCard>();
                }
                break;

            case CAMPOS.CNPJ:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cnpj).AsQueryable <BaneseCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cnpj).AsQueryable <BaneseCard>();
                }
                break;

            case CAMPOS.IDOPERADORA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idOperadora).AsQueryable <BaneseCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idOperadora).AsQueryable <BaneseCard>();
                }
                break;

            case CAMPOS.IDBANDEIRA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idBandeira).AsQueryable <BaneseCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idBandeira).AsQueryable <BaneseCard>();
                }
                break;

            case CAMPOS.DTARECEBIMENTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtaRecebimento).AsQueryable <BaneseCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtaRecebimento).AsQueryable <BaneseCard>();
                }
                break;

            case CAMPOS.IDTERMINALLOGICO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idTerminalLogico).AsQueryable <BaneseCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idTerminalLogico).AsQueryable <BaneseCard>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #22
0
        /// <summary>
        /// Get GoodCard/GoodCard
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <GoodCard> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.GoodCards.AsQueryable <GoodCard>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.ID:
                    Int32 id = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id.Equals(id)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.LANCAMENTO:
                    string lancamento = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.lancamento.Equals(lancamento)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.DTAHORA:
                    DateTime dtaHora = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtaHora.Equals(dtaHora)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.QTDTOTALPARCELAS:
                    Int32 qtdTotalParcelas = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.qtdTotalParcelas.Equals(qtdTotalParcelas)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.LOTE:
                    string lote = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.lote.Equals(lote)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.CNPJ:
                    string cnpj = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cnpj.Equals(cnpj)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.NUMCARTAO:
                    string numCartao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.numCartao.Equals(numCartao)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.REDECAPTURA:
                    string redeCaptura = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.redeCaptura.Equals(redeCaptura)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.VALORTRANSACAO:
                    decimal valorTransacao = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valorTransacao.Equals(valorTransacao)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.VALORREEMBOLSO:
                    decimal valorReembolso = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valorReembolso.Equals(valorReembolso)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.VALORDESCONTADO:
                    decimal valorDescontado = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valorDescontado.Equals(valorDescontado)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.DTARECEBIMENTO:
                    DateTime dtaRecebimento = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtaRecebimento.Equals(dtaRecebimento)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.IDOPERADORA:
                    Int32 idOperadora = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idOperadora.Equals(idOperadora)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.IDBANDEIRA:
                    Int32 idBandeira = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idBandeira.Equals(idBandeira)).AsQueryable <GoodCard>();
                    break;

                case CAMPOS.IDTERMINALLOGICO:
                    Int32 idTerminalLogico = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idTerminalLogico.Equals(idTerminalLogico)).AsQueryable <GoodCard>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.ID:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.LANCAMENTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.lancamento).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.lancamento).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.DTAHORA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtaHora).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtaHora).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.QTDTOTALPARCELAS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.qtdTotalParcelas).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.qtdTotalParcelas).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.LOTE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.lote).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.lote).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.CNPJ:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cnpj).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cnpj).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.NUMCARTAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.numCartao).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.numCartao).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.REDECAPTURA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.redeCaptura).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.redeCaptura).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.VALORTRANSACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valorTransacao).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valorTransacao).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.VALORREEMBOLSO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valorReembolso).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valorReembolso).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.VALORDESCONTADO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valorDescontado).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valorDescontado).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.DTARECEBIMENTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtaRecebimento).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtaRecebimento).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.IDOPERADORA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idOperadora).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idOperadora).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.IDBANDEIRA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idBandeira).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idBandeira).AsQueryable <GoodCard>();
                }
                break;

            case CAMPOS.IDTERMINALLOGICO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idTerminalLogico).AsQueryable <GoodCard>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idTerminalLogico).AsQueryable <GoodCard>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #23
0
        /// <summary>
        /// Get TbRecebimentoVenda/TbRecebimentoVenda
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        public static SimpleDataBaseQuery getQuery(int campo, int orderby, Dictionary <string, string> queryString)
        {
            Dictionary <string, string> join = new Dictionary <string, string>();

            List <string> where = new List <string>();
            List <string> order = new List <string>();

            #region WHERE - ADICIONA OS FILTROS A QUERY
            // ADICIONA OS FILTROS A QUERY
            foreach (KeyValuePair <string, string> item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.IDRECEBIMENTOVENDA:
                    Int32 idRecebimentoVenda = Convert.ToInt32(item.Value);
                    where.Add(SIGLA_QUERY + ".idRecebimentoVenda = " + idRecebimentoVenda);
                    break;

                case CAMPOS.NRCNPJ:
                    string nrCNPJ = Convert.ToString(item.Value);
                    where.Add(SIGLA_QUERY + ".nrCNPJ = '" + nrCNPJ + "'");
                    break;

                case CAMPOS.NRNSU:
                    string nrNSU = Convert.ToString(item.Value);
                    if (nrNSU.Contains("%"))     // usa LIKE => ENDS WITH
                    {
                        string busca = nrNSU.Replace("%", "").ToString();
                        where.Add(SIGLA_QUERY + ".nrNSU like '%" + busca + "'");
                    }
                    else
                    {
                        where.Add(SIGLA_QUERY + ".nrNSU = '" + nrNSU + "'");
                    }
                    break;

                case CAMPOS.DTVENDA:
                    if (item.Value.Contains("|"))     // BETWEEN
                    {
                        string[] busca    = item.Value.Split('|');
                        DateTime dtaIni   = DateTime.ParseExact(busca[0] + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        DateTime dtaFim   = DateTime.ParseExact(busca[1] + " 23:59:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        string   dtInicio = DataBaseQueries.GetDate(dtaIni);
                        string   dtFim    = DataBaseQueries.GetDate(dtaFim);
                        where.Add(SIGLA_QUERY + ".dtVenda BETWEEN '" + dtInicio + "' AND '" + dtFim + " 23:59:00'");
                    }
                    else     // IGUAL
                    {
                        string   busca = item.Value;
                        DateTime data  = DateTime.ParseExact(busca + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        string   dt    = DataBaseQueries.GetDate(data);
                        where.Add(SIGLA_QUERY + ".dtVenda BETWEEN '" + dt + "' AND '" + dt + " 23:59:00'");
                    }
                    break;

                case CAMPOS.CDADQUIRENTE:
                    Int32 cdAdquirente = Convert.ToInt32(item.Value);
                    where.Add(SIGLA_QUERY + ".cdAdquirente = " + cdAdquirente);
                    break;

                case CAMPOS.DSBANDEIRA:
                    string dsBandeira = Convert.ToString(item.Value);
                    where.Add(SIGLA_QUERY + ".dsBandeira = '" + dsBandeira + "'");
                    break;

                case CAMPOS.VLVENDA:
                    decimal vlVenda = Convert.ToDecimal(item.Value);
                    where.Add(SIGLA_QUERY + ".vlVenda = " + vlVenda.ToString(CultureInfo.GetCultureInfo("en-GB")));
                    break;

                case CAMPOS.QTPARCELAS:
                    byte qtParcelas = Convert.ToByte(item.Value);
                    where.Add(SIGLA_QUERY + ".qtParcelas = " + qtParcelas);
                    break;

                case CAMPOS.CDERP:
                    string cdERP = Convert.ToString(item.Value);
                    where.Add(SIGLA_QUERY + ".cdERP = '" + cdERP + "'");
                    break;

                case CAMPOS.CDSACADO:
                    string cdSacado = Convert.ToString(item.Value);
                    where.Add(SIGLA_QUERY + ".cdSacado = '" + cdSacado + "'");
                    break;

                case CAMPOS.DTAJUSTE:
                    if (item.Value.Contains("|"))     // BETWEEN
                    {
                        string[] busca    = item.Value.Split('|');
                        DateTime dtaIni   = DateTime.ParseExact(busca[0] + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        DateTime dtaFim   = DateTime.ParseExact(busca[1] + " 23:59:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        string   dtInicio = DataBaseQueries.GetDate(dtaIni);
                        string   dtFim    = DataBaseQueries.GetDate(dtaFim);
                        where.Add(SIGLA_QUERY + ".dtAjuste BETWEEN '" + dtInicio + "' AND '" + dtFim + " 23:59:00'");
                    }
                    else     // IGUAL
                    {
                        string   busca = item.Value;
                        DateTime data  = DateTime.ParseExact(busca + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        string   dt    = DataBaseQueries.GetDate(data);
                        where.Add(SIGLA_QUERY + ".dtAjuste BETWEEN '" + dt + "' AND '" + dt + " 23:59:00'");
                    }
                    break;

                case CAMPOS.DSMENSAGEM:
                    string dsMensagem = Convert.ToString(item.Value);
                    where.Add(SIGLA_QUERY + ".dsMensagem = '" + dsMensagem + "'");
                    break;

                case CAMPOS.DSDETALHE:
                    string dsDetalhe = Convert.ToString(item.Value);
                    where.Add(SIGLA_QUERY + ".dsDetalhe = '" + dsDetalhe + "'");
                    break;

                // RELACIONAMENTOS
                case CAMPOS.ID_GRUPO:
                    Int32 id_grupo = Convert.ToInt32(item.Value);
                    // JOIN
                    if (!join.ContainsKey("INNER JOIN cliente.empresa " + GatewayEmpresa.SIGLA_QUERY))
                    {
                        join.Add("INNER JOIN cliente.empresa " + GatewayEmpresa.SIGLA_QUERY, " ON " + SIGLA_QUERY + ".nrCNPJ = " + GatewayEmpresa.SIGLA_QUERY + ".nu_cnpj");
                    }
                    where.Add(GatewayEmpresa.SIGLA_QUERY + ".id_grupo = " + id_grupo);
                    break;
                }
            }
            #endregion

            string outValue = null;
            if (queryString.TryGetValue("" + (int)CAMPOS.TIPO, out outValue))
            {
                string      script = String.Empty;
                TIPO_FILTRO tipo   = (TIPO_FILTRO)Convert.ToInt32(queryString["" + (int)CAMPOS.TIPO]);
                switch (tipo)
                {
                case TIPO_FILTRO.CONCILIADO:
                    // Adiciona o join
                    if (!join.ContainsKey("LEFT JOIN pos.Recebimento " + GatewayRecebimento.SIGLA_QUERY))
                    {
                        join.Add("LEFT JOIN pos.Recebimento " + GatewayRecebimento.SIGLA_QUERY, " ON " + GatewayRecebimento.SIGLA_QUERY + ".idRecebimentoVenda = " + SIGLA_QUERY + ".idRecebimentoVenda");
                    }
                    where.Add(GatewayRecebimento.SIGLA_QUERY + ".idRecebimentoVenda IS NOT NULL");
                    break;

                case TIPO_FILTRO.NAO_CONCILIADO:
                    // Adiciona o join
                    if (!join.ContainsKey("LEFT JOIN pos.Recebimento " + GatewayRecebimento.SIGLA_QUERY))
                    {
                        join.Add("LEFT JOIN pos.Recebimento " + GatewayRecebimento.SIGLA_QUERY, " ON " + GatewayRecebimento.SIGLA_QUERY + ".idRecebimentoVenda = " + SIGLA_QUERY + ".idRecebimentoVenda");
                    }
                    where.Add(GatewayRecebimento.SIGLA_QUERY + ".idRecebimentoVenda IS NULL");
                    break;

                case TIPO_FILTRO.CORRIGIDO:
                    where.Add(SIGLA_QUERY + ".dtAjuste IS NOT NULL");
                    break;

                case TIPO_FILTRO.CORRECAO_MANUAL:
                    where.Add(SIGLA_QUERY + ".dtAjuste IS NOT NULL && " + SIGLA_QUERY + ".dsMensagem IS NOT NULL");
                    break;
                }
            }

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.IDRECEBIMENTOVENDA:
                if (orderby == 0)
                {
                    order.Add(SIGLA_QUERY + ".idRecebimentoVenda ASC");
                }
                else
                {
                    order.Add(SIGLA_QUERY + ".idRecebimentoVenda DESC");
                }
                break;

            case CAMPOS.NRCNPJ:
                if (orderby == 0)
                {
                    order.Add(SIGLA_QUERY + ".nrCNPJ ASC");
                }
                else
                {
                    order.Add(SIGLA_QUERY + ".nrCNPJ DESC");
                }
                break;

            case CAMPOS.NRNSU:
                if (orderby == 0)
                {
                    order.Add(SIGLA_QUERY + ".nrNSU ASC");
                }
                else
                {
                    order.Add(SIGLA_QUERY + ".nrNSU DESC");
                }
                break;

            case CAMPOS.DTVENDA:
                if (orderby == 0)
                {
                    order.Add(SIGLA_QUERY + ".dtVenda ASC");
                }
                else
                {
                    order.Add(SIGLA_QUERY + ".dtVenda DESC");
                }
                break;

            case CAMPOS.CDADQUIRENTE:
                if (orderby == 0)
                {
                    order.Add(SIGLA_QUERY + ".cdAdquirente ASC");
                }
                else
                {
                    order.Add(SIGLA_QUERY + ".cdAdquirente DESC");
                }
                break;

            case CAMPOS.DSBANDEIRA:
                if (orderby == 0)
                {
                    order.Add(SIGLA_QUERY + ".dsBandeira ASC");
                }
                else
                {
                    order.Add(SIGLA_QUERY + ".dsBandeira DESC");
                }
                break;

            case CAMPOS.VLVENDA:
                if (orderby == 0)
                {
                    order.Add(SIGLA_QUERY + ".vlVenda ASC");
                }
                else
                {
                    order.Add(SIGLA_QUERY + ".vlVenda DESC");
                }
                break;

            case CAMPOS.QTPARCELAS:
                if (orderby == 0)
                {
                    order.Add(SIGLA_QUERY + ".qtParcelas ASC");
                }
                else
                {
                    order.Add(SIGLA_QUERY + ".qtParcelas DESC");
                }
                break;

            case CAMPOS.CDERP:
                if (orderby == 0)
                {
                    order.Add(SIGLA_QUERY + ".cdERP ASC");
                }
                else
                {
                    order.Add(SIGLA_QUERY + ".cdERP DESC");
                }
                break;

            case CAMPOS.CDSACADO:
                if (orderby == 0)
                {
                    order.Add(SIGLA_QUERY + ".cdSacado ASC");
                }
                else
                {
                    order.Add(SIGLA_QUERY + ".cdSacado DESC");
                }
                break;

            case CAMPOS.DTAJUSTE:
                if (orderby == 0)
                {
                    order.Add(SIGLA_QUERY + ".dtAjuste ASC");
                }
                else
                {
                    order.Add(SIGLA_QUERY + ".dtAjuste DESC");
                }
                break;

            case CAMPOS.DSMENSAGEM:
                if (orderby == 0)
                {
                    order.Add(SIGLA_QUERY + ".dsMensagem ASC");
                }
                else
                {
                    order.Add(SIGLA_QUERY + ".dsMensagem DESC");
                }
                break;
            }
            #endregion

            return(new SimpleDataBaseQuery(null, "card.tbRecebimentoVenda " + SIGLA_QUERY,
                                           join, where.ToArray(), null, order.ToArray()));
        }
예제 #24
0
        /// <summary>
        /// Get TerminalLogico/TerminalLogico
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <TerminalLogico> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.TerminalLogicoes.AsQueryable <TerminalLogico>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.IDTERMINALLOGICO:
                    Int32 idTerminalLogico = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idTerminalLogico.Equals(idTerminalLogico)).AsQueryable <TerminalLogico>();
                    break;

                case CAMPOS.DSTERMINALLOGICO:
                    string dsTerminalLogico = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsTerminalLogico.Equals(dsTerminalLogico)).AsQueryable <TerminalLogico>();
                    break;

                case CAMPOS.IDOPERADORA:
                    Int32 idOperadora = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idOperadora.Equals(idOperadora)).AsQueryable <TerminalLogico>();
                    break;

                // RELACIONAMENTOS
                case CAMPOS.CDADQUIRENTE:     // Não vem a correta!
                    //    string outValue = null;
                    //    // tem que estar associado a um grupo empresa
                    //    if (!queryString.TryGetValue("" + (int)CAMPOS.IDGRUPOEMPRESA, out outValue)) continue;
                    //    Int32 idGrupoEmpresa = Convert.ToInt32(queryString["" + (int)CAMPOS.IDGRUPOEMPRESA]);
                    //    Int32 cdAdquirente = Convert.ToInt32(item.Value);
                    //    tbAdquirente tbAdquirente = _db.tbAdquirentes.Where(a => a.cdAdquirente == cdAdquirente).FirstOrDefault();
                    //    if (tbAdquirente == null) continue;
                    //    Operadora operadora = _db.Operadoras.Where(o => o.idGrupoEmpresa == idGrupoEmpresa)
                    //                                        .Where(o => o.nmOperadora.Equals(tbAdquirente.nmAdquirente))
                    //                                        .FirstOrDefault();
                    //    if (operadora == null) continue;
                    //    entity = entity.Where(e => e.idOperadora == operadora.id).AsQueryable<TerminalLogico>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.IDTERMINALLOGICO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idTerminalLogico).AsQueryable <TerminalLogico>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idTerminalLogico).AsQueryable <TerminalLogico>();
                }
                break;

            case CAMPOS.DSTERMINALLOGICO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsTerminalLogico).AsQueryable <TerminalLogico>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsTerminalLogico).AsQueryable <TerminalLogico>();
                }
                break;

            case CAMPOS.IDOPERADORA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idOperadora).AsQueryable <TerminalLogico>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idOperadora).AsQueryable <TerminalLogico>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #25
0
        /// <summary>
        /// Get GetNetSantander/GetNetSantander
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <GetNetSantander> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.GetNetSantanders.AsQueryable <GetNetSantander>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.ID:
                    Int32 id = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id.Equals(id)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.BANDEIRA:
                    string bandeira = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.bandeira.Equals(bandeira)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.PRODUTO:
                    string produto = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.produto.Equals(produto)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.DESCRICAOTRANSACAO:
                    string descricaoTransacao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.descricaoTransacao.Equals(descricaoTransacao)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.DTATRANSACAO:
                    DateTime dtaTransacao = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtaTransacao.Equals(dtaTransacao)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.HRATRANSACAO:
                    DateTime hraTransacao = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.hraTransacao.Equals(hraTransacao)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.DTAHRATRANSACAO:
                    DateTime dtahraTransacao = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtahraTransacao.Equals(dtahraTransacao)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.NUMCARTAO:
                    string numCartao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.numCartao.Equals(numCartao)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.NUMCV:
                    string numCv = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.numCv.Equals(numCv)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.NUMAUTORIZACAO:
                    string numAutorizacao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.numAutorizacao.Equals(numAutorizacao)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.VALORTOTALTRANSACAO:
                    decimal valorTotalTransacao = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valorTotalTransacao.Equals(valorTotalTransacao)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.TOTALPARCELAS:
                    Int32 totalParcelas = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.totalParcelas.Equals(totalParcelas)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.CNPJ:
                    string cnpj = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cnpj.Equals(cnpj)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.IDOPERADORA:
                    Int32 idOperadora = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idOperadora.Equals(idOperadora)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.IDBANDEIRA:
                    Int32 idBandeira = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idBandeira.Equals(idBandeira)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.DTARECEBIMENTO:
                    DateTime dtaRecebimento = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtaRecebimento.Equals(dtaRecebimento)).AsQueryable <GetNetSantander>();
                    break;

                case CAMPOS.IDTERMINALLOGICO:
                    Int32 idTerminalLogico = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idTerminalLogico.Equals(idTerminalLogico)).AsQueryable <GetNetSantander>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.ID:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.BANDEIRA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.bandeira).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.bandeira).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.PRODUTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.produto).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.produto).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.DESCRICAOTRANSACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.descricaoTransacao).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.descricaoTransacao).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.DTATRANSACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtaTransacao).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtaTransacao).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.HRATRANSACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.hraTransacao).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.hraTransacao).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.DTAHRATRANSACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtahraTransacao).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtahraTransacao).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.NUMCARTAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.numCartao).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.numCartao).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.NUMCV:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.numCv).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.numCv).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.NUMAUTORIZACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.numAutorizacao).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.numAutorizacao).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.VALORTOTALTRANSACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valorTotalTransacao).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valorTotalTransacao).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.TOTALPARCELAS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.totalParcelas).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.totalParcelas).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.CNPJ:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cnpj).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cnpj).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.IDOPERADORA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idOperadora).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idOperadora).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.IDBANDEIRA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idBandeira).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idBandeira).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.DTARECEBIMENTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtaRecebimento).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtaRecebimento).AsQueryable <GetNetSantander>();
                }
                break;

            case CAMPOS.IDTERMINALLOGICO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idTerminalLogico).AsQueryable <GetNetSantander>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idTerminalLogico).AsQueryable <GetNetSantander>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #26
0
        /// <summary>
        /// Get TbRecebimentoTEF/TbRecebimentoTEF
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <tbRecebimentoTEF> getQuery(painel_taxservices_dbContext _db, int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.tbRecebimentoTEFs.AsQueryable <tbRecebimentoTEF>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.IDRECEBIMENTOTEF:
                    Int32 idRecebimentoTEF = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idRecebimentoTEF.Equals(idRecebimentoTEF)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.CDGRUPO:
                    Int32 cdGrupo = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.cdGrupo.Equals(cdGrupo)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.NRCNPJ:
                    string nrCNPJ = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nrCNPJ.Equals(nrCNPJ)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.CDEMPRESATEF:
                    string cdEmpresaTEF = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cdEmpresaTEF.Equals(cdEmpresaTEF)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.NRPDVTEF:
                    string nrPDVTEF = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nrPDVTEF.Equals(nrPDVTEF)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.NRNSUHOST:
                    string nrNSUHost = Convert.ToString(item.Value);
                    if (nrNSUHost.Contains("%"))     // usa LIKE => ENDS WITH
                    {
                        string busca = nrNSUHost.Replace("%", "").ToString();
                        entity = entity.Where(e => e.nrNSUHost.EndsWith(busca)).AsQueryable <tbRecebimentoTEF>();
                    }
                    else
                    {
                        entity = entity.Where(e => e.nrNSUHost.Equals(nrNSUHost)).AsQueryable <tbRecebimentoTEF>();
                    }
                    break;

                case CAMPOS.NRNSUTEF:
                    string nrNSUTEF = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nrNSUTEF.Equals(nrNSUTEF)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.CDAUTORIZACAO:
                    string cdAutorizacao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cdAutorizacao.Equals(cdAutorizacao)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.CDSITUACAOREDETEF:
                    Int32 cdSituacaoRedeTEF = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.cdSituacaoRedeTEF.Equals(cdSituacaoRedeTEF)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.DTVENDA:
                    //DateTime dtVenda = Convert.ToDateTime(item.Value);
                    //DateTime dtVenda = Convert.ToDateTime(item.Value);
                    //entity = entity.Where(e => e.dtVenda.Equals(dtVenda)).AsQueryable();
                    //break;

                    if (item.Value.Contains("|"))     // BETWEEN
                    {
                        string[] busca  = item.Value.Split('|');
                        DateTime dtaIni = DateTime.ParseExact(busca[0] + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        DateTime dtaFim = DateTime.ParseExact(busca[1] + " 23:59:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        //entity = entity.Where(e => e.dtVenda >= dtaIni && e.dtVenda <= dtaFim);
                        entity = entity.Where(e => (e.dtVenda.Year > dtaIni.Year || (e.dtVenda.Year == dtaIni.Year && e.dtVenda.Month > dtaIni.Month) ||
                                                    (e.dtVenda.Year == dtaIni.Year && e.dtVenda.Month == dtaIni.Month && e.dtVenda.Day >= dtaIni.Day)) &&
                                              (e.dtVenda.Year < dtaFim.Year || (e.dtVenda.Year == dtaFim.Year && e.dtVenda.Month < dtaFim.Month) ||
                                               (e.dtVenda.Year == dtaFim.Year && e.dtVenda.Month == dtaFim.Month && e.dtVenda.Day <= dtaFim.Day)));
                    }
                    else     // IGUAL
                    {
                        string   busca  = item.Value;
                        DateTime dtaIni = DateTime.ParseExact(busca + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        entity = entity.Where(e => e.dtVenda.Year == dtaIni.Year && e.dtVenda.Month == dtaIni.Month && e.dtVenda.Day == dtaIni.Day);
                    }
                    break;

                //entity = entity.Where(e => e.dtVenda.Equals(dtVenda)).AsQueryable<tbRecebimentoTEF>();
                //break;
                case CAMPOS.HRVENDA:
                    TimeSpan hrVenda = TimeSpan.Parse(item.Value);
                    entity = entity.Where(e => e.hrVenda.Equals(hrVenda)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.VLVENDA:
                    decimal vlVenda = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.vlVenda.Equals(vlVenda)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.QTPARCELAS:
                    Int32 qtParcelas = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.qtParcelas.Equals(qtParcelas)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.NRCARTAO:
                    string nrCartao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nrCartao.Equals(nrCartao)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.CDBANDEIRA:
                    Int32 cdBandeira = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.cdBandeira.Equals(cdBandeira)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.NMOPERADORA:
                    string nmOperadora = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nmOperadora.Equals(nmOperadora)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.DTHRVENDA:
                    DateTime dthrVenda = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dthrVenda.Equals(dthrVenda)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.CDESTADOTRANSACAOTEF:
                    Int32 cdEstadoTransacaoTEF = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.cdEstadoTransacaoTEF.Equals(cdEstadoTransacaoTEF)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.CDTRASACAOTEF:
                    Int32 cdTrasacaoTEF = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.cdTrasacaoTEF.Equals(cdTrasacaoTEF)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.CDMODOENTRADATEF:
                    Int32 cdModoEntradaTEF = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.cdModoEntradaTEF.Equals(cdModoEntradaTEF)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.CDREDETEF:
                    Int32 cdRedeTEF = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.cdRedeTEF.Equals(cdRedeTEF)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.CDPRODUTOTEF:
                    Int32 cdProdutoTEF = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.cdProdutoTEF.Equals(cdProdutoTEF)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.CDBANDEIRATEF:
                    Int32 cdBandeiraTEF = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.cdBandeiraTEF.Equals(cdBandeiraTEF)).AsQueryable <tbRecebimentoTEF>();
                    break;

                case CAMPOS.CDESTABELECIMENTOHOST:
                    string cdEstabelecimentoHost = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cdEstabelecimentoHost.Equals(cdEstabelecimentoHost)).AsQueryable <tbRecebimentoTEF>();
                    break;

                // RELACIONAMENTOS
                case CAMPOS.ID_GRUPO:
                    Int32 id_grupo = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => _db.empresas.Where(f => f.nu_cnpj.Equals(e.nrCNPJ) && f.id_grupo == id_grupo).Count() > 0).AsQueryable <tbRecebimentoTEF>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.IDRECEBIMENTOTEF:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idRecebimentoTEF).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idRecebimentoTEF).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.CDGRUPO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdGrupo).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdGrupo).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.NRCNPJ:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nrCNPJ).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nrCNPJ).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.CDEMPRESATEF:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdEmpresaTEF).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdEmpresaTEF).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.NRPDVTEF:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nrPDVTEF).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nrPDVTEF).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.NRNSUHOST:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nrNSUHost).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nrNSUHost).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.NRNSUTEF:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nrNSUTEF).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nrNSUTEF).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.CDAUTORIZACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdAutorizacao).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdAutorizacao).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.CDSITUACAOREDETEF:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdSituacaoRedeTEF).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdSituacaoRedeTEF).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.DTVENDA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtVenda).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtVenda).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.HRVENDA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.hrVenda).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.hrVenda).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.VLVENDA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.vlVenda).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.vlVenda).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.QTPARCELAS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.qtParcelas).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.qtParcelas).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.NRCARTAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nrCartao).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nrCartao).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.CDBANDEIRA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdBandeira).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdBandeira).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.NMOPERADORA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nmOperadora).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nmOperadora).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.DTHRVENDA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dthrVenda).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dthrVenda).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.CDESTADOTRANSACAOTEF:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdEstadoTransacaoTEF).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdEstadoTransacaoTEF).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.CDTRASACAOTEF:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdTrasacaoTEF).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdTrasacaoTEF).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.CDMODOENTRADATEF:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdModoEntradaTEF).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdModoEntradaTEF).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.CDREDETEF:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdRedeTEF).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdRedeTEF).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.CDPRODUTOTEF:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdProdutoTEF).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdProdutoTEF).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.CDBANDEIRATEF:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdBandeiraTEF).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdBandeiraTEF).AsQueryable <tbRecebimentoTEF>();
                }
                break;

            case CAMPOS.CDESTABELECIMENTOHOST:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdEstabelecimentoHost).AsQueryable <tbRecebimentoTEF>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdEstabelecimentoHost).AsQueryable <tbRecebimentoTEF>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #27
0
        /// <summary>
        /// Get Pessoa/Pessoa
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <pessoa> getQuery(painel_taxservices_dbContext _db, int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.pessoas.AsQueryable <pessoa>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.ID_PESSSOA:
                    Int32 id_pesssoa = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id_pesssoa.Equals(id_pesssoa)).AsQueryable <pessoa>();
                    break;

                case CAMPOS.NM_PESSOA:
                    string nm_pessoa = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nm_pessoa.Equals(nm_pessoa)).AsQueryable <pessoa>();
                    break;

                case CAMPOS.DT_NASCIMENTO:
                    DateTime dt_nascimento = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dt_nascimento.Equals(dt_nascimento)).AsQueryable <pessoa>();
                    break;

                case CAMPOS.NU_TELEFONE:
                    string nu_telefone = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nu_telefone.Equals(nu_telefone)).AsQueryable <pessoa>();
                    break;

                case CAMPOS.NU_RAMAL:
                    string nu_ramal = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nu_ramal.Equals(nu_ramal)).AsQueryable <pessoa>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.ID_PESSSOA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id_pesssoa).AsQueryable <pessoa>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id_pesssoa).AsQueryable <pessoa>();
                }
                break;

            case CAMPOS.NM_PESSOA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nm_pessoa).AsQueryable <pessoa>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nm_pessoa).AsQueryable <pessoa>();
                }
                break;

            case CAMPOS.DT_NASCIMENTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dt_nascimento).AsQueryable <pessoa>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dt_nascimento).AsQueryable <pessoa>();
                }
                break;

            case CAMPOS.NU_TELEFONE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nu_telefone).AsQueryable <pessoa>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nu_telefone).AsQueryable <pessoa>();
                }
                break;

            case CAMPOS.NU_RAMAL:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nu_ramal).AsQueryable <pessoa>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nu_ramal).AsQueryable <pessoa>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #28
0
        /// <summary>
        /// Get Cielo/Cielo
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <Cielo> getQuery(int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.Cieloes.AsQueryable <Cielo>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.ID:
                    Int32 id = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id.Equals(id)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.DTAVENDA:
                    DateTime dtaVenda = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtaVenda.Equals(dtaVenda)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.DTAPREVISTAPAGTO:
                    DateTime dtaPrevistaPagto = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtaPrevistaPagto.Equals(dtaPrevistaPagto)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.DESCRICAO:
                    string descricao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.descricao.Equals(descricao)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.RESUMO:
                    string resumo = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.resumo.Equals(resumo)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.CNPJ:
                    string cnpj = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cnpj.Equals(cnpj)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.NUMCARTAO:
                    string numCartao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.numCartao.Equals(numCartao)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.NSU:
                    string nsu = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nsu.Equals(nsu)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.CDAUTORIZADOR:
                    string cdAutorizador = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.cdAutorizador.Equals(cdAutorizador)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.VALORTOTAL:
                    decimal valorTotal = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valorTotal.Equals(valorTotal)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.VALORBRUTO:
                    decimal valorBruto = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valorBruto.Equals(valorBruto)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.REJEITADO:
                    string rejeitado = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.rejeitado.Equals(rejeitado)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.VALORSAQUE:
                    decimal valorSaque = Convert.ToDecimal(item.Value);
                    entity = entity.Where(e => e.valorSaque.Equals(valorSaque)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.IDOPERADORA:
                    Int32 idOperadora = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idOperadora.Equals(idOperadora)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.IDBANDEIRA:
                    Int32 idBandeira = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idBandeira.Equals(idBandeira)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.DTARECEBIMENTO:
                    DateTime dtaRecebimento = Convert.ToDateTime(item.Value);
                    entity = entity.Where(e => e.dtaRecebimento.Equals(dtaRecebimento)).AsQueryable <Cielo>();
                    break;

                case CAMPOS.IDTERMINALLOGICO:
                    Int32 idTerminalLogico = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idTerminalLogico.Equals(idTerminalLogico)).AsQueryable <Cielo>();
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.ID:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.DTAVENDA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtaVenda).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtaVenda).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.DTAPREVISTAPAGTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtaPrevistaPagto).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtaPrevistaPagto).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.DESCRICAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.descricao).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.descricao).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.RESUMO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.resumo).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.resumo).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.CNPJ:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cnpj).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cnpj).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.NUMCARTAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.numCartao).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.numCartao).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.NSU:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nsu).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nsu).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.CDAUTORIZADOR:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.cdAutorizador).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.cdAutorizador).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.VALORTOTAL:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valorTotal).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valorTotal).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.VALORBRUTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valorBruto).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valorBruto).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.REJEITADO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.rejeitado).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.rejeitado).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.VALORSAQUE:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.valorSaque).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.valorSaque).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.IDOPERADORA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idOperadora).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idOperadora).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.IDBANDEIRA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idBandeira).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idBandeira).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.DTARECEBIMENTO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtaRecebimento).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtaRecebimento).AsQueryable <Cielo>();
                }
                break;

            case CAMPOS.IDTERMINALLOGICO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idTerminalLogico).AsQueryable <Cielo>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idTerminalLogico).AsQueryable <Cielo>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #29
0
        /// <summary>
        /// Get Webpages_Users/Webpages_Users
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <webpages_Users> getQuery(painel_taxservices_dbContext _db, int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.webpages_Users.AsQueryable <webpages_Users>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.ID_USERS:
                    Int32 id_users = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id_users.Equals(id_users)).AsQueryable <webpages_Users>();
                    break;

                case CAMPOS.DS_LOGIN:
                    string ds_login = Convert.ToString(item.Value);
                    if (ds_login.Contains("%"))     // usa LIKE
                    {
                        string busca = ds_login.Replace("%", "").ToString();
                        entity = _db.webpages_Users.Where(e => e.ds_login.Contains(busca));
                    }
                    else
                    {
                        entity = entity.Where(e => e.ds_login.Equals(ds_login)).AsQueryable <webpages_Users>();
                    }
                    break;

                case CAMPOS.DS_EMAIL:
                    string ds_email = Convert.ToString(item.Value);
                    if (ds_email.Contains("%"))     // usa LIKE
                    {
                        string busca = ds_email.Replace("%", "").ToString();
                        entity = _db.webpages_Users.Where(e => e.ds_email.Contains(busca));
                    }
                    else
                    {
                        entity = entity.Where(e => e.ds_email.Equals(ds_email)).AsQueryable <webpages_Users>();
                    }
                    break;

                case CAMPOS.ID_GRUPO:
                    Int32 id_grupo = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id_grupo == id_grupo).AsQueryable <webpages_Users>();
                    //var ent = entity.Where(e => e.id_grupo == id_grupo);
                    break;

                case CAMPOS.NU_CNPJEMPRESA:
                    string nu_cnpjEmpresa = Convert.ToString(item.Value);

                    entity = entity.Where(e => e.nu_cnpjEmpresa.Equals(nu_cnpjEmpresa)).AsQueryable <webpages_Users>();
                    break;

                case CAMPOS.NU_CNPJBASEEMPRESA:
                    string nu_cnpjBaseEmpresa = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.nu_cnpjBaseEmpresa.Equals(nu_cnpjBaseEmpresa)).AsQueryable <webpages_Users>();
                    break;

                case CAMPOS.ID_PESSOA:
                    Int32 id_pessoa = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.id_pessoa.Equals(id_pessoa)).AsQueryable <webpages_Users>();
                    break;


                // PERSONALIZADO


                case CAMPOS.DS_NOME:
                    string ds_nome = Convert.ToString(item.Value);
                    if (ds_nome.Contains("%"))     // usa LIKE
                    {
                        string busca = ds_nome.Replace("%", "").ToString();
                        entity = entity.Where(e => e.grupo_empresa.ds_nome.Contains(busca)).AsQueryable <webpages_Users>();
                    }
                    else
                    {
                        entity = entity.Where(e => e.grupo_empresa.ds_nome.Equals(ds_nome)).AsQueryable <webpages_Users>();
                    }
                    break;


                case CAMPOS.DS_FANTASIA:
                    string ds_fantasia = Convert.ToString(item.Value);
                    if (ds_fantasia.Contains("%"))     // usa LIKE
                    {
                        string busca = ds_fantasia.Replace("%", "").ToString();
                        entity = entity.Where(e => e.empresa.ds_fantasia.Contains(busca)).AsQueryable <webpages_Users>();
                    }
                    else
                    {
                        entity = entity.Where(e => e.empresa.ds_fantasia.Equals(ds_fantasia)).AsQueryable <webpages_Users>();
                    }
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.ID_USERS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id_users).AsQueryable <webpages_Users>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id_users).AsQueryable <webpages_Users>();
                }
                break;

            case CAMPOS.DS_LOGIN:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.ds_login).AsQueryable <webpages_Users>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.ds_login).AsQueryable <webpages_Users>();
                }
                break;

            case CAMPOS.DS_EMAIL:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.ds_email).ThenBy(e => e.ds_login).AsQueryable <webpages_Users>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.ds_email).ThenByDescending(e => e.ds_login).AsQueryable <webpages_Users>();
                }
                break;

            case CAMPOS.ID_GRUPO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id_grupo).AsQueryable <webpages_Users>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id_grupo).AsQueryable <webpages_Users>();
                }
                break;

            case CAMPOS.NU_CNPJEMPRESA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nu_cnpjEmpresa).AsQueryable <webpages_Users>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nu_cnpjEmpresa).AsQueryable <webpages_Users>();
                }
                break;

            case CAMPOS.NU_CNPJBASEEMPRESA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.nu_cnpjBaseEmpresa).AsQueryable <webpages_Users>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.nu_cnpjBaseEmpresa).AsQueryable <webpages_Users>();
                }
                break;

            case CAMPOS.ID_PESSOA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.id_pessoa).AsQueryable <webpages_Users>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.id_pessoa).AsQueryable <webpages_Users>();
                }
                break;



            // PERSONALIZADO


            case CAMPOS.DS_NOME:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.grupo_empresa.ds_nome).ThenBy(e => e.empresa.ds_fantasia).ThenBy(e => e.ds_login).AsQueryable <webpages_Users>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.grupo_empresa.ds_nome).ThenByDescending(e => e.empresa.ds_fantasia).ThenByDescending(e => e.ds_login).AsQueryable <webpages_Users>();
                }
                break;


            case CAMPOS.DS_FANTASIA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.empresa.ds_fantasia).ThenBy(e => e.ds_login).AsQueryable <webpages_Users>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.empresa.ds_fantasia).ThenByDescending(e => e.ds_login).AsQueryable <webpages_Users>();
                }
                break;
            }
            #endregion

            return(entity);
        }
예제 #30
0
        /// <summary>
        /// Get TbLogAcessoUsuario/TbLogAcessoUsuario
        /// </summary>
        /// <param name="colecao"></param>
        /// <param name="campo"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private static IQueryable <tbLogAcessoUsuario> getQuery(painel_taxservices_dbContext _db, int colecao, int campo, int orderby, int pageSize, int pageNumber, Dictionary <string, string> queryString)
        {
            // DEFINE A QUERY PRINCIPAL
            var entity = _db.tbLogAcessoUsuarios.AsQueryable <tbLogAcessoUsuario>();

            #region WHERE - ADICIONA OS FILTROS A QUERY

            // ADICIONA OS FILTROS A QUERY
            foreach (var item in queryString)
            {
                int    key        = Convert.ToInt16(item.Key);
                CAMPOS filtroEnum = (CAMPOS)key;
                switch (filtroEnum)
                {
                case CAMPOS.IDLOGACESSOUSUARIO:
                    Int32 idLogAcessoUsuario = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idLogAcessoUsuario == idLogAcessoUsuario).AsQueryable <tbLogAcessoUsuario>();
                    break;

                case CAMPOS.IDUSER:
                    Int32 idUser = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idUser == idUser).AsQueryable <tbLogAcessoUsuario>();
                    break;

                case CAMPOS.DSURL:
                    string dsUrl = Convert.ToString(item.Value);
                    if (dsUrl.Contains("%"))     // usa LIKE
                    {
                        string busca = dsUrl.Replace("%", "").ToString();
                        entity = entity.Where(e => e.dsUrl.Contains(busca)).AsQueryable <tbLogAcessoUsuario>();
                    }
                    else
                    {
                        entity = entity.Where(e => e.dsUrl.Equals(dsUrl)).AsQueryable <tbLogAcessoUsuario>();
                    }
                    break;

                case CAMPOS.IDCONTROLLER:
                    Int32 idController = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.idController == idController).AsQueryable <tbLogAcessoUsuario>();
                    break;

                case CAMPOS.DSPARAMETROS:
                    string dsParametros = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsParametros.Equals(dsParametros)).AsQueryable <tbLogAcessoUsuario>();
                    break;

                case CAMPOS.DSFILTROS:
                    string dsFiltros = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsFiltros.Equals(dsFiltros)).AsQueryable <tbLogAcessoUsuario>();
                    break;

                case CAMPOS.DTACESSO:
                    if (item.Value.Contains("|"))     // BETWEEN
                    {
                        string[] busca  = item.Value.Split('|');
                        DateTime dtaIni = DateTime.ParseExact(busca[0] + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        DateTime dtaFim = DateTime.ParseExact(busca[1] + " 23:59:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        entity = entity.Where(e => (e.dtAcesso.Year > dtaIni.Year || (e.dtAcesso.Year == dtaIni.Year && e.dtAcesso.Month > dtaIni.Month) ||
                                                    (e.dtAcesso.Year == dtaIni.Year && e.dtAcesso.Month == dtaIni.Month && e.dtAcesso.Day >= dtaIni.Day)) &&
                                              (e.dtAcesso.Year < dtaFim.Year || (e.dtAcesso.Year == dtaFim.Year && e.dtAcesso.Month < dtaFim.Month) ||
                                               (e.dtAcesso.Year == dtaFim.Year && e.dtAcesso.Month == dtaFim.Month && e.dtAcesso.Day <= dtaFim.Day)));
                    }
                    else     // ANO + MES + DIA
                    {
                        string   busca  = item.Value;
                        DateTime dtaIni = DateTime.ParseExact(busca + " 00:00:00.000", "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                        entity = entity.Where(e => e.dtAcesso.Year == dtaIni.Year && e.dtAcesso.Month == dtaIni.Month && e.dtAcesso.Day == dtaIni.Day);
                    }
                    break;

                case CAMPOS.DSAPLICACAO:
                    string dsAplicacao = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsAplicacao.Equals(dsAplicacao)).AsQueryable <tbLogAcessoUsuario>();
                    break;

                case CAMPOS.CODRESPOSTA:
                    Int32 codResposta = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.codResposta == codResposta).AsQueryable <tbLogAcessoUsuario>();
                    break;

                case CAMPOS.MSGERRO:
                    string msgErro = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.msgErro.Equals(msgErro)).AsQueryable <tbLogAcessoUsuario>();
                    break;

                case CAMPOS.DSJSON:
                    string dsJson = Convert.ToString(item.Value);
                    if (dsJson.Contains("%"))     // usa LIKE
                    {
                        string busca = dsJson.Replace("%", "").ToString();
                        entity = entity.Where(e => e.dsJson.Contains(busca)).AsQueryable <tbLogAcessoUsuario>();
                    }
                    else
                    {
                        entity = entity.Where(e => e.dsJson.Equals(dsJson)).AsQueryable <tbLogAcessoUsuario>();
                    }
                    break;

                case CAMPOS.DSUSERAGENT:
                    string dsUserAgent = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsUserAgent.Equals(dsUserAgent)).AsQueryable <tbLogAcessoUsuario>();
                    break;

                case CAMPOS.DSMETHOD:
                    string dsMethod = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.dsMethod.Equals(dsMethod)).AsQueryable <tbLogAcessoUsuario>();
                    break;


                // PERSONALIZADO
                case CAMPOS.NU_CNPJ:
                    string nu_cnpj = Convert.ToString(item.Value);
                    entity = entity.Where(e => e.webpages_Users.nu_cnpjEmpresa.Equals(nu_cnpj)).AsQueryable <tbLogAcessoUsuario>();
                    break;

                case CAMPOS.DS_LOGIN:
                    string ds_login = Convert.ToString(item.Value);
                    if (ds_login.Contains("%"))     // usa LIKE
                    {
                        string busca = ds_login.Replace("%", "").ToString();
                        entity = entity.Where(e => e.webpages_Users.ds_login.Contains(busca)).AsQueryable <tbLogAcessoUsuario>();
                    }
                    else
                    {
                        entity = entity.Where(e => e.webpages_Users.ds_login.Equals(ds_login)).AsQueryable <tbLogAcessoUsuario>();
                    }
                    break;

                case CAMPOS.ID_GRUPO:
                    Int32 id_grupo = Convert.ToInt32(item.Value);
                    entity = entity.Where(e => e.webpages_Users.id_grupo == id_grupo).AsQueryable <tbLogAcessoUsuario>();
                    break;

                case CAMPOS.DS_CONTROLLER:
                    string ds_controller = Convert.ToString(item.Value);
                    if (ds_controller.Contains("%"))     // usa LIKE
                    {
                        string busca = ds_controller.Replace("%", "").ToString();
                        entity = entity.Where(e => e.webpages_Controllers.ds_controller.Contains(busca)).AsQueryable <tbLogAcessoUsuario>();
                    }
                    else
                    {
                        entity = entity.Where(e => e.webpages_Controllers.ds_controller.Equals(ds_controller)).AsQueryable <tbLogAcessoUsuario>();
                    }
                    break;
                }
            }
            #endregion

            #region ORDER BY - ADICIONA A ORDENAÇÃO A QUERY
            // ADICIONA A ORDENAÇÃO A QUERY
            CAMPOS filtro = (CAMPOS)campo;
            switch (filtro)
            {
            case CAMPOS.IDLOGACESSOUSUARIO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idLogAcessoUsuario).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idLogAcessoUsuario).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.IDUSER:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idUser).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idUser).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.DSURL:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsUrl).ThenByDescending(e => e.dtAcesso).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsUrl).ThenByDescending(e => e.dtAcesso).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.IDCONTROLLER:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.idController).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.idController).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.DSPARAMETROS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsParametros).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsParametros).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.DSFILTROS:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsFiltros).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsFiltros).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.DTACESSO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dtAcesso).ThenBy(e => e.webpages_Users.ds_login).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dtAcesso).ThenBy(e => e.webpages_Users.ds_login).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.DSAPLICACAO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsAplicacao).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsAplicacao).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.CODRESPOSTA:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.codResposta).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.codResposta).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.MSGERRO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.msgErro).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.msgErro).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.DSJSON:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsJson).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsJson).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.DSUSERAGENT:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsUserAgent).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsUserAgent).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.DSMETHOD:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.dsMethod).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.dsMethod).AsQueryable <tbLogAcessoUsuario>();
                }
                break;


            // PERSONALIZADO
            case CAMPOS.DS_LOGIN:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.webpages_Users.ds_login).ThenByDescending(e => e.dtAcesso).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.webpages_Users.ds_login).ThenByDescending(e => e.dtAcesso).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.ID_GRUPO:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.webpages_Users.id_grupo).ThenByDescending(e => e.dtAcesso).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.webpages_Users.id_grupo).ThenByDescending(e => e.dtAcesso).AsQueryable <tbLogAcessoUsuario>();
                }
                break;

            case CAMPOS.DS_CONTROLLER:
                if (orderby == 0)
                {
                    entity = entity.OrderBy(e => e.webpages_Controllers.ds_controller).ThenByDescending(e => e.dtAcesso).AsQueryable <tbLogAcessoUsuario>();
                }
                else
                {
                    entity = entity.OrderByDescending(e => e.webpages_Controllers.ds_controller).ThenByDescending(e => e.dtAcesso).AsQueryable <tbLogAcessoUsuario>();
                }
                break;
            }
            #endregion

            return(entity);
        }