FUNCTION nDaysMonth( dDate )
Local nMes, cYear
Local dDay
Local aDays := {31,28,31,30,31,30,31,31,30,31,30,31}
Local nReturn
Local dateformat
if empty( dDate )
return 0
endif
nMes := Month( dDate )
cYear := str( year( dDate ),4 )
if nMes == 2
dateformat := set( _SET_DATEFORMAT, "dd-mm-yyyy" )
if day( ctod( "29-02-" + cYear ) ) != 0
nReturn := 29
else
nReturn := 28
endif
set( _SET_DATEFORMAT, dateformat )
else
nReturn := aDays[ nMes ]
endif
Return nReturn
aData := { {'Marzo', aDatiDisp[1][1],aDatiDisp[1][2],aDatiDisp[1][3],aDatiDisp[1][4],aDatiDisp[1][5],aDatiDisp[1][6],aDatiDisp[1][7],aDatiDisp[1][8],aDatiDisp[1][9],aDatiDisp[1][10],;
aDatiDisp[1][11],aDatiDisp[1][12],aDatiDisp[1][13],aDatiDisp[1][14],aDatiDisp[1][15],aDatiDisp[1][16],aDatiDisp[1][17],aDatiDisp[1][18],aDatiDisp[1][19],aDatiDisp[1][20],;
aDatiDisp[1][21],aDatiDisp[1][22],aDatiDisp[1][23],aDatiDisp[1][24],aDatiDisp[1][25],aDatiDisp[1][26],aDatiDisp[1][27],aDatiDisp[1][28],aDatiDisp[1][29],aDatiDisp[1][30],aDatiDisp[1][31]},;
{'Aprile', aDatiDisp[2][1],aDatiDisp[2][2],aDatiDisp[2][3],aDatiDisp[2][4],aDatiDisp[2][5],aDatiDisp[2][6],aDatiDisp[2][7],aDatiDisp[2][8],aDatiDisp[2][9],aDatiDisp[2][10],;
aDatiDisp[2][11],aDatiDisp[2][12],aDatiDisp[2][13],aDatiDisp[2][14],aDatiDisp[2][15],aDatiDisp[2][16],aDatiDisp[2][17],aDatiDisp[2][18],aDatiDisp[2][19],aDatiDisp[2][20],;
aDatiDisp[2][21],aDatiDisp[2][22],aDatiDisp[2][23],aDatiDisp[2][24],aDatiDisp[2][25],aDatiDisp[2][26],aDatiDisp[2][27],aDatiDisp[2][28],aDatiDisp[2][29],aDatiDisp[2][30],aDatiDisp[2][31]},;
{'Maggio', aDatiDisp[3][1],aDatiDisp[3][2],aDatiDisp[3][3],aDatiDisp[3][4],aDatiDisp[3][5],aDatiDisp[3][6],aDatiDisp[3][7],aDatiDisp[3][8],aDatiDisp[3][9],aDatiDisp[3][10],;
aDatiDisp[3][11],aDatiDisp[3][12],aDatiDisp[3][13],aDatiDisp[3][14],aDatiDisp[3][15],aDatiDisp[3][16],aDatiDisp[3][17],aDatiDisp[3][18],aDatiDisp[3][19],aDatiDisp[3][20],;
aDatiDisp[3][21],aDatiDisp[3][22],aDatiDisp[3][23],aDatiDisp[3][24],aDatiDisp[3][25],aDatiDisp[3][26],aDatiDisp[3][27],aDatiDisp[3][28],aDatiDisp[3][29],aDatiDisp[3][30],aDatiDisp[3][31]},;
{'Giugno', aDatiDisp[4][1],aDatiDisp[4][2],aDatiDisp[4][3],aDatiDisp[4][4],aDatiDisp[4][5],aDatiDisp[4][6],aDatiDisp[4][7],aDatiDisp[4][8],aDatiDisp[4][9],aDatiDisp[4][10],;
aDatiDisp[4][11],aDatiDisp[4][12],aDatiDisp[4][13],aDatiDisp[4][14],aDatiDisp[4][15],aDatiDisp[4][16],aDatiDisp[4][17],aDatiDisp[4][18],aDatiDisp[4][19],aDatiDisp[4][20],;
aDatiDisp[4][21],aDatiDisp[4][22],aDatiDisp[4][23],aDatiDisp[4][24],aDatiDisp[4][25],aDatiDisp[4][26],aDatiDisp[4][27],aDatiDisp[4][28],aDatiDisp[4][29],aDatiDisp[4][30],aDatiDisp[4][31]},;
{'Luglio', aDatiDisp[5][1],aDatiDisp[5][2],aDatiDisp[5][3],aDatiDisp[5][4],aDatiDisp[5][5],aDatiDisp[5][6],aDatiDisp[5][7],aDatiDisp[5][8],aDatiDisp[5][9],aDatiDisp[5][10],;
aDatiDisp[5][11],aDatiDisp[5][12],aDatiDisp[5][13],aDatiDisp[5][14],aDatiDisp[5][15],aDatiDisp[5][16],aDatiDisp[5][17],aDatiDisp[5][18],aDatiDisp[5][19],aDatiDisp[5][20],;
aDatiDisp[5][21],aDatiDisp[5][22],aDatiDisp[5][23],aDatiDisp[5][24],aDatiDisp[5][25],aDatiDisp[5][26],aDatiDisp[5][27],aDatiDisp[5][28],aDatiDisp[5][29],aDatiDisp[5][30],aDatiDisp[5][31]},;
{'Agosto', aDatiDisp[6][1],aDatiDisp[6][2],aDatiDisp[6][3],aDatiDisp[6][4],aDatiDisp[6][5],aDatiDisp[6][6],aDatiDisp[6][7],aDatiDisp[6][8],aDatiDisp[6][9],aDatiDisp[6][10],;
aDatiDisp[6][11],aDatiDisp[6][12],aDatiDisp[6][13],aDatiDisp[6][14],aDatiDisp[6][15],aDatiDisp[6][16],aDatiDisp[6][17],aDatiDisp[6][18],aDatiDisp[6][19],aDatiDisp[6][20],;
aDatiDisp[6][21],aDatiDisp[6][22],aDatiDisp[6][23],aDatiDisp[6][24],aDatiDisp[6][25],aDatiDisp[6][26],aDatiDisp[6][27],aDatiDisp[6][28],aDatiDisp[6][29],aDatiDisp[6][30],aDatiDisp[6][31]},;
{'Settembre', aDatiDisp[7][1],aDatiDisp[7][2],aDatiDisp[7][3],aDatiDisp[7][4],aDatiDisp[7][5],aDatiDisp[7][6],aDatiDisp[7][7],aDatiDisp[7][8],aDatiDisp[7][9],aDatiDisp[7][10],;
aDatiDisp[7][11],aDatiDisp[7][12],aDatiDisp[7][13],aDatiDisp[7][14],aDatiDisp[7][15],aDatiDisp[7][16],aDatiDisp[7][17],aDatiDisp[7][18],aDatiDisp[7][19],aDatiDisp[7][20],;
aDatiDisp[7][21],aDatiDisp[7][22],aDatiDisp[7][23],aDatiDisp[7][24],aDatiDisp[7][25],aDatiDisp[7][26],aDatiDisp[7][27],aDatiDisp[7][28],aDatiDisp[7][29],aDatiDisp[7][30],aDatiDisp[7][31]}}
DEFINE RIBBONBAR oRBar WINDOW oWnd PROMPT "Disponibiltà", "test", "test"
ADD GROUP oGr RIBBON oRBar TO OPTION 1 PROMPT "Disponibiltà" width 950
@ 2,2 xbrowse oBrw ;
COLUMNS 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32 ;
HEADERS "Mese","1","2","3","4","5","6","7","8","9","10","11","12","13","14",;
"15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31" ;
ARRAY aData of oGr size oGr:nWidth -5, oGr:nHeight - oGr:nHeight/7 - 2 pixel ;
SIZES 50, 25, 25, 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25
for n = 2 to Len( oBrw:aCols )
// COLORS
oBrw:aCols[ n ]:bClrStd := ;
{|| { RGB( 216, 230, 246 ), ;
IF ( EVAL (oBrw:bKeyno, NIL, oBrw ) %2 == 0, ;
CLR_WHITE,RGB( 255, 255, 189 ) ) } }
// BMPDATA
oBrw:aCols[ n ]:AddBmpFile("SELECT.BMP")
oBrw:aCols[ n ]:AddBmpFile("UNSELECT.BMP")
oBrw:aCols[ n ]:bBmpData := {|| oBrw:nArrayAt }
Next
#include 'fivewin.ch'
#include 'ord.ch'
#include 'xbrowse.ch'
REQUEST DBFCDX
#define NUM_TABLES 3
function Main()
RDDSetDefault( 'DBFCDX' )
CreateDBF() // Create Sample Data
ShowTables( LoadData() )
return nil
static function LoadData()
local i, n, aRes := Array( NUM_TABLES, 0 )
local dMonth := AddMonth( BOY( DATE() ), 2 ) // 1st March
for n := 1 to 7
for i := 1 to NUM_TABLES
AAdd( aRes[ i ], Array( LastDayOM( dMonth ) + 1 ) )
AFill( aRes[ i ][ -1 ], .f. )
aRes[ i ][ -1 ][ 1 ] := cMonth( dMonth )
next i
dMonth := AddMonth( dMonth, 1 )
next n
USE RESERVATION
do while ! Eof()
for n := FIELD->DATAIN to FIELD->DATAFIN
aRes[ FIELD->NUMTABLE ][ Month( n ) - 2 ][ Day( n ) + 1 ] := .t.
next
SKIP
enddo
CLOSE RESERVATION
return aRes
static function ShowTables( aRes )
local oTabs, aTabs := {}
local oDlg, oBrw, oCol, n
DEFINE DIALOG oDlg SIZE 960,200 PIXEL
@ 05,05 XBROWSE oBrw SIZE 470, 80 PIXEL OF oDlg ;
ARRAY aRes[ 1 ] AUTOCOLS LINES CELL NOBORDER
oBrw:aCols[ 1 ]:cHeader := 'Month'
for n := 2 to 32
WITH OBJECT oBrw:aCols[ n ]
:cHeader := LTrim( Str( n - 1 ) )
:SetCheck( { 'c:\fwh\bitmaps\level1.bmp', 'c:\fwh\bitmaps\level2.bmp' } )
END
next
WITH OBJECT oBrw
:lHScroll := :lVScroll := .f.
:nStretchCol := 1
:nFreeze := 1
END
oBrw:CreateFromCode()
for n := 1 to NUM_TABLES
AAdd( aTabs, 'Table-' + LTrim( Str( n ) ) )
next
@ 85, 05 TABS oTabs OF oDlg SIZE oBrw:nWidth, 17 PIXEL
WITH OBJECT oTabs
:aPrompts := aTabs
:bAction := { | n | oBrw:aArrayData := aRes[ n ], oBrw:Refresh() }
END
ACTIVATE DIALOG oDlg CENTERED
return nil
//-------------------------- CREATION OF SAMPLE DATA -----------//
function CreateDBF()
FIELD NUMTABLE
local n, dStart
local aCols := { { 'NUMTABLE', 'N', 2, 0 }, ;
{ 'DATAIN' , 'D', 8, 0 }, ;
{ 'DATAFIN' , 'D', 8, 0 } }
DbCreate( 'RESERVATION', aCols )
USE RESERVATION
INDEX ON NUMTABLE TAG NUMTABLE
dStart := AddMonth( BOY( Date() ), 2 ) // 1st March
for n := 1 to 100 * NUM_TABLES
APPEND BLANK
FIELD->NUMTABLE := HB_RandomInt( 1, NUM_TABLES )
FIELD->DATAIN := dStart + HB_RandomInt( 0, 200 )
FIELD->DATAFIN := FIELD->DATAIN + HB_RandomInt( 0, 5 )
next n
CLOSE RESERVATION
return nil
oBrw:aCols[34]:bPaintText := { |oCol, hDC, cText, aCoord| DrawText( oCol, hDC, cText, aCoord, oBrw, aRes[ 1 ],aRes[ 2 ] ) }
static function DrawText( oCol, hDC, cText, aCoord, oBrw, aZeile,aZeile2)
local nTop := aCoord[ 1 ]
local nBottom := aCoord[ 3 ]
local nLeft := aCoord[ 2 ]
local nRight := aCoord[ 4 ]
local nRow := nTop
local cLine
local nFontHt
local nAt
local oBrush
local oBrush2
local aRect1 := {}
local rcttop := nTop
local rctleft := nLeft
local rctbottom := nBottom
local rctright := nRight
local I := 0
local nRowheight := nBottom - nTop
local nWidth := 0
local cPen := CreatePen( 0, 0.3, RGB(255,128,64) ) //RGB(128,128,255)
local cPenRed := CreatePen( 0, 0.3, RGB(128,128,255) )
local nMax := 20 // missing: get the Maxvalue here I use 100
*----------------------------------------------------------
DEFINE BRUSH oBrush2 COLOR 4646935
DEFINE BRUSH oBrush COLOR 3092271
FOR I := 3 to 33
rcttop := INT( rctbottom - nRowheight / nMax * aZeile[ oBrw:nArrayAt,I] ) //oBrw:aCols[I]:value )
rctleft := rctleft + 4 //8
rctright := rctleft + 3
aRect1 := { rcttop, rctleft, rctbottom, rctright }
FillRect( hDC, aRect1, oBrush:hBrush )
rcttop := INT( rctbottom - nRowheight / nMax * aZeile2[ oBrw:nArrayAt,I] ) //oBrw:aCols[I]:value )
rctleft := rctleft + 4 //8
rctright := rctleft + 3
aRect1 := { rcttop, rctleft, rctbottom, rctright }
FillRect( hDC, aRect1, oBrush2:hBrush )
rctleft := rctleft + 0.5
next
SelectObject( hDC, cPen )
rcttop := INT( rctbottom - oBrw:nRowHeight/2 )
MoveTo( hDC, rctleft-260, rcttop )
LineTo( hDC, rctleft + 5 ,rcttop )
return nil
*----------------------------------------------------------
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot], Marc Venken and 107 guests