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 add search window to a combobox.

2 - Implementation Steps

Create new file using (Browse window – child class) template.

s1.JPG

Fig. 1

File name = SelectItem.SSF

s2.JPG

Fig. 2

s3.JPG

Fig. 3

Class name = SelectItemClass

s4.JPG

Fig. 4

s5.JPG

Fig. 5

s6.JPG

Fig. 6

cWindowname = SelectItemWindow

s7.JPG

Fig. 7

s8.JPG

Fig. 8

Tablename = Items

s9.JPG

Fig. 9

Column = Itemname

s10.JPG

Fig. 10

Columns = {"itemname"}

s11.JPG

Fig. 11

Columnstitles = {“Item Name"}

s12.JPG

Fig. 12

Columnswidths = {200}

s13.JPG

Fig. 13

s14.JPG

Fig. 14

s15.JPG

Fig. 15

Window title = “Select Item Window”

s16.JPG

Fig. 16

s17.JPG

Fig. 17

Delete print button.

s18.JPG

Fig. 18

Add image to the window

s19.JPG

Fig. 19

s20.JPG

Fig. 20

s21.JPG

Fig. 21

s22.JPG

Fig. 22

Open method OpenDataWindow

s23.JPG

Fig. 23

Open method ShowDataWindow

s24.JPG

Fig. 24

Delete the steps in the method

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

s33.JPG

Fig. 33

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

s34.JPG

Fig. 34

Open Main.SSF

s35.JPG

Fig. 35

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

s36.JPG

Fig. 36

s37.JPG

Fig. 37

s38.JPG

Fig. 38

Create object SelectItemObject of class SelectItemClass

s39.JPG

Fig. 39

Open MasterDetailsTest.SSF

s40.JPG

Fig. 40

s41.JPG

Fig. 41

Add new button to the window

s42.JPG

Fig. 42

s43.JPG

Fig. 43

s44.JPG

Fig. 44

s45.JPG

Fig. 45

s46.JPG

Fig. 46

s47.JPG

Fig. 47

s48.JPG

Fig. 48

s49.JPG

Fig. 49

s50.JPG

Fig. 50

s51.JPG

Fig. 51

s52.JPG

Fig. 52

s53.JPG

Fig. 53

s54.JPG

Fig. 54

s55.JPG

Fig. 55

s56.JPG

Fig. 56

s57.JPG

Fig. 57

Press CTRL+R to generate the source code MasterDetailsTest.SSF

s58.JPG

Fig. 58

Open Main.SSF and run the application

s59.JPG

Fig. 59

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"

                                Set Procedure to "CustomersReport2.PRG"

                                Set Procedure to "MasterDetailsTest.PRG"

                                Set Procedure to "OrdersReport.PRG"

                                Set Procedure to "SelectItem.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

                                Create Object CustomersReport2Object of Class CustomersReport2Class

                                Create Object OrdersObject of Class OrdersClass

                                Create Object OrdersReportObject of Class OrdersReportClass

                                Create Object SelectItemObject of Class SelectItemClass

                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 ( "Customers Report - filter by date of birth" )

                                                                                                                Define ITEM ( "Master Details test" )

                                                                                                                Define ITEM ( "Master Details 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

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

SelectItem.SSF

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

Set Class Name & Window Name

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

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

Class

                Define Class MyClassName From SystemDatabase

                                Declare Class Data

                                                Data cWindowName Init Value "SelectItemWindow"

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

                                                                Data tablename Init Value "Items"

                                                                Data column Init Value "itemname"

                                                                Data PrimaryKey Init Value "id"

                                                                Data columns Init Value {"itemname"}

                                                                Data columnstitles Init Value {"Item Name"}

                                                                Data columnswidths Init Value {200}

                                                Data nSelectedID Init Value 0

                                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 : "Select Item 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 : "Name"

                                                                                                                                Label Events

                                                                                                                                Label Properties

                                                                                                                Define TextBox ( textName )

                                                                                                                                TextBox EVENTS

                                                                                                                                TextBox 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

                                                                                                End Of Window

                                                                                                MyWindowName.Center ( )

                                                                                                Activate window

                                                                End of Method (Return 0)

                                                Define Method ShowDataWindow(nValue) Class MyClassName

                                                                Start Here

                                                                                self.nSelectedID = self:ResultPrimaryKeys[nValue]

                                                                                self:nSelectedID = CONVERT self:nSelectedID TO Numeric

                                                                                myout = Self.CloseWindow()

                                                                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

                                                                                cName = MyWindowName.textName.Value

                                                                End of Method (Return cName)

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

MasterDetailsTest.SSF

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

Set Class Name & Window Name

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

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

Classes

                Define Class MyClassName From SystemDatabase

                                Declare Class Data

                                                Data cWindowName Init Value "OrdersWindow"

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

                                                Data TableName Init Value "Orders_All"

                                                Data nID Init Value 0

                                                Data column Init Value "OrderNumber"

                                                Data PrimaryKey Init Value "id"

                                                Data columns Init Value {"OrderNumber","CustName"}

                                                Item

                                                                Data nItem Init Value 0

                                                                Data itemitems Init Value {}

                                                                Data itemitemsids Init Value {}

                                                Data nOrderNumber Init Value ""

                                                detailstable

                                                                Data TableName2 Init Value "OrderItems_All"

                                                                Data column2 Init Value "ItemName"

                                                                Data PrimaryKey2 Init Value "id"

                                                                Data columns2 Init Value {"ItemName"}

                                                                Data ResultPrimaryKeys2 Init Value {}

                                                Join Table

                                                                Data TableName3 Init Value "OrderItems"

                                                                Data PrimaryKey3 Init Value "id"

                                                                Data linkmasterkey Init Value "OrderNumber"

                                                                Data linkchildkey Init Value "ItemNumber"

                                                Counter Table

                                                                Data TableName4 Init Value "SystemCounter"

                                                                Data CounterColumn Init Value "OrderNumber"

                                                Items Table

                                                                Data itemstable Init Value "items"

                                                                Data Itemscolumn Init Value "itemname"

                                                Customers

                                                                Data nCustomer Init Value 0

                                                                Data CustomerItems Init Value {}

                                                                Data CustomerItemsIDs Init Value {}

                                Declare Class Methods

                                                Method showwindow

                                                Method closewindow

                                                Method SetMode

                                                Method UserInterface2Class

                                                Method Class2ADO

                                                Method ADO2Class

                                                Method Class2UserInterface

                                                Method ClearRecord

                                                Method AutoGotoRecord

                                                Method OpenDataWindow

                                                Method showdatawindow

                                                Method myTimer

                                                Method itemchange

                                                Method OnAfterAddEdit

                                                Method OnBeforeDelete

                                                Method onbeforeedit

                                                Method onAddClick

                                                Method search2

                                                Method delrecord2

                                                Method addrecord2

                                                Method BeforeSearch

                                                Method SearchAdd

                                                Method settimer

                                                Method GetSearchValue

                                                Method SelectItem

                                End of Class

                                ******************************* Methods to Customize *****************************

                                                Define Method showwindow Class MyClassName

                                                                Start Here

                                                                                myout = self.connect()

                                                                                myout = self.AutoGotoRecord()

                                                                                Define New Window ( MyWindowName ) , Title : "Enter Orders"

                                                                                                Window Events

                                                                                                                Event: ON INIT : Action self:Search()

                                                                                                Window Properties

                                                                                                Window Controls

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

                                                                                                                                Events

                                                                                                                                Properties

                                                                                                                Data Buttons

                                                                                                                                Define New Button ( btnFirst ) , Caption : "First"

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:firstrecord()

                                                                                                                                                Button Properties

                                                                                                                                Define New Button ( btnNext ) , Caption : "Next"

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:nextrecord()

                                                                                                                                                Button Properties

                                                                                                                                Define New Button ( btnLast ) , Caption : "Last"

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:lastrecord()

                                                                                                                                                Button Properties

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

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:closewindow()

                                                                                                                                                Button Properties

                                                                                                                                Define New Button ( btnPrev ) , Caption : "Prev "

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:prevrecord()

                                                                                                                                                Button Properties

                                                                                                                                Define New Button ( btnDel ) , Caption : "Delete"

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:delrecord()

                                                                                                                                                Button Properties

                                                                                                                                Define New Button ( btnsave ) , Caption : "Save"

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:saverecord()

                                                                                                                                                Button Properties

                                                                                                                                Define New Button ( btncancel ) , Caption : "Cancel"

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:cancelrecord()

                                                                                                                                                Button Properties

                                                                                                                                Define New Button ( btnedit ) , Caption : "Edit"

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:editrecord()

                                                                                                                                                Button Properties

                                                                                                                                Define New Button ( btnadd ) , Caption : "Add"

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:addrecord()

                                                                                                                                                Button Properties

                                                                                                                Window Title

                                                                                                                                Define Label ( lblTitle ) , Caption : "                                                                                                                                                                                                                                                Master/Details"

                                                                                                                                                Label Events

                                                                                                                                                Label Properties

                                                                                                                Browse

                                                                                                                                Define Label ( lbl1browse ) , Caption : "Order Number"

                                                                                                                                                Label Events

                                                                                                                                                Label Properties

                                                                                                                                Define TextBox ( textnamebrowse )

                                                                                                                                                TextBox EVENTS

                                                                                                                                                TextBox Properties

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

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:search()

                                                                                                                                                Button Properties

                                                                                                                                Define New Grid ( Grid1browse ) , HEADERS : {"Order Number","Customer Name"}

                                                                                                                                                Events

                                                                                                                                                                Event: ON CHANGE : Action self:OpenDataWindow

                                                                                                                                                Properties

                                                                                                                Define Timer ( Timer1 )

                                                                                                                Item

                                                                                                                                items

                                                                                                                                                myout = self.LoadLookupTable(self:itemstable,self:itemscolumn,@self:ItemItems,"id",@self:ItemItemsIDS)

                                                                                                                                Define Label ( lblitems ) , Caption : "Item"

                                                                                                                                                Label Events

                                                                                                                                                Label Properties

                                                                                                                                Define Combobox ( comboitem ) , Items : self:itemitems

                                                                                                                                                Combobox Events

                                                                                                                                                                Event: ON CHANGE : Action self:itemchange()

                                                                                                                                                Combobox Properties

                                                                                                                Order Number

                                                                                                                                Define Label ( lblOrdernumber ) , Caption : "Order Number"

                                                                                                                                                Label Events

                                                                                                                                                Label Properties

                                                                                                                                Define TextBox ( textOrderNumber )

                                                                                                                                                TextBox EVENTS

                                                                                                                                                TextBox Properties

                                                                                                                Browse Order Items

                                                                                                                                Define Label ( lbl1browse2 ) , Caption : "Item Name"

                                                                                                                                                Label Events

                                                                                                                                                Label Properties

                                                                                                                                Define TextBox ( textNamebrowse2 )

                                                                                                                                                TextBox EVENTS

                                                                                                                                                TextBox Properties

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

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:search2()

                                                                                                                                                Button Properties

                                                                                                                                Define New Grid ( Grid1browse2 ) , HEADERS : {"Item Name"}

                                                                                                                                                Events

                                                                                                                                                Properties

                                                                                                                Data Buttons 2

                                                                                                                                Define New Button ( btnDel2 ) , Caption : "Delete Item"

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:delrecord2()

                                                                                                                                                Button Properties

                                                                                                                                Define New Button ( btnadd2 ) , Caption : "Add Item"

                                                                                                                                                Button Events

                                                                                                                                                                Event: ON CLICK : Action self:addrecord2()

                                                                                                                                                Button Properties

                                                                                                                Customers

                                                                                                                                myout = self.LoadLookupTable("Customers","CustName",@self:CustomerItems,"ID",@self:CustomerItemsIDs)

                                                                                                                                Define Label ( lbl13 ) , Caption : "Customer"

                                                                                                                                                Label Events

                                                                                                                                                Label Properties

                                                                                                                                Define Combobox ( comboCustomer ) , Items : self:CustomerItems

                                                                                                                                                Combobox Events

                                                                                                                                                Combobox Properties

                                                                                                                Define New Button ( btnSelectItem ) , Caption : ":::"

                                                                                                                                Button Events

                                                                                                                                                Event: ON CLICK : Action self:SelectItem()

                                                                                                                                Button Properties

                                                                                                End Of Window

                                                                                                MyWindowName.Center ( )

                                                                                                myout = self.showrecord()

                                                                                                myout = self.setmode(2)

                                                                                                MyWindowName.Timer1.Enabled := false

                                                                                                MyWindowName.textOrderNumber.Enabled := false

                                                                                                Activate window

                                                                End of Method (Return 0)

                                                Define Method UserInterface2Class Class MyClassName

                                                                Start Here

                                                                                Customers

                                                                                                self:nCustomer = MyWindowName.comboCustomer.Value

                                                                                                self.nCustomer = self:CustomerItemsIDs[self:nCustomer]

                                                                End of Method (Return 0)

                                                Define Method Class2ADO Class MyClassName

                                                                Start Here

                                                                                ADODB RecordSet (self:oRS) Set Field (self:linkmasterkey) Value To (self:nOrderNumber)

                                                                                ADODB RecordSet (self:oRS) Set Field ("CustomerID") Value To (self:nCustomer)

                                                                End of Method (Return 0)

                                                Define Method ADO2Class Class MyClassName

                                                                Start Here

                                                                                self:nOrderNumber = ADODB RecordSet (self:oRS) Get Field (self:linkmasterkey) Value

                                                                                self:nCustomer = ADODB RecordSet (self:oRS) Get Field ("CustomerID") Value

                                                                End of Method (Return 0)

                                                Define Method Class2UserInterface Class MyClassName

                                                                Start Here

                                                                                MyWindowName.textOrderNumber.Value := alltrim(str(self:nOrderNumber))

                                                                                myout = self.search2()

                                                                                Customer

                                                                                                self:nCustomer = self.LookupIDtoIndex(self:nCustomer,@self:customeritemsIDs)

                                                                                                MyWindowName.ComboCustomer.Value := self:nCustomer

                                                                End of Method (Return 0)

                                                Define Method ClearRecord Class MyClassName

                                                                Start Here

                                                                                IF ( self:addrec = false )

                                                                                                Start Here

                                                                                                                self:nOrderNumber = 0

                                                                                                END OF IF STATEMENT

                                                                                self.nCustomer = 0

                                                                End of Method (Return 0)

                                                Define Method setmode(p1) Class MyClassName

                                                                Start Here

                                                                                IF ( p1 = 1 )

                                                                                                Start Here

                                                                                                                MyWindowName.btnfirst.Enabled := false

                                                                                                                MyWindowName.btnnext.Enabled := false

                                                                                                                MyWindowName.btnprev.Enabled := false

                                                                                                                MyWindowName.btnlast.Enabled := false

                                                                                                                MyWindowName.btndel.Enabled := false

                                                                                                                MyWindowName.btnclose.Enabled := false

                                                                                                                MyWindowName.btnsave.Enabled := true

                                                                                                                MyWindowName.btncancel.Enabled := true

                                                                                                                MyWindowName.btnedit.Enabled := false

                                                                                                                MyWindowName.btnadd.Enabled := false

                                                                                                                MyWindowName.btnadd2.Enabled := false

                                                                                                                MyWindowName.btndel2.Enabled := false

                                                                                                                Search Controls

                                                                                                                                MyWindowName.textNameBrowse.Enabled := false

                                                                                                                                MyWindowName.btn1Browse.Enabled := false

                                                                                                                                MyWindowName.Grid1Browse.Enabled := false

                                                                                                                MyWindowName.ComboCustomer.Enabled := True

                                                                                                END OF IF STATEMENT

                                                                                IF ( p1 = 2 )

                                                                                                Start Here

                                                                                                                MyWindowName.btnfirst.Enabled := true

                                                                                                                MyWindowName.btnnext.Enabled := true

                                                                                                                MyWindowName.btnprev.Enabled := true

                                                                                                                MyWindowName.btnlast.Enabled := true

                                                                                                                MyWindowName.btndel.Enabled := true

                                                                                                                MyWindowName.btnclose.Enabled := true

                                                                                                                MyWindowName.btnsave.Enabled := false

                                                                                                                MyWindowName.btncancel.Enabled := false

                                                                                                                MyWindowName.btnedit.Enabled := true

                                                                                                                MyWindowName.btnadd.Enabled := true

                                                                                                                MyWindowName.btnadd2.Enabled := true

                                                                                                                MyWindowName.btndel2.Enabled := true

                                                                                                                Search Controls

                                                                                                                                MyWindowName.textNameBrowse.Enabled := True

                                                                                                                                MyWindowName.btn1Browse.Enabled := True

                                                                                                                                MyWindowName.Grid1Browse.Enabled := True

                                                                                                                MyWindowName.ComboCustomer.Enabled := False

                                                                                                END OF IF STATEMENT

                                                                                self:OperationMode = p1

                                                                End of Method (Return 0)

                                                Define Method OnBeforeDelete Class MyClassName

                                                                Start Here

                                                                                myout = self:oCon.execute("delete from "+self:tablename3+" where "+self:linkmasterkey+" = " + str(self:nOrderNumber))

                                                                End of Method (Return myout)

                                                Define Method onAddClick Class MyClassName

                                                                Start Here

                                                                                Local myRS,nValue

                                                                                nvalue = 0

                                                                                get new order number

                                                                                                myRS = Create New ADODB RecordSet Object

                                                                                                Open Recordset myRS , Connection self:oCon , CursorType 1 , SQL Statement "Select * from " + self:tablename4

                                                                                                nValue = ADODB RecordSet (myRS) Get Field (self:countercolumn) Value

                                                                                                nvalue = nvalue+1

                                                                                                ADODB RecordSet (myRS) Set Field (self:countercolumn) Value To (nvalue)

                                                                                                ADODB RecordSet myRS - Update Record

                                                                                                Close ADODB RecordSet myRS

                                                                                self:nOrderNumber = nValue

                                                                                MyWindowName.textOrderNumber.Value := alltrim(str(self:nOrderNumber))

                                                                End of Method (Return 0)

                                                Define Method search2 Class MyClassName

                                                                Start Here

                                                                                Local oRS,cName,myMax,x,x2,mymax2,vname,vname2,vid

                                                                                cName = MyWindowName.textNamebrowse2.Value

                                                                                oRS = Create New ADODB RecordSet Object

                                                                                Open Recordset oRS , Connection self:oCon , CursorType 1 ,

                                                                                SQL Statement "Select * from "+self:tableName2 +" where "+self:linkmasterkey+"= "+str(self:nOrderNumber)+" and "+self:column2+" like '" + cName + "%'"

                                                                                mymax := ADODB RecordSet (oRS) , Get Records Count

                                                                                MyWindowName.grid1browse2.DeleteAllItems ( )

                                                                                self:ResultPrimaryKeys2 = {}

                                                                                MyWindowName.grid1browse2.Value := 0

                                                                                IF ( mymax > 0 )

                                                                                                Start Here

                                                                                                                FOR LOOP ( From x = 1 To mymax Step 1)

                                                                                                                                Start Here

                                                                                                                                                vname = ADODB RecordSet (oRS) Get Field (self:column2) Value

                                                                                                                                                temp_array = {}

                                                                                                                                                mymax2 = Get Length of String/Variable/Array self:columns2

                                                                                                                                                FOR LOOP ( From x2 = 1 To mymax2 Step 1)

                                                                                                                                                                Start Here

                                                                                                                                                                                vname2 = ADODB RecordSet (oRS) Get Field (self:columns2[x2]) Value

                                                                                                                                                                                IF ( valtype(vname2) = "N" )

                                                                                                                                                                                                Start Here

                                                                                                                                                                                                                VNAME2 = CONVERT VNAME2 TO STRING

                                                                                                                                                                                                                VNAME2 = All Trim VNAME2

                                                                                                                                                                                                END OF IF STATEMENT

                                                                                                                                                                                Add item vname2 To Array temp_array

                                                                                                                                                                End of For Loop

                                                                                                                                                MyWindowName.grid1browse2.AddItem ( temp_array )

                                                                                                                                                vid = ADODB RecordSet (oRS) Get Field (self:PrimaryKey2) Value

                                                                                                                                                vid = CONVERT vid TO STRING

                                                                                                                                                Add item vid To Array self:ResultPrimaryKeys2

                                                                                                                                                ADODB RecordSet oRS - Goto Next Record

                                                                                                                                End of For Loop

                                                                                                END OF IF STATEMENT

                                                                                Close ADODB RecordSet oRS

                                                                End of Method (Return 0)

                                                Define Method DelRecord2 Class MyClassName

                                                                Start Here

                                                                                Local nvalue,myout

                                                                                nvalue = MyWindowName.grid1browse2.Value

                                                                                IF ( nvalue > 0 )

                                                                                                Start Here

                                                                                                                nvalue = self:resultprimarykeys2[nvalue]

                                                                                                                myout = self:oCon.execute("delete from "+self:tablename3+" where "+self:primarykey3+" = " + nvalue)

                                                                                                                myout = self.search2()

                                                                                                ELSE

                                                                                                                Start Here

                                                                                                                                Show Message "You should Create/Select Item First" Title "Sorry" Type: Message Box

                                                                                                END OF IF STATEMENT

                                                                End of Method (Return 0)

                                                Define Method AddRecord2 Class MyClassName

                                                                Start Here

                                                                                Local oRS,nValue

                                                                                IF ( self:nOrderNumber > 0 )

                                                                                                Start Here

                                                                                                                Item

                                                                                                                                self:nItem = MyWindowName.ComboItem.Value

                                                                                                                                self:nItem = self:ItemItemsids[self:nItem]

                                                                                                                                oRS = Create New ADODB RecordSet Object

                                                                                                                                Open Recordset oRS , Connection self:oCon , CursorType 1 , SQL Statement "Select * from "+self:tablename3

                                                                                                                                ADODB RecordSet oRS - Add New Record

                                                                                                                                save data

                                                                                                                                                ADODB RecordSet (oRS) Set Field (self:linkchildkey) Value To (self:nItem)

                                                                                                                                                ADODB RecordSet (oRS) Set Field (self:linkmasterkey) Value To (self:nOrderNumber)

                                                                                                                                ADODB RecordSet oRS - Update Record

                                                                                                                                Close ADODB RecordSet oRS

                                                                                                                                myout = self.Search2()

                                                                                                ELSE

                                                                                                                Start Here

                                                                                                                                Show Message "You should Create/Select Order First" Title "Sorry" Type: Message Box

                                                                                                END OF IF STATEMENT

                                                                End of Method (Return 0)

                                                Define Method itemchange Class MyClassName

                                                                Start Here

                                                                                Local myrs,MYVALUE

                                                                                TVALUE = MyWindowName.Comboitem.Value

                                                                                IF ( TVALUE = 0 )

                                                                                                Start Here

                                                                                                                Return 0

                                                                                                END OF IF STATEMENT

                                                                                MYVALUE = self:ItemItemsids[TVALUE]

                                                                                myrs = Create New ADODB RecordSet Object

                                                                                MYVALUE = CONVERT MYVALUE TO STRING

                                                                                Do Task based on item change

                                                                End of Method (Return 0)

                                                Define Method SelectItem Class MyClassName

                                                                Start Here

                                                                                myout = SelectItemObject.ShowWindow()

                                                                                IF ( SelectItemObject:nSelectedID != 0 )

                                                                                                Start Here

                                                                                                                myindex = Self.LookupIDToIndex(selectItemObject:nSelectedID,@self:itemItemsIDs)

                                                                                                                MyWindowName.ComboItem.Value := myindex

                                                                                                END OF IF STATEMENT

                                                                End of Method (Return 0)

                                Class Methods

                                                Define Method closewindow Class MyClassName

                                                                Start Here

                                                                                myout = self.disconnect()

                                                                                MyWindowName.Release ( )

                                                                End of Method (Return 0)

                                                Define Method AutoGotoRecord Class MyClassName

                                                                Start Here

                                                                                IF ( self:LFindRecord = true .and. self:OperationMode = 2 )

                                                                                                Start Here

                                                                                                                ADODB RecordSet (self:oRS) Find , Cirteria self:CFindExpr

                                                                                                                mycheck = ADODB RecordSet self:oRS , Check EOF

                                                                                                                IF ( mycheck = true )

                                                                                                                                Start Here

                                                                                                                                                ADODB RecordSet self:oRS - Goto Previous Record

                                                                                                                                END OF IF STATEMENT

                                                                                                                IF ( iswindowdefined( MyWindowName ) )

                                                                                                                                Start Here

                                                                                                                                                myout = self.showrecord()

                                                                                                                                                MyWindowName.SetFocus ( )

                                                                                                                                END OF IF STATEMENT

                                                                                                END OF IF STATEMENT

                                                                                self:LFindRecord = false

                                                                                self:CFindExpr = ""

                                                                End of Method (Return 0)

                                                Define Method BeforeSearch Class MyClassName

                                                                Start Here

                                                                                MyWindowName.grid1Browse.DeleteAllItems ( )

                                                                                MyWindowName.grid1Browse.Value := 0

                                                                End of Method (Return 0)

                                                Define Method SearchAdd(temp_array) Class MyClassName

                                                                Start Here

                                                                                MyWindowName.grid1Browse.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

                                                                                cName = MyWindowName.textNameBrowse.Value

                                                                End of Method (Return cName)

                                                Define Method OpenDataWindow Class MyClassName

                                                                Start Here

                                                                                Local nvalue,myout

                                                                                nvalue = MyWindowName.grid1browse.Value

                                                                                IF ( nvalue > 0 )

                                                                                                Start Here

                                                                                                                myout = self.ShowDataWindow(nvalue)

                                                                                                                MyWindowName.Grid1browse.SetFocus ( )

                                                                                                END OF IF STATEMENT

                                                                End of Method (Return 0)

                                                Define Method ShowDataWindow(nvalue) Class MyClassName

                                                                Start Here

                                                                                self.LFindRecord = true

                                                                                self.CFindExpr = self:primarykey+"= '"+self:resultprimarykeys[nvalue]+"' "

                                                                                myout = self.ShowWindow()

                                                                End of Method (Return 0)

                                                Define Method mytimer Class MyClassName

                                                                Start Here

                                                                                myout = self.search()

                                                                                MyWindowName.Timer1.Enabled := false

                                                                End of Method (Return 0)

                                                Define Method OnBeforeEdit Class MyClassName

                                                                Start Here

                                                                End of Method (Return myout)

                                                Define Method OnAfterAddEdit Class MyClassName

                                                                Start Here

                                                                End of Method (Return myout)

4 - Application during the runtime

runtime1.JPG

Fig.60

runtime2.JPG

Fig.61

runtime3.JPG

Fig.62

runtime4.JPG

Fig.63