#include "fivewin.ch"
REQUEST DBFCDX
function Main()
OpenData()
BrowseData()
return nil
function BrowseData()
local oDlg, oFont, oCbx, oBrw
local nMonth := 1
local aMonths[ 12 ]
local nOffSet
AEval( aMonths, { |c,i| aMonths[ i ] := NtoCMonth( i ) } )
nOffSet := MARCV->( FIELDPOS( "T1_1" ) ) - 4
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
DEFINE DIALOG oDlg SIZE 400,400 PIXEL TRUEPIXEL FONT oFont
@ 20,20 COMBOBOX oCbx VAR nMonth SIZE 200,400 PIXEL OF oDlg ;
ITEMS aMonths ON CHANGE oBrw:Refresh()
@ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE "MARCV" ;
COLUMNS "ID", "Name", ;
{ || ( oBrw:cAlias )->( FieldGet( nMonth * 4 + nOffSet ) ) }, ;
{ || ( oBrw:cAlias )->( FieldGet( nMonth * 4 + nOffSet + 1 ) ) }, ;
{ || ( oBrw:cAlias )->( FieldGet( nMonth * 4 + nOffSet + 2 ) ) }, ;
{ || ( oBrw:cAlias )->( FieldGet( nMonth * 4 + nOffSet + 3 ) ) } ;
HEADERS nil, nil, "C1", "C2", "C3", "C4" ;
PICTURES nil, nil, "9999", "9999", "9999", "9999" ;
CELL LINES NOBORDER
WITH OBJECT oBrw
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
function OpenData()
CreateData()
USE MARCV NEW SHARED VIA "DBFCDX"
return nil
function CreateData()
local aCols := { { "ID", "+", 4, 0 }, { "NAME", "C", 6, 0 } }
local i, j, c, a
for i := 1 to 12
for j := 1 to 4
c := "T" + LTrim( Str( i ) ) + "_" + Str( j, 1 )
AAdd( aCols, { c, "N", 4, 0 } )
next
next
DBCREATE( "MARCV", aCols, "DBFCDX", .T., "DB" )
for i := 1 to 10
APPEND BLANK
FIELD->NAME := "Name" + StrZero( i, 2 )
for j := 3 to FCOUNT()
FieldPut( j, HB_RandomInt( 10,9999 ) )
next
next
CLOSE DATA
return nil