	 unloadForm;
=================================================
bnClear_click(btn: Button input) updating;			// re-set datafields to empty state
vars
begin
	tbMemberName.text		:=	"";
	tbMemberNumber.text		:=	"";
	tbBookName.text			:=	"";	
	tbBookNumber.text		:=	"";
end;
=================================================
vars  btn : Button;

begin	bnClear_click (btn);  		// The load method is calling upon the clear method.
end;
====================================================
bnNext_click ( btn:Button input ) updating ; 

begin	nextAndOK ( bnNext );			// We pass the buttons name (bnNext) in so that nextAndOK can tell 
end ;									// which button called it.
====================================================
bnOk_click ( btn:Button input ) updating ; 

begin	nextAndOK ( bnOk );			// We pass the buttons name (bnOk) in so that nextAndOK can tell 
end ;									// which button called it.
=====================================================
nextAndOK( whoCalledMe : Button) updating;	// We receive the identity of the caller, bnNext or bnOK
												// in whoCalledMe.
vars	uc 		: UC_IssueBook;
		result 	: String;
		btn		: Button;
begin
	stBar.caption := ;
	beginTransaction;
	create uc;										// create an instance of the UC_IssueBook  usecase
	result 	:= uc.issueBook (	
						tbMemberNumber.text,	// and run its issueBook method
						tbBookNumber.text,
						tbMemberName.text,
						tbBookName.text);			// the result, a String, is put into 'result'
	if result = null  then							// Look at the result
		stBar.caption := "Issue recorded";			// No error! Display a success message.
		if whoCalledMe = bnOk  then
		 	bnClose_click (btn);					// We Close
		else
			bnClear_click (btn);					// We Clear
		endif;
		commitTransaction;						// update the database
	else
		stBar.caption := result;						// Display the error message
		abortTransaction;							// Do not update the database
	endif ;
end;
====================================================
issueBook(    mNumb, 	bNumb,  mName, bName  : String io ) : String updating; 
											// io means input-output; the method can change these values
											//     when control  returns to the calling method
vars	
	libr				: Publibrary;		today	: Date ;
	member, m	: Member ;			buk		: Book ; 	
	bwh, b			: BookWeHold ;		errMsg	: String ;			 		

begin
	libr	:= PubLibrary.firstInstance;					// Get a reference to the library object
	if (  mNumb <> null and bNumb <> null ) then 	// is the vital data there?
		mNumb 		:= mNumb.toUpper ; 			// uppercase the member number
		bNumb  		:= bNumb.toUpper ; 			// uppercase the book number		
		
		member	 	:= null;							// Search for that Member object
		foreach m in Member.instances do			//  We use a   loop   to search
			if m.memNumb = mNumb then 
				member := m;							// found it !
			endif;	
		endforeach;
		if member=null then
				errMsg := "That member number is not known! " ;
		endif;		

		bwh := null; 									// search for that BookWeHold object			
		foreach b in BookWeHold.instances do		// We use a   loop   to search through all books
			if b.accessionNo = bNumb  then 
				bwh := b;								// found it !
			endif;	
		endforeach;
		if bwh=null then
			errMsg := errMsg & "That book no. is not known!" ;
		else											// is known, but?
			if bwh.isLent then
				errMsg 	:= errMsg & "Book out on loan to " &   bwh.myBorrower.memNumb ;
			endif;
		endif;		
													
		if errMsg=null then							// any errors?
				mName			:= member.name ;	// both member and book have been found
				buk					:= bwh.myBook ;	// Look up the BookWehold's title
				bName				:= buk.name ;
				bwh.isLent			:= true ;
				bwh.dateLent		:= today ;
				bwh.dateDueBack	:= today + 14 ;
				bwh.numbXIssued	:= bwh.numbXIssued + 1 ;
				bwh.myBorrower	:= member ; 	// book now knows who borrowed it
		endif ;								//so (by inverse) the member knows the book he borrowed
	endif ;
	return errMsg ;		// Return to calling method.
end ;
=============================================================