RE: TZF - Primary Index

[email protected] Sat, 17 Jan 2004 10:19:39 -0600
Newsgroups gmane.comp.lang.delphi.topaz
Message-ID <[email protected]>
-----Original Message-----
From: B. Evers [mailto:[email protected]]
Sent: Saturday, January 17, 2004 8:07 AM
To: [email protected]
Subject: Re: TZF - Primary Index


Jodell,

----- Original Message -----
From: "Jodell Bumatai" <[email protected]>
To: <[email protected]>
Sent: Saturday, January 17, 2004 1:51 AM
Subject: TZF - Primary Index


> Hello,
>
> I am new to Topaz: I bought the SSI VCL to re-use .dbf files.  I would
> like to have .dbf files for end-users and also be able to use the same
> file format on a dBase/BDE server. The end-users do not need to be
> clients. Only a few end-users would exchange the .dbf files to the
> dBase/BDE server. But those files will be sent out, available, to the
> end-users. So, I need a file that is readable by both local and by a
> remote server.
>
> My first issue is setting a Primary Key Field. I have a Field called
> AccountID but I want it to Autoincrement and I cannot find a SSI
> Increment for a Table Field so I am suspecting I have to write one. but
> ar there any samples/examples?
>

Hello,

In times past, I have stored the data path in an ini file which would be
differenet on each machine depending upon how the drive was mapped to the
"server". This way the same exe can live on each machine and all machines
will look to the same data files. Be sure to use Topaz locking devices
ALock, RLock, FLock and Unlock.

During its OnCreate event of the MainForm, it reads the ini file and fills a
global variable of the MainForm called DataPathVar. During the OnCreate
event of the datamodule, which is the second object created (after
MainForm), I assign all of the dbfFileName properties of each dataset.'

with tzMembersTbl
do begin
   DbfFileName := FrmMainForm.DatapathVar + 'Member.DBF';
   Active := False;
   end;
with tzDependTbl
do begin
   DbfFileName := FrmMainForm.DataPathVar + 'Depend.DBF';
   Active := False;
   end;
(I choose to open and close dbf files as needed rather than to have them
open for the duration of the program execution).

With reagard to auto incrementing numbers, I have always written the code to
handle it, so I don't know if there are any components written to do so. I
will again either use an ini file to keep track of the numbers but I prefer
to store them in a utility type dbf file. This file will only have one
record in it that is modified as the user enters and deletes data. I don't
like to use the dbNavigators and have created my own buttons that do
everything the navagator does but I can control every small aspect of the
buttons plus its a personal thing that I don't like the look of the
navagator bars.

I also keep a boolean variable of the form called IsNewRec. If the user
pushes the Add button, IsNewRec is set to true and if the user presses the
Edit button IsNewRec is set to False. When the user hits the post or cancel
buttons, I take the appropriate action according to the value of IsNewRec.
if IsNewRec //Is just now being added
then begin
     --------
     end
else begin //Is existing and has been modified
     --------
     end;

Besure to "undo" any changes to incremented values if the user "cancels" the
add or edit.

Hope this helps.

JWise

--^----------------------------------------------------------------
This email was sent to: [email protected]

EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt
Or send an email to: [email protected]

TOPICA - Start your own email discussion group. FREE!
http://www.topica.com/partner/tag02/create/index2.html
--^----------------------------------------------------------------