ApplyParams Tdatabase
Posted: Tue Jul 13, 2021 7:35 am
I use this Nages function for search on a dbf ( with tdatabase)
however, I realized that if I call the function several times, it makes an error, that is, it does not make a truthful search
making mistakes in the procedure
In edit procedure I must change the position continuously and look for the most appropriate for the client
when I change the position I mean the type of the item, the number and the date range for the reservation.

the procedure should search the archive if the element (type) with the selected dates is free or busy and return me an info message
Code: Select all | Expand
Function IsFree(cCamera,dCheck_in,dCheck_out,cTypeRoom,oPrenotazioni)
local lFree
local cSearch
cSearch := oPrenotazioni:ApplyParams( "ROOMS_ID == ? .AND. ALLTRIM(TYPE) == ? .AND. RECNO() != ? .AND. (CHECK_IN > ? .OR. CHECK_OUT < ? )", ;
{ cCamera, ALLTRIM( cTypeRoom ), oPrenotazioni:RecNo(), dCheck_out, dCheck_in } )
if oPrenotazioni:LookUp( cSearch, nil, { || .T. } ) == .T.
lFree:=.t.
Msginfo("room is available"+CRLF+CRLF+;
"Room number : "+cCamera+CRLF+;
"Room ctype : "+cTypeRoom+CRLF+;
"Check in : "+cf(dCheck_in)+CRLF+;
"Check out : "+cf(dCheck_out)+CRLF+;
"No Record : "+ltrim(str(oPrenotazioni:RecNo())) )
else
Msginfo("room is not availble"+CRLF+CRLF+;
"Room number : "+cCamera+CRLF+;
"Room ctype : "+cTypeRoom+CRLF+;
"Check in : "+cf(dCheck_in)+CRLF+;
"Check out : "+cf(dCheck_out)+CRLF+;
"No Record : "+ltrim(str(oPrenotazioni:RecNo())) )
lFree:=.f.
endif
return lFree
however, I realized that if I call the function several times, it makes an error, that is, it does not make a truthful search
making mistakes in the procedure
In edit procedure I must change the position continuously and look for the most appropriate for the client
when I change the position I mean the type of the item, the number and the date range for the reservation.

the procedure should search the archive if the element (type) with the selected dates is free or busy and return me an info message