To Rao: Tdatabase search with ApplyParams/lookup

To Rao: Tdatabase search with ApplyParams/lookup

Postby Silvio.Falconi » Mon Jan 29, 2024 10:24 am

I must add two logic value to reasearch
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
 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 41 guests