- Code: Select all Expand view RUN
#include "fivewin.ch"
#include "xbrowse.ch"
function main()
local oWnd,oBar
field me_mc_serl, me_date
set date format to "DD/MM/YYYY"
set deleted on
set resources to "test04.dll"
setHandleCount(99)
use mete exclusive
*recall all
index on me_mc_serl to mete
index on me_date to mete2
use
define window oWnd title "Test Tmeter class" MDI
define buttonbar oBar of oWnd size 26,28 3d
define button of oBar resource "people" noborder;
action Tmeter():new():browser()
activate window oWnd
set resources to
close databases
return nil
//--- End test
//---------------------------------------------------------------------------//
//--- meter class
class Tmeter from TData
method new
method browser
method add
method edit
message delete method _delete
Hidden:
data lAdd as logical
endclass
//---------------------------------------------------------------------------//
method new()
super:new(,"mete")
if ::use()
::addIndex("mete")
::addIndex("mete2")
::setOrder(1)
::gotop()
msgInfo( ::recno(),"recno()")
msgInfo( ::fcount(),"fcount()")
endif
::lAdd:=.f.
return self
//---------------------------------------------------------------------------//
method browser()
local oDlg,oBrw,oMeter,oFont,oCol,nFor,oChild
::setOrder(2)
::gotop()
define font oFont name "Ms Sans Serif" size 0,-14 BOLD
*define font oFont name getsysfont() size 0,-14
DEFINE DIALOG oDlg FROM 0,0 TO 45,128 TITLE "meter reads browse "
oBrw := TXBrowse():New( oDlg )
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:lColDividerComplete := .t.
oBrw:nHeaderLines := 1
oBrw:nFooterLines := 1
oBrw:nDataLines := 1
oBrw:lFooter := .t.
oBrw:CreateFromCode()
oBrw:nTop = 0
oBrw:nLeft = 0
oBrw:nWidth = 1000
oBrw:nHeight =600
oBrw:SetRDD()
for nFor := 1 to ::Fcount()
oBrw:aCols[ nFor ]:oDataFont := oFont
next
// Setup for using database class
oBrw:cAlias:= ::cAlias
oBrw:bSkip:= {|nRecs| ::skipper( nRecs ) }
oBrw:bGotop:= {|| ::gotop() }
oBrw:bGoBottom:= {|| ::goBottom() }
oBrw:bBookMark := {| n | iif( n == nil, ::RecNo() , ::Goto( n ) ) }
oMeter:= self
ACTIVATE DIALOG oDlg ON INIT (oBrw:SetSize( 1000, 600 ), BuildButtons( oMeter,oBrw,oDlg),oBrw:Refresh(.t.), oDlg:Refresh(.t.))
RETURN nil
//---------------------------------------------------------------------------//
function BuildButtons(oMeter, oBrw, oDlg)
*--------------------------------------------------
@ 34, 1 BUTTON "&New" OF oDlg SIZE 60, 20 ACTION ( oMeter:add(oBrw),oBrw:refresh(),oDlg:update())
@ 34, 15 BUTTON "&Modify" OF oDlg SIZE 60, 20 ACTION ( oMeter:edit(oBrw),oBrw:refresh(),oDlg:update())
@ 34, 30 BUTTON "&Delete" OF oDlg SIZE 60, 20 ACTION ( oMeter:delete(oBrw,oDlg),oBrw:refresh(),oDlg:update())
@ 34,45 BUTTON "&Search" OF oDlg SIZE 60, 20 //ACTION addmete( oBrw , oDlg )
@ 34,60 BUTTON "&Print" OF oDlg SIZE 60, 20 //ACTION oDlg:Report ( "meter reads Report", .t. )
@ 36, 1 BUTTON "&Order" OF oDlg SIZE 60, 20//ACTION ordercust(oLbx) SIZE 40, 12
@ 36, 15 BUTTON "&Filter" OF oDlg SIZE 60, 20//ACTION filtercust(oLbx) SIZE 40, 12
@ 36, 30 BUTTON "&Unfilter" OF oDlg SIZE 60, 20//ACTION Nonfiltercust(oLbx) SIZE 40, 12
@ 36, 45 BUTTON "&Exit" OF oDlg SIZE 60, 20 //ACTION oDlg:End() SIZE 40, 12
return nil
method add(oBrw)
::lAdd:=.t.
::edit(oBrw)
::load() // in case they cancel
::lAdd:=.f.
::GOTOP()
return self
//---------------------------------------------------------------------------//
method edit(oBrw)
local oDlg,oBtnNew
local ometer:= TRecord():new( self )
if ::lAdd
ometer:blank()
endif
DEFINE DIALOG oDlg FROM 8, 2 TO 600, 700 PIXEL ;
TITLE if(::lAdd,"Untitled","Update")
@ 1,2 SAY "&Serial" OF oDlg PIXEL
@ 1,50 SAY ":" OF oDlg PIXEL
@ 1,60 GET ometer:me_mc_serl OF oDlg PIXEL UPDATE
@ 15,1 SAY "&Meter date" OF oDlg PIXEL
@ 15,50 SAY ":" OF oDlg PIXEL
@ 15,60 GET ometer:me_date pict ("99/99/9999") OF oDlg PIXEL UPDATE
@ 280, 10 BUTTON oBtnNew PROMPT "&Save" OF oDlg PIXEL SIZE 30, 12 ;
ACTION ( ometer:save(), oDlg:end() )
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( oBrw:Refresh(), oDlg:Update() )
ometer:end()
oDlg:update()
return self
//---------------------------------------------------------------------------//
method _delete(oBrw,oDlg)
if msgYesNo("Delete this record?")
super:delete()
endif
return self
//---------------------------------------------------------------------------//