lmorning and levening
I'm probably setting the search wrong, could you help me solve it?
- Code: Select all Expand view RUN
- function Isfree( oRec, oSay )
local lNew := ( oRec:RecNo == 0 )
local oDbf := oRec:uSource
local oBrw := oRec:oBrw
local lreturn := .t.
local cSearch, nBooked := 0, hBooked
cSearch := "ROOMS_ID == ? .AND. ALLTRIM(TYPE) == ? .AND. RECNO() != ? .AND. " + ;
"CHECK_IN <= ? .AND. CHECK_OUT >= ? .AND. MORNING !=? .AND. EVENING !=?"
if Empty( oRec:rooms_id ) .or. Empty( oRec:Type ) .or. Empty( oRec:check_in ) .or. ;
Empty( oRec:check_out ) .or. oRec:check_in > oRec:check_out
lreturn := .f.
oSay:VarPut( "INVALID DATA" )
oSay:SetColor( CLR_WHITE, CLR_RED )
oSay:Refresh()
else
cSearch := oDbf:ApplyParams( cSearch, { oRec:rooms_id, oRec:type, oRec:RecNo, ;
oRec:check_out, oRec:check_in, oRec:morning,oRec:evening } )
if oDbf:LookUp( cSearch, nil, { || nBooked := RECNO(), hBooked := FW_RecToHash(), .t. } ) == .t.
lreturn := .f.
oSay:VarPut( "BOOKED FROM " + DTOC( hBooked[ "check_in" ] ) + " TO " + ;
DTOC( hBooked[ "check_out" ] ) )
oSay:SetColor( CLR_WHITE, CLR_HRED )
oSay:Refresh()
elseif oRec:Modified()
lreturn := .t.
oSay:VarPut( "FREE" )
oSay:SetColor( CLR_WHITE, CLR_GREEN )
oSay:Refresh()
else
lreturn := .f.
oSay:VarPut( "" )
oSay:SetColor( CLR_BLACK, oSay:oWnd:nClrPane )
oSay:Refresh()
endif
endif
if oBrw != nil .and. oBrw:nBooked != nBooked
oBrw:nBooked := nBooked
oBrw:Refresh()
endif
return lreturn