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 filter report using browse window. 2 - Implementation Steps Open CustomersBrowse.SSF Fig. 1 Fig. 2 Fig. 3 Fig. 4 Fig. 5 Fig. 6 Fig. 7 Fig. 8 Fig. 9 Open method Print Fig. 10 Fig. 11 Fig. 12 Fig. 13 Fig. 14 Fig. 15 Press CTRL+R to generate the source code file CustomersBrowse.PRG Fig. 16 3 - Final Steps Tree ========================== CustomersBrowse.SSF ========================== Set Class Name & Window Name PWCT-Code Generator: Replace String (MyClassName) with (CustomersBrowseClass) PWCT-Code Generator: Replace String (MyWindowName) with (&(self:cWindowName)) Class Define Class MyClassName From SystemDatabase Declare Class Data Data cWindowName Init Value "CustomersBrowseWindow" ********************************* Record Data Here ********************************** Data tablename Init Value "Customers" Data column Init Value "CustName" Data PrimaryKey Init Value "id" Data columns Init Value {"CustName","CustPhone"} Data columnstitles Init Value {"Name","Phone"} Data columnswidths Init Value {200,100} Declare Class Methods Method showwindow Method closewindow Method OpenDataWindow Method showdatawindow Method print Method BeforeSearch Method SearchAdd Method settimer Method GetSearchValue Method SetColumn 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 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 Define Combobox ( comboFind ) , Items : self:ColumnsTitles Combobox Events Event: ON CHANGE : Action self:SetColumn() Combobox Properties Define New Button ( btnPrint ) , Caption : "Print" Button Events Event: ON CLICK : Action self:Print() Button Properties End Of Window MyWindowName.Center ( ) Activate window End of Method (Return 0) Define Method ShowDataWindow(nValue) Class MyClassName Start Here CustomersDataObject.LFindRecord = true CustomersDataObject.CFindExpr = self:primarykey+"= '"+self:resultprimarykeys[nvalue]+"' " myout = CustomersDataObject.ShowWindow() End of Method (Return 0) Define Method Print Class MyClassName Start Here Local cName,myout cName = MyWindowName.textName.Value cName = All Trim cName Customersreportobject.filter = "" IF ( .not. empty(cName) ) Start Here Customersreportobject.filter = '(('+self:tablename+'.'+self:column+') Like "'+cName+'*")' END OF IF STATEMENT myout = Customersreportobject.ShowWindow() End of Method (Return 0) Define Method SetColumn Class MyClassName Start Here Local nIndex nIndex = MyWindowName.ComboFind.Value Self.Column = self:Columns[nIndex] 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) 4 - Application during the runtime Fig. 17
|