Lookup method of Tdatabase
- Silvio.Falconi
- Posts: 7140
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 1 time
Re: Lookup method of Tdatabase
sent a new demo reserva.dbf
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
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
- Silvio.Falconi
- Posts: 7140
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 1 time
Re: Lookup method of Tdatabase
Antonio Linares wrote:James,
very good finding
many thanks
Antonio congratulations for the new look, you look like santa claus ( fivewin's Santa claus)
Anyway I don't think the error is that i don't think at all that the function makes mistake for those wrong records, anyway tonight I recreated a new demo archive and I'm trying IsFree ()
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
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
- Antonio Linares
- Site Admin
- Posts: 42537
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 77 times
- Contact:
Re: Lookup method of Tdatabase
thank you ![Very Happy :-D](./images/smilies/icon_biggrin.gif)
I am trying to get a better quality photo with 80x80 pixels from this one. Maybe someone could help ?
![Image](https://github.com/FiveTechSoft/screenshots/blob/master/antonio_claus.jpg?raw=true)
![Very Happy :-D](./images/smilies/icon_biggrin.gif)
I am trying to get a better quality photo with 80x80 pixels from this one. Maybe someone could help ?
![Image](https://github.com/FiveTechSoft/screenshots/blob/master/antonio_claus.jpg?raw=true)
Re: Lookup method of Tdatabase
![Image](https://github.com/FiveTechSoft/screenshots/blob/master/antonio80_80.jpg?raw=true)
Mejor calidad es difícil
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
- Silvio.Falconi
- Posts: 7140
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 1 time
Re: Lookup method of Tdatabase
I tested a small sample with one record on archive
as you an see here
![Image](https://i.postimg.cc/bJWfbqcj/test.png)
on Edit I check ( when I change the date or type or number)
lFreeRoom:= Isfree(cCamera,cTypeRoom,ddcheckout,ddcheckin,oPrenotazioni)
give me the message "room is not availble"
as you an see here
![Image](https://i.postimg.cc/bJWfbqcj/test.png)
on Edit I check ( when I change the date or type or number)
lFreeRoom:= Isfree(cCamera,cTypeRoom,ddcheckout,ddcheckin,oPrenotazioni)
Code: Select all | Expand
Function Isfree(cCamera,cTypeRoom,dCheckOut,dCheckIn,oPrenotazioni)
local lreturn :=.f.
local cSearch := oPrenotazioni:ApplyParams( "ROOM_ID == ? .AND. ALLTRIM(TYPE) == ? .AND. RECNO() != ? .AND. (CHECK_IN > ? .OR. CHECK_OUT < ? )", ;
{ cCamera, ALLTRIM( cTypeRoom ), oPrenotazioni:RecNo(), dCheckOut, dCheckIn } )
if oPrenotazioni:LookUp( cSearch, nil, { || .T. } ) == .T.
? "room is available"
lreturn :=.t.
else
? "room is not availble"
lreturn :=.f.
endif
return lreturn
give me the message "room is not availble"
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
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
Re: Lookup method of Tdatabase
Sorry Silvio
You don't think this line should be
Code: Select all | Expand
{ cCamera, ALLTRIM( cTypeRoom ), oPrenotazioni:RecNo(), dCheckOut, dCheckIn }
You don't think this line should be
Code: Select all | Expand
{ cCamera, ALLTRIM( cTypeRoom ), oPrenotazioni:RecNo(), dCheckIn, dCheckOut }
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Lookup method of Tdatabase
CNavarro,
You don't think this line should be:
Originally, I thought this also, but it gets evaluated like this:
Thus it is checking to see that the proposed check_IN is less than the check_OUT of the record being evaluated OR the proposed check_OUT is less than the check_IN date of the record being evaluated. I know it is hard to grasp, but it only wants to know if there is no overlap in the reservation time. If it meets either one of the above tests, then it does not overlap.
James
You don't think this line should be:
Code: Select all | Expand
{ cCamera, ALLTRIM( cTypeRoom ), oPrenotazioni:RecNo(), dCheckIn, dCheckOut }
Originally, I thought this also, but it gets evaluated like this:
Code: Select all | Expand
... .and. ( oPrenotazioni:Check_IN > dCheck_OUT .or. oPrenotazioni:Check_OUT < dCheck_IN )
Thus it is checking to see that the proposed check_IN is less than the check_OUT of the record being evaluated OR the proposed check_OUT is less than the check_IN date of the record being evaluated. I know it is hard to grasp, but it only wants to know if there is no overlap in the reservation time. If it meets either one of the above tests, then it does not overlap.
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
- Enrico Maria Giordano
- Posts: 8756
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
Re: Lookup method of Tdatabase
Antonio Linares wrote:I am trying to get a better quality photo with 80x80 pixels from this one. Maybe someone could help ?
Look at your mailbox and let me know.
EMG
- Antonio Linares
- Site Admin
- Posts: 42537
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 77 times
- Contact:
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Lookup method of Tdatabase
Mr. Silvio
I modified the test.prg sent by you.
Please try this.
I am sure the results are correct.
![Image](https://imagizer.imageshack.com/img922/1557/BUPCTo.gif)
I modified the test.prg sent by you.
Please try this.
I am sure the results are correct.
Code: Select all | Expand
#include "FiveWin.ch"
#include "dtpicker.ch"
request dbfcdx
request dbffpt
request hb_lang_it
request hb_codepage_itwin
function Main()
RddSetDefault( "DBFCDX" )
HB_LANGSELECT( "IT" )
HB_SETCODEPAGE( "ITWIN" )
SetHandleCount( 100 )
FWNumFormat( "E", .t. )
SetGetColorFocus()
SET DATE FORMAT "dd-mm-yyyy"
SET DELETED ON
SET CENTURY ON
SET EPOCH TO year( date() ) - 20
SET MULTIPLE OFF
Test()
return nil
//----------------------------------------------------------------------------------------------------------------------------------------------//
function test()
local oReserva
local oDlg, oBar, oBrw, oFont
oReserva := TReserva():New()
oReserva :setorder( 0 )
oReserva:GoTop()
/*
oReserva:goto(6) // nrecord number 6
oReserva:Edit()
*/
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE DIALOG oDlg SIZE 700,400 PIXEL TRUEPIXEL FONT oFont TITLE "RESERVA"
DEFINE BUTTONBAR oBar OF oDlg SIZE 80,32 2007
@ 32,20 XBROWSE oBrw SIZE -200,-20 PIXEL OF oDlg DATASOURCE oReserva ;
COLUMNS "DATE","ROOMS_ID","CHECK_IN","CHECK_OUT","STATUS","TYPE" ;
LINES NOBORDER
WITH OBJECT oBrw
:nMarqueeStyle := MARQSTYLE_HIGHLROW
:RecSelShowRecNo()
:AddVar( "nBooked", 0 )
:bClrStd := { || If( oBrw:BookMark == oBrw:nBooked, { CLR_WHITE, CLR_HRED }, { CLR_BLACK, CLR_WHITE } ) }
//
:CreateFromCode()
END
DEFINE BUTTON OF oBar PROMPT "New" CENTER ACTION oBrw:EditSource( .t. )
DEFINE BUTTON OF oBar PROMPT "Modify" CENTER ACTION oBrw:EditSource()
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
//----------------------------------------------------------------------------------------------------------------------------------------------//
function Edit_Reservation( oRec )
local oDlg, oFont, oBold, oSay, oGrp, oBtn, bCheck, cText := ""
local aGet[4]
local oBrw := oRec:oBrw
local lNew := ( oRec:RecNo == 0 )
local lSave := .f.
local lFree := .t.
DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0,-8
oBold := oFont:Bold()
DEFINE DIALOG oDlg SIZE 276,230 PIXEL TRUEPIXEL ;
TITLE If( lNew, "New","Modifica" ) + " record" FONT oFont
@ 0, 8 GROUP oGrp TO 140, 268 OF oDlg PIXEL
@ 24, 20 SAY "Number:" OF oDlg SIZE 52, 16 PIXEL FONT oFont
@ 20, 94 GET aGet[1] VAR oRec:Rooms_Id PICTURE "9999" OF oDlg SIZE 40, 24 PIXEL FONT oFont
@ 52, 20 SAY "Type:" OF oDlg SIZE 36, 16 PIXEL FONT oFont
@ 48, 94 GET aGet[2] VAR oRec:Type PICTURE "99" OF oDlg SIZE 20, 24 PIXEL FONT oFont
@ 80, 20 SAY "Check In:" OF oDlg SIZE 54, 16 PIXEL FONT oFont
@ 76, 94 DTPICKER aGet[3] VAR oRec:Check_In OF oDlg SIZE 108, 24 PIXEL FONT oFont
@ 108, 20 SAY "Check Out:" OF oDlg SIZE 64,16 PIXEL FONT oFont
@ 104, 94 DTPICKER aGet[4] VAR oRec:Check_Out OF oDlg SIZE 108, 24 PIXEL FONT oFont ;
@ 148, 8 SAY oSay PROMPT cText SIZE 260,24 PIXEL OF oDlg CENTER VCENTER FONT oBold
@ 192, 96 BUTTON oBtn PROMPT "Confirm" OF oDlg SIZE 84, 24 PIXEL FONT oFont ;
WHEN oRec:Modified() .and. lFree ;
DEFAULT ACTION ( lSave := .t., oDlg:End() )
@ 192, 184 BUTTON oBtn PROMPT "Exit" OF oDlg SIZE 84, 24 PIXEL FONT oFont ;
CANCEL ACTION (oDlg:End())
bCheck := { || lFree := IsFree( oRec, oSay ), oDlg:AEvalWhen(), .t. }
AEval( aGet, { |o| o:bValid := bCheck } )
AEval( aGet, { |o| o:bChange := bCheck }, 3, 2 )
ACTIVATE DIALOG oDlg CENTERED ON INIT Eval( bCheck )
RELEASE FONT oFont, oBold
if oBrw != nil .and. oBrw:nBooked != 0
oBrw:nBooked := 0
oBrw:Refresh()
endif
IF lSave
// oRec:SAVE()
ENDIF
return nil
//----------------------------------------------------------------------------//
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 >= ?"
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 } )
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
//-------------------------------------------------------------------------------------------------------------------------------------------//
// CLASSES
//----------------------------------------------------------------------------//
CLASS TXData from TDataBase
DATA cDbfPath INIT cFilePath( ExeName() )
ENDCLASS
//----------------------------------------------------------------------------//
CLASS TReserva from TXData
METHOD New()
METHOD Record( cFieldList, lNew )
ENDCLASS
METHOD New( lShared ) CLASS TReserva
Default lShared := .t.
::Super:Open(,::cDbfPath + "Reserva" ,"DBFCDX", lShared)
if ::Used()
::setOrder(1)
::GoTop()
endif
::bEdit := { |oRec| Edit_Reservation( oRec ) }
return Self
METHOD Record( cFieldList, lNew ) CLASS TReserva
local oRec := ::Super:Record( cFieldList, lNew )
if oRec:RecNo == 0 // lNew
WITH OBJECT oRec
:Rooms_id := "0001"
:Type := "01"
:Check_in := Date()
:Check_Out := Date()
END
endif
return oRec
//----------------------------------------------------------------------------//
![Image](https://imagizer.imageshack.com/img922/1557/BUPCTo.gif)
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Lookup method of Tdatabase
Nages,
Hmm, is there something different about the above two postings you made, or are they the same and you accidentally posted it twice?
Hmm, is there something different about the above two postings you made, or are they the same and you accidentally posted it twice?
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
- Otto
- Posts: 6404
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 24 times
- Been thanked: 2 times
- Contact:
Re: Lookup method of Tdatabase
Dear Mr. Rao,
Thank you for this nice sample. Would you be so kind to post the dbf structure?
Best regards,
Otto
Thank you for this nice sample. Would you be so kind to post the dbf structure?
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Lookup method of Tdatabase
James Bott wrote:Nages,
Hmm, is there something different about the above two postings you made, or are they the same and you accidentally posted it twice?
Same posting got posted twice. I don't know why. I deleted one of them now.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Lookup method of Tdatabase
Otto:
Code: Select all | Expand
Function genRESERVA()
local aStruc:={}
aadd( aStruc, { "DATE", "D",8, 0 } )
aadd( aStruc, { "ROOMS_ID", "C",4, 0 } )
aadd( aStruc, { "CHECK_IN", "D",8, 0 } )
aadd( aStruc, { "CHECK_OUT", "D",8, 0 } )
aadd( aStruc, { "STATUS", "C",2, 0 } )
aadd( aStruc, { "TYPE", "C",2, 0 } )
aadd( aStruc, { "FIRST", "C",15, 0 } )
aadd( aStruc, { "LAST", "C",15, 0 } )
aadd( aStruc, { "GUEST", "C",30, 0 } )
aadd( aStruc, { "PHONE", "C",14, 0 } )
aadd( aStruc, { "NUMPRE", "C",18, 0 } )
aadd( aStruc, { "INVOICE", "C",18, 0 } )
aadd( aStruc, { "SUBTOTAL", "N",12, 2 } )
aadd( aStruc, { "DESCOUNT", "N",12, 2 } )
aadd( aStruc, { "DATAPAYED", "D",8, 0 } )
aadd( aStruc, { "DEPOSIT", "N",12, 2 } )
aadd( aStruc, { "TOPAY", "N",12, 2 } )
aadd( aStruc, { "TOTAL", "N",12, 2 } )
aadd( aStruc, { "NOTE", "C",80, 0 } )
aadd( aStruc, { "OMAGGIO", "L",1, 0 } )
aadd( aStruc, { "LISTINO", "C",2, 0 } )
aadd( aStruc, { "TIPODAY", "C",1, 0 } )
aadd( aStruc, { "SECTOR", "C",1, 0 } )
dbcreate( "RESERVA.DBF" , aStruc, "DBFCDX" )
Return nil
//---------------------------------------------------------------------------//
Function Reindex()
ferase("Reserva.cdx")
field ROOMS_ID, CHECK_IN, FIRST, LAST, TYPE, NUMPRE
use Reserva exclusive
index on (ROOMS_ID + DToS( CHECK_IN )) TAG "res_pre" TO RESERVA.cdx FOR ! deleted()
index on ROOMS_ID + TYPE + DToS( CHECK_IN ) TAG "ROOMS+TYPE+CHECK_IN" TO RESERVA.cdx for ! deleted()
index on upper(FIRST) TAG "FIRST" TO RESERVA.cdx FOR ! deleted()
index on upper(LAST) TAG "LAST" TO RESERVA.cdx FOR ! deleted()
index on TYPE tag "TYPE" TO RESERVA.cdx FOR ! deleted()
index on NUMPRE TAG "NUMPRE" TO RESERVA.cdx FOR ! deleted()
//index on ROOMS_ID + TYPE TAG "ROOM+TYPE" TO RESERVA.cdx FOR ! deleted() // maybe not needed?
use
Return nil
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
- Otto
- Posts: 6404
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 24 times
- Been thanked: 2 times
- Contact:
Re: Lookup method of Tdatabase
James,
thank you.
Best regards,
Otto
thank you.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************