예제 #1
0
        public IEnumerable <Titulo> Filtrar(TituloFiltroDTO filtro)
        {
            using (var db = new SqlConnection(ConnectionString))
            {
                var query = new StringBuilder(@"SELECT t.*, v.Id, v.ClienteId, v.QuantParcelas, v.DiaVencimento, v.LoteId, v.ValorParcela, c.Nome, l.Codigo, lo.Nome, lo.EmpresaId FROM Titulos t LEFT JOIN Vendas v ON t.VendaId = v.Id LEFT JOIN UsuariosClientes c ON v.ClienteId = c.Id LEFT JOIN Lotes l ON v.LoteId = l.Id LEFT JOIN Loteamentos lo ON l.LoteamentoId = lo.Id WHERE v.ClienteId = @ClienteId");

                if (filtro.DataEmissaoDe != null && filtro.DataEmissaoAte != null)
                {
                    query.Append(" AND v.DataHora >= @DataEmissaoDe AND v.DataHora <= @DataEmissaoAte");
                }

                if (filtro.DataVencimentoDe != null && filtro.DatavencimentoAte != null)
                {
                    query.Append(" AND t.DataVencimento >= @DataVencimentoDe AND t.DataVencimento <= @DataVencimentoAte");
                }

                if (filtro.DataPgtoDe != null && filtro.DataPgtoAte != null)
                {
                    query.Append(" AND t.DataPgto >= @DataPgtoDe AND t.DataPgto <= @DataPgtoAte");
                }

                if (filtro.Status != null)
                {
                    query.Append(" AND t.Pago = @Status");
                }

                query.Append(" ORDER BY t.Pago, t.DataVencimento;");

                return(db.Query <Titulo, Venda, UsuarioCliente, Lote, Loteamento, Titulo>(query.ToString(), (tit, venda, cliente, lote, loteamento) =>
                {
                    lote.Loteamento = loteamento;
                    venda.Lote = lote;
                    venda.Cliente = cliente;
                    tit.Venda = venda;
                    return tit;
                }, filtro, splitOn: "Id, Nome, Codigo, Nome"));
            }
        }
예제 #2
0
 public IEnumerable <Titulo> Filtrar(TituloFiltroDTO filtro)
 {
     return(_dao.Filtrar(filtro));
 }
예제 #3
0
 public IEnumerable <Titulo> Filtrar(TituloFiltroDTO filtro) => _bo.Filtrar(filtro);