PWCT 1.9 Art Documentation ( http://doublesvsoop.sourceforge.net )

2006-2013, Mahmoud Fayed ( msfclipper@users.sourceforge.net )

_____________________________________________________________________________________

Table of contents

1 - Introduction

2 - Implementation steps

3 - Final Steps Tree

4 - Application during the runtime

1 - Introduction

In this lesson we are going to learn how to use

1 - (Access Report - Parent Class) template

2 - (Access Report - Child Class) template

2 - Implementation Steps

Open database SysData.mdb , password = systemdatabase123

s1.JPG

Fig. 1

Create new report using Wizard

s2.JPG

Fig. 2

s3.JPG

Fig. 3

s4.JPG

Fig. 4

s5.JPG

Fig. 5

s6.JPG

Fig. 6

s7.JPG

Fig. 7

s8.JPG

Fig. 8

s9.JPG

Fig. 9

s10.JPG

Fig. 10

s11.JPG

Fig. 11

s12.JPG

Fig. 12

s13.JPG

Fig. 13

s14.JPG

Fig. 14

s15.JPG

Fig. 15

s16.JPG

Fig. 16

s17.JPG

Fig. 17

s18.JPG

Fig. 18

s19.JPG

Fig. 19

s20.JPG

Fig. 20

s21.JPG

Fig. 21

s22.JPG

Fig. 22

s23.JPG

Fig. 23

s24.JPG

Fig. 24

s25.JPG

Fig. 25

Run PWCT, Create new file using Access Report Parent Class template

s26.JPG

Fig. 26

File name = ReportParent.SSF

s27.JPG

Fig. 27

s28.JPG

Fig. 28

Press CTRL+R to  generate the source code file ReportParent.PRG

s29.JPG

Fig. 29

Open Main.SSF

s30.JPG

Fig. 30

Use the component (Set procedure to) to include the source code file (ReportParent.PRG)

s31.JPG

Fig. 31

s32.JPG

Fig. 32

Create new file using the template (Access Report Child Class)

s33.JPG

Fig. 33

File name = CustomersReport.SSF

s34.JPG

Fig. 34

s35.JPG

Fig. 35

Set class name = CustomersReportClass

s36.JPG

Fig. 36

s37.JPG

Fig. 37

s38.JPG

Fig. 38

Set window name = CustomersReportWindow

s39.JPG

Fig. 39

Set report name = Customers_All

s40.JPG

Fig. 40

s41.JPG

Fig. 41

s42.JPG

Fig. 42

Set the window title to Customers Report

s43.JPG

Fig. 43

s44.JPG

Fig. 44

Press CTRL+R to generate the source code file CustomersReport.PRG

s45.JPG

Fig. 45

Open Main.SSF

s46.JPG

Fig. 46

Use the component (Set procedure to ) to include the source code file CustomersReport.PRG

s47.JPG

Fig. 47

s48.JPG

Fig. 48

s49.JPG

Fig. 49

Create new object CustomersReportObject of class CustomersReportClass

s50.JPG

Fig. 50

s51.JPG

Fig. 51

s52.JPG

Fig. 52

s53.JPG

Fig. 53

s54.JPG

Fig. 54

3 - Final Steps Tree

=====================

Main.SSF

=====================

The First Step

                Load System Modules

                                Set Procedure to "About.PRG"

                                Set Procedure to "Database.PRG"

                                Set Procedure to "Customers.PRG"

                                Set Procedure to "CustomersBrowse.PRG"

                                Set Procedure to "CustDataBrowse.PRG"

                                Set Procedure to "CustomerBrowse2.PRG"

                                Set Procedure to "ReportParent.PRG"

                                Set Procedure to "CustomersReport.PRG"

                Create System Objects

                                Create Object AboutObject of Class AboutClass

                                Create Object CustomersDataObject of Class CustomersDataClass

                                Create Object CustomersBrowseObject of Class CustomersBrowseClass

                                Create Object CustDataBrowseObject of Class CustDataBrowseClass

                                Create Object CustomersBrowse2Object of Class CustomersBrowse2Class

                                Create Object CustomersReportObject of Class CustomersReportClass

                Define New Window ( win1 ) , Title : "System"

                                Window Events

                                Window Properties

                                Window Controls

                                                START OF MAIN MENU

                                                                MENU POPUPS

                                                                                DEFINE POPUP "File"

                                                                                                POPUP ITEMS

                                                                                                                Define ITEM ( "Customers Data/Browse" )

                                                                                                                Define ITEM ( "Customers Browse" )

                                                                                                                Define ITEM ( "Customers Browse by Country" )

                                                                                                                Define ITEM ( "Customers" )

                                                                                                                Define ITEM ( "Customers Report" )

                                                                                                                Define ITEM ( "About" )

                                                                                                                Define ITEM ( "Close System" )

                                                                                                END OF POPUP

                                                                END OF MAIN MENU

                                                Define New Statusbar

                                                                Items

                                                                                Define New StatusItem ( "Ready" )

                                                                                                Events

                                                                                                Properties

                                                                                Keyboard

                                                                                                Events

                                                                                                Properties

                                                                                Clock

                                                                                                Events

                                                                                                Properties

                                                                End Statusbar

                                End Of Window

                                win1.Maximize ( )

                                Activate window

Procedures

                Define Procedure closesystem

                                Start Here

                                                win1.Release ( )

                                End of Procedure

========================

CustomersReport.SSF

========================

Set Class Name & Window Name

                PWCT-Code Generator: Replace String (MyClassName) with (CustomersReportClass)

                PWCT-Code Generator: Replace String (MyWindowName) with (&(self:cWindowName))

Class

                Define Class MyClassName From Report_Base

                                Declare Class Data

                                                Data ReportName Init Value "Customers_All"

                                                Data cWindowName Init Value "CustomersReportWindow"

                                Declare Class Methods

                                                Method showwindow

                                                Method closewindow

                                                Method SizeReport

                                End of Class

                                Class Methods

                                                Define Method ShowWindow Class MyClassName

                                                                Start Here

                                                                                Define New Window ( MyWindowName ) , Title : "Customers Report"

                                                                                                Window Events

                                                                                                                Event: ON INIT : Action self:ShowReport()

                                                                                                                Event: ON SIZE : Action self:SizeReport()

                                                                                                                Event: ON MAXIMIZE : Action self:SizeReport()

                                                                                                Window Properties

                                                                                                Window Controls

                                                                                                                Define New Button ( btn1 ) , Caption : "Close"

                                                                                                                                Button Events

                                                                                                                                                Event: ON CLICK : Action self:CloseWindow()

                                                                                                                                Button Properties

                                                                                                                Define New Button ( btn2 ) , Caption : "Print"

                                                                                                                                Button Events

                                                                                                                                                Event: ON CLICK : Action self:PrintReport()

                                                                                                                                Button Properties

                                                                                                                Define New Button ( btn3 ) , Caption : "Refresh"

                                                                                                                                Button Events

                                                                                                                                                Event: ON CLICK : Action self:ShowReport()

                                                                                                                                Button Properties

                                                                                                                Active Control ( self:oActiveX )

                                                                                                End Of Window

                                                                                                MyWindowName.Maximize ( )

                                                                                                Activate window

                                                                End of Method (Return 0)

                                                Define Method CloseWindow Class MyClassName

                                                                Start Here

                                                                                MyWindowName.Release ( )

                                                                End of Method (Return 0)

                                                Define Method SizeReport Class MyClassName

                                                                Start Here

                                                                                Local tempvar1,tempvar2

                                                                                tempvar1 = MyWindowName.Width

                                                                                tempvar2 = MyWindowName.Height

                                                                                self:oactivex.nWidth := tempvar1 - 84

                                                                                self:oactivex.nHeight := tempvar2 - 125

                                                                                MyWindowName.btn1.Row := tempvar2-88

                                                                                MyWindowName.btn2.Row := tempvar2-88

                                                                                MyWindowName.btn3.Row := tempvar2-88

                                                                                self:oactivex.Show ( )

                                                                End of Method (Return 0)

=====================

ReportParent.SSF

=====================

Class

                Define Class Report_Base

                                Declare Class Data

                                                Data database Init Value GetStartUpFolder()+"\data\sysdata.mdb"

                                                Data outputfile Init Value GetStartUpFolder()+"\tempfile.snp"

                                                Data myaccessobj Init Value 0

                                                Data oActiveX Init Value 0

                                                Data Filter Init Value ""

                                                Data dbpassword Init Value "systemdatabase123"

                                                Data outputfile2 Init Value GetStartUpFolder()+"\tempfile.html"

                                                Data outputfile3 Init Value GetStartUpFolder()+"\tempfile.xls"

                                                Data ComplexSearch Init Value ""

                                Declare Class Methods

                                                Method showreport

                                                Method printreport

                                                Method exportreport

                                                Method exportreport2

                                End of Class

                                Class Methods

                                                Define Method ShowReport Class Report_Base

                                                                Start Here

                                                                                StartUpFolder := Get StartUp Folder

                                                                                Set Filter

                                                                                                Create OLE Object self:myaccessobj of Type "Access.Application"

                                                                                                self:myaccessobj.OpenCurrentDatabase ( self:database,false,self:dbpassword )

                                                                                                self:myaccessobj.DoCmd:OpenReport ( self:ReportName,1 )

                                                                                                IF ( .not. empty(alltrim(self:filter)) )

                                                                                                                Start Here

                                                                                                                                self:myaccessobj.Reports(Self:ReportName):Filter := Self:Filter + Self:ComplexSearch

                                                                                                                ELSE

                                                                                                                                Start Here

                                                                                                                                                self:myaccessobj.Reports(Self:ReportName):Filter := "1 = 1" + Self:ComplexSearch

                                                                                                                END OF IF STATEMENT

                                                                                self:myaccessobj.DoCmd:OutputTo ( 3,,"SnapshotFormat(*.snp)",self:outputfile )

                                                                                self:myaccessobj.Quit ( )

                                                                                self:oactivex.snapshotpath := self:outputfile

                                                                End of Method (Return 0)

                                                Define Method PrintReport Class Report_Base

                                                                Start Here

                                                                                StartUpFolder := Get StartUp Folder

                                                                                Create OLE Object self:myaccessobj of Type "Access.Application"

                                                                                self:myaccessobj.OpenCurrentDatabase ( self:database,false,self:dbpassword )

                                                                                IF ( .not. empty(alltrim(self:filter)) )

                                                                                                Start Here

                                                                                                                self:myaccessobj.DoCmd:OpenReport ( self:ReportName,,,self:filter + Self:ComplexSearch )

                                                                                                ELSE

                                                                                                                Start Here

                                                                                                                                self:myaccessobj.DoCmd:OpenReport ( self:ReportName,,,"1 = 1 " + Self:ComplexSearch )

                                                                                                END OF IF STATEMENT

                                                                                self:myaccessobj.Quit ( )

                                                                End of Method (Return 0)

                                                Define Method ExportReport Class Report_Base

                                                                Start Here

                                                                                StartUpFolder := Get StartUp Folder

                                                                                Set Filter

                                                                                                Create OLE Object self:myaccessobj of Type "Access.Application"

                                                                                                self:myaccessobj.OpenCurrentDatabase ( self:database,false,self:dbpassword )

                                                                                                self:myaccessobj.DoCmd:OpenReport ( self:ReportName,1 )

                                                                                                IF ( .not. empty(alltrim(self:filter)) )

                                                                                                                Start Here

                                                                                                                                self:myaccessobj.Reports(Self:ReportName):Filter := Self:Filter + Self:ComplexSearch

                                                                                                                ELSE

                                                                                                                                Start Here

                                                                                                                                                self:myaccessobj.Reports(Self:ReportName):Filter := "1 = 1" + Self:ComplexSearch

                                                                                                                END OF IF STATEMENT

                                                                                self:myaccessobj.DoCmd:OutputTo ( 3,,"HTML(*.html)",self:outputfile2 )

                                                                                self:myaccessobj.Quit ( )

                                                                                Execute File self:outputfile2

                                                                End of Method (Return 0)

                                                Define Method ExportReport2 Class Report_Base

                                                                Start Here

                                                                                StartUpFolder := Get StartUp Folder

                                                                                Set Filter

                                                                                                Create OLE Object self:myaccessobj of Type "Access.Application"

                                                                                                self:myaccessobj.OpenCurrentDatabase ( self:database,false,self:dbpassword )

                                                                                                self:myaccessobj.DoCmd:OpenReport ( self:ReportName,1 )

                                                                                                IF ( .not. empty(alltrim(self:filter)) )

                                                                                                                Start Here

                                                                                                                                self:myaccessobj.Reports(Self:ReportName):Filter := Self:Filter + Self:ComplexSearch

                                                                                                                ELSE

                                                                                                                                Start Here

                                                                                                                                                self:myaccessobj.Reports(Self:ReportName):Filter := "1 = 1" + Self:ComplexSearch

                                                                                                                END OF IF STATEMENT

                                                                                self:myaccessobj.DoCmd:OutputTo ( 3,,"Microsoft Excel 97-2002 (*.xls)",self:outputfile3 )

                                                                                self:myaccessobj.Quit ( )

                                                                                Execute File self:outputfile3

                                                                End of Method (Return 0)

4 - Application during the runtime

runtime1.JPG

Fig. 55

runtime2.JPG

Fig. 56