Page 1 of 2

EXIT BUTTON VALIDATION

Posted: Fri Sep 27, 2013 2:31 pm
by manoj_duamzn
Dear Sir,
I have started to work in HMG. Kindly help me. I have set validation for Company Code & Company Name and when I press Exit Button it is going on validation of
Company Code because focus is on CC TextBox. Kindly suggest me what coding will be done. I am attaching test.prg for you. and also guide me for better codeing.

Re: EXIT BUTTON VALIDATION

Posted: Fri Sep 27, 2013 6:43 pm
by Javier Tovar
Hello

In my opinion you are doing things a little difficult, since HMG and is a bit more friendly.

I find that when looking for the key to the company not doing it for index, I think you should create an index for the search is fast and effective.

I see you're back to validate the name, you just have to do a search, either by a single field or field compound (two or more key fields name). I think in your example should only be by CODE and the name alone bring it to the database and put it in the textbox name.

And you must open and close the databases in each function, Habren and close only once.

The structure of your program must have the following structure +o-:

# include "hmg.ch"
# define TRUE. T.

Function main ()
Local hWnd

Public nWCrt: = GetDesktopWidth ()
SET EXCLUSIVE OFF

REQUEST HB_LANG_ES / / that the cancellation error messages or display them in Castilian me
REQUEST DBFCDX
RddSetDefault ("DBFCDX")

DEFINE WINDOW Win_Prin;
AT 0.0;
WIDTH 307;
HEIGHT 147;
TITLE 'SYSTEM';
ICON "LOGO";
BACKCOLOR {0,0,255};
MAIN;
ON INIT (BasesOpen ()) / / OPEN THE BASIS FOR UNIQUE OPPORTUNITY
ON RELEASE (BasesClose ()) / / CLOSE THE BASIS FOR UNIQUE OPPORTUNITY

DEFINE TEXTBOX text_1
ROW 10
COL 140
........

END TEXTBOX


END WINDOW

WINDOW CENTER Win_Prin

ACTIVATE WINDOW Win_Prin

ENDIF


RETURN



ADVISE YOU THAT:
1. - JUST OPEN YOUR DBFs E RATIOS NTX or CDX ONCE
2. - You referred FOR THEM TO "SELECT" ..... ETC.
3. - BE IS ORDERED, A TEACHER TOLD ME, "MAKE THINGS FOR FOOLS" (understandable MOST ANYTHING YOU CAN).

PS: I am also beginner but this has helped me.


PRG DOS COMMAND YOU FOUND THAT ONE OF THE TOPICS AND I HAVE SERVED AS A GUIDE.

Re: EXIT BUTTON VALIDATION

Posted: Fri Sep 27, 2013 6:48 pm
by Javier Tovar
FILE...........

Re: EXIT BUTTON VALIDATION

Posted: Fri Sep 27, 2013 6:49 pm
by Javier Tovar
file...

Re: EXIT BUTTON VALIDATION

Posted: Sat Sep 28, 2013 4:46 am
by bpd2000
Change logic of ON LOSTFOCUS validation
Simple way is validate during saving of data
Either
Send data file along with .prg

Re: EXIT BUTTON VALIDATION

Posted: Sat Sep 28, 2013 6:57 am
by esgici
bpd2000 wrote:Change logic of ON LOSTFOCUS validation
Simple way is validate during saving of data
Either
Send data file along with .prg
I agree with Dave (bpd2000);

Simple ways are always easy and secure :arrow:

... and without (sample) data file(s) working on problem isn't easy and secure :?

Happy HMG'ing :D

Re: EXIT BUTTON VALIDATION

Posted: Sat Sep 28, 2013 11:23 am
by manoj_duamzn
I am attaching herewith prg & dbf file as per your need.
Beside this I want to say that in previous period in clipper application I always give validation question to question and Is is required because manytimes another question is depend on answer of previous question.

Re: EXIT BUTTON VALIDATION

Posted: Sat Sep 28, 2013 4:42 pm
by Javier Tovar
If ...

What I see is that if your program works ....

1. - When you give the code of the company, if there does not say anything and goes to the next textbox, if there is already alerts you that this code already exists.
Two. - When you give a company name and does not warn you if you leave anything blank, you say there is a BUG, that you can not leave empty the Textbox.
Three. - When you want to register, just this that option and give enter.

The problem I see is that you have no option to cancel if not correct. you back or if you want to change something.

I think you should implement "High", "Low", "Changes", and "Queries" on your screen.

Or is something else you need?

Re: EXIT BUTTON VALIDATION

Posted: Sun Sep 29, 2013 9:15 am
by esgici
manoj_duamzn wrote:...another question is depend on answer of previous question.
Don't be lost yourself into labirent of questions built by yourself ;)

Attached a suggestion, not a real manager; a simple sample only :

Doesn't provide bell and whistles; only works, does its job ;)
Screen shoot of Company Database Manager
Screen shoot of Company Database Manager
CompDBMan.jpg (51.04 KiB) Viewed 5935 times
CompDBMan.zip
Source files for Company Database Manager
(2.74 KiB) Downloaded 324 times
I hope give you an idea :idea:

Happy HMG'ing :D

Re: EXIT BUTTON VALIDATION

Posted: Mon Sep 30, 2013 9:48 am
by gfilatov
manoj_duamzn wrote:I am attaching herewith prg & dbf file as per your need.
Beside this I want to say that in previous period in clipper application I always give validation question to question and Is is required because manytimes another question is depend on answer of previous question.
Hello,

It seems that you think in clipper direction hitherto however your environment was changed now ;)

BTW you can take a look for your updated sample with implemented your needs below:

Code: Select all

#include "minigui.ch"
#xtranslate VALID <condition> [MESSAGE <message>];
=>;
ON LOSTFOCUS _DOVALID (<condition>,<message>)
MEMVAR _HMG_ISVALIDINPROGRESS

PROCEDURE MAIN()
	PUBLIC CDIR,_HMG_ISVALIDINPROGRESS := .F.,exit := .F.
	SET MULTIPLE OFF WARNING
	SET NAVIGATION EXTENDED
	CDIR='\'+CURDIR()	
	SET DEFA TO &CDIR
	USE COMPANY
	DEFINE WINDOW WINMAIN AT 0,0;
                      WIDTH 500 HEIGHT 700 TITLE "TESTING SOFTWARE";
                      WINDOWTYPE MAIN
		DEFINE MAIN MENU
			POPUP "FIRM MENU"
				ITEM "CREATE NEW FIRM" ACTION COMPADD()
				ITEM "EDIT FIRM DATA"  ACTION NIL
				ITEM "SELECT A FIRM"   ACTION NIL
				ITEM "BACKUP FIRM DATA" ACTION NIL
				ITEM "RESTORE FIRM DATA" ACTION NIL
				ITEM "DELETE FIRM" ACTION NIL
				SEPARATOR
				ITEM "Exit" ACTION EXIT PROGRAM    
			END POPUP
		END MENU
	END WINDOW
        MAXIMIZE WINDOW WINMAIN
	WINMAIN.ACTIVATE()
RETURN 

*****************
PROCEDURE COMPADD
*****************
exit := .F.
DEFINE WINDOW WINCOMPADD AT 100,100; 
              WIDTH 560 HEIGHT 360;
              TITLE "Add New Company";
              FONT 'ARIAL' SIZE 12;
              WINDOWTYPE CHILD;
              ON INIT  WINCOMPADD.CC.SETFOCUS ;
              ON INTERACTIVECLOSE exit:=.T.
	@ 30, 30  LABEL LBLCC    VALUE 'Company Code' 
	@ 80, 30  LABEL LBLCNAME VALUE 'Company Name'  
	@ 130,30  LABEL LBLCADD1 VALUE 'Address'
	@ 230,30  LABEL LBLFDATE VALUE 'From Date'
	@ 230,300 LABEL LBLTDATE VALUE 'To Date'
	@ 30, 150 TEXTBOX CC WIDTH 25 MAXLENGTH 2 VALID V_CC() MESSAGE 'THIS COMPANY CODE ALREADY EXISTS....'
	@ 80, 150 TEXTBOX CNAME WIDTH 375 MAXLENGTH 35 VALID V_CNAME() 
	@ 130,150 TEXTBOX CADD1 WIDTH 375 MAXLENGTH 80 
	@ 155,150 TEXTBOX CADD2 WIDTH 375 MAXLENGTH 80 
	@ 180,150 TEXTBOX CADD3 WIDTH 375 MAXLENGTH 80 
	@ 230,150 DATEPICKER FDATE 
	@ 230,380 DATEPICKER TDATE 
	@ 280,175 BUTTON BTNSAVE CAPTION 'Save' WIDTH 100 ON CLICK SAVECOMPANYDATA()
	@ 280,285 BUTTON BTNEXIT CAPTION 'Exit' WIDTH 100 ACTION EXITWINDOW()
END WINDOW
WINCOMPADD.CENTER()
WINCOMPADD.ACTIVATE()
RETURN

*************
FUNCTION V_CC
*************
IF ! EMPTY(THIS.VALUE)
   SELECT COMPANY
   LOCA FOR COMPCODE=WINCOMPADD.CC.VALUE
   IF FOUND()
	RETURN .F.
   ENDIF
ENDIF
RETURN .T.

****************
FUNCTION V_CNAME
****************
IF EMPTY(WINCOMPADD.CNAME.VALUE)
	RETURN .F.
ENDIF
RETURN .T.

************************
FUNCTION SAVECOMPANYDATA
************************
IF ! EMPTY(WINCOMPADD.CC.VALUE)
	SELECT COMPANY
	APPE BLAN
	REPL COMPCODE WITH WINCOMPADD.CC.Value
	REPL COMPNAME WITH WINCOMPADD.CNAME.VALUE
	REPL COMPADD1 WITH WINCOMPADD.CADD1.VALUE
	REPL COMPADD2 WITH WINCOMPADD.CADD2.VALUE
	REPL COMPADD3 WITH WINCOMPADD.CADD3.VALUE
	REPL FROMDATE WITH WINCOMPADD.FDATE.VALUE
	REPL TODATE   WITH WINCOMPADD.TDATE.VALUE
	MSGINFO("COMPANY HAS BEEN INSTALLED")
	RELEASE WINDOW WINCOMPADD
ELSE
	MSGSTOP("PLEASE ENTER COMPANY CODE!")
	SETFOCUS CC OF WINCOMPADD
ENDIF
RETURN NIL

*******************
FUNCTION EXITWINDOW
*******************
RELEASE WINDOW WINCOMPADD
RETURN .T.

************************************** 
FUNCTION _DOVALID (EXPRESSION,MESSAGE)
************************************** 
IF _HMG_ISVALIDINPROGRESS .OR. THIS.FOCUSEDCONTROL == "BTNEXIT" .OR. exit
	RETURN NIL
ELSE
	IF VALTYPE(MESSAGE)="U"
		MESSAGE := "INVALID ENTRY"
	ENDIF
	_HMG_ISVALIDINPROGRESS := .T.
	IF (EXPRESSION,NIL,(MSGSTOP(MESSAGE,"ERROR"),THIS.SETFOCUS))
	_HMG_ISVALIDINPROGRESS := .F.
ENDIF
RETURN NIL
Please looks at above code for using FOCUSEDCONTROL property and ON INTERACTIVECLOSE event for breaking of unneeded validation on exit from form.

Hope that helps :idea: