EXIT BUTTON VALIDATION
Moderator: Rathinagiri
- serge_girard
- Posts: 3167
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: EXIT BUTTON VALIDATION
Grigory,
Your last code will lock then COMPANY table forever as long as the application is running....
Better to CLOSE and re-USE it !
Greetings, Serge
Your last code will lock then COMPANY table forever as long as the application is running....
Better to CLOSE and re-USE it !
Greetings, Serge
There's nothing you can do that can't be done...
Re: EXIT BUTTON VALIDATION
Thank you Grigory for excellent tip
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
Re: EXIT BUTTON VALIDATION
Hello Serge,serge_girard wrote:Grigory,
Your last code will lock then COMPANY table forever as long as the application is running....
Better to CLOSE and re-USE it !
IMHO It is a sample for show of breaking a textbox validation only but not a database network using...
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
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: EXIT BUTTON VALIDATION
Thank to fix and clarify, Grigorygfilatov wrote:... updated sample with implemented your needs below:
Actually, your VALIDATION code is very nice, when used correct
Happy HMG
Viva INTERNATIONAL HMG
- dhaine_adp
- Posts: 457
- Joined: Wed Aug 06, 2008 12:22 pm
- Location: Manila, Philippines
Re: EXIT BUTTON VALIDATION
Hi,
Here is a multiple flat table and multiple windows validation routine written in clipper logic and was adopted to HMG (windows). Its a code snippet but if you read the code carefully you'll find that it is more like a clipper code roughly equivalent to:
In HMG, the same principles was adopted as described above. The variable cDBMain is a PRIVATE parameter received as follows and called from the Main Menu or Toolbar as: FileMain( "HOLIDAY" )
Sorry about the function name GraphicUserInterface(), I named it when I am still learning HMG way back in the year 2007. Since then I used that way and out of pure laziness became the monicker of this routine. LOL as you can see it is still the same old dinasour Clipper wearing the mask of HMG with BEGIN..BREAK..END SEQUENCE. The catch here is that VALIDATE the fields that requires on ON LOSTFOCUS events. When you need ON CHANGE you can still call CheckEventLostFocus( cMode ) but ON LOSTFOCUS must be like this: ON LOSTFOCUS NIL.
The main disadvantage of this is that users can only open one window at a time most especially if they are the same database. And on a case to case basis I comment out this statement on my source code and use SET MULTIPLE ON to let the users open more than one instance of the application. But if you do it this way your code must be fully written in a network environment scheme. Now, in the same sense, you can also test your network routines if your app can put record locks and or file locks effectively before deployment on the same computer without network.
GUISaveButtonEnable() - enables the "Save" button after a successful validation during "EDIT" mode otherwise changes it will remain disable. That ensures users will click either the Close or exit button or the windows close box itself (INTERACTIVECLOSE).
To Moderators: I'm sorry its a long post but perhaps it can be considered.
Regards,
Danny
Here is a multiple flat table and multiple windows validation routine written in clipper logic and was adopted to HMG (windows). Its a code snippet but if you read the code carefully you'll find that it is more like a clipper code roughly equivalent to:
Code: Select all
function Label( cMode )
DO CASE
CASE cMain == "EMPLOYEE"
**Screen 1
@ Row, Col SAY "Code"
@ Row, Col SAY "Name"
CASE cMain == "PRODUCT"
**Screen 2
@ Row, Col SAY "Code"
@ Row, Col SAY "Description"
END CASE
function GetFlds( cMode )
DO CASE
CASE cMain == "EMPLOYEE"
*Code
IF cMode == "ADD"
@ Row, Col GET aFVar_[ 1 ] VALID validation()
ELSE
@ Row, Col SAY aFVar_[ 1 ]
ENDIF
@ Row, Col GET aFVar_[ 2 ] VALID validation() // Name
CASE cMain == "PRODUCT"
** here same logic applies as in the above CASE block and
END CASE
READ
Code: Select all
function FileMain()
PARAMETERS cDBMain
--> Then loads a browse or grid window with buttons: Add, Edit, Delete, Search, Print, Close
--> When Add button is click: GraphicUserInterface( "ADD" )
--> When Edit button is click: GraphicUserInterface( "EDIT" )
--> Search: Show Search window
--> Print: Dump to the contents of the database
--> Close: Terminate the window
The main disadvantage of this is that users can only open one window at a time most especially if they are the same database. And on a case to case basis I comment out this statement on my source code and use SET MULTIPLE ON to let the users open more than one instance of the application. But if you do it this way your code must be fully written in a network environment scheme. Now, in the same sense, you can also test your network routines if your app can put record locks and or file locks effectively before deployment on the same computer without network.
**SET MULTIPLE OFF WARNING
SET MULTIPLE ON
Code: Select all
**********************************************
static function GraphicUserInterface( cMode )
local nebxLen := 0
///////////////////////////////////////////////////////////////////////////////////
// Variable to properly display the record pointer position on the browse window //
///////////////////////////////////////////////////////////////////////////////////
LOCAL nBrwCurRecPos := oTable:BrowseCurrentPos()
///////////////////////////////////////////////////
// draw the form or the User Interface in memory //
///////////////////////////////////////////////////
IF ISWINDOWDEFINED( frmGUI_1 )
DOMETHOD("frmGUI_1","Restore")
DOMETHOD("frmGUI_1","Setfocus")
RETURN NIL
ENDIF
IF cDBMain == "EVENTS" .AND. LEN( aDbfFilter_ ) = 0
MSGSTOP( 'Please set filter for a council that you wish to work with. To do this click on the button that says,"Select View".', "Record filter is required" )
RETURN NIL
ENDIF
IF cMode == "ADD"
DBGOBOTTOM()
DBSKIP()
ELSE
IF .NOT. RecLock()
RETURN NIL
ENDIF
ENDIF
lLostFocusEvents := FALSE // reset lost focus events switch
///////////////////////////////////////////////////////////
// draw Add/Edit windows in memory but not activated yet //
///////////////////////////////////////////////////////////
DO CASE
CASE cDBMain == "HOLIDAY"
DEFINE WINDOW frmGUI_1;
AT 0,0;
WIDTH 409 HEIGHT 215;
TITLE IF( cMode == "ADD","New Record Property","Record Property" );
ICON ImageHome + "nsdla.ico";
NOMINIMIZE NOMAXIMIZE NOSIZE;
ON INTERACTIVECLOSE ( lLostFocusEvents := TRUE, ButtonClose( nBrwCurRecPos ) );
FONT "Arial" SIZE 9
ON KEY ESCAPE ACTION ( lLostFocusEvents := TRUE, ButtonClose( nBrwCurRecPos, TRUE ) )
@ 140,170 BUTTON btnGUISave OF frmGUI_1 CAPTION "&Save";
PICTURE ImageHome + "hp_save.bmp" LEFT ACTION ButtonSave( cMode, @nBrwCurRecPos );
WIDTH 100 HEIGHT 28
@ 140,280 BUTTON btnGUIClose OF frmGUI_1 CAPTION "&Close";
PICTURE ImageHome + "exit20.bmp" LEFT;
ACTION ButtonClose( nBrwCurRecPos, TRUE );
WIDTH 100 HEIGHT 28
@ 8, 20 FRAME Frame_GUI OF frmGUI_1 CAPTION "Please fill-up the following information";
WIDTH 360 HEIGHT 122 FONT "Arial" SIZE 9 BACKCOLOR NIL FONTCOLOR NIL OPAQUE
@ 33, 30 LABEL lblCode OF frmGUI_1 VALUE "&Code:";
ACTION Nil WIDTH 70 HEIGHT 18 FONT "Arial" SIZE 9
IF cMode == "ADD"
@ 30,120 TEXTBOX txbCode OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( HOLIDAY->F1 ) WIDTH 120;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 5;
ON LOSTFOCUS CheckEventLostFocus( cMode )
ELSE
@ 30,120 TEXTBOX txbCode OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( HOLIDAY->F1 ) READONLY WIDTH 120;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 5;
ON LOSTFOCUS CheckEventLostFocus( cMode )
ENDIF
@ 63, 30 LABEL lblDesc OF frmGUI_1 VALUE "&Description:";
ACTION Nil WIDTH 70 HEIGHT 18 FONT "Arial" SIZE 9
@ 60,120 TEXTBOX txbDesc OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( HOLIDAY->F2 ) WIDTH 250;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 40 ON LOSTFOCUS Nil;
ON CHANGE GUISaveButtonEnable()
@ 93, 30 LABEL lblHolidayType OF frmGUI_1 VALUE "Holida&y Type";
ACTION Nil WIDTH 70 HEIGHT 18 FONT "Arial" SIZE 9
@ 90,120 COMBOBOX cboHolidayType OF frmGUI_1 ITEMS acHolidayType_;
VALUE IF( cMode == "ADD", 0, IF( ASCAN( acHolidayTypeCode_, HOLIDAY->F3 ) > 0,;
ASCAN( acHolidayTypeCode_, HOLIDAY->F3 ), 0 ) ) ;
WIDTH 130 HEIGHT 80 FONT "Arial" SIZE 9 ON LOSTFOCUS CheckEventLostFocus()
END WINDOW
CASE cDBMain == "ROLES"
DEFINE WINDOW frmGUI_1;
AT 0,0;
WIDTH 466 HEIGHT 254;
TITLE IF( cMode == "ADD","New Record Property","Record Property" );
ICON ImageHome + "nsdla.ico";
NOMINIMIZE NOMAXIMIZE NOSIZE;
ON INTERACTIVECLOSE ( lLostFocusEvents := TRUE, ButtonClose( nBrwCurRecPos ) );
FONT "Arial" SIZE 9
ON KEY ESCAPE ACTION ( lLostFocusEvents := TRUE, ButtonClose( nBrwCurRecPos, TRUE ) )
@ 180,220 BUTTON btnGUISave OF frmGUI_1 CAPTION "&Save";
PICTURE ImageHome + "hp_save.bmp" LEFT ACTION ButtonSave( cMode, @nBrwCurRecPos );
WIDTH 100 HEIGHT 28
@ 180,330 BUTTON btnGUIClose OF frmGUI_1 CAPTION "&Close";
PICTURE ImageHome + "exit20.bmp" LEFT ACTION ButtonClose( nBrwCurRecPos, TRUE );
WIDTH 100 HEIGHT 28
@ 20, 30 FRAME Frame_GUI OF frmGUI_1 CAPTION "Please fill-up the following information";
WIDTH 400 HEIGHT 150 FONT "Arial" SIZE 9 BACKCOLOR NIL FONTCOLOR NIL OPAQUE
@ 43, 50 LABEL lblCode OF frmGUI_1 VALUE "Role &Code:";
ACTION Nil WIDTH 70 HEIGHT 18 FONT "Arial" SIZE 9
@ 83, 50 LABEL lblDesc OF frmGUI_1 VALUE "&Description:";
ACTION Nil WIDTH 70 HEIGHT 18 FONT "Arial" SIZE 9
@ 123, 50 LABEL lblGenCat OF frmGUI_1 VALUE "&General Category:";
ACTION Nil WIDTH 70 HEIGHT 18 FONT "Arial" SIZE 9
IF cMode == "ADD"
@ 40,160 TEXTBOX txbCode OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( ROLES->F1 ) WIDTH 120;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 3 ON LOSTFOCUS CheckEventLostFocus( cMode )
ELSE
@ 40,160 TEXTBOX txbCode OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( ROLES->F1 ) READONLY WIDTH 120;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 3 ON LOSTFOCUS CheckEventLostFocus( cMode )
ENDIF
@ 80,160 TEXTBOX txbDesc OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( ROLES->F2 ) WIDTH 250;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 50 ON LOSTFOCUS Nil;
ON CHANGE GUISaveButtonEnable()
@ 120,160 COMBOBOX cboGenCat OF frmGUI_1 ITEMS acRoles_ VALUE IIF( cMode == "ADD", 0, RoleGenCat( ROLES->F3 ) );
WIDTH 120 HEIGHT 120 FONT "Arial" SIZE 9 ON CHANGE NIL
END WINDOW
CASE cDBMain == "BARRIO"
DEFINE WINDOW frmGUI_1;
AT 0,0;
WIDTH 466 HEIGHT 289;
TITLE IF( cMode == "ADD","New Record Property","Record Property" );
ICON ImageHome + "nsdla.ico";
NOMINIMIZE NOMAXIMIZE NOSIZE;
ON INTERACTIVECLOSE ( lLostFocusEvents := TRUE, ButtonClose( nBrwCurRecPos ) );
FONT "Arial" SIZE 9
ON KEY ESCAPE ACTION ( lLostFocusEvents := TRUE, ButtonClose( nBrwCurRecPos, TRUE ) )
@ 20, 30 FRAME Frame_1 OF frmGUI_1 CAPTION NIL;
WIDTH 400 HEIGHT 180 FONT "Arial" SIZE 9 BACKCOLOR NIL FONTCOLOR NIL OPAQUE
@ 43, 50 LABEL lblAreaCode OF frmGUI_1 VALUE "&Area Code :";
ACTION frmGUI_1.txbAreaCode.Setfocus WIDTH 100 HEIGHT 18 FONT "Arial" SIZE 9
IF cMode == "ADD"
@ 40,160 TEXTBOX txbAreaCode OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( BARRIO->F1 ) WIDTH 30;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 2 ON LOSTFOCUS CheckEventLostFocus( cMode )
ELSE
@ 40,160 TEXTBOX txbAreaCode OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( BARRIO->F1 ) READONLY WIDTH 30;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 2 ON LOSTFOCUS NIL
ENDIF
@ 73, 50 LABEL lblAreaDesc OF frmGUI_1 VALUE "&Description";
ACTION frmGUI_1.txbAreaDesc.Setfocus WIDTH 100 HEIGHT 18 FONT "Arial" SIZE 9
@ 70,160 TEXTBOX txbAreaDesc OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( BARRIO->F2 ) WIDTH 250;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 50 ON LOSTFOCUS CheckEventLostFocus( cMode )
@ 103,200 CHECKBOX chkZone OF frmGUI_1 ;
CAPTION "&Zone &Required";
WIDTH 100 HEIGHT 18 VALUE BARRIO->F6 ON CHANGE ZoneCBxChange()
@ 103, 50 LABEL lblZoneCode OF frmGUI_1 VALUE "&Zone Code";
ACTION frmGUI_1.txbZoneCode.Setfocus WIDTH 100 HEIGHT 18 FONT "Arial" SIZE 9
IF cMode == "ADD"
@ 100,160 TEXTBOX txbZoneCode OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( BARRIO->F3 ) WIDTH 30;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 2 ON LOSTFOCUS CheckEventLostFocus( cMode )
ELSE
@ 100,160 TEXTBOX txbZoneCode OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( BARRIO->F3 ) READONLY WIDTH 30;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 2 ON LOSTFOCUS Nil
ENDIF
@ 133, 50 LABEL lblZoneDesc OF frmGUI_1 VALUE "Zo&ne Description";
ACTION frmGUI_1.txbZoneDesc.Setfocus() WIDTH 100 HEIGHT 18 FONT "Arial" SIZE 9
@ 130,160 TEXTBOX txbZoneDesc OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( BARRIO->F4 ) WIDTH 250;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 50 ON LOSTFOCUS CheckEventLostFocus( cMode )
@ 163, 50 LABEL lblPPCZone OF frmGUI_1 VALUE "P&PC Zone Alias";
ACTION frmGUI_1.txbPPCZone.Setfocus() WIDTH 100 HEIGHT 18 FONT "Arial" SIZE 9
@ 160,160 TEXTBOX txbPPCZone OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( BARRIO->F5 ) WIDTH 250;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 50 ON LOSTFOCUS Nil
@ 210,230 BUTTON btnGUISave OF frmGUI_1 CAPTION "&Save";
PICTURE ImageHome + "hp_save.bmp" LEFT ACTION ButtonSave( cMode, @nBrwCurRecPos );
WIDTH 100 HEIGHT 28
@ 210,330 BUTTON btnGUIClose OF frmGUI_1 CAPTION "&Close";
PICTURE ImageHome + "exit20.bmp" LEFT ACTION ButtonClose( nBrwCurRecPos, TRUE );
WIDTH 100 HEIGHT 28
END WINDOW
CASE cDBMain == "COUNCIL"
DEFINE WINDOW frmGUI_1;
AT 0,0;
WIDTH 418 HEIGHT 445;
TITLE IF( cMode == "ADD","New Record Property","Record Property" );
ICON ImageHome + "nsdla.ico";
NOMINIMIZE NOMAXIMIZE NOSIZE;
ON INTERACTIVECLOSE ( lLostFocusEvents := TRUE, ButtonClose( nBrwCurRecPos ) );
FONT "Arial" SIZE 9
ON KEY ESCAPE ACTION ( lLostFocusEvents := TRUE, ButtonClose( nBrwCurRecPos, TRUE ) )
@ 20, 20 FRAME Frame_Council OF frmGUI_1 CAPTION "Pas&toral Councils";
WIDTH 370 HEIGHT 150 FONT "Arial" SIZE 9 BACKCOLOR NIL FONTCOLOR NIL OPAQUE
@ 43, 40 LABEL lblParentCode OF frmGUI_1 VALUE "&Parent Code";
ACTION frmGUI_1.txbParent.Setfocus() WIDTH 70 HEIGHT 18 FONT "Arial" SIZE 9
@ 73, 40 LABEL lblChildCode OF frmGUI_1 VALUE "&Child Code";
ACTION frmGUI_1.txbChild.Setfocus() WIDTH 70 HEIGHT 18 FONT "Arial" SIZE 9
@ 103, 40 LABEL lblDesc OF frmGUI_1 VALUE "&Description";
ACTION frmGUI_1.txbDesc.Setfocus() WIDTH 70 HEIGHT 18 FONT "Arial" SIZE 9
@ 133, 40 LABEL lblLevel OF frmGUI_1 VALUE "&Level";
ACTION frmGUI_1.spnLevel.Setfocus() WIDTH 70 HEIGHT 18 FONT "Arial" SIZE 9
IF cMode == "ADD"
@ 40,120 TEXTBOX txbParent OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( COUNCIL->F1 ) WIDTH 40;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 3 ON LOSTFOCUS CheckEventLostFocus( cMode )
@ 70,120 TEXTBOX txbChild OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( COUNCIL->F2 ) WIDTH 40;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 3 ON LOSTFOCUS CheckEventLostFocus( cMode )
ELSE
@ 40,120 TEXTBOX txbParent OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( COUNCIL->F1 ) READONLY WIDTH 40;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 3 ON LOSTFOCUS NIL
@ 70,120 TEXTBOX txbChild OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( COUNCIL->F2 ) READONLY WIDTH 40;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 3 ON LOSTFOCUS NIL
ENDIF
@ 100,120 TEXTBOX txbDesc OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( COUNCIL->F3 ) WIDTH 250;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 50 ON LOSTFOCUS CheckEventLostFocus( cMode )
@ 130,120 SPINNER spnLevel OF frmGUI_1 RANGE 1,5;
VALUE COUNCIL->F4 WIDTH 40 HEIGHT 24;
FONT "Arial" SIZE 9 ON CHANGE Nil
@ 133,170 CHECKBOX chkPerspective OF frmGUI_1 ;
CAPTION "&Enable View" WIDTH 170 HEIGHT 18 VALUE .F. ON CHANGE CouncilPerspectiveChange()
@ 220, 20 FRAME Frame_Perspective OF frmGUI_1 CAPTION "Report Perspective";
WIDTH 370 HEIGHT 180 FONT "Arial" SIZE 9 BACKCOLOR NIL FONTCOLOR NIL OPAQUE
@ 240, 30 EDITBOX ebxPerspective OF frmGUI_1 WIDTH 350 HEIGHT 150;
VALUE "" READONLY FONT "Consolas" SIZE 10 TOOLTIP "" NOTABSTOP
@ 180,180 BUTTON btnGUISave OF frmGUI_1 CAPTION "&Save";
PICTURE ImageHome + "hp_save.bmp" LEFT ACTION ButtonSave( cMode, @nBrwCurRecPos );
WIDTH 100 HEIGHT 28
@ 180,290 BUTTON btnGUIClose OF frmGUI_1 CAPTION "&Close";
PICTURE ImageHome + "exit20.bmp" LEFT ACTION ButtonClose( nBrwCurRecPos, TRUE );
WIDTH 100 HEIGHT 28
END WINDOW
CASE cDBMain == "EVENTS"
DEFINE WINDOW frmGUI_1;
AT 0,0;
WIDTH 428 HEIGHT 323;
TITLE IF( cMode == "ADD","New Record Property","Event Property" );
ICON ImageHome + "nsdla.ico";
NOMINIMIZE NOMAXIMIZE NOSIZE;
ON RELEASE ( lLostFocusEvents := TRUE, ButtonClose( nBrwCurRecPos ) );
ON INTERACTIVECLOSE ( lLostFocusEvents := TRUE, ButtonClose( nBrwCurRecPos ) );
FONT "Arial" SIZE 9
ON KEY ESCAPE ACTION ( lLostFocusEvents := TRUE, ButtonClose( nBrwCurRecPos, TRUE ) )
@ 20, 20 FRAME Frame_Events OF frmGUI_1 CAPTION NIL;
WIDTH 380 HEIGHT 210 FONT "Arial" SIZE 9 BACKCOLOR Nil FONTCOLOR Nil OPAQUE
@ 34, 40 LABEL lblEventCode OF frmGUI_1 VALUE "Event Co&de:";
ACTION frmGUI_1.txbEventCode.Setfocus() WIDTH 80 HEIGHT 14 FONT "Arial" SIZE 9
@ 74, 40 LABEL lblEventName OF frmGUI_1 VALUE "Event Na&me:";
ACTION frmGUI_1.txtEventName.Setfocus() WIDTH 80 HEIGHT 14 FONT "Arial" SIZE 9
@ 114, 40 LABEL lblParentClass OF frmGUI_1 VALUE "Pare&nt Class:";
ACTION frmGUI_1.txbParent.Setfocus() WIDTH 80 HEIGHT 14 FONT "Arial" SIZE 9
@ 154, 40 LABEL lblChildClass OF frmGUI_1 VALUE "C&hild Class:";
ACTION frmGUI_1.txbChild.Setfocus() WIDTH 80 HEIGHT 14 FONT "Arial" SIZE 9
@ 194, 40 LABEL lblCouncilName OF frmGUI_1 VALUE "Desc&ription:";
ACTION frmGUI_1.txbDesc.Setfocus() WIDTH 80 HEIGHT 14 FONT "Arial" SIZE 9
@ 30,130 TEXTBOX txbEventCode OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( EVENTS->F1 ) READONLY WIDTH 120;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 10 ON LOSTFOCUS CheckEventLostFocus( cMode )
@ 70,130 TEXTBOX txtEventName OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( EVENTS->F2 ) WIDTH 250;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 50 ON LOSTFOCUS CheckEventLostFocus( cMode )
@ 110,130 TEXTBOX txbParent OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( EVENTS->F3 ) READONLY WIDTH 40;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 3 ON LOSTFOCUS Nil NOTABSTOP
@ 150,130 TEXTBOX txbChild OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( EVENTS->F4 ) READONLY WIDTH 40;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 3 ON LOSTFOCUS Nil NOTABSTOP
@ 190,130 TEXTBOX txbDesc OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( EVENTS->F5 ) READONLY WIDTH 250;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 50 ON LOSTFOCUS Nil NOTABSTOP
@ 240,200 BUTTON btnGUISave OF frmGUI_1 CAPTION "&Save";
PICTURE ImageHome + "hp_save.bmp" LEFT ACTION ButtonSave( cMode, @nBrwCurRecPos );
WIDTH 100 HEIGHT 28
@ 240,300 BUTTON btnGUIClose OF frmGUI_1 CAPTION "&Close";
PICTURE ImageHome + "exit20.bmp" LEFT ACTION ButtonClose( nBrwCurRecPos, TRUE );
WIDTH 100 HEIGHT 28
END WINDOW
CASE cDBMain == "FEAST"
DEFINE WINDOW frmGUI_1;
AT 0,0;
WIDTH 470 HEIGHT 453;
TITLE IF( cMode == "ADD","New Record Property","Event Property" );
ICON ImageHome + "nsdla.ico";
NOMAXIMIZE;
FONT "Arial" SIZE 9
ON KEY ESCAPE ACTION ( lLostFocusEvents := TRUE, ButtonClose( nBrwCurRecPos, TRUE ) )
@ 30, 30 FRAME Frame_Feast OF frmGUI_1 CAPTION NIL;
WIDTH 400 HEIGHT 130 FONT "Arial" SIZE 9 BACKCOLOR Nil FONTCOLOR Nil OPAQUE
@ 170, 30 FRAME Frame_ebxRemarks OF frmGUI_1 CAPTION "Remarks ( 300 Characters Only: Used: 0 Left : 300)";
WIDTH 400 HEIGHT 180 FONT "Arial" SIZE 9 BACKCOLOR Nil FONTCOLOR Nil OPAQUE
@ 44, 50 LABEL lblFeastCode OF frmGUI_1 VALUE "&Feast Code:";
ACTION frmGUI_1.txbFeastCode.Setfocus() WIDTH 85 HEIGHT 18 FONT "Arial" SIZE 9
@ 40,160 TEXTBOX txbFeastCode OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( FEAST->F1 ) READONLY WIDTH 120;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 10 ON LOSTFOCUS Nil
@ 83, 50 LABEL lblFeastName OF frmGUI_1 VALUE "&Description:";
ACTION frmGUI_1.txbFeastDesc.Setfocus() WIDTH 85 HEIGHT 24 FONT "Arial" SIZE 9
@ 80,160 TEXTBOX txbFeastDesc OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( FEAST->F2 ) WIDTH 250;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 50 ON LOSTFOCUS CheckEventLostFocus( cMode )
@ 123, 50 LABEL lblMonthDay OF frmGUI_1 VALUE "&Month and Day:";
ACTION Nil WIDTH 85 HEIGHT 24 FONT "Arial" SIZE 9
@ 120,160 TEXTBOX txbMonthDay OF frmGUI_1 HEIGHT 24 VALUE ALLTRIM( FEAST->F3 ) WIDTH 50;
FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 5 ON LOSTFOCUS CheckEventLostFocus( cMode )
@ 188, 37 EDITBOX ebxRemarks OF frmGUI_1 WIDTH 385 HEIGHT 155;
FIELD FEAST->F6 FONT "Arial" SIZE 9 TOOLTIP "" MAXLENGTH 300;
ON CHANGE frmGUI_1.Frame_ebxRemarks.Caption := "300 Characters (Used: " + ;
ALLTRIM( STR( LEN( ALLTRIM( This.Value ) ) ) )+ " Remaining: " +;
ALLTRIM( STR( ( 300 - LEN( ALLTRIM( This.Value ) ) ) ) ) + ")" NOHSCROLL
@ 360,220 BUTTON btnGUISave OF frmGUI_1 CAPTION "&Save";
PICTURE ImageHome + "hp_save.bmp" LEFT ACTION ButtonSave( cMode, @nBrwCurRecPos );
WIDTH 100 HEIGHT 28
@ 360,330 BUTTON btnGUIClose OF frmGUI_1 CAPTION "&Close";
PICTURE ImageHome + "exit20.bmp" LEFT ACTION ButtonClose( nBrwCurRecPos, TRUE );
WIDTH 100 HEIGHT 28
END WINDOW
ENDCASE
frmGUI_1.btnGUISave.Enabled := FALSE
frmGUI_1.Center
*************************************************************************
** setup form controls, disable primary keys and put the control focus **
** to initial form controls depending on the table in use. **
*************************************************************************
IF cMode == "ADD"
DO CASE
CASE cDBMain == "HOLIDAY"
frmGUI_1.txbCode.Setfocus
CASE cDBMain == "ROLES"
frmGUI_1.txbCode.Setfocus
CASE cDBMain == "BARRIO"
frmGUI_1.txbAreaCode.Setfocus()
CASE cDBMain == "COUNCIL"
frmGUI_1.chkPerspective.Value := FALSE
CouncilPerspectiveChange()
frmGUI_1.txbParent.Setfocus()
CASE cDBMain == "EVENTS"
frmGUI_1.txbEventCode.Setfocus()
CASE cDBMain == "FEAST"
frmGUI_1.txbFeastCode.Value := NewFeastCode()
frmGUI_1.txbFeastDesc.Setfocus()
ENDCASE
ELSEIF cMode == "EDIT"
DO CASE
CASE cDBMain == "HOLIDAY"
frmGUI_1.txbDesc.Setfocus
CASE cDBMain == "ROLES"
frmGUI_1.txbDesc.Setfocus
CASE cDBMain == "BARRIO"
frmGUI_1.txbAreaDesc.Setfocus()
CASE cDBMain == "COUNCIL"
frmGUI_1.chkPerspective.Value := TRUE
CouncilPerspectiveChange()
frmGUI_1.txbDesc.Setfocus()
CASE cDBMain == "EVENTS"
frmGUI_1.txtEventName.Setfocus()
CASE cDBMain == "FEAST"
nebxLen := LEN( ALLTRIM( frmGUI_1.ebxRemarks.Value ) )
frmGUI_1.Frame_ebxRemarks.Caption := "300 Characters (Used: " +;
ALLTRIM( STR( nebxLen ) ) + " Remaining: " + ALLTRIM( STR( ( 300 - nebxLen ) ) ) + ")"
IF SUBSTR( FEAST->F1, 1, 3 ) == "SYS"
frmGUI_1.txbFeastDesc.Enabled := FALSE
frmGUI_1.txbFeastCode.Enabled := FALSE
frmGUI_1.txbMonthDay.Enabled := FALSE
frmGUI_1.ebxRemarks.Enabled := FALSE
ENDIF
frmGUI_1.txbFeastDesc.Setfocus()
ENDCASE
ENDIF cMode == "ADD"
frmGUI_1.Activate
RETURN NIL
********************************************************************************
static function CheckEventLostFocus( cMode )
LOCAL cControlName := UPPER( ALLTRIM( This.Name ) )
IF lLostfocusEvents
RETURN NIL
ELSE
lLostfocusEvents := TRUE
IF( VALIDATION( UPPER( cControlName ), cMode ), NIL, This.Setfocus )
lLostfocusEvents := FALSE
ENDIF
RETURN NIL
*********************************************
static function Validation( cObjName, cMode )
LOCAL cOrigOrder := ""
LOCAL cIndex := ""
LOCAL lResetOrder := FALSE
LOCAL lRetVal := FALSE
LOCAL nCurPos := RECNO()
LOCAL TVar1 := ""
LOCAL cSearchKey := ""
PRIVATE cScope
BEGIN SEQUENCE
DO CASE
CASE cDBMain == "HOLIDAY"
DO CASE
CASE cObjName == "TXBCODE"
IF cMode == "EDIT"; lRetVal := TRUE; BREAK; ENDIF
IF EMPTY( frmGUI_1.txbCode.Value )
MSGINFO("This is a required field, please fill-up the information","Input Mandatory")
BREAK
ENDIF
cSearchKey := frmGUI_1.txbCode.Value
IF Duplication( cSearchKey )
BREAK
ENDIF
CASE cObjName == "CBOHOLIDAYTYPE"
IF frmGUI_1.cboHolidayType.Value = 0
MSGINFO( "Please select holiday type", "Selection is Mandatory")
BREAK
ENDIF
ENDCASE
GUISaveButtonEnable()
CASE cDBMain == "ROLES"
DO CASE
CASE cObjName == "TXBCODE"
cIndex := dbRoles
lResetOrder := TRUE
IF cMode == "ADD"
frmGUI_1.txbCode.Value := NewDBRoleCode()
ENDIF
cSearchKey := frmGUI_1.txbCode.Value
DBSELECTAREA( "ROLES" )
cOrigOrder := ORDSETFOCUS( "Code", ( dbRoles ) )
IF Duplication( cSearchKey )
BREAK
ENDIF
ENDCASE
GUISaveButtonEnable()
CASE cDBMain == "BARRIO"
DO CASE
CASE cObjName == "TXBAREACODE"
cIndex := dbBarrio
lResetOrder := TRUE
IF cMode == "ADD" .AND. EMPTY( frmGUI_1.txbAreaCode.Value )
frmGUI_1.txbAreaCode.Value := NewBgyCode()
IF frmGUI_1.chkZone.Value = FALSE
frmGUI_1.txbZoneCode.Value := "00"
ELSE
frmGUI_1.txbZoneCode.Value := NewBgyZoneCode( frmGUI_1.txbAreaCode.Value )
ENDIF
ENDIF
cSearchKey := ALLTRIM( frmGUI_1.txbAreaCode.Value ) + ALLTRIM( frmGUI_1.txbZoneCode.Value )
DBSELECTAREA( "BARRIO" )
cOrigOrder := ORDSETFOCUS( "Zones", ( dbBarrio ) )
IF Duplication( cSearchKey )
IF MsgYesNo( "Are you going to input Zone information?","Duplicate Code over ride" ) = TRUE
lREtVal := TRUE
frmGUI_1.chkZone.Value := TRUE
ENDIF
BREAK
ENDIF
CASE cObjName == "TXBZONECODE"
cIndex := dbBarrio
lResetOrder := TRUE
IF cMode == "ADD"
IF frmGUI_1.chkZone.Value = TRUE
IF ALLTRIM( frmGUI_1.txbZoneCode.Value ) == "00"
frmGUI_1.txbZoneCode.Value := NewBgyZoneCode( frmGUI_1.txbAreaCode.Value )
ENDIF
ENDIF
ENDIF
cSearchKey := ALLTRIM( frmGUI_1.txbAreaCode.Value ) + ALLTRIM( frmGUI_1.txbZoneCode.Value )
DBSELECTAREA( "BARRIO" )
cOrigOrder := ORDSETFOCUS( "Zones", ( dbBarrio ) )
IF Duplication( cSearchKey )
BREAK
ENDIF
CASE cObjName == "TXBAREADESC"
IF EMPTY( frmGUI_1.txbAreaDesc.Value )
MSGSTOP( "Please fill-in with Baranggay or Barrio Name.", "Input mandatory" )
BREAK
ENDIF
TVar1 := "SPPC - " + ALLTRIM( frmGUI_1.txbAreaDesc.Value )
frmGUI_1.txbPPCZone.Value := TVar1
CASE cObjName == "TXBZONEDESC"
IF EMPTY( frmGUI_1.txbZoneDesc.Value )
MSGSTOP( "Please fill-in with Zone Name (Pangalan ng Purok)", "Input mandatory" )
BREAK
ENDIF
TVar1 := "SPPC - " + ALLTRIM( frmGUI_1.txbAreaDesc.Value )
TVar1 += " (" + ALLTRIM( frmGUI_1.txbZoneDesc.Value ) + ")"
frmGUI_1.txbPPCZone.Value := TVar1
ENDCASE
GUISaveButtonEnable()
CASE cDBMain == "COUNCIL"
DO CASE
CASE cObjName == "TXBPARENT"
cIndex := dbBarrio
lResetOrder := TRUE
IF cMode == "ADD" .AND. EMPTY( frmGUI_1.txbParent.Value )
frmGUI_1.txbParent.Value := NewCouncilParent()
frmGUI_1.txbChild.Value := "000"
ENDIF
cSearchKey := ALLTRIM( frmGUI_1.txbParent.Value ) + ALLTRIM( frmGUI_1.txbChild.Value )
DBSELECTAREA( "COUNCIL" )
cOrigOrder := ORDSETFOCUS( "ParentChild", ( dbCouncil ) )
DBSEEK( cSearchKey )
IF FOUND()
IF MsgYesNo( "Are you going to make an entry for Ministry or an Organization?","Duplicate Code" ) = TRUE
lRetVal := TRUE
ENDIF
BREAK
ENDIF
CASE cObjName == "TXBCHILD"
cIndex := dbCouncil
lResetOrder := TRUE
IF cMode == "ADD"
IF !ALLTRIM( frmGUI_1.txbChild.Value ) == "000"
frmGUI_1.txbChild.Value := NewCouncilChild( frmGUI_1.txbParent.Value )
ENDIF
ENDIF
cSearchKey := ALLTRIM( frmGUI_1.txbParent.Value ) + ALLTRIM( frmGUI_1.txbChild.Value )
DBSELECTAREA( "COUNCIL" )
cOrigOrder := ORDSETFOCUS( "ParentChild", ( dbCouncil ) )
IF Duplication( cSearchKey )
BREAK
ENDIF
CASE cObjName == "TXBDESC"
IF EMPTY( frmGUI_1.txbDesc.Value )
MSGSTOP( "Please fill-in the required name or information.", "Input mandatory" )
BREAK
ENDIF
ENDCASE
GUISaveButtonEnable()
CASE cDBMain == "EVENTS"
DO CASE
CASE cObjName == "TXBEVENTCODE"
IF cMode == "ADD"
IF EMPTY( frmGUI_1.txbEventCode.Value )
frmGUI_1.txbEventCode.Value := CodeGenerator( "EN" )
ENDIF
cScope := aDbfFilter_[ 1 ] + aDbfFilter_[ 2 ]
nCurPos := EVENTS->( RECNO() )
DBSELECTAREA( "EVENTS" )
ORDSCOPE( 0, NIL )
ORDSCOPE( 1, NIL )
IndexManager( "EVENTS", "EventCode", dbEvents )
IF DUPLICATION( frmGUI_1.txbEventCode.Value )
DBSELECTAREA( "EVENTS" )
IndexManager( "EVENTS", "ClassDesc", dbEvents )
ORDSCOPE( 0, "&cScope" )
ORDSCOPE( 1, "&cScope" )
DBGOTOP()
DBGOTO( nCurPos )
MSGSTOP( "Please check the computer's clock and set it to correct time. If error persist replace the CMOS battery.", "Duplication is not allowed" )
BREAK
ENDIF
DBSELECTAREA( "EVENTS" )
IndexManager( "EVENTS", "ClassDesc", dbEvents )
ORDSCOPE( 0, "&cScope" )
ORDSCOPE( 1, "&cScope" )
DBGOTOP()
DBGOTO( nCurPos )
frmGUI_1.txbParent.Value := aDbfFilter_[ 1 ]
frmGUI_1.txbChild.Value := aDbfFilter_[ 2 ]
frmGUI_1.txbDesc.Value := aDbfFilter_[ 3 ]
ENDIF
CASE cObjName == "TXTEVENTNAME"
IF EMPTY( frmGUI_1.txtEventName.Value )
MSGSTOP( "Please fill-in the information required.", "Input mandatory" )
BREAK
ENDIF
ENDCASE
GUISaveButtonEnable()
CASE cDBMain == "FEAST"
DO CASE
CASE cObjName == "TXBFEASTDESC"
IF EMPTY( frmGUI_1.txbFeastDesc.Value )
MSGSTOP( "Please fill-in the information required.", "Input mandatory" )
BREAK
ENDIF
CASE cObjName == "TXBMONTHDAY"
IF EMPTY( frmGUI_1.txbMonthDay.Value )
MSGSTOP( "Please fill-in the information required.", "Input mandatory" )
BREAK
ENDIF
ENDCASE
GUISaveButtonEnable()
ENDCASE
lRetVal := TRUE
END SEQUENCE
DBSELECTAREA( (oTable:cMainAlias ) )
IF lResetOrder
ORDSETFOCUS( ( cOrigOrder ), ( cIndex ) )
ENDIF
DBGOTO( nCurPos )
RETURN lREtVal
*************************************
static function GUISaveButtonEnable()
frmGUI_1.btnGUISave.Enabled := TRUE
RETURN NIL
To Moderators: I'm sorry its a long post but perhaps it can be considered.
Regards,
Danny
Regards,
Danny
Manila, Philippines
Danny
Manila, Philippines
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: EXIT BUTTON VALIDATION
Hi Danny
Not a SSW, but an useful and interesting reading to compare and denote differences between text and GUI programming
Viva HMG
Thank to share you codedhaine_adp wrote:Here is a multiple flat table and multiple windows validation routine written in clipper logic and was adopted to HMG (windows). Its a code snippet but if you read the code carefully you'll find that it is more like a clipper code roughly equivalent to:...
Not a SSW, but an useful and interesting reading to compare and denote differences between text and GUI programming
Viva HMG
Viva INTERNATIONAL HMG
Re: EXIT BUTTON VALIDATION
Hi Danny
Nice Code to learn like me
Nice Code to learn like me
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
-
- Posts: 21
- Joined: Fri Aug 30, 2013 5:38 am
Re: EXIT BUTTON VALIDATION
Thank you gfilatov
Your suggesion worked perfectly
Your suggesion worked perfectly