3 databases 3 tabs 3 grids

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

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,
I hope this can be useful for you. I've not used array to simulate a dbf seeking.
Best regards

Code: Select all

#include "hmg.ch"

FUNCTION main()

 p000_FrmDefine()

 ACTIVATE WINDOW ALL

RETURN NIL

/***********************************************************
* definizione main form
***********************************************************/
STATIC FUNCTION p000_FrmDefine()

 LOCAL aGcol1 := { "TEXTBOX", "CHARACTER"}
 LOCAL aGcol3 := { "TEXTBOX", "NUMERIC", "99,999,999" }

 LOCAL aGr1Head := { "CusCode","CusDescription" }
 LOCAL aGr1Widt := { 100, 200 }
 LOCAL aGr1Cols := { aGcol1, aGcol1 }
 LOCAL aGr1Just := { GRID_JTFY_LEFT, GRID_JTFY_LEFT }

 LOCAL aGr2Head := { "CusCode", "InvCode","Amount" }
 LOCAL aGr2Widt := { 100, 100, 200 }
 LOCAL aGr2Cols := { aGcol1, aGcol1, aGcol3 }
 LOCAL aGr2Just := { GRID_JTFY_LEFT, GRID_JTFY_LEFT, GRID_JTFY_LEFT }

 LOCAL aGr3Head := { "CusCode", "InvCode", "Detail", "Amount" }
 LOCAL aGr3Widt := { 100, 100, 100, 200 }
 LOCAL aGr3Cols := { aGcol1, aGcol1, aGcol1, aGcol3 }
 LOCAL aGr3Just := { GRID_JTFY_LEFT, GRID_JTFY_LEFT, GRID_JTFY_LEFT, GRID_JTFY_LEFT }

 SET NAVIGATION EXTENDED
 DEFINE WINDOW p000Frm ;
  ROW 0 ;
  COL 0 ;
  WIDTH 860 ;
  HEIGHT 645 ;
  WINDOWTYPE MAIN ;
  TITLE "3 grids" ;
  ON INIT p000_OnInit()

  DEFINE MAIN MENU
   DEFINE POPUP '&File'
    MENUITEM 'e&Xit' ACTION p000_Exit()
   END POPUP
  END MENU

 DEFINE GRID grid1
  ROW 10
  COL 60
  WIDTH 500
  HEIGHT 100
  ONDBLCLICK MsgInfo( "You can do something on Grid1" )
  ONCHANGE LoadGrd2()
  HEADERS aGr1Head
  WIDTHS aGr1Widt
  COLUMNCONTROLS aGr1Cols
  JUSTIFY aGr1Just
 END GRID

 DEFINE GRID grid2
  ROW 150
  COL 60
  WIDTH 500
  HEIGHT 100
  ONDBLCLICK MsgInfo( "You can do something on Grid2" )
  ONCHANGE LoadGrd3()
  HEADERS aGr2Head
  WIDTHS aGr2Widt
  COLUMNCONTROLS aGr2Cols
  JUSTIFY aGr2Just
 END GRID

 DEFINE GRID grid3
  ROW 300
  COL 60
  WIDTH 500
  HEIGHT 100
  ONDBLCLICK MsgInfo( "You can do something on Grid3" )
  HEADERS aGr3Head
  WIDTHS aGr3Widt
  COLUMNCONTROLS aGr3Cols
  JUSTIFY aGr3Just
 END GRID

 END WINDOW

RETURN NIL

/***********************************************************
* OnInit
***********************************************************/
STATIC FUNCTION p000_OnInit()

 p000Frm.Center
 LoadGrd1()

RETURN NIL

/***********************************************************
* exit
***********************************************************/
STATIC FUNCTION p000_Exit()

 ReleaseAllWindows()

RETURN NIL

/***********************************************************
* Load Data grid1
***********************************************************/
STATIC FUNCTION LoadGrd1()
 
 p000Frm.grid1.AddItem ( {"CUSID001", "Customer 001" } )
 p000Frm.grid1.AddItem ( {"CUSID002", "Customer 002" } )
 p000Frm.grid1.AddItem ( {"CUSID003", "Customer 003" } )
 p000Frm.grid1.AddItem ( {"CUSID004", "Customer 004" } )
 p000Frm.grid1.AddItem ( {"CUSID005", "Customer 005" } )

RETURN NIL

/***********************************************************
* Load Data grid2
***********************************************************/
STATIC FUNCTION LoadGrd2()

 LOCAL aTemp := {}
 
 p000Frm.grid2.DeleteAllItems
 p000Frm.grid3.DeleteAllItems

 aTemp := p000Frm.grid1.Item( p000Frm.grid1.Value )
 
 IF aTemp[1] == "CUSID001"
  p000Frm.grid2.AddItem ( {"CUSID001", "INVID011", 11 } )
  p000Frm.grid2.AddItem ( {"CUSID001", "INVID012", 12 } )
 ENDIF

 IF aTemp[1] == "CUSID002"
  p000Frm.grid2.AddItem ( {"CUSID002", "INVID023", 23 } )
 ENDIF

 IF aTemp[1] == "CUSID004"
  p000Frm.grid2.AddItem ( {"CUSID004", "INVID044", 44 } )
  p000Frm.grid2.AddItem ( {"CUSID004", "INVID045", 45 } )
 ENDIF

RETURN NIL


/***********************************************************
* Load Data grid3
***********************************************************/
STATIC FUNCTION LoadGrd3()

 LOCAL aTemp := {}
 
 p000Frm.grid3.DeleteAllItems
 aTemp := p000Frm.grid2.Item( p000Frm.grid2.Value )

 IF aTemp[1] == "CUSID001" .AND. aTemp[2] == "INVID011"
  p000Frm.grid3.AddItem ( {"CUSID001", "INVID011", "ITMID001", 1 } )
  p000Frm.grid3.AddItem ( {"CUSID001", "INVID011", "ITMID002", 2 } )
  p000Frm.grid3.AddItem ( {"CUSID001", "INVID011", "ITMID003", 3 } )
  p000Frm.grid3.AddItem ( {"CUSID001", "INVID011", "ITMID004", 4 } )
  p000Frm.grid3.AddItem ( {"CUSID001", "INVID011", "ITMID005", 5 } )
  p000Frm.grid3.AddItem ( {"CUSID001", "INVID011", "ITMID006", 6 } )
 ENDIF

 IF aTemp[1] == "CUSID001" .AND. aTemp[2] == "INVID012"
  p000Frm.grid3.AddItem ( {"CUSID001", "INVID012", "ITMID001", 1 } )
  p000Frm.grid3.AddItem ( {"CUSID001", "INVID012", "ITMID002", 2 } )
  p000Frm.grid3.AddItem ( {"CUSID001", "INVID012", "ITMID003", 3 } )
  p000Frm.grid3.AddItem ( {"CUSID001", "INVID012", "ITMID004", 4 } )
  p000Frm.grid3.AddItem ( {"CUSID001", "INVID012", "ITMID005", 5 } )
  p000Frm.grid3.AddItem ( {"CUSID001", "INVID012", "ITMID006", 6 } )
 ENDIF

 IF aTemp[1] == "CUSID002" .AND. aTemp[2] == "INVID023"
  p000Frm.grid3.AddItem ( {"CUSID002", "INVID023", "ITMID001", 1 } )
  p000Frm.grid3.AddItem ( {"CUSID002", "INVID023", "ITMID002", 2 } )
  p000Frm.grid3.AddItem ( {"CUSID002", "INVID023", "ITMID003", 3 } )
  p000Frm.grid3.AddItem ( {"CUSID002", "INVID023", "ITMID004", 4 } )
  p000Frm.grid3.AddItem ( {"CUSID002", "INVID023", "ITMID005", 5 } )
  p000Frm.grid3.AddItem ( {"CUSID002", "INVID023", "ITMID006", 6 } )
 ENDIF

 IF aTemp[1] == "CUSID004" .AND. aTemp[2] == "INVID044"
  p000Frm.grid3.AddItem ( {"CUSID004", "INVID044", "ITMID001", 1 } )
  p000Frm.grid3.AddItem ( {"CUSID004", "INVID044", "ITMID002", 2 } )
  p000Frm.grid3.AddItem ( {"CUSID004", "INVID044", "ITMID003", 3 } )
  p000Frm.grid3.AddItem ( {"CUSID004", "INVID044", "ITMID004", 4 } )
  p000Frm.grid3.AddItem ( {"CUSID004", "INVID044", "ITMID005", 5 } )
  p000Frm.grid3.AddItem ( {"CUSID004", "INVID044", "ITMID006", 6 } )
 ENDIF

 IF aTemp[1] == "CUSID004" .AND. aTemp[2] == "INVID045"
  p000Frm.grid3.AddItem ( {"CUSID004", "INVID045", "ITMID001", 1 } )
  p000Frm.grid3.AddItem ( {"CUSID004", "INVID045", "ITMID002", 2 } )
  p000Frm.grid3.AddItem ( {"CUSID004", "INVID045", "ITMID003", 3 } )
  p000Frm.grid3.AddItem ( {"CUSID004", "INVID045", "ITMID004", 4 } )
  p000Frm.grid3.AddItem ( {"CUSID004", "INVID045", "ITMID005", 5 } )
  p000Frm.grid3.AddItem ( {"CUSID004", "INVID045", "ITMID006", 6 } )
 ENDIF

RETURN NIL
Luigi from Italy
www.L3W.it
User avatar
Czarny_Pijar
Posts: 172
Joined: Thu Mar 18, 2010 11:31 pm
Location: 19.2341 E 50.2267 N

Re: 3 databases 3 tabs 3 grids

Post by Czarny_Pijar »

rathinagiri wrote:The filter is set. But it is not properly refreshed. I don't know why!?
That's quite easy ( if yuo know about this quirk, ofcourse ;) ) - the filtered database has to be indexed, and this fact is nowhere documented :geek: . This behaviour was present also in the original Clipper, so here the Harbour is better than we can imagine, in terms of backward compatibility :lol:

What's more important, after yours corrections the error disappeared, :!: so I can proceed, thx rathinagiri!
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: 3 databases 3 tabs 3 grids

Post by Rathinagiri »

Oh, that would be so nice. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
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
and this one is made with dbf and (of course) index files.
Best regards
Attachments
app000.zip
source
(2.08 KiB) Downloaded 369 times
Luigi from Italy
www.L3W.it
mexicanto

Re: 3 databases 3 tabs 3 grids

Post by mexicanto »

thank you luigi

is it possible to send me the .dbf and the index files too ?
or publish it here in a zip file ?

thanks again

daniel
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,
files are created when you run the program.
Luigi from Italy
www.L3W.it
mexicanto

Re: 3 databases 3 tabs 3 grids

Post by mexicanto »

ah, thank you !!!

i just check the other program, with the arrays

is working !!

luigi, you are the man !!

thanks
User avatar
Czarny_Pijar
Posts: 172
Joined: Thu Mar 18, 2010 11:31 pm
Location: 19.2341 E 50.2267 N

Re: 3 databases 3 tabs 3 grids

Post by Czarny_Pijar »

Here is the another version of the promised program, this time the IDE version (it's my default style of programming, very often found here). Good luck :)
Attachments
3b_grids_customer_order_detail.zip
(3.5 KiB) Downloaded 325 times
mexicanto

Re: 3 databases 3 tabs 3 grids

Post by mexicanto »

thanks czany

i think most of the programs for business is based in this example

client - invoice- detail

department-employee-worked hours

grandparent account - father account - child account

and more examples i can imagine

so thank you very very much for all your help

and i belive i am speaking for other beginner users like me when i say tank you guys

daniel

if somebody have the time, and want to do it, i will apreciatte if you can publish a more complex program, with a toolbar or buttons with "first - preview - next - last -- add - del - modify -- seek -- report" or so, with both, dbf itself and the array

it could be user as a template for many many programs (i promise to leave the author (you) in the first line as a tribute for that help, and i think that could be used for many other novice hmg user

i even recomend to put it in the "samples" directory together with the hmg setup

it is mho
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: 3 databases 3 tabs 3 grids

Post by Rathinagiri »

Great idea. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply