master/detail

Hi guys

1)
I'm "fighting" with a triple master/detail stuff and would like you to point me and help me with:
I've these entities
Company -> Orders -> Products
How should I links these 3 entities, talking about primary keys, foreign keys, etc. so i build a tri master/detail stuff (hope this to be the name for this kind of relation) ?

2)
after 1) how could I build a report, using 4 eg. FastReport, and how could I load data into report @ runtime, and not designtime, coz I'd build data using queries...

I just need a quick and easy approach, so I can learn to manage this... just that...

Hope you've understood my idea and hope your help...

Thanks a lot in advance.

Comments

  • dschuchdschuch Dresden,Germany
    edited 12:21PM
    look in demos in fr3 source path. They will awnser your questions.
  • edited 12:21PM
    Yea I see the demo, but I need add data to report in runtime, the demo uses BDE.

    Thz ;)
  • dschuchdschuch Dresden,Germany
    edited 12:21PM
    And what kind of data-components do you use? ADO? So you want do get data in depened from values of the report?
  • edited 12:21PM
    I use nexusdb, and in run time I need to be arming the form, but not like doing it.
    I saw demo, but it is not what I need.

    I need an example the code to fill with data the form in run time. I already have armed to the report with details and subdetails.

    I hope that you understand to me, and thanks to respond
  • dschuchdschuch Dresden,Germany
    edited 12:21PM
    Hm not really.

    in my app i had 2 problems:
    1) i need data in depends from Values of fields. So i wrote a Own functions named
    SQL_PREPARE(SQLSTRING : String);
    SQL_OPEN;
    SQL_GETFIELD(FIELDNAME : String);

    I call this funciton from inside my report and let Delphi open a query with sqlstring (1 st and 2 nd function), and let delphi return the value of the field called "FieldName" (3 nd function)

    2) my Databindings aren't hardcoded so i create my datasets at runtime. To link them to FR i create TfrxDBDataSet at runtime too, set DataSet to my runtimedataset and use
    frxReport1.DataSets.Add(Components AS TfrxDBDataSet)
    to publish them to FR.

    Perhaps i awnsered some of your problems but i cant understand you really. Or which form do you want to fill with runtimedata?
  • edited 12:21PM
    thanks to respond to me well.
    but it seems to me that we are not speaking of the same.
    if you have a time I tell you as it is the problem:

    1) I must show a report in this order with: (the leaf of the report already this ok)
    MASTERDATA
    |-- custmers.company
    DETAILDATA
    |-- Order No
    SUBDETAILDATA
    |-- Item.Part Item.Name Item.Price Item.Qty

    (FastReport 3 brings one demo of something asi but with full data bases BDE already loaded and of data.)

    2) everything in run time, and data base nexusdb.
    1) SQL_QUERY(select customers_id, customers_company from customers)
    2) SQL_QUERY(select orders_idsale from orders where orders_idcustomers = customers_id group by orders_idsale)
    3) SQL_QUERY(select item.cod, item.name, item.price, item.qty from item where item_norders = orders_idsale)

    Now I while in run time I am reading the results of the SQL_QUERY, and need to be filling the report soon to be shown.

    I wait for you understand my problem to me since for my he is very complicated.
    and sotty by my ingles translated in google.
    thz
  • dschuchdschuch Dresden,Germany
    edited 12:21PM
    Yea but where is the problem?

    You need a
    MasterData - Band,
    DetailData - Band and a
    SubDetailData - Band.

    Assign the correct DataSet to each Band. You can create your Query components at designtime in Delphi and link them with TfrxDBDataSet to FR. So you have you DataSets in the DataTree and use them.

    You need to use DataSource/MasterSource to link your querys. Read the documentation and see the source code of the examples.

    Daniel.
  • edited 12:21PM
    thz daniel, for you help. ;)

    I can data pass ok!! thz

    but I need something like this example:
        DBmodule.db.nxQuery.SQL.Clear;
        DBmodule.db.nxQuery.SQL.Add(
             'select ventas.venta_idclientectacte, clientes.client_razon, clientes.client_titular '
            +'from ventas, clientes '
            +'where clientes.client_id=ventas.venta_idclientectacte '
            +'group by venta_idclientectacte, clientes.client_razon, clientes.client_titular'
            );
        DBmodule.db.nxQuery.Open;
    
        for x:=0 to DBmodule.db.nxQuery.RecordCount - 1 do
        begin
    
            {*** Listado de productos del cliente ***}
            DBmodule.db.nxQuery2.SQL.Clear;
            DBmodule.db.nxQuery2.SQL.Add('select * from ventas where venta_idclientectacte=:IDCLIENTE');
            DBmodule.db.nxQuery2.ParamByName('IDCLIENTE').AsInteger := DBmodule.db.nxQuery.fieldbyname('venta_idclientectacte').AsInteger;
            DBmodule.db.nxQuery2.Open;
    
            for y:=0 to DBmodule.db.nxQuery2.RecordCount - 1 do
            begin
                DBmodule.db.nxQuery2.Next;
            end;
    
            DBmodule.db.nxQuery2.Close;
            {*** Fin Listado de productos del cliente ***}
    
            DBmodule.db.nxQuery.Next;
        end;
        DBmodule.db.nxQuery.Close;
    
        rep_ctacte.ShowReport(true);
    

    the first SQL works well, the second also works ok, but in the report it shows the data of last nxQuery2.

    I hope you understand to me, thanks

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.