You can drag & drop the reservations using the mouse
booking.prg
- Code: Select all Expand view
- #include "fivewin.ch"
function Main()
local oDlg, oBrw, oFont, oCur
local aData := Array( 6, 11 )
local n
local aColors := { METRO_AMBER, METRO_OLIVE, CLR_HMAGENTA, CLR_HBLUE, CLR_HRED, CLR_HGREEN, CLR_RED, CLR_MAGENTA, CLR_GREEN }
AEval( aData, { |a,i| AFill( a, 0 ), a[ 1 ] := "Camera n." + Str(i,1,0) } )
SET DATE ITALIAN
DEFINE CURSOR oCur DRAG
DEFINE FONT oFont NAME "VERDANA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 760,430 PIXEL TRUEPIXEL ;
RESIZABLE FONT oFont
@ 5,5 XBROWSE oBrw SIZE 0,400 PIXEL OF oDlg DATASOURCE aData ;
COLUMNS 1,2,3,4,5,6,7,8,9,10,11 ;
HEADERS "", "AM","PM","AM","PM","AM","PM","AM","PM","AM","PM" ;
NOBORDER STYLE FLAT
WITH OBJECT oBrw
:nWidths := 60
:nRowHeight := 60
:nHeaderHeight := 60
:nColDividerStyle := ;
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:nMarqueeStyle := MARQSTYLE_SOLIDCELL
:lDrawBorder := .t.
:nDataStrAligns := AL_CENTER
:lDisplayZeros := .f.
:nFreeze := 1
:lLockFreeze := .t.
:lAllowColSwapping := .f.
:lAllowColHiding := .f.
:lAllowRowSizing := .f.
:lAllowSizings := .f.
:lColChangeNotify := .t.
:bClrStd := <|b,oCol|
local nClr := CLR_WHITE
if oCol != nil .and. !Empty( oCol:Value )
nClr := aColors[ oCol:Value ]
endif
return { ContrastClr( nClr ), nClr }
>
for n := 2 to 10 step 2
:SetGroupHeader( DTOC( Date() + n/2 - 1 ), n, n + 1, nil, nil, 30 )
next
WITH OBJECT :aCols[ 1 ]
:nWidth := aData[ 1, 1 ] + "9999"
:bClrStd := ;
:bClrHeader := { || { CLR_BLACK, RGB(125,135,249) } }
:nDataStrAlign := AL_CENTER
END
:bPopUp := { |oCol| CellMenu( oCol ) }
:lRecordSelector := .f.
:lFitGridHeight := .t.
// drag and drop
:bChange := < ||
local oCol := oBrw:SelectedCol()
if oCol:nArrayCol > 1 .and. !Empty( oCol:Value )
oBrw:oDragCursor := oCur
else
oBrw:oDragCursor := nil
endif
return nil
>
:bDragBegin := < |r,c,f|
SetDropInfo( { oBrw:nArrayAt, oBrw:SelectedCol():nArrayCol } )
return nil
>
:bDropOver := < |u,r,c,f|
oBrw:SetPos( r, c, .t. )
oBrw:SelectedCol():Value := aData[ u[ 1 ], u[ 2 ] ]
aData[ u[ 1 ], u[ 2 ] ] := 0
XEval( oBrw:bChange, oBrw )
oBrw:Refresh()
return nil
>
//
:nColSel := 2
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
RELEASE CURSOR oCur
return nil
//----------------------------------------------------------------------------//
static function CellMenu( oCol )
local oPop, oItem, oBrw, nVal, n
if oCol:nCreationOrder > 1
nVal := oCol:Value
oBrw := oCol:oBrw
MENU oPop POPUP 2010
MENUITEM "Reserve To:"
MENU
for n := 1 to 9
MENUITEM "Customer-" + Str(n,1,0) BLOCK Reserve( oCol, n )
next
ENDMENU
MENUITEM "Cancel" WHEN nVal > 0 ACTION ;
( oCol:Value := 0, oBrw:RefreshCurrent() )
ENDMENU
endif
return oPop
static function Reserve( oCol, n )
return { || oCol:Value := n, oCol:oBrw:RefreshCurrent() }