nageswaragunupudi wrote:Is what is wanted something like this?
Logic to load data into array is very simple, as can be seen from the LoadData() function given below. (Length of array in each row is different. But Xbrowse can handle that.)
Even coding of xbrowse can be much shorter.
- Code: Select all Expand view
#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
This is a self contained program that can complied and executed independently. The program creates a sample DBF.
The logic can be adopted to the actual requirements.
I have used xHarbour with FWH 10.1. CT.LIB of xHarbour needs to be linked for the date functions.
Nages ,
to insert a tooltip to each column as " August 6 2011" how I can make
:bToolTip := { | oBrw, nRow, nCol, nFlags | MyToolTip( oBrw, nRow, nCol, nFlags) }
Function MyToolTip( oBrw, nRow, nCol, nFlags,aRes)
local nMouseRow := oBrw:MouseRowPos( nRow )
if nMouseRow > 0
return oBrw:aArrayData[ oBrw:nArrayAt - oBrw:nRowSel + nMouseRow ]
endif
return ""
But i see only the mouth how I can make to have day,mouth and year ?
I need to know it to make an research on archive and see wich customer have the reservation of table