3 databases 3 tabs 3 grids

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

mexicanto

3 databases 3 tabs 3 grids

Post by mexicanto »

a very beginner questions

1st database : customers.dbf
fields : cus_num , c , 6 number of the customer
cus_nam , c , 30 name of the customer

2nd database : invoices.dbf
inv_num , c , 6 number of the invoice
inv_cus , c , 6 customer number of the invoice
inv_dat , n , 9.2 date of the invoice

3rd database detail.dbf
det_inv , c , 6 number of the invoice
det_pro , c , 30 name of the product
det_qty , n , 3 quantity of the product
det_pri , n , 6.2 price of the product

first tab
a grid with the customers, where you can select a customer to see or add

second tab
a grid showing only the invoices that belongs to the customer selected in the first grid, to select or add a invoice

third tab
a grid showing only the detail of the invoice selected in the second grid, where you can add or delete items

how can i only show the information that i need in the grids ??

thank you very very much for your help
mexicanto

Re: 3 databases 3 tabs 3 grids

Post by mexicanto »

an addendum

i forgot to clarify, how can i do this example without an array

thats mean working with direct to the dbf

thabks again
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: 3 databases 3 tabs 3 grids

Post by l3whmg »

Hello Mexicanto,
I believe that the solution is through the use of the ONDBLCLICK event from GRID control.
I will use pseudo-code to explain my solution.
Three grid named: CustomerGrid , InvoiceGrid , DetailGrid

1) When you show the form:
clean DetailGrid
clean InvoiceGrid
clean CustomerGrid and load all customers

2) When the user fire on the ONDBLCLICK event on CustomerGrid:
load InvoiceGrid with selected customer

3) When the user fire on the ONDBLCLICK event on InvoiceGrid:
load DetailGrid with selected invoice

4) When the user fire on the ONDBLCLICK event on DetailGrid:
Insert/Edit/Delete a row

A) to add or modify Customer or Invoice you can use specific button for every one grid
B) You must have a specific button to clear all grids
C) You can't use ONDBLCLICK for other actions
D) Moving the cursor over the grid CutomerGrid and InvoiceGrid, you should realign accordingly the subsequent otherwise you would see different data :o

IMHO this solution is difficult to handle both the end user and (especially) the programmer.
Personally, I would select the Customer in a form (in this way you could have also the ability to add / edit customer), I would select the Invoice in another form (in this way you could have also the ability to add / edit invoices) and finally I would select the Detail in another form. In this way, I could better handle the various scenarios. It's like previous, but I think you will have advantages.

Best regards
Luigi from Italy
www.L3W.it
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: 3 databases 3 tabs 3 grids

Post by mrduck »

l3whmg wrote: 2) When the user fire on the ONDBLCLICK event on CustomerGrid:
load InvoiceGrid with selected customer
and clean the DetailGrid
D) Moving the cursor over the grid CutomerGrid and InvoiceGrid, you should realign accordingly the subsequent otherwise you would see different data :o
Infact, to me you shouldn't use double-click but the single click AND cursor up/down in the grid, otherwise you can move the selected line in clientGrid but data in other grids belong to the old client....
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: 3 databases 3 tabs 3 grids

Post by l3whmg »

Hi Mrduck,
Infact, to me you shouldn't use double-click but the single click AND cursor up/down in the grid
I don't remember about ONCLICK event for a GRID. I know: "ONGOTFOCUS, ONCHANGE, ONLOSTFOCUS, ONDBLCLICK, ONHEADCLICK, ONQUERYDATA, ONSAVE".
Can you give me more detail, please, I'm very interested.
Best regards
Luigi from Italy
www.L3W.it
mexicanto

Re: 3 databases 3 tabs 3 grids

Post by mexicanto »

thank you very much for your interest

let me explained myself in better way

if i select a customer, how can i only load the invoices for that customer
in the invoices grid ??
i see a sample in PEDIDOS, but it is working with arrays

is there a way to working directly with the dbf ??
like a rowset ?? or a filter ?? "Set filter to" ?? maybe ?


thanks again
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: 3 databases 3 tabs 3 grids

Post by mrduck »

Sorry, ONCLICK -> ONCHANGE
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: 3 databases 3 tabs 3 grids

Post by l3whmg »

Hi Mexicanto,
there are different way: filter or index; I don't like very mutch filter I prefer index.

The most simple example is:

Code: Select all

invoices->(DBGOTOP())
DO WHILE !invoices->(EOF())
 IF invoices->inv_cus == customers->cus_num
  LoadDataIntoGrid
 ENDIF
 invoices->(DBSKIP(+1))
ENDDO
If you have an index on invoices

Code: Select all

invoices->(DBSEEK(customers->cus_num, .T.))
DO WHILE !invoices->(EOF()) .AND. invoices->inv_cus == customers->cus_num
  LoadDataIntoGrid
 invoices->(DBSKIP(+1))
ENDDO
Ciao
Luigi from Italy
www.L3W.it
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: 3 databases 3 tabs 3 grids

Post by l3whmg »

Hi Mrduck,
can you give me a little example? Because I have some troubles with ONCHANGE

Ciao
Luigi from Italy
www.L3W.it
mexicanto

Re: 3 databases 3 tabs 3 grids

Post by mexicanto »

ciao luigy

whe you say "LoadDataintoGrid"
are you talking about load data into an array for the grid ??
bucause i wanto to show just the record on the criteria
but not an array, instead the DBF itself

is that possible ?

thank you very much again
Post Reply