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

2006-2019, 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 search using combobox added to (Browse Window - Child Class).

2 - Implementation Steps

Create new file using the template (Browse Window – Child Class)

s1.JPG

Fig. 1

File name (CustomerBrowse2.SSF)

s2.JPG

Fig. 2

Set the class name to (CustomersBrowse2Class)

s3.JPG

Fig. 3

s4.JPG

Fig. 4

Set the window name to CustomersBrowse2Window

s5.JPG

Fig. 5

s6.JPG

Fig. 6

s7.JPG

Fig. 7

Set the table name to Customers_All (It’s a Query)

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

Open method (GetSearchValue)

s22.JPG

Fig. 22

Delete the step cName = MyWindowName.textName.value

s23.JPG

Fig. 23

s24.JPG

Fig. 24

s25.JPG

Fig. 25

s26.JPG

Fig. 26

s27.JPG

Fig. 27

s28.JPG

Fig. 28

s29.JPG

Fig. 29

s30.JPG

Fig. 30

s31.JPG

Fig. 31

s32.JPG

Fig. 32

Save and run (Press CTRL+R) to generate the source code file CustomerBrowse2.PRG

s33.JPG

Fig. 33

Open Main.SSF

s34.JPG

Fig. 34

Uset the component (Set procedure to) to include the source code file CustomerBrowse2.PRG

s35.JPG

Fig. 35

s36.JPG

Fig. 36

s37.JPG

Fig. 37

Use the component (New object) to create the object CustomersBrowse2Object of Class CustomersBrowse2Class

s38.JPG

Fig. 38

s39.JPG

Fig. 39

s40.JPG

Fig. 40

s41.JPG

Fig. 41

s42.JPG

Fig. 42

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"

                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

                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 ( "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

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

CustomerBrowse2.SSF

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

Set Class Name & Window Name

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

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

Class

                Define Class MyClassName From SystemDatabase

                                Declare Class Data

                                                Data cWindowName Init Value "CustomersBrowse2Window"

                                                ********************************* Record Data Here **********************************

                                                                Data tablename Init Value "Customers_All"

                                                                Data column Init Value "Country"

                                                                Data PrimaryKey Init Value "id"

                                                                Data columns Init Value {"CustName","CustPhone","Country"}

                                                                Data columnstitles Init Value {"Name","Phone","Country"}

                                                                Data columnswidths Init Value {200,100,100}

                                                                Data CountryItems Init Value {}

                                                                Data CountryItemsIDs Init Value {}

                                Declare Class Methods

                                                Method showwindow

                                                Method closewindow

                                                Method OpenDataWindow

                                                Method showdatawindow

                                                Method print

                                                Method BeforeSearch

                                                Method SearchAdd

                                                Method settimer

                                                Method GetSearchValue

                                End of Class

                                ******************************** Methods To Customize *******************************

                                                Define Method showwindow Class MyClassName

                                                                Start Here

                                                                                Define New Window ( MyWindowName ) , Title : "Search/Browse Window"

                                                                                                Window Events

                                                                                                                Event: ON INIT : Action self:Search()

                                                                                                Window Properties

                                                                                                Window Controls

                                                                                                                Define New Image ( image1 ) , Image : "Image\back.jpg"

                                                                                                                                Events

                                                                                                                                Properties

                                                                                                                Define Label ( lbl1 ) , Caption : "Country"

                                                                                                                                Label Events

                                                                                                                                Label Properties

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

                                                                                                                                Button Events

                                                                                                                                                Event: ON CLICK : Action self:search()

                                                                                                                                Button Properties

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

                                                                                                                                Button Events

                                                                                                                                                Event: ON CLICK : Action self:closewindow()

                                                                                                                                Button Properties

                                                                                                                Define New Grid ( Grid1 ) , HEADERS : self:columnstitles

                                                                                                                                Events

                                                                                                                                                Event: ON DBLCLICK : Action self:OpenDataWindow

                                                                                                                                Properties

                                                                                                                Country

                                                                                                                                myout = self.LoadLookupTable("country","country",@self:countryitems,"id",@self:countryitemsids)

                                                                                                                                Define Combobox ( comboCountry ) , Items : self:CountryItems

                                                                                                                                                Combobox Events

                                                                                                                                                Combobox Properties

                                                                                                End Of Window

                                                                                                MyWindowName.Center ( )

                                                                                                Activate window

                                                                End of Method (Return 0)

                                                Define Method ShowDataWindow(nValue) Class MyClassName

                                                                Start Here

                                                                End of Method (Return 0)

                                                Define Method Print Class MyClassName

                                                                Start Here

                                                                                Local cName,myout

                                                                                cName = MyWindowName.textName.Value

                                                                                cName = All Trim cName

                                                                                IF ( .not. empty(cName) )

                                                                                                Start Here

                                                                                                END OF IF STATEMENT

                                                                End of Method (Return 0)

                                Class Methods

                                                Define Method closewindow Class MyClassName

                                                                Start Here

                                                                                MyWindowName.Release ( )

                                                                End of Method (Return 0)

                                                Define Method OpenDataWindow Class MyClassName

                                                                Start Here

                                                                                Local nvalue,myout

                                                                                nvalue = MyWindowName.grid1.Value

                                                                                IF ( nvalue > 0 )

                                                                                                Start Here

                                                                                                                myout = self.ShowDataWindow(nvalue)

                                                                                                END OF IF STATEMENT

                                                                End of Method (Return 0)

                                                Define Method BeforeSearch Class MyClassName

                                                                Start Here

                                                                                MyWindowName.grid1.DeleteAllItems ( )

                                                                                MyWindowName.grid1.Value := 0

                                                                End of Method (Return 0)

                                                Define Method SearchAdd(temp_array) Class MyClassName

                                                                Start Here

                                                                                MyWindowName.grid1.AddItem ( temp_array )

                                                                End of Method (Return 0)

                                                Define Method SetTimer(p1) Class MyClassName

                                                                Start Here

                                                                                MyWindowName.Timer1.Enabled := p1

                                                                End of Method (Return 0)

                                                Define Method GetSearchValue Class MyClassName

                                                                Start Here

                                                                                nValue = MyWindowName.ComboCountry.Value

                                                                                IF ( nvalue = 0 )

                                                                                                Start Here

                                                                                                                Return ""

                                                                                                END OF IF STATEMENT

                                                                                nvalue = self:CountryItems[nvalue]

                                                                End of Method (Return nValue)

4 - Application during the runtime

runtime1.JPG

Fig. 43

runtime2.JPG

Fig. 44

runtime3.JPG

Fig. 45