Board index » delphi » Hard to design a Master/Details interface...

Hard to design a Master/Details interface...

Hi everyone,

I find that my basic knowledge is not very strong in database field.
How to say that? Recently, I help my friend to develop a very simple
program. Just maintain two tables, one as master and one as details.
And the back-end database uses Interbase 6 and using InterbaseExpress
to access it from Delphi.

I found that it is hard to get the Auto-increment primary key from the
Master table just after insert a record to it. The auto-inc method uses
Trigger & Generator database object to do that. I think it is most
likely
in Oracle, right?

Ok, so in Delphi. I must use TIBStoredProc to do insertion instead
of TIBTable. I tried to set TField.AutoInc property but seems not
work. For example, I can't do this:
      taMaster.Post;
      NewID := taMaster.FieldByName('NewID').AsInteger;

You know that. If I can't retrieve the approprate Primary Key, I
can't carry it to the Foreign Key into Details table. No matter how
I set MasterSource to link up both tables, still failed.

Another problem is, I must frequently enable/disable the window
controls from the screen interface. Let say in the browsing mode,
Add Record button, Edit Record button and Delete Record
button all should be available(enabled). But when the table is under
appending or editing mode, all three buttons should be locked(disabled).

And also, a lot of window control is binded for Details table. The
these control must be switch on and off to cope with the difference
mode of the Master table.

Do you know my bad situation? Isn't it I miss some database concept
to handle all of these?

Thank you very much.

--
Best regards,
Diviner.

 

Re:Hard to design a Master/Details interface...


"Diviner" <divi...@hknet.com> schrieb im Newsbeitrag
news:3AF2C4FD.F9652F42@hknet.com...

Quote
> Hi everyone,

> I find that my basic knowledge is not very strong in database field.
> How to say that? Recently, I help my friend to develop a very simple
> program. Just maintain two tables, one as master and one as details.
> And the back-end database uses Interbase 6 and using InterbaseExpress
> to access it from Delphi.

> I found that it is hard to get the Auto-increment primary key from the
> Master table just after insert a record to it. The auto-inc method uses
> Trigger & Generator database object to do that. I think it is most
> likely
> in Oracle, right?

> Ok, so in Delphi. I must use TIBStoredProc to do insertion instead
> of TIBTable. I tried to set TField.AutoInc property but seems not
> work. For example, I can't do this:
>       taMaster.Post;
>       NewID := taMaster.FieldByName('NewID').AsInteger;

> You know that. If I can't retrieve the approprate Primary Key, I
> can't carry it to the Foreign Key into Details table. No matter how
> I set MasterSource to link up both tables, still failed.

Have a look at the Generator Property of IBDataset/IBQuery and you'll find
the solution!

Quote
> Another problem is, I must frequently enable/disable the window
> controls from the screen interface. Let say in the browsing mode,
> Add Record button, Edit Record button and Delete Record
> button all should be available(enabled). But when the table is under
> appending or editing mode, all three buttons should be locked(disabled).

Use an TActionList for the append-edit-delete tasks and enable/disable them
in
the ActionList OnUpdate-event according to the dataset's state (eg,
actionDeleteRec.Enabled := Dataset.State = dsBrowse)

Quote
> And also, a lot of window control is binded for Details table. The
> these control must be switch on and off to cope with the difference
> mode of the Master table.

again, set the enabled property within ActionList OnUpdate-event.

Quote
> Do you know my bad situation? Isn't it I miss some database concept
> to handle all of these?

> Thank you very much.

regards, clemens

- Show quoted text -

Quote
> --
> Best regards,
> Diviner.

Re:Hard to design a Master/Details interface...


Quote
> "Diviner" <divi...@hknet.com> schrieb im Newsbeitrag
> news:3AF2C4FD.F9652F42@hknet.com...
> > Hi everyone,

> > I find that my basic knowledge is not very strong in database field.
> > How to say that? Recently, I help my friend to develop a very simple
> > program. Just maintain two tables, one as master and one as details.
> > And the back-end database uses Interbase 6 and using InterbaseExpress
> > to access it from Delphi.

> > I found that it is hard to get the Auto-increment primary key from the
> > Master table just after insert a record to it. The auto-inc method uses
> > Trigger & Generator database object to do that. I think it is most
> > likely
> > in Oracle, right?

> > Ok, so in Delphi. I must use TIBStoredProc to do insertion instead
> > of TIBTable. I tried to set TField.AutoInc property but seems not
> > work. For example, I can't do this:
> >       taMaster.Post;
> >       NewID := taMaster.FieldByName('NewID').AsInteger;

> > You know that. If I can't retrieve the approprate Primary Key, I
> > can't carry it to the Foreign Key into Details table. No matter how
> > I set MasterSource to link up both tables, still failed.

> Have a look at the Generator Property of IBDataset/IBQuery and you'll find
> the solution!

I can't find Generator property inside both IBDataset/IBQuery. My
InterbaseExpress is version 4.52. Is it something wrong here?

Quote

> > Another problem is, I must frequently enable/disable the window
> > controls from the screen interface. Let say in the browsing mode,
> > Add Record button, Edit Record button and Delete Record
> > button all should be available(enabled). But when the table is under
> > appending or editing mode, all three buttons should be locked(disabled).

> Use an TActionList for the append-edit-delete tasks and enable/disable them
> in
> the ActionList OnUpdate-event according to the dataset's state (eg,
> actionDeleteRec.Enabled := Dataset.State = dsBrowse)

Thank you. Let me study here.

- Show quoted text -

Quote
> > And also, a lot of window control is binded for Details table. The
> > these control must be switch on and off to cope with the difference
> > mode of the Master table.

> again, set the enabled property within ActionList OnUpdate-event.

> > Do you know my bad situation? Isn't it I miss some database concept
> > to handle all of these?

> > Thank you very much.

> regards, clemens

> > --
> > Best regards,
> > Diviner.

Re:Hard to design a Master/Details interface...


Quote
Diviner wrote:

> I can't find Generator property inside both IBDataset/IBQuery. My
> InterbaseExpress is version 4.52. Is it something wrong here?

Right click on the IBDataSet and see what version you really have.
GeneratorField was introduced in IBX 4.4.

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
Anyone who cannot cope with mathematics is not fully human.
At best he is a tolerable subhuman who has learned to wear
shoes, bathe and not make messes in the house.   (Heinlein)

Re:Hard to design a Master/Details interface...


I found the property now. But I can't find its document from help file.
Would you tell me the related document? And also, I hope to get a
ActiveList sample program and related document. Would you introduce
to me?
Quote
> Diviner wrote:

> > I can't find Generator property inside both IBDataset/IBQuery. My
> > InterbaseExpress is version 4.52. Is it something wrong here?

> Right click on the IBDataSet and see what version you really have.
> GeneratorField was introduced in IBX 4.4.

> --
> Jeff Overcash (TeamB)
>       (Please do not email me directly unless  asked. Thank You)
> Anyone who cannot cope with mathematics is not fully human.
> At best he is a tolerable subhuman who has learned to wear
> shoes, bathe and not make messes in the house.   (Heinlein)

Re:Hard to design a Master/Details interface...


Quote
Diviner wrote:

> I found the property now. But I can't find its document from help file.
> Would you tell me the related document?

Get the 4.4 readme from CodeCentral.

Quote
> And also, I hope to get a
> ActiveList sample program and related document. Would you introduce
> to me?

I'm not certain what you are asking here.  What is a ActiveList?

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
Anyone who cannot cope with mathematics is not fully human.
At best he is a tolerable subhuman who has learned to wear
shoes, bathe and not make messes in the house.   (Heinlein)

Other Threads