rooms_id
type
check in
check_out
every time I change a reservation date I have to check if the TYPE element with number ROOMS_ID is free
using this function:
- Code: Select all Expand view
@ 52, 47 DTPICKER aGet[4] VAR oRecPrenota:Check_Out OF oDlg SIZE 54, 12 PIXEL FONT oFont ;
on change Isfree(oRecPrenota:Rooms_Id,oRecPrenota:Type,oRecPrenota:Check_Out,oRecPrenota:Check_In,oReserva)
Nages IsFree() function
- Code: Select all Expand view
Function Isfree(cCamera,cTypeRoom,dCheckOut,dCheckIn,oReserva)
local lreturn :=.f.
local cSearch := oReserva:ApplyParams( "ROOM_ID == ? .AND. ALLTRIM(TYPE) == ? .AND. RECNO() != ? .AND. (CHECK_IN > ? .OR. CHECK_OUT < ? )", ;
{ cCamera, ALLTRIM( cTypeRoom ), oReserva:RecNo(), dCheckOut, dCheckIn } )
if oReserva:LookUp( cSearch, nil, { || .T. } ) == .T.
? "room is available"
lreturn :=.t.
else
? "room is not availble"
lreturn :=.f.
endif
return lreturn
this my sample archive
Results
0006, 08-07-2021, 29-07-2021, 01, isFree() = F correct F
0001, 08-07-2021, 29-07-2021, 02, isFree() = F incorrect T
0006, 08-07-2021, 28-07-2021, 01, isFree() = T incorrect F
0002, 14-07-2021, 14-07-2021, 01, isFree() = F incorrect T
As you can see, 3 out of 4 are incorrect.
There is something seriously wrong with the search logic in the code for the search parameters or in the TDatabase LookUp() method.
any solution pls?