HMG Case
Moderator: Rathinagiri
- dragancesu
- Posts: 926
- Joined: Mon Jun 24, 2013 11:53 am
- DBs Used: DBF, MySQL, Oracle
- Location: Subotica, Serbia
HMG Case
I finally made a brief guide to the program that I want to introduce myself and that I think will help someone
Enclosed you have a program, demo data, the icon for the program and the examples mentioned in the text
Not everything is as polished as it should expect criticism and suggestions, first how to fix the generated code
This I did for myself, and see if you can use like
Enclosed you have a program, demo data, the icon for the program and the examples mentioned in the text
Not everything is as polished as it should expect criticism and suggestions, first how to fix the generated code
This I did for myself, and see if you can use like
- Attachments
-
- data.zip
- (1.93 KiB) Downloaded 589 times
-
- program.zip
- (1.05 MiB) Downloaded 660 times
Last edited by dragancesu on Wed Sep 25, 2013 11:45 am, edited 1 time in total.
- dragancesu
- Posts: 926
- Joined: Mon Jun 24, 2013 11:53 am
- DBs Used: DBF, MySQL, Oracle
- Location: Subotica, Serbia
Re: HMG Case
Just another attachment
- dragancesu
- Posts: 926
- Joined: Mon Jun 24, 2013 11:53 am
- DBs Used: DBF, MySQL, Oracle
- Location: Subotica, Serbia
Re: HMG Case
Just manual
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: HMG Case
Hi Dragandragancesu wrote:I finally made a brief guide to the program that I want to introduce myself and that I think will help someone
Enclosed you have a program, demo data, the icon for the program and the examples mentioned in the text
Not everything is as polished as it should expect criticism and suggestions, prvko how to fix the generated code
This I did for myself, and see if you can use like
FYI : Here we are share our source code and data files ( as you made ) and don't send executable files, and moreover don't run .exes came from internet in general.
Happy HMG'ing
Viva INTERNATIONAL HMG
Re: HMG Case
I agree with Esgici, HMG is OpenSource & All post should be in .prg and not in .exeesgici wrote: FYI : Here we are share our source code and data files ( as you made ) and don't send executable files, and moreover don't run .exes came from internet in general.
Happy HMG'ing
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
-
- Posts: 1275
- Joined: Tue Sep 03, 2013 4:22 am
- Location: Tecámac, México
Re: HMG Case
Hey do not be afraid to share your effort, many colleagues have mountains alongside our sand castles.
Re: HMG Case
Hi Dragan,dragancesu wrote:I finally made a brief guide to the program that I want to introduce myself and that I think will help someone
Enclosed you have a program, demo data, the icon for the program and the examples mentioned in the text
Not everything is as polished as it should expect criticism and suggestions, first how to fix the generated code
This I did for myself, and see if you can use like
It is very interesting tool
I've made the small corrections and suggestions in the generated code as below:
Code: Select all
#include <hmg.ch>
MEMVAR New_rec, _qry_exp
PROCEDURE MAIN // for test, usually edit_EMPLOYE
PUBLIC New_rec:= .F. , _qry_exp := ""
SET PROCEDURE TO Use_dbf.prg // for test
SET NAVIGATION EXTENDED
SET CENTURY ON
SET DATE GERMAN
SET DELETED ON
Use_employe() // from use_dbf.prg
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 800 ;
HEIGHT 700 ;
TITLE "Table EMPLOYE" ;
ICON "EMPLOYE.ICO" ;
MAIN // for test, usually MODAL
ON KEY ESCAPE ACTION Win_1.Release
DEFINE STATUSBAR FONT "Arial" SIZE 12
STATUSITEM "Table EMPLOYE"
KEYBOARD WIDTH 90
DATE WIDTH 100
CLOCK WIDTH 80
END STATUSBAR
DEFINE TOOLBAR ToolBar_1 BUTTONSIZE 60,40 IMAGESIZE 32,32 FLAT BORDER
BUTTON FIRST_EMPL ;
CAPTION "&First" ;
PICTURE "go_first.bmp" ;
ACTION( dbGotop(), Win_1.Browse_1.Value := RecNo() )
BUTTON PREV_EMPL ;
CAPTION "&Prev" ;
PICTURE "go_prev.bmp" ;
ACTION( dbSkip( -1 ), Win_1.Browse_1.Value := RecNo() )
BUTTON NEXT_EMPL ;
CAPTION "&Next" ;
PICTURE "go_next.bmp" ;
ACTION( dbSkip(), if ( Eof(), dbGobottom(), Nil ), Win_1.Browse_1.Value := RecNo() )
BUTTON LAST_EMPL ;
CAPTION "&Last" ;
PICTURE "go_last.bmp" ;
ACTION( dbGoBottom(), Win_1.Browse_1.Value := RecNo() ) SEPARATOR
BUTTON FIND_EMPL ;
CAPTION "F&ind" ;
PICTURE "edit_find.bmp" ;
ACTION Find_EMPL()
BUTTON NEW_EMPL ;
CAPTION "&New" ;
PICTURE "edit_new.bmp" ;
ACTION ( New_rec := .T., NewRecord_EMPL() )
BUTTON EDIT_EMPL ;
CAPTION "&Edit" ;
PICTURE "edit_edit.bmp" ;
ACTION iif ( RecordStatus_EMPL(), EnableField_EMPL(), Nil )
BUTTON DELETE_EMPL ;
CAPTION "&Delete" ;
PICTURE "edit_delete.bmp" ;
ACTION iif ( RecordStatus_EMPL(), DeleteRecord_EMPL(), Nil )
BUTTON PRINT_EMPL ;
CAPTION "P&rint" ;
PICTURE "edit_print.bmp" ;
ACTION PrintData_EMPL()
BUTTON EXIT_EMPL ;
CAPTION "E&xit" ;
PICTURE "edit_close.bmp" ;
ACTION Win_1.Release
END TOOLBAR
PaintDisplay_EMPL()
@ 90,10 BROWSE Browse_1 ;
WIDTH 350 ;
HEIGHT 450 ;
FONT "Arial" ;
SIZE 11 ;
HEADERS { "CLI_ID","CLI_SNAM","CLI_NAME","CLI_TLF","CLI_DAYS","CLI_WAGE","CLI_BDATE","CLI_HDATE","CLI_SALARY","CLI_CITY" } ;
WIDTHS { 70,130,130,120,90,90,110,110,110,110 } ;
WORKAREA EMPLOYE ;
FIELDS { "CLI_ID","CLI_SNAM","CLI_NAME","CLI_TLF","CLI_DAYS","CLI_WAGE","CLI_BDATE","CLI_HDATE","CLI_SALARY","CLI_CITY" } ;
JUSTIFY { BROWSE_JTFY_RIGHT, ,,, BROWSE_JTFY_RIGHT, BROWSE_JTFY_RIGHT, ,, BROWSE_JTFY_RIGHT, } ;
ON CHANGE LoadData_EMPL() ;
ON HEADCLICK { {|| Head1_EMPL()}, ,,,,,,,, {|| Head10_EMPL()} } ;
ON DBLCLICK ( EnableField_EMPL(), iif ( ! RecordStatus_EMPL(), DisableField_EMPL(), Nil ) )
@ 580, 50 BUTTON SAVE_EMPL ;
CAPTION "&Save" ;
PICTURE "ok.bmp" ;
ACTION SaveRecord_EMPL() ;
RIGHT ;
WIDTH 100 ;
HEIGHT 40
@ 580,150 BUTTON CANCEL_EMPL ;
CAPTION "&Cancel" ;
PICTURE "cancel.bmp" ;
ACTION CancelEdit_EMPL() ;
RIGHT ;
WIDTH 100 ;
HEIGHT 40
@ 580,300 BUTTON QUERY_EMPL ;
CAPTION "&Query" ;
PICTURE "edit_find.bmp" ;
ACTION QueryRecord_EMPL() ;
RIGHT ;
WIDTH 100 ;
HEIGHT 40
END WINDOW
DisableField_EMPL()
Win_1.Browse_1.Value := EMPLOYE->( RecNo() )
LoadData_EMPL()
Win_1.Browse_1.SetFocus
CENTER WINDOW Win_1
ACTIVATE WINDOW Win_1
RETURN
*---------------------------------------------*
PROCEDURE DisableField_EMPL
Win_1.Browse_1.Enabled := .T.
Win_1.Control_1.Enabled := .F.
Win_1.Control_2.Enabled := .F.
Win_1.Control_3.Enabled := .F.
Win_1.Control_4.Enabled := .F.
Win_1.Control_5.Enabled := .F.
Win_1.Control_6.Enabled := .F.
Win_1.Control_7.Enabled := .F.
Win_1.Control_8.Enabled := .F.
Win_1.Control_9.Enabled := .F.
Win_1.Control_10.Enabled := .F.
Win_1.Save_EMPL.Enabled := .F.
Win_1.Cancel_EMPL.Enabled := .F.
Win_1.Query_EMPL.Enabled := .F.
EnableToolbar_EMPL()
Win_1.Browse_1.SetFocus
RETURN
*---------------------------------------------*
PROCEDURE EnableField_EMPL
Win_1.Browse_1.Enabled := .F.
Win_1.Control_1.Enabled := .T.
Win_1.Control_2.Enabled := .T.
Win_1.Control_3.Enabled := .T.
Win_1.Control_4.Enabled := .T.
Win_1.Control_5.Enabled := .T.
Win_1.Control_6.Enabled := .T.
Win_1.Control_7.Enabled := .T.
Win_1.Control_8.Enabled := .T.
Win_1.Control_9.Enabled := .T.
Win_1.Control_10.Enabled := .T.
Win_1.Save_EMPL.Enabled := .T.
Win_1.Cancel_EMPL.Enabled := .T.
Win_1.Query_EMPL.Enabled := .F.
DisableToolbar_EMPL()
Win_1.Control_2.SetFocus
RETURN
*---------------------------------------------*
PROCEDURE DisableToolbar_EMPL
Win_1.Toolbar_1.FIRST_EMPL.Enabled := .F.
Win_1.Toolbar_1.PREV_EMPL.Enabled := .F.
Win_1.Toolbar_1.NEXT_EMPL.Enabled := .F.
Win_1.Toolbar_1.LAST_EMPL.Enabled := .F.
Win_1.Toolbar_1.FIND_EMPL.Enabled := .F.
Win_1.Toolbar_1.NEW_EMPL.Enabled := .F.
Win_1.Toolbar_1.EDIT_EMPL.Enabled := .F.
Win_1.Toolbar_1.DELETE_EMPL.Enabled := .F.
Win_1.Toolbar_1.PRINT_EMPL.Enabled := .F.
Win_1.Toolbar_1.EXIT_EMPL.Enabled := .F.
RETURN
*---------------------------------------------*
PROCEDURE EnableToolbar_EMPL
Win_1.Toolbar_1.FIRST_EMPL.Enabled := .T.
Win_1.Toolbar_1.PREV_EMPL.Enabled := .T.
Win_1.Toolbar_1.NEXT_EMPL.Enabled := .T.
Win_1.Toolbar_1.LAST_EMPL.Enabled := .T.
Win_1.Toolbar_1.FIND_EMPL.Enabled := .T.
Win_1.Toolbar_1.NEW_EMPL.Enabled := .T.
Win_1.Toolbar_1.EDIT_EMPL.Enabled := .T.
Win_1.Toolbar_1.DELETE_EMPL.Enabled := .T.
Win_1.Toolbar_1.PRINT_EMPL.Enabled := .T.
Win_1.Toolbar_1.EXIT_EMPL.Enabled := .T.
RETURN
*---------------------------------------------*
FUNCTION RecordStatus_EMPL()
Local RetVal
EMPLOYE->( dbGoTo ( Win_1.Browse_1.Value ) )
IF EMPLOYE->(RLock())
RetVal := .T.
ELSE
MsgExclamation ("Record is LOCKED, try again later")
RetVal := .F.
ENDIF
RETURN RetVal
*---------------------------------------------*
PROCEDURE LoadData_EMPL
EMPLOYE->( dbGoTo ( Win_1.Browse_1.Value ) )
Win_1.Control_1.Value := EMPLOYE->CLI_ID
Win_1.Control_2.Value := EMPLOYE->CLI_SNAM
Win_1.Control_3.Value := EMPLOYE->CLI_NAME
Win_1.Control_4.Value := EMPLOYE->CLI_TLF
Win_1.Control_5.Value := EMPLOYE->CLI_DAYS
Win_1.Control_6.Value := EMPLOYE->CLI_WAGE
Win_1.Control_7.Value := EMPLOYE->CLI_BDATE
Win_1.Control_8.Value := EMPLOYE->CLI_HDATE
Win_1.Control_9.Value := EMPLOYE->CLI_SALARY
Win_1.Control_10.Value := EMPLOYE->CLI_CITY
RETURN
*---------------------------------------------*
PROCEDURE CancelEdit_EMPL
DisableField_EMPL()
LoadData_EMPL()
UNLOCK
New_rec := .F.
RETURN
*---------------------------------------------*
PROCEDURE SaveRecord_EMPL
Local NewRecNo
DisableField_EMPL()
IF New_rec == .T.
EMPLOYE->( dbAppend() )
New_rec := .F.
ELSE
EMPLOYE->( dbGoto ( Win_1.Browse_1.Value ) )
ENDIF
NewRecNo := EMPLOYE->( RecNo() )
EMPLOYE->CLI_ID := Win_1.Control_1.Value
EMPLOYE->CLI_SNAM := Win_1.Control_2.Value
EMPLOYE->CLI_NAME := Win_1.Control_3.Value
EMPLOYE->CLI_TLF := Win_1.Control_4.Value
EMPLOYE->CLI_DAYS := Win_1.Control_5.Value
EMPLOYE->CLI_WAGE := Win_1.Control_6.Value
EMPLOYE->CLI_BDATE := Win_1.Control_7.Value
EMPLOYE->CLI_HDATE := Win_1.Control_8.Value
EMPLOYE->CLI_SALARY := Win_1.Control_9.Value
EMPLOYE->CLI_CITY := Win_1.Control_10.Value
dbCommit()
UNLOCK
Win_1.Browse_1.Value := NewRecNo
Win_1.Browse_1.Refresh
Win_1.StatusBar.Item(1) := "Save Record"
RETURN
*---------------------------------------------*
PROCEDURE NewRecord_EMPL
Win_1.StatusBar.Item(1) := "Editing"
SET ORDER TO 1
dbGoBottom()
Win_1.Control_1.Value := EMPLOYE->CLI_ID + 1
Win_1.Control_2.Value := space(12)
Win_1.Control_3.Value := space(12)
Win_1.Control_4.Value := space(11)
Win_1.Control_5.Value := 0
Win_1.Control_6.Value := 0
Win_1.Control_7.Value := date()
Win_1.Control_8.Value := date()
Win_1.Control_9.Value := 0
Win_1.Control_10.Value := space(10)
EnableField_EMPL()
Win_1.Control_2.SetFocus
RETURN
*---------------------------------------------*
PROCEDURE DeleteRecord_EMPL
IF MsgYesNo ( "Are you sure you want to delete record?", "Confirmation" )
DELETE
dbSkip()
IF EMPLOYE->(Eof())
dbGoBottom()
ENDIF
Win_1.Browse_1.Value := RecNo()
Win_1.Browse_1.Refresh
ENDIF
UNLOCK
RETURN
*---------------------------------------------*
PROCEDURE Find_EMPL
Win_1.StatusBar.Item(1) := "Query"
Win_1.Control_1.Value := 0
Win_1.Control_2.Value := space(12)
Win_1.Control_3.Value := space(12)
Win_1.Control_4.Value := space(11)
Win_1.Control_5.Value := 0
Win_1.Control_6.Value := 0
Win_1.Control_7.Value := ctod('')
Win_1.Control_8.Value := ctod('')
Win_1.Control_9.Value := 0
Win_1.Control_10.Value := space(10)
EnableField_EMPL()
Win_1.Save_EMPL.Enabled := .F.
Win_1.Query_EMPL.Enabled := .T.
Win_1.Control_1.SetFocus
RETURN
*---------------------------------------------*
PROCEDURE PrintData_EMPL
Local RecRec
RecRec := EMPLOYE->( RecNo() )
dbGoTop()
DO REPORT ;
TITLE "EMPLOYE" ;
HEADERS { "","","","","","","","","","" }, { "CLI_ID","CLI_SNAM","CLI_NAME","CLI_TLF","CLI_DAYS","CLI_WAGE","CLI_BDATE","CLI_HDATE","CLI_SALARY","CLI_CITY" } ;
FIELDS { "CLI_ID","CLI_SNAM","CLI_NAME","CLI_TLF","CLI_DAYS","CLI_WAGE","CLI_BDATE","CLI_HDATE","CLI_SALARY","CLI_CITY" } ;
WIDTHS { 7,13,13,12,9,9,11,11,11,11 } ;
TOTALS { .F.,.F.,.F.,.F.,.F.,.F.,.F.,.F.,.T.,.F. } ;
NFORMATS { '','','','','','999.99','','',"99,999.99",'' } ;
WORKAREA EMPLOYE ;
LPP 50 ;
CPL 80 ;
LMARGIN 10 ;
PREVIEW
EMPLOYE->( dbGoTo(RecRec) )
RETURN
*---------------------------------------------*
PROCEDURE PaintDisplay_EMPL
@ 90,410 FRAME Frame_1 WIDTH 300 HEIGHT 450
@ 100, 420 LABEL Label_1 VALUE "CLI_ID"
@ 130, 420 LABEL Label_2 VALUE "CLI_SNAM"
@ 160, 420 LABEL Label_3 VALUE "CLI_NAME"
@ 190, 420 LABEL Label_4 VALUE "CLI_TLF"
@ 220, 420 LABEL Label_5 VALUE "CLI_DAYS"
@ 250, 420 LABEL Label_6 VALUE "CLI_WAGE"
@ 280, 420 LABEL Label_7 VALUE "CLI_BDATE"
@ 310, 420 LABEL Label_8 VALUE "CLI_HDATE"
@ 340, 420 LABEL Label_9 VALUE "CLI_SALARY"
@ 370, 420 LABEL Label_10 VALUE "CLI_CITY"
@ 100, 520 TEXTBOX Control_1 NUMERIC INPUTMASK "99999"
@ 130, 520 TEXTBOX Control_2 INPUTMASK repl("A",12)
@ 160, 520 TEXTBOX Control_3 INPUTMASK repl("A",12)
@ 190, 520 TEXTBOX Control_4 INPUTMASK repl("A",11)
@ 220, 520 TEXTBOX Control_5 NUMERIC INPUTMASK "99"
@ 250, 520 TEXTBOX Control_6 NUMERIC INPUTMASK "9.99"
@ 280, 520 TEXTBOX Control_7 DATE
@ 310, 520 TEXTBOX Control_8 DATE
@ 340, 520 TEXTBOX Control_9 NUMERIC INPUTMASK "99999.99"
@ 370, 520 TEXTBOX Control_10 INPUTMASK repl("A",10)
RETURN
*---------------------------------------------*
PROCEDURE Head1_EMPL
SELECT EMPLOYE
SET ORDER TO 1
dbGotop()
Win_1.Browse_1.Value := RecNo()
Win_1.Browse_1.Refresh
LoadData_EMPL()
RETURN
*---------------------------------------------*
PROCEDURE Head10_EMPL
SELECT EMPLOYE
SET ORDER TO 2
dbGotop()
Win_1.Browse_1.Value := RecNo()
Win_1.Browse_1.Refresh
LoadData_EMPL()
RETURN
*---------------------------------------------*
PROCEDURE QueryRecord_EMPL
Local found_rec
PreQuery_EMPL()
SET FILTER TO
dbGotop()
IF ! EMPTY( _qry_exp )
COUNT TO found_rec FOR &_qry_exp
dbGotop()
IF found_rec = 0
Win_1.Statusbar.Item(1) := "Not found!"
ELSE
SET FILTER TO &_qry_exp
dbGotop()
Win_1.Statusbar.Item(1) := "Found " + ALLTRIM(STR(found_rec)) + " record(s)!"
ENDIF
ENDIF
DisableField_EMPL()
Win_1.Browse_1.Value := RecNo()
Win_1.Browse_1.Refresh
Win_1.Browse_1.Enabled := .T.
RETURN
*---------------------------------------------*
PROCEDURE PreQuery_EMPL
Local _ima_filter
_qry_exp := ""
_ima_filter := .F.
IF ! EMPTY ( Win_1.Control_1.Value ) // CLI_ID
IF _ima_filter
_qry_exp = _qry_exp + " .AND. "
ENDIF
_qry_exp = _qry_exp + "CLI_ID = " + STR( Win_1.Control_1.Value )
_ima_filter := .T.
ENDIF
IF ! EMPTY ( Win_1.Control_2.Value ) // CLI_SNAM
IF _ima_filter
_qry_exp = _qry_exp + " .AND. "
ENDIF
_qry_exp = _qry_exp + "CLI_SNAM = " + chr(34) + Win_1.Control_2.Value + chr(34)
_ima_filter := .T.
ENDIF
IF ! EMPTY ( Win_1.Control_3.Value ) // CLI_NAME
IF _ima_filter
_qry_exp = _qry_exp + " .AND. "
ENDIF
_qry_exp = _qry_exp + "CLI_NAME = " + chr(34) + Win_1.Control_3.Value + chr(34)
_ima_filter := .T.
ENDIF
IF ! EMPTY ( Win_1.Control_4.Value ) // CLI_TLF
IF _ima_filter
_qry_exp = _qry_exp + " .AND. "
ENDIF
_qry_exp = _qry_exp + "CLI_TLF = " + chr(34) + Win_1.Control_4.Value + chr(34)
_ima_filter := .T.
ENDIF
IF ! EMPTY ( Win_1.Control_5.Value ) // CLI_DAYS
IF _ima_filter
_qry_exp = _qry_exp + " .AND. "
ENDIF
_qry_exp = _qry_exp + "CLI_DAYS = " + STR( Win_1.Control_5.Value )
_ima_filter := .T.
ENDIF
IF ! EMPTY ( Win_1.Control_6.Value ) // CLI_WAGE
IF _ima_filter
_qry_exp = _qry_exp + " .AND. "
ENDIF
_qry_exp = _qry_exp + "CLI_WAGE = " + STR( Win_1.Control_6.Value )
_ima_filter := .T.
ENDIF
IF ! EMPTY ( Win_1.Control_7.Value ) // CLI_BDATE
IF _ima_filter
_qry_exp = _qry_exp + " .AND. "
ENDIF
_qry_exp = _qry_exp + "CLI_BDATE = " + "CTOD(" + chr(34) + DTOC(Win_1.Control_7.Value) + chr(34) + ")"
_ima_filter := .T.
ENDIF
IF ! EMPTY ( Win_1.Control_8.Value ) // CLI_HDATE
IF _ima_filter
_qry_exp = _qry_exp + " .AND. "
ENDIF
_qry_exp = _qry_exp + "CLI_HDATE = " + "CTOD(" + chr(34) + DTOC(Win_1.Control_8.Value) + chr(34) + ")"
_ima_filter := .T.
ENDIF
IF ! EMPTY ( Win_1.Control_9.Value ) // CLI_SALARY
IF _ima_filter
_qry_exp = _qry_exp + " .AND. "
ENDIF
_qry_exp = _qry_exp + "CLI_SALARY = " + STR( Win_1.Control_9.Value )
_ima_filter := .T.
ENDIF
IF ! EMPTY ( Win_1.Control_10.Value ) // CLI_CITY
IF _ima_filter
_qry_exp = _qry_exp + " .AND. "
ENDIF
_qry_exp = _qry_exp + "CLI_CITY = " + chr(34) + Win_1.Control_10.Value + chr(34)
ENDIF
RETURN
* end of program *
P.S. I've placed here a most recent version with small improvements
- Attachments
-
- how it is looks?
- employe.png (33.61 KiB) Viewed 8376 times
Last edited by gfilatov on Thu Sep 26, 2013 1:19 pm, edited 1 time in total.
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Re: HMG Case
Hi Esgici,esgici wrote:gfilatov wrote: ...corrections in the generated code...
I've considered the generated code as good example of Browse control handling.
That's all
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein