Antonio Linares wrote:James,
very good finding
many thanks
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
{ cCamera, ALLTRIM( cTypeRoom ), oPrenotazioni:RecNo(), dCheckOut, dCheckIn }
{ cCamera, ALLTRIM( cTypeRoom ), oPrenotazioni:RecNo(), dCheckIn, dCheckOut }
{ cCamera, ALLTRIM( cTypeRoom ), oPrenotazioni:RecNo(), dCheckIn, dCheckOut }
... .and. ( oPrenotazioni:Check_IN > dCheck_OUT .or. oPrenotazioni:Check_OUT < dCheck_IN )
Antonio Linares wrote:I am trying to get a better quality photo with 80x80 pixels from this one. Maybe someone could help ?
#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
//----------------------------------------------------------------------------//
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?
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
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 35 guests