home *** CD-ROM | disk | FTP | other *** search
- //--------------------------------------------------------------
- //
- // CustomerSelect.wfm - Mugs Sample Application
- //
- // Customer selection dialog for Invoice data entry form.
- //
- // Dependencies: <none>
- //
- // Visual dBASE Samples Group
- //
- // $Revision: 1.10 $
- //
- // Copyright (c) 1997, Borland International, Inc.
- // All rights reserved.
- //
- //---------------------------------------------------------------
- ** END HEADER -- do not remove this line
- //
- // Generated on 10/23/97
- //
- parameter bModal
- local f
- f = new CustomerSelectForm()
- if (bModal)
- f.mdi = false // ensure not MDI
- f.readModal()
- else
- f.open()
- endif
-
- class CustomerSelectForm of FORM
- with (this)
- open = class::FORM_OPEN
- onOpen = class::FORM_ONOPEN
- readModal = class::FORM_READMODAL
- autoCenter = true
- scaleFontSize = 8
- scaleFontBold = false
- height = 12.1364
- left = 23.4286
- top = 3.1364
- width = 55.8571
- text = "Select Customer"
- endwith
-
-
- this.DMCONNECT = new DATAMODREF()
- this.DMCONNECT.parent = this
- with (this.DMCONNECT)
- filename = "connect.dmd"
- dataModClass = "connectDataModule"
- share = 0
- active = true
- left = 50
- top = 0
- endwith
-
-
- this.TEXT1 = new TEXT(this)
- with (this.TEXT1)
- height = 1
- left = 2
- top = 1
- width = 12
- metric = 0
- colorNormal = "BtnText"
- fontName = "MS Sans Serif"
- fontSize = 8
- text = "Customer:"
- endwith
-
-
- this.LISTCUSTOMER = new LISTBOX(this)
- with (this.LISTCUSTOMER)
- height = 8
- left = 2
- top = 2
- width = 35
- metric = 0
- id = 103
- fontName = "MS Sans Serif"
- fontSize = 8
- colorHighLight = "HighLightText/HighLight"
- endwith
-
-
- this.LABELSORTBY = new TEXT(this)
- with (this.LABELSORTBY)
- height = 1
- left = 3
- top = 10.5
- width = 7
- metric = 0
- colorNormal = "BtnText"
- fontName = "MS Sans Serif"
- fontSize = 8
- text = "Sort by:"
- endwith
-
-
- this.RADIOID = new RADIOBUTTON(this)
- with (this.RADIOID)
- onGotFocus = {; this.form.setList(this.form, class::getID())}
- transparent = false
- height = 1
- left = 10
- top = 10.5
- width = 5
- text = "ID"
- metric = 0
- colorNormal = "WindowText/BtnFace"
- fontName = "MS Sans Serif"
- fontSize = 8
- group = true
- value = true
- endwith
-
-
- this.RADIOLAST = new RADIOBUTTON(this)
- with (this.RADIOLAST)
- onGotFocus = {; this.form.setList(this.form, class::getID())}
- transparent = false
- height = 1
- left = 16
- top = 10.5
- width = 12
- text = "Last name"
- metric = 0
- colorNormal = "WindowText/BtnFace"
- fontName = "MS Sans Serif"
- fontSize = 8
- group = false
- value = false
- endwith
-
-
- this.RADIOFIRST = new RADIOBUTTON(this)
- with (this.RADIOFIRST)
- onGotFocus = {; this.form.setList(this.form, class::getID())}
- transparent = false
- height = 1
- left = 29
- top = 10.5
- width = 14
- text = "First name"
- metric = 0
- colorNormal = "WindowText/BtnFace"
- fontName = "MS Sans Serif"
- fontSize = 8
- group = false
- value = false
- endwith
-
-
- this.BUTTONNEW = new PUSHBUTTON(this)
- with (this.BUTTONNEW)
- onClick = class::BUTTONNEW_ONCLICK
- height = 1.1818
- left = 39
- top = 2.5
- width = 15
- text = "New Customer"
- metric = 0
- fontName = "MS Sans Serif"
- fontSize = 8
- group = true
- colorNormal = "BtnText/BtnFace"
- value = false
- endwith
-
-
- this.BUTTONSELECT = new PUSHBUTTON(this)
- with (this.BUTTONSELECT)
- onClick = class::BUTTONSELECT_ONCLICK
- height = 1.1818
- left = 39
- top = 4
- width = 15
- text = "Select"
- metric = 0
- default = true
- fontName = "MS Sans Serif"
- fontSize = 8
- group = true
- colorNormal = "BtnText/BtnFace"
- value = false
- endwith
-
-
- this.BUTTONCANCEL = new PUSHBUTTON(this)
- with (this.BUTTONCANCEL)
- onClick = class::BUTTONCANCEL_ONCLICK
- height = 1.1818
- left = 39
- top = 5.5
- width = 15
- text = "Cancel"
- metric = 0
- fontName = "MS Sans Serif"
- fontSize = 8
- group = true
- colorNormal = "BtnText/BtnFace"
- value = false
- endwith
-
-
- // {Linked Method} form.buttoncancel.onClick
- function BUTTONCANCEL_OnClick
- this.form.selectID = null
- return ( this.form.close() )
-
- // {Linked Method} form.buttonnew.onClick
- function BUTTONNEW_OnClick
- this.form.selectID = -1
- return ( this.form.close() )
-
- // {Linked Method} form.buttonselect.onClick
- function BUTTONSELECT_OnClick
- this.form.selectID = class::getID()
- return ( this.form.close() )
-
- // {Linked Method} form.open
- function Form_Open
- return ( class::Form_readModal() )
-
- // {Linked Method} form.readModal
- function Form_ReadModal
- local nCount, sID
- q = new Query()
- with ( q )
- database := this.dmConnect.ref.dbMugs
- sql := 'SELECT customer."Customer ID", ' + ;
- ' customer."Last Name", ' + ;
- ' customer."First Name" ' + ;
- ' FROM "customer.dbf" customer ' + ;
- ' ORDER BY customer."Customer ID"'
- active := true
- endwith
- nCount = q.rowset.count()
-
- // Add custom properties to the form
- this.aID = new Array( nCount )
- this.aLast = new Array( nCount )
- this.aFirst = new Array( nCount )
- this.aListSource = new Array( nCount )
-
- for i = 1 to nCount
- this.aID[i] := LTRIM(STR(q.rowset.fields["Customer ID"].value))
- this.aLast[i] := q.rowset.fields["Last Name"].value.rightTrim()
- this.aFirst[i] := q.rowset.fields["First Name"].value.rightTrim()
- q.rowset.next()
- next
- q.active := false
- class::SetList( this, -1 )
-
- with ( this )
- visible := false // set to visible after curSel is set.
- mdi := false
- endwith
-
- if ( TYPE("this.selectID") == "N" )
- this.listCustomer.dataSource := null
- this.listCustomer.dataSource := "ARRAY form.aListSource"
- endif
-
- return ( CUSTOMERSELECTFORM::ReadModal() )
-
- function Form_onOpen
- local sID
- sID = ""
- if ( TYPE("this.selectID") == "N" )
- sID := LTRIM( STR( this.selectID ) )
- this.listCustomer.curSel := this.aID.scan( sID )
- else
- this.listCustomer.curSel := 1
- endif
- this.visible := true
- return true
-
- function getID
- local nID, sID
- nID = null
- sID = RTRIM(this.form.listCustomer.value)
- if ( RIGHT(sID,1) = "]" and "[" $ sID )
- sID = SUBSTR( sID, RAT("[",sID) + 1, LEN(sID) )
- endif
- nID = VAL( sID )
- return ( nID )
-
- function SetList( thisForm, nID )
- local sKey
- for i = 1 to thisForm.aListSource.size
- do case
- case thisForm.radioID.value
- thisForm.aListSource[i] := TRANSFORM(VAL(thisForm.aID[i]),"9999") + " - " + thisForm.aLast[i] + ", " + thisForm.aFirst[i]
- case thisForm.radioLast.value
- thisForm.aListSource[i] := thisForm.aLast[i] + ", " + thisForm.aFirst[i] + " [ " + thisForm.aID[i] + " ]"
- otherwise
- thisForm.aListSource[i] := thisForm.aFirst[i] + " " + thisForm.aLast[i] + " [ " + thisForm.aID[i] + " ] "
- endcase
- if ( nID == VAL( thisForm.aID[i] ) )
- sKey = thisForm.aListSource[i]
- endif
- next
- thisForm.aListSource.sort()
- thisForm.listCustomer.visible := false
- if ( nID > 0)
- thisForm.listCustomer.curSel := thisForm.aListSource.scan( sKey )
- endif
- thisForm.listCustomer.dataSource := null
- thisForm.listCustomer.dataSource := "ARRAY form.aListSource"
- thisForm.listCustomer.visible := true
- return ( i )
- endclass
-