************
* BANKER.PRG
************

#DEFINE BUTTONEVENT 6
SET PROCEDURE TO BANKER

USE BANKER2
INDEX ON NAME TO BANKER2

DECLARE anames[RECCOUNT() + 1]
anames[1] = 'Customers'
FILL ARRAY ALL START WITH 2 anames ;
	WITH SUBSTR(NAME,1,20)
GOTO TOP

SET LISTBOX TO 7

mname = anames[2]
tname = NAME

CREATE BUTTON ' Done ' AT 23,35
CENTER("Demo Application",2,0,75,10)

@ 6,0 SAY "  Lending Customer's Name:" GET tname ;
	VALID NEWNAME(tname) CHANGE
@ 8,0 SAY "           Account Number:" GET acct_no
@ 9,45 GET mname LISTBOX @anames VALID LISTNAME()
@ 10,0 SAY "     Date the Loan Opened:" GET date_open
@ 12,0 SAY "    Beginning Loan Amount:" ;
	GET beg_amount
@ 14,0 SAY "          Current Balance:" GET balance
@ 16,0 SAY "            Loan Category:" GET category

DO WHILE .T.
	tname = NAME
	READ SAVE
	IF LASTKEY() = 27 .OR. EVENT() = BUTTONEVENT
		EXIT
	ENDIF
ENDDO

CLEAR GETS
RETURN

******************
FUNCTION NEWNAME()
******************
PARAMETER findme
SEEK TRIM(findme)
IF .NOT. EOF()
	tname = NAME
	mname = SUBSTR(NAME,1,20)
	UPDATE GETS
	GETNO(1)
ELSE
	BEEP
	MESSAGE(TRIM(findme),' Does Not Exist')
	RETURN(.F.)
ENDIF
RETURN(.T.)

*******************
FUNCTION LISTNAME()
*******************
retval = NEWNAME(mname)
RETURN(retval)
