Share add on method report to xbrowse

Post Reply
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Share add on method report to xbrowse

Post by ShumingWang »

METHOD Report( cTitle, lPreview, aHeaders, aFooters, cCaption,lModal ) CLASS TXBrowse

Local oRpt ,nCols := Len( ::acols ), oldbskip:=::bskip
local odevice,cmsg:={"Print","Date","time","Page"}

oDevice := TPrinter():New(cmsg[1],.t.)
if odevice:hdc==0; odevice:end(); return .f.; end
odevice:end()

Default cTitle := ::oWnd:GetText(), ;
lPreview := .T., ;
aHeaders := {cmsg[2] + DTOC(DATE())+ " "+cmsg[3]+TIME()},;
cCaption := ::oWnd:GetText(), ;
lModal := .T.


if EVAL(::beof)
if (EVAL(::bBookMark)==EVAL(::bKeycount)+1).and.(len(::aSelected)==1) ; return self ; end
::SKIP(-1)
end
if ::nDataType==DATATYPE_MYSQL //3
::bskip:=::bskipper
end

::gotop()



If lPreview
REPORT oRpt TITLE cTitle CAPTION cCaption PREVIEW ;
HEADER aHeaders[1];
FOOTER cmsg[4] + Str( oRpt:nPage, 3 ) ;
CENTER
Else
REPORT oRpt TITLE cTitle CAPTION cCaption ;
HEADER aHeaders[1];
FOOTER cmsg[4]+ Str( oRpt:nPage, 3 ) ;
CENTER
EndIf

oRpt:oDevice:lPrvModal := lModal
oRpt:bPostEnd := {|| ::SetFocus() }

For nI := 1 To nCols
If len(::aCols[ nI ]:abitmaps)==0 .and. !::aCols[nI]:lHide

ocol:=oRpt:AddColumn( TrColumn():New( { GenHead( ::acols, nI ) },, ;
{ GenData( ::aCols, nI ) },::acols[ni]:nwidth*0.11, ;
{ If( ! Empty( ::acols[ nI ]:cEditPicture), ;
::acols[ nI ]:cEditPicture, "" ) },, ;
( len(::acols[ nI ]:cFooter)>0 .and.::acols[nI]:nDataStrAlign==1 ),, ; // prints footings if the column has one (numeric only)
If( ::acols[nI]:nDataStrAlign==1, "RIGHT", Nil ),,,, oRpt ) )

endif

next

END REPORT

oRpt:bSkip := { || oRpt:Cargo := ::rptSKIP( ) }
oRpt:Cargo := 1
oRpt:cellview() // option

IF len(::aselected)>0
While AScan( ::aSelected, ;
If( ::NDATATYPE==DATATYPE_ARRAY,::nArrayAt,eval(::bKeyno)))==0
::skip(1)
End
end


ACTIVATE REPORT oRpt ;
WHILE If( ::ndatatype == DATATYPE_ARRAY,;
oRpt:nCounter <= Max( ( Eval( ::bLogicLen ) ) - 1, 1 ),;
oRpt:Cargo >= 1 )


::bskip:=oldbskip
::GoTop()


Return Self


Static Function GenHead( aArray, nPos )
Return {|| aArray[nPos]:cHeader }


Static Function GenData( aArray, nPos )
Return If( ValType(Eval(aArray[nPos]:bStrData)) != "U", ;
if(len(aArray[nPos]:cfooter)>=1.and.aArray[nPos]:nfootStrAlign==1,aArray[ nPos ]:bStrData,aArray[ nPos ]:bStrData), {|| "" } )

Method Rptskip() class Txbrowse
local n1,n1old


n1old:=::skip(1)
n1:=n1old

IF len(::aSelected)>0
While AScan( ::aSelected, If( ::nDatatype==DATATYPE_ARRAY,::nArrayAt,eval(::bKeyno)))==0
n1+=::skip(1)
if ::nDATATYPE<>DATATYPE_ARRAY
if eval(::bKeyno)==eval(::bkeyCount)
n1:=0
exit
end
else
if ::nArrayAt==len(::aArray)
n1:=0
exit
end
end
if n1==n1old
exit
end
n1old:=n1

enddo
end
return n1
Post Reply