*fecha('crMonitorFacturas') RELEASE ge_snnocalfis local consulta consulta='' if empty(m.ObjRecebido.Janela.pageframe1.page1.dtini.Value) or datavazia(m.ObjRecebido.Janela.pageframe1.page1.dtini.Value) m.ObjRecebido.Janela.pageframe1.page1.dtini.Value=date(1900, 1, 1) endif if empty(m.ObjRecebido.Janela.pageframe1.page1.dtfim.Value) or datavazia(m.ObjRecebido.Janela.pageframe1.page1.dtfim.Value) m.ObjRecebido.Janela.pageframe1.page1.dtfim.Value= date(1900, 1, 1) &&date(year(date()), 12, 31) endif if !empty(PDU_Riesgo.Pageframe1.Page1.ftObj12.Value) consulta=(" and ft.nome='"+alltrim(PDU_Riesgo.Pageframe1.Page1.ftObj12.Value)+"'") endif if !empty(m.ObjRecebido.Janela.pageframe1.page1.ftobj17.Value) consulta=consulta+(" and ft.nmdoc='"+alltrim(m.ObjRecebido.Janela.pageframe1.page1.ftobj17.Value)+"'") endif if !empty(m.ObjRecebido.Janela.pageframe1.page1.ftobj18.Value) consulta=consulta+(" and ft.fno="+alltrim(m.ObjRecebido.Janela.pageframe1.page1.ftobj18.Value)) endif if !empty(m.ObjRecebido.Janela.pageframe1.page1.ftobj20.Value) consulta=consulta+(" and ft.tpdesc='"+alltrim(m.ObjRecebido.Janela.pageframe1.page1.ftobj20.Value)+"'") endif Text To usql Textmerge Noshow pretext 7 select ft.nmdoc, ft.fno,cast( ft.fdata AS DATE ) as fdata , cast(ft.pdata as DATE) as pdata, ft.nome, iif (cc.cm = 1, cc.edeb - cc.edebf, -(cc.ecred - cc.ecredf)) as pendiente, ft.etotal, ft.ettiliq, ft.ettiva, ft.ccusto, ft.plano, ft.ftstamp, ft.ndoc, case ft.pais when 1 then 'Nacional' when 2 then 'U.E.' when 3 then 'Otros' end as pais, (select pncont from cl (nolock) where no=ft.no and estab=ft.estab) as pncont from ft (nolock) join cc (nolock) on cc.ftstamp=ft.ftstamp where ft.ndoc in (1,4) and cc.situacao=1 and ft.anulado=0 and ft.fdata between '<<dtosql(m.ObjRecebido.Janela.pageframe1.page1.DTINI.Value)>>' and '<<dtosql(m.ObjRecebido.Janela.pageframe1.page1.DTFIM.Value)>>' <<consulta>> order by ft.nmdoc, ft.fno endtext IF NOT u_sqlexec(usql, 'crMonitorFacturas') msg(usql) Else u_sqlexec(usql, 'crMonitorFacturas') PDU_RIESGO.pageframe1.page1.Obj1.Refresh() select sum(etotal) as 'Total' , count(*) as 'reg' from crMonitorFacturas into Cursor Crstotal select crstotal PDU_RIESGO.Pageframe1.Page1.FTValorOBJ21.Value = crstotal.Total PDU_RIESGO.Pageframe1.Page1.FTnrregOBJ23.Value = crstotal.reg FECHA([Crstotal]) Set DATE BRIT Set Date DMY && ddmmyy Set Century On Select crMonitorFacturas Index On crMonitorFacturas.FDATA Tag i_dat Index On crMonitorFacturas.PDATA Tag i_venc Index On crMonitorFacturas.NOME Tag i_nm Index On crMonitorFacturas.pendiente Tag i_pend Index On crMonitorFacturas.etotal Tag i_tot Go Top In crMonitorFacturas Endif Public m_monitor_MAPAUTENTE *!* Crias o teu obj m_monitor_MAPAUTENTE=Newobject("new_MAPAUTENTE") *!* executar o procedimento que faz Bindevent Do sp_eventOBJ *!* Criar a classe Define Class new_MAPAUTENTE As Session Procedure Ordenarfecha Select crMonitorFacturas If Val(Sys(21))<>3 && current index number Set Order To 3 In crMonitorFacturas Else If Descending(3,"crMonitorFacturas") Set Order To 3 In crMonitorFacturas Ascending Else Set Order To 3 In crMonitorFacturas Descending Endif Endif Go Top In crMonitorFacturas PDU_Riesgo.pageframe1.page1.Obj1.Refresh() Endproc Procedure OrdenarVenc Select crMonitorFacturas If Val(Sys(21))<>4 && current index number Set Order To 4 In crMonitorFacturas Else If Descending(4,"crMonitorFacturas") Set Order To 4 In crMonitorFacturas Ascending Else Set Order To 4 In crMonitorFacturas Descending Endif Endif Go Top In crMonitorFacturas PDU_Riesgo.pageframe1.page1.Obj1.Refresh() Endproc Procedure OrdenarCliente Select crMonitorFacturas If Val(Sys(21))<>5 && current index number Set Order To 5 In crMonitorFacturas Else If Descending(5,"crMonitorFacturas") Set Order To 5 In crMonitorFacturas Ascending Else Set Order To 5 In crMonitorFacturas Descending Endif Endif Go Top In crMonitorFacturas PDU_Riesgo.pageframe1.page1.Obj1.Refresh() Endproc Procedure OrdenarPendente Select crMonitorFacturas If Val(Sys(21))<>6 && current index number Set Order To 6 In crMonitorFacturas Else If Descending(6,"crMonitorFacturas") Set Order To 6 In crMonitorFacturas Ascending Else Set Order To 6 In crMonitorFacturas Descending Endif Endif Go Top In crMonitorFacturas PDU_Riesgo.pageframe1.page1.Obj1.Refresh() Endproc Procedure OrdenarTotal Select crMonitorFacturas If Val(Sys(21))<>7 && current index number Set Order To 7 In crMonitorFacturas Else If Descending(7,"crMonitorFacturas") Set Order To 7 In crMonitorFacturas Ascending Else Set Order To 7 In crMonitorFacturas Descending Endif Endif Go Top In crMonitorFacturas PDU_Riesgo.pageframe1.page1.Obj1.Refresh() Endproc enddefine ***************************************************************************************** *Fim da Classe - Separador Utentes * *Criar o procedimento sp_eventOBJ que faz o "Bindevent" aos objectos * ***************************************************************************************** Procedure sp_eventOBJ Bindevent(PDU_RIESGO.pageframe1.page1.Obj1.column3.header1,"click",m_monitor_MAPAUTENTE,"Ordenarfecha",1) Bindevent(PDU_RIESGO.pageframe1.page1.Obj1.column4.header1,"click",m_monitor_MAPAUTENTE,"Ordenarvenc",1) Bindevent(PDU_RIESGO.pageframe1.page1.Obj1.column5.header1,"click",m_monitor_MAPAUTENTE,"OrdenarCliente",1) Bindevent(PDU_RIESGO.pageframe1.page1.Obj1.column6.header1,"click",m_monitor_MAPAUTENTE,"OrdenarPendente",1) Bindevent(PDU_RIESGO.pageframe1.page1.Obj1.column7.header1,"click",m_monitor_MAPAUTENTE,"OrdenarTotal",1) EndprocMany thanks