static function OpenDataBases()
field CODE,INVNUM,SERIAL
if ! File( "invoices.dbf" )
DbCreate( "invoices.dbf",;
{ { "INVNUM", "C", 10, 0 }, ;
{ "DATE", "D", 8, 0 }, ;
{ "CODE", "C", 10, 0 }, ; // Client Code
{ "CLIENT", "C", 40, 0 }, ; // Client Name
{ "ADDRESS", "M", 10, 0 }, ; // Client Address
{ "DETAILS", "C", 30, 0 }, ; // Invoice Details
{ "AMOUNT", "N", 9, 0 }, ;
{ "TAXRATE", "N", 5, 2 }, ;
{ "TAX", "N", 9, 0 }, ;
{ "TOTAL", "N", 9, 0 }, ;
{ "PAYDATE", "D", 8, 0 } }, "DBFCDX", .T., "DB" )
INDEX ON INVNUM TAG INVNUM
CLOSE DB
elseif !File( "invoices.cdx" )
USE INVOICES EXCLUSIVE NEW ALIAS DB
INDEX ON INVNUM TAG INVNUM
CLOSE DB
endif
USE invoices SHARED
SET ORDER TO TAG INVNUM
GO BOTTOM
nTaxRate := INVOICES->TAXRATE
GO TOP
if ! File( "items.dbf" )
DbCreate( "items.dbf",;
{ { "CODE", "C", 10, 0 }, ;
{ "NAME", "C", 30, 0 }, ;
{ "UNIT", "C", 5, 0 }, ;
{ "PRICE", "N", 6, 2 } }, "DBFCDX", .T., "DB" )
INDEX ON CODE TAG CODE
CLOSE DB
elseif !File( "items.cdx" )
USE ITEMS NEW EXCLUSIVE ALIAS DB
INDEX ON CODE TAG CODE
CLOSE DB
endif
USE items NEW SHARED
SET ORDER TO TAG CODE
GO TOP
if ! File( "invitems.dbf" )
DbCreate( "invitems.dbf",;
{ { "INVNUM", "C", 10, 0 }, ;
{ "SERIAL", "N", 3, 0 }, ;
{ "ITEMCODE", "C", 10, 0 }, ;
{ "ITEMNAME", "C", 30, 0 }, ;
{ "QUANTITY", "N", 8, 3 }, ;
{ "UNIT", "C", 5, 0 }, ;
{ "PRICE", "N", 6, 2 }, ;
{ "DISCOUNT", "N", 9, 0 } }, "DBFCDX", .T., "DB" )
INDEX ON INVNUM + STR( SERIAL, 3, 0 ) TAG INVNUM
INDEX ON DELETED() TAG DELETED
CLOSE DB
elseif !File( "invitems.cdx" )
USE INVITEMS EXCLUSIVE NEW ALIAS DB
INDEX ON INVNUM + STR( SERIAL, 3, 0 ) TAG INVNUM
INDEX ON DELETED() TAG DELETED
CLOSE DB
endif
USE invitems NEW SHARED
aBlankItem := Array( FCount() + 1 )
AEval( aBlankItem, { |u,i| aBlankItem[ i ] := uValBlank( FieldGet( i ) ) }, 1, FCount() )
aBlankItem[ FCount() + 1 ] := 0
SET ORDER TO TAG INVNUM
GO TOP
USE invitems NEW SHARED ALIAS IIT
SET ORDER TO TAG INVNUM
GO TOP
if ! File( "clients2.dbf" )
DbCreate( "clients2.dbf",;
{ { "CODE", "C", 10, 0 },;
{ "FIRST", "C", 20, 0 },;
{ "LAST", "C", 20, 0 },;
{ "ADDRESS1", "C", 30, 0 },;
{ "ADDRESS2", "C", 30, 0 },;
{ "CITY", "C", 20, 0 },;
{ "ZIPCODE", "C", 20, 0 },;
{ "PHONE", "C", 20, 0 },;
{ "EMAIL", "C", 20, 0 } }, "DBFCDX", .T., "DB" )
INDEX ON CODE TAG CODE
CLOSE DB
elseif !File( "clients2.cdx" )
USE CLIENTS2 EXCLUSIVE NEW ALIAS DB
INDEX ON CODE TAG CODE
CLOSE DB
endif
USE Clients2 NEW SHARED ALIAS "Clients"
SET ORDER TO TAG CODE
GO TOP
SELECT invoices
SET RELATION TO INVNUM INTO invitems SCOPED
GO TOP
return nil
//----------------------------------------------------------------------------//