returnThisBook(whoCalledMe : Button ) updating;

vars	
	bwh 				: BookWeHold;
	mbr				: Member;
	today		 	: Date ; 
	btn 				: Button;
	isOK				: String ;
	uc					: UC_ReturnBook;

begin
	// -------------------------------------------------------------- validate the data  // Upfront
	stBar.caption := null;
	if tbBookNumb.text<>null then							// is there a book number
		if tbBookNumb.text.trimBlanks<>null then							// is there a book number
			bwh 	:= global.lib.allBooksWeHold	.getAtKey( tbBookNumb.text );
			if bwh=null then																				// Does that book exist?
				stBar.caption := stBar.caption & "Bk that ID unknown! ";
			else																										// Yes, Book exists
					tbBookTitle.text := bwh.myBook.name;						// fill in its name
					
					if not bwh.isLent then 														// Is it on loan?
						stBar.caption := "Bk '" & bwh.accessionNo & "'  not on loan! ";   //Can't be returned
					else																								// Is lent, to ...
						tbMembName.text 	:= bwh.myBorrower.name;
						tbMembNumb.text	:= bwh.myBorrower.memNumb;
					endif;	
			endif;					//----------------------------------------- end validation
		else
			stBar.caption := "Enter a book number! ";
		endif;	
	endif;
	
	if stBar.caption=null then										// No errors found in the input data
		beginTransaction;													// Do the return, and exit
			create uc;
			uc.returnABook (bwh, mbr);							// Trivial usecase
			delete uc;
		commitTransaction;
		stBar.caption := "Returned.";//  Display Success message
		process.sleep(500);
		if whoCalledMe= bnNext then
						bnClear_click (btn);
				else
						bnClose_click (btn);
		endif;				
		abortTransaction;
	endif ;
end ;
