Add seven new instance variables to your class.
I am going to make up just two for this explaination.
You will also need to override the load(), save(), and blank() methods of the parent TData class.
class TCustomer
DATA active
DATA approved
method load()
method save()
method blank()
...
endclass
You may want to initialize them in the new method:
method new() class TCustomer
::active:=.t.
::approved:=.f.
...
return self
And also in your blank() method.
method blank() class TCustomer
super:blank()
::active:=.t.
::approved:=.f.
return self
Then in your load method
method load() class TCustomer
super():load()
if substr(::ehrungjahr,1,1)="1"
::active:=.t.
else
::active:=.f.
endif
if substr(::ehrungjahr,2,1)="1"
::approved:=.t.
else
::approved:=.f.
endif
endif
return self
And in the edit () method you treat them just the same as fieldnames:
REDEFINE CHECKBOX oEhre1 VAR ::active ID 401 OF oFld:aDialogs [ 5 ]
REDEFINE CHECKBOX oEhre2 VAR ::approved ID 402 OF oFld:aDialogs [ 5 ]
Then in your save() method you convert them back to the legacy database:
method save() class TCustomer()
::ehrungjahr = stuff( ::ehrungjahr,1,1, if( ::active, "1", "0" ) )
::ehrungjahr = stuff( ::ehrungjahr,2,1, if( ::approved, "1", "0" ) )
::super():save()
return self
Now, converting from 1/0 to logical and back is all transparent.
You can use the new logical instance variables just as you would regular fields.
oCustomer:= TCustomer():new()
msgInfo( oCustomer:active )
oCustomer:active:=.f.
oCustomer:save()
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: nageswaragunupudi, Willi Quintana and 83 guests