in the reservation I have two datepick controls dFirst and dLast
in Insertion I have no problems but
in modification if the operator changes a date I always have to carry out a search to see if there is a reservation and the function always restores me a true value because it also sees the same reservation which, however, is in modification.
If the operator enters dlast - 1 day the search function tells me that it is already in the archive
if the operator enters dLast + 1 the search function tells me that it is already in the archive
if the operator changes the whole period and the search finds a reservation, it returns me a true value
how can i make sure that the modification does not fall into this error?
this is the function
- Code: Select all Expand view RUN
- Function Search_Element(cCamera,dCheck_in,dCheck_out,cTypeRoom)
Local cRoom
local lFree:=.T.
local nBottomScope, nTopScope
local oSearchDb
local afatture:={}
oSearchDb:=TReserva():New()
oSearchDb:SetOrder("room_in" )
oSearchDb:GoTop()
nTopScope:=oSearchDb:ordScope( 0, cCamera )
nBottomScope:=oSearchDb:ordScope( 1, cCamera )
oSearchDb:GoTop()
do while ! oSearchDb:Eof()
IF ( dCheck_in <= oSearchDb:CHECK_OUT .AND. dCheck_out >= oSearchDb:CHECK_IN ;
.AND. AllTrim(oSearchDb:TYPE ) == AllTrim( cTypeRoom ))
lFree:=.f.
ENDIF
oSearchDb:Skip()
enddo
oSearchDb:ordScope(0,nTopScope)
oSearchDb:ordScope(1,nBottomScope)
oSearchDb:Close()
return lFree
the dbf is index on oSearchDb:SetOrder("room_in" ) (ROOMS_ID + DToS( CHECK_IN ))
Someone can help me please ?