Marc,
OK, I see, you were just trying to update the DBF/DBT file structure to the current format.
I will be interested to hear how your conversion from TSBrowse to XBrowse goes.
James
DATABASE oDbfklant
REDEFINE GET oDbfklant:Naam_1 ID 110 OF oDlg UPDATE on change oBtn1:enable()
REDEFINE GET oDbfklant:Naam_2 ID 120 OF oDlg UPDATE on change oBtn1:enable()
REDEFINE GET oDbfklant:Straat ID 130 OF oDlg UPDATE on change oBtn1:enable()
REDEFINE GET oDbfklant:Postcode ID 140 OF oDlg UPDATE on change oBtn1:enable()
REDEFINE GET oDbfklant:Gemeente ID 150 OF oDlg UPDATE on change oBtn1:enable()
REDEFINE GET oDbfklant:Tel_nr ID 160 OF oDlg UPDATE on change oBtn1:enable()
REDEFINE GET oDbfklant:Fax_nr ID 170 OF oDlg UPDATE on change oBtn1:enable()
///.....
//and for saving
function endklant(oDbfklant,oDlg)
if oDbfklant:modified()
if msgyesno("Gewijzigde gegevens bewaren")
oDbfklant:save()
If !dial->(dbseek(oDbfklant:tel_nr))
dial->(dbappend())
dial->tel = TrimTelFax(oDbfklant:tel_nr)
dial->firma = oDbfklant:naam_1
dial->code = oDbfklant:klant_nr
dial->type = "K"
dial->toestel = "T"
endif
If !dial->(dbseek(oDbfklant:fax_nr))
dial->(dbappend())
dial->tel = TrimTelFax(oDbfklant:fax_nr)
dial->firma = oDbfklant:naam_1
dial->code = oDbfklant:klant_nr
dial->type = "K"
dial->toestel = "F"
endif
endif
endif
return(.t.)
The code for changing the oDbfklant:tel_nr and oDbfklant:fax_nr could be changed into a new method from the save()
Class TKants from TDatabase
Method New()
Method Save()
Endclass
Method New()
...
Return Self
Method Save() Class TKants
::super:save() // call the parent save method
// add code to save phone numbers
// add code to save fax numbers
Return nil
if msgyesno("Gewijzigde gegevens bewaren")
...
endif
oCustomer:=TCustomer():New(cCustNo)
oEditCustomer:=TEditCustomer():New()
oEditCustomer:edit(oCustomer)
Class MyBrowse from Xbrowse
Method New()
Method XB_Save()
Endclass
Method xB_save() Class MyBrowse
::super:save() // call the parent save method from xbrowse and let Xbrowse do all it normaly does.
// add code to save phone numbers
// add code to save fax numbers
Return nil
Method New() Class TKlants
::super():New(,"klant") // or whatever the filename is
::use()
::load()
Return self
Method Save() Class TKlants
msgInfo("Save method called")
Return nil
oKlants := TKlants():New()
@ 0, 0 XBROWSE oBrw OF oWnd OBJECT oKlants
...
function GetMail()
local oInMail
oWnd:SetMsg( "Geting Internet email..." )
oInMail = TPop3():New( "MycIp",110,"MyAccount", "MyPaswoord" ) // mail server IP
oInMail:lHeaderOnly:=.T.
oInMail:lDelMsgs := .F.
oInMail:bConnecting = { || oWnd:SetMsg( "Connecting to 194.224.203.2..." ) }
oInMail:bConnected = { || oWnd:SetMsg( "Connected" ) }
oInMail:bDone = { || ReadEmails( oInMail ) }
oInMail:GetMail()
return nil
//----------------------------------------------------------------------------//
function ReadEmails( oInMail )
local n
MsgInfo( "Total emails: " + Str( Len( oInMail:aMsgs ) ) )
for n = 1 to Len( oInMail:aMsgs )
MsgInfo( oInMail:aMsgs[ n ] )
next
return nil
//----------------------------------------------------------------------------//
/*
Purpose : Customer class
Program : TKlants.prg
Author : James Bott
Date : 07/20/2017 10:09:18 AM
Company : Intellitech
Copyright:
Language : Fivewin/xHarbour
Updated :
Notes : For Marc Venken
*/
#include "fivewin.ch"
Function Main()
Local oKlants
Field klant_nr, naam_1
REQUEST DBFCDX
rddsetdefault( "DBFCDX" )
SET(_SET_AUTOPEN, .T. )
SET EXCLUSIVE OFF
// Test only
use Klant
index on klant_nr tag "klant_nr" to klant
index on naam_1 tag "naam_1" to klant
use
// End test
oKlants:= TKlants():New()
msgInfo( oKlants:naam_1, "Naam_1")
oKlants:end()
Return nil
//---------------------------------------------------------------------------//
// Customers database class
// Question, do the phone and fax numbers need to be loaded from the dial database?
// If so then a Load() method will also be needed.
Class TKlants from TDatabase
Data oDial
Method New()
Method Save()
Method TrimTelFax()
Method End()
endclass
Method New() Class TKlants
::super:new(,"klant")
::use()
::setOrder(1) // primary key index
::oDial:= TDial():New()
//::oDail:setOrder( ? ) // phone number index
Return Self
// Function endKlant made into TKlants:save() method
Method Save() Class TKlants
::super:save()
If ! ::oDial:seek(::tel_nr)
::oDial:append()
::oDial:tel = ::TrimTelFax(::tel_nr)
::oDial:firma = ::naam_1
::oDial:code = ::klant_nr
::oDial:type = "K"
::oDial:toestel = "T"
::oDial:save()
endif
If ! ::oDial:seek(::fax_nr)
::oDial:append()
::oDial:tel := ::TrimTelFax(::fax_nr)
::oDial:firma = ::naam_1
::oDial:code = ::klant_nr
::oDial:type = "K"
::oDial:toestel = "F"
::oDial:save()
endif
Return nil
Method End() Class TKlants
::oDial:close()
::super:close() // Because TDatabase doesn't have an End method
Return nil
Method TrimTelFax(cNumber) Class TKlants
// cNumber := ?
return cNumber
//---------------------------------------------------------------------------//
Class TDial from TDatabase
Method New()
Endclass
Method New() Class TDial
::super():New(,"dial")
::use()
//::setOrder( ? ) // the primary key index
Return self
//---------------------------------------------------------------------------//
// EOF
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 67 guests