Page 3 of 5

Re: 3 databases 3 tabs 3 grids

Posted: Tue Nov 09, 2010 10:25 am
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

Re: 3 databases 3 tabs 3 grids

Posted: Tue Nov 09, 2010 11:39 am
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!

Re: 3 databases 3 tabs 3 grids

Posted: Tue Nov 09, 2010 12:34 pm
by Rathinagiri
Oh, that would be so nice. :)

Re: 3 databases 3 tabs 3 grids

Posted: Tue Nov 09, 2010 1:40 pm
by l3whmg
Hi Mexicanto
and this one is made with dbf and (of course) index files.
Best regards

Re: 3 databases 3 tabs 3 grids

Posted: Tue Nov 09, 2010 6:08 pm
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

Re: 3 databases 3 tabs 3 grids

Posted: Tue Nov 09, 2010 6:11 pm
by l3whmg
Hi Mexicanto,
files are created when you run the program.

Re: 3 databases 3 tabs 3 grids

Posted: Tue Nov 09, 2010 6:20 pm
by mexicanto
ah, thank you !!!

i just check the other program, with the arrays

is working !!

luigi, you are the man !!

thanks

Re: 3 databases 3 tabs 3 grids

Posted: Tue Nov 09, 2010 8:19 pm
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 :)

Re: 3 databases 3 tabs 3 grids

Posted: Wed Nov 10, 2010 2:18 am
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

Re: 3 databases 3 tabs 3 grids

Posted: Wed Nov 10, 2010 3:57 am
by Rathinagiri
Great idea. :)