Fórum Clientes atrasados #375540
02/10/2009
0
Tipo tem um form com o DBgrid nesse grid tengo q nostrar so os clientes Atrasados em uma consulta
mas sem usar filtered e to perdidinho algum tem uma forma q eu possa mostrar so os clientes atrasados....
Tchucky
Curtir tópico
+ 0Posts
02/10/2009
Edsant
Você tera que criar uma consulta SQL:
ficaria asssim:
with Query1 do
begin
Close;
SQL.Add(´SELECT * FROM TABELA WHERE DATAVENCIMENTO < :HOJE´);
params.ParamByName(´HOJE´).AsDateTime := Date;
Open;
end;
Depois vc linka o DataSource a essa Query1 e já era
Não testei o código, mas é isso ai....
Espero ter ajudado...
Gostei + 0
02/10/2009
Facc
Exemplo (simples):
Select * from <tabela> where DtVecto < << vc determina qntos dias de atraso>>
como disse é simples o exemplo... vc precisa melhorar e adequar ao que vc precisa...
Gostei + 0
02/10/2009
Tchucky
Var Q: TSQLQuery; begin Q := TSQLQuery.Create(Application); Q.SQLConnection := dm_conexao.sc_conexao; try Q.Close; Q.SQL.Text := ´SELECT T.DT_VENCIMENTO FROM TITULO T´ +#13+´WHERE (´ +13+´ (T.DT_VENCIMENTO > ´+QuotedStr(date)+´) ´ +13+´)´; Q.Open; finally FreeAndNil(Q); end;
mas esta dando erro no Date
Gostei + 0
03/10/2009
Tchucky
Var Q: TSQLQuery; begin Q := TSQLQuery.Create(nil); Q.SQLConnection := dm_cliente_atrasado.sq_titulo.SQLConnection; try Q.Close; Q.SQL.Text := ´ SELECT ´ +#13+´ T.DT_VENCIMENTO, ´ +13+´ T.PAGAR_RECEBER, ´ +13+´ T.DT_PAGAMENTO ´ +13+´ FROM TITULO T ´ +13+´WHERE (´ +13+´ (T.DT_VENCIMENTO < ´+Quotedstr (datetostr (Date))+´) ´ +13+´ AND´ +13+´ PAGAR_RECEBER =´+(´1´) + ´and DT_PAGAMENTO IS NULL´ +13+´)´; Q.Open; finally FreeAndNil(Q); end;
mas ela sempre fica fechada
fiz com filter mas queria padronizar com uma sql
no filter ficou dessa forma
dm_cliente_atrasado.cds_titulo.open; dm_cliente_atrasado.cds_titulo.indexfieldnames := ´DT_VENCIMENTO´; dm_cliente_atrasado.cds_titulo.filtered := false; dm_cliente_atrasado.cds_titulo.filter := ´DT_VENCIMENTO < ´+ Quotedstr(datetostr(Date))+ ´and PAGAR_RECEBER =´+(´1´) + ´and DT_PAGAMENTO IS NULL´; dm_cliente_atrasado.cds_titulo.filtered := true;
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)