home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form CustomerDetailsDataControl
- Caption = "Customer Details (Supports the DataControl within the VBObjectFrameWorkCollection)"
- ClientHeight = 6000
- ClientLeft = 75
- ClientTop = 330
- ClientWidth = 8865
- Height = 6405
- Left = 15
- LinkTopic = "Form1"
- ScaleHeight = 6000
- ScaleWidth = 8865
- Top = -15
- Width = 8985
- Begin VB.Data Data3
- Caption = "Data3"
- Connect = "Access"
- DatabaseName = "DemoVBFW.mdb"
- Exclusive = 0 'False
- Height = 300
- Left = 8040
- Options = 0
- ReadOnly = -1 'True
- RecordsetType = 1 'Dynaset
- RecordSource = "Phones"
- Top = 1920
- Visible = 0 'False
- Width = 1140
- End
- Begin VB.CommandButton pbOK
- Cancel = -1 'True
- Caption = "OK"
- Default = -1 'True
- Height = 375
- Left = 7800
- TabIndex = 11
- Top = 2280
- Width = 975
- End
- Begin VB.CommandButton pbDeleteCustomer
- Caption = "Delete"
- Height = 375
- Left = 7800
- TabIndex = 10
- Top = 1200
- Width = 975
- End
- Begin VB.CommandButton pbUpdateCustomer
- Caption = "Update"
- Height = 375
- Left = 7800
- TabIndex = 9
- Top = 720
- Width = 975
- End
- Begin VB.CommandButton pbAddNewCustomer
- Caption = "Add New"
- Height = 375
- Left = 7800
- TabIndex = 8
- Top = 240
- Width = 975
- End
- Begin VB.Frame Frame1
- Caption = "Customer Details"
- Height = 2535
- Left = 4440
- TabIndex = 31
- Top = 120
- Width = 3255
- Begin VB.ComboBox lbxGenderCodes
- Height = 315
- Left = 2400
- Sorted = -1 'True
- TabIndex = 7
- Top = 2160
- Width = 615
- End
- Begin VB.ComboBox lbxMaritalStatusCodes
- Height = 315
- Left = 1200
- Sorted = -1 'True
- TabIndex = 6
- Top = 2160
- Width = 855
- End
- Begin VB.TextBox efCustomerNumber
- Height = 285
- Left = 1200
- TabIndex = 1
- Top = 360
- Width = 1815
- End
- Begin VB.TextBox efDateOfBirth
- Height = 285
- Left = 1200
- TabIndex = 5
- Top = 1800
- Width = 1815
- End
- Begin VB.TextBox efFirstName
- Height = 285
- Left = 1200
- TabIndex = 2
- Top = 720
- Width = 1815
- End
- Begin VB.TextBox efLastName
- Height = 285
- Left = 1200
- TabIndex = 3
- Top = 1080
- Width = 1815
- End
- Begin VB.TextBox efSSN
- Height = 285
- Left = 1200
- TabIndex = 4
- Top = 1440
- Width = 1815
- End
- Begin VB.Label Label1
- Caption = "Cust Number"
- Height = 255
- Index = 12
- Left = 120
- TabIndex = 38
- Top = 360
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Sex"
- Height = 255
- Index = 11
- Left = 2040
- TabIndex = 37
- Top = 2160
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "Marital Status"
- Height = 255
- Index = 4
- Left = 120
- TabIndex = 36
- Top = 2160
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Date Of Birth"
- Height = 255
- Index = 3
- Left = 120
- TabIndex = 35
- Top = 1800
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "First Name"
- Height = 255
- Index = 0
- Left = 120
- TabIndex = 34
- Top = 720
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Last Name"
- Height = 255
- Index = 1
- Left = 120
- TabIndex = 33
- Top = 1080
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "SSN"
- Height = 255
- Index = 2
- Left = 120
- TabIndex = 32
- Top = 1440
- Width = 975
- End
- End
- Begin VB.Data Data2
- Caption = "Data2"
- Connect = "Access"
- DatabaseName = "DemoVBFW.mdb"
- Exclusive = 0 'False
- Height = 300
- Left = 8040
- Options = 0
- ReadOnly = -1 'True
- RecordsetType = 1 'Dynaset
- RecordSource = "Addresses"
- Top = 1680
- Visible = 0 'False
- Width = 1140
- End
- Begin VB.Data Data1
- Caption = "Data1"
- Connect = "Access"
- DatabaseName = "DemoVBFW.mdb"
- Exclusive = 0 'False
- Height = 300
- Left = 8040
- Options = 0
- ReadOnly = -1 'True
- RecordsetType = 1 'Dynaset
- RecordSource = "Persons"
- Top = 1440
- Visible = 0 'False
- Width = 1140
- End
- Begin TabDlg.SSTab SSTab1
- Height = 3135
- Left = 120
- TabIndex = 12
- Top = 2760
- Width = 8775
- _Version = 65536
- _ExtentX = 15478
- _ExtentY = 5530
- _StockProps = 15
- Caption = "Phones"
- TabsPerRow = 2
- Tab = 1
- TabOrientation = 0
- Tabs = 2
- Style = 1
- TabMaxWidth = 0
- TabHeight = 529
- TabCaption(0) = "Addresses"
- Tab(0).ControlCount= 7
- Tab(0).ControlEnabled= 0 'False
- Tab(0).Control(0)= "DBGrid2"
- Tab(0).Control(1)= "Label1(13)"
- Tab(0).Control(2)= "efFormattedAddress"
- Tab(0).Control(3)= "Frame2"
- Tab(0).Control(4)= "pbDeleteAddress"
- Tab(0).Control(5)= "pbUpdateAddress"
- Tab(0).Control(6)= "pbAddNewAddress"
- TabCaption(1) = "Phones"
- Tab(1).ControlCount= 7
- Tab(1).ControlEnabled= -1 'True
- Tab(1).Control(0)= "DBGrid3"
- Tab(1).Control(1)= "Label1(21)"
- Tab(1).Control(2)= "efFormattedPhoneNumber"
- Tab(1).Control(3)= "Frame3"
- Tab(1).Control(4)= "pbDeletePhone"
- Tab(1).Control(5)= "pbUpdatePhone"
- Tab(1).Control(6)= "pbAddPhone"
- Begin VB.CommandButton pbAddPhone
- Caption = "Add New"
- Height = 375
- Left = 7680
- TabIndex = 28
- Top = 480
- Width = 975
- End
- Begin VB.CommandButton pbUpdatePhone
- Caption = "Update"
- Height = 375
- Left = 7680
- TabIndex = 29
- Top = 960
- Width = 975
- End
- Begin VB.CommandButton pbDeletePhone
- Caption = "Delete"
- Height = 375
- Left = 7680
- TabIndex = 30
- Top = 1440
- Width = 975
- End
- Begin VB.Frame Frame3
- Caption = "Address Details"
- Height = 2655
- Left = 4320
- TabIndex = 50
- Top = 360
- Width = 3255
- Begin VB.TextBox efUsage
- Height = 285
- Left = 1200
- TabIndex = 27
- Top = 720
- Width = 1815
- End
- Begin VB.TextBox efPhoneNumber
- Height = 285
- Left = 1200
- TabIndex = 26
- Top = 360
- Width = 1815
- End
- Begin VB.Label Label1
- Caption = "Usage"
- Height = 255
- Index = 16
- Left = 120
- TabIndex = 52
- Top = 720
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Phone Num"
- Height = 255
- Index = 15
- Left = 120
- TabIndex = 51
- Top = 360
- Width = 975
- End
- End
- Begin VB.CommandButton pbAddNewAddress
- Caption = "Add New"
- Height = 375
- Left = -67320
- TabIndex = 22
- Top = 480
- Width = 975
- End
- Begin VB.CommandButton pbUpdateAddress
- Caption = "Update"
- Height = 375
- Left = -67320
- TabIndex = 23
- Top = 960
- Width = 975
- End
- Begin VB.CommandButton pbDeleteAddress
- Caption = "Delete"
- Height = 375
- Left = -67320
- TabIndex = 24
- Top = 1440
- Width = 975
- End
- Begin VB.Frame Frame2
- Caption = "Address Details"
- Height = 2655
- Left = -70680
- TabIndex = 39
- Top = 360
- Width = 3255
- Begin VB.ComboBox lbxStateCodes
- Height = 315
- Left = 1200
- Sorted = -1 'True
- TabIndex = 18
- Top = 1800
- Width = 1815
- End
- Begin VB.TextBox efLine1
- Height = 285
- Left = 1200
- TabIndex = 14
- Top = 360
- Width = 1815
- End
- Begin VB.TextBox efLine2
- Height = 285
- Left = 1200
- TabIndex = 15
- Top = 720
- Width = 1815
- End
- Begin VB.TextBox efLine3
- Height = 285
- Left = 1200
- TabIndex = 16
- Top = 1080
- Width = 1815
- End
- Begin VB.TextBox efCity
- Height = 285
- Left = 1200
- TabIndex = 17
- Top = 1440
- Width = 1815
- End
- Begin VB.TextBox efZipCode
- Height = 285
- Left = 1200
- MaxLength = 5
- TabIndex = 19
- Top = 2160
- Width = 735
- End
- Begin VB.TextBox efZipExtension
- Height = 285
- Left = 2640
- MaxLength = 2
- TabIndex = 21
- Top = 2160
- Width = 375
- End
- Begin VB.TextBox efZipSupplement
- Height = 285
- Left = 2040
- MaxLength = 4
- TabIndex = 20
- Top = 2160
- Width = 495
- End
- Begin VB.Label Label1
- Caption = "Line 1"
- Height = 255
- Index = 5
- Left = 120
- TabIndex = 45
- Top = 360
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Line 2"
- Height = 255
- Index = 6
- Left = 120
- TabIndex = 44
- Top = 720
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Line 3"
- Height = 255
- Index = 7
- Left = 120
- TabIndex = 43
- Top = 1080
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "City"
- Height = 255
- Index = 10
- Left = 120
- TabIndex = 42
- Top = 1440
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "State"
- Height = 255
- Index = 8
- Left = 120
- TabIndex = 41
- Top = 1800
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Zip Code"
- Height = 255
- Index = 9
- Left = 120
- TabIndex = 40
- Top = 2160
- Width = 975
- End
- End
- Begin VB.Label efFormattedPhoneNumber
- BorderStyle = 1 'Fixed Single
- ForeColor = &H00FF0000&
- Height = 255
- Left = 120
- TabIndex = 54
- Top = 2760
- Width = 4095
- End
- Begin VB.Label Label1
- Caption = "Formatted Phone"
- Height = 255
- Index = 21
- Left = 120
- TabIndex = 53
- Top = 2520
- Width = 1575
- End
- Begin MSDBGrid.DBGrid DBGrid3
- Bindings = "DemoCust.frx":0000
- Height = 1935
- Left = 120
- OleObjectBlob = "DemoCust.frx":000E
- TabIndex = 25
- Top = 480
- Width = 4095
- End
- Begin VB.Label efFormattedAddress
- BorderStyle = 1 'Fixed Single
- ForeColor = &H00FF0000&
- Height = 975
- Left = -74880
- TabIndex = 47
- Top = 2040
- Width = 4095
- End
- Begin VB.Label Label1
- Caption = "Formatted Address"
- Height = 255
- Index = 13
- Left = -74880
- TabIndex = 46
- Top = 1800
- Width = 1575
- End
- Begin MSDBGrid.DBGrid DBGrid2
- Bindings = "DemoCust.frx":08E2
- Height = 1215
- Left = -74880
- OleObjectBlob = "DemoCust.frx":08F0
- TabIndex = 13
- Top = 480
- Width = 4095
- End
- End
- Begin VB.Label efAge
- BorderStyle = 1 'Fixed Single
- ForeColor = &H00FF0000&
- Height = 255
- Left = 3720
- TabIndex = 56
- Top = 2400
- Width = 615
- End
- Begin VB.Label Label1
- Caption = "Age"
- Height = 255
- Index = 17
- Left = 3720
- TabIndex = 55
- Top = 2160
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "Formatted Name"
- Height = 255
- Index = 14
- Left = 120
- TabIndex = 49
- Top = 2160
- Width = 1575
- End
- Begin VB.Label efFormattedName
- BorderStyle = 1 'Fixed Single
- ForeColor = &H00FF0000&
- Height = 255
- Left = 120
- TabIndex = 48
- Top = 2400
- Width = 3495
- End
- Begin MSDBGrid.DBGrid DBGrid1
- Bindings = "DemoCust.frx":0FF8
- Height = 1935
- Left = 120
- OleObjectBlob = "DemoCust.frx":1006
- TabIndex = 0
- Top = 120
- Width = 4215
- End
- Attribute VB_Name = "CustomerDetailsDataControl"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- ' This example show how the VBOFW can
- ' support the VB application through conventional
- ' VB programming techniques, including the use of
- ' the VB DataControl, via the
- ' VBOFWDataWrapper
- Private pvtCurrentPerson As Person
- Private pvtPersonsDataWrapper As VBOFDataWrapper
- Private pvtCurrentAddress As Address
- Private pvtAddressesDataWrapper As VBOFDataWrapper
- Private pvtCurrentPhone As Phone
- Private pvtPhonesDataWrapper As VBOFDataWrapper
- Private pvtStates As VBOFCollection
- Private pvtStatesListBoxWrapper As VBOFListBoxWrapper
- Private pvtGenderCodes As VBOFCollection
- Private pvtGenderCodesListBoxWrapper As VBOFListBoxWrapper
- Private pvtMaritalStatusCodes As VBOFCollection
- Private pvtMaritalStatusCodesListBoxWrapper As VBOFListBoxWrapper
- Public ObjectManager As VBOFObjectManager
- Private Sub PopulateGenderCodes()
- ' instantiate pvtGenderCodes as a
- ' reference to pvtGenderCodes
- Set pvtGenderCodes = _
- pubGenderCodes
- ' attach the Collection, ListBox and ListBoxWrapper
- Set pvtGenderCodesListBoxWrapper = _
- ObjectManager. _
- NewVBOFListBoxWrapper( _
- Collection:=pvtGenderCodes, _
- ListBox:=lbxGenderCodes)
- pvtGenderCodesListBoxWrapper. _
- AddItems
- End Sub
- Private Sub PopulateMaritalStatusCodes()
- ' instantiate pvtMaritalStatusCodes as a
- ' reference to pubMaritalStatusCodes
- Set pvtMaritalStatusCodes = _
- pubMaritalStatusCodes
- ' attach the Collection, ListBox and ListBoxWrapper
- Set pvtMaritalStatusCodesListBoxWrapper = _
- ObjectManager. _
- NewVBOFListBoxWrapper( _
- Collection:=pvtMaritalStatusCodes, _
- ListBox:=lbxMaritalStatusCodes)
- pvtMaritalStatusCodesListBoxWrapper. _
- AddItems
- End Sub
- Public Sub ObjectEventCallBack(Optional Event As Variant, Optional Object As Variant)
- Dim tempObjectType As String
- Dim tempUCaseEvent As String
- On Local Error Resume Next
- tempObjectType = TypeName(Object)
- tempUCaseEvent = UCase$(Event)
- If tempObjectType = "Person" Then
-
- If tempUCaseEvent = "REMOVEDITEM" _
- Or tempUCaseEvent = "REPLACEDITEM" _
- Then
- pvtPersonsDataWrapper.Refresh
-
- If Object.ObjectID = pvtCurrentPerson.ObjectID Then
- pvtPersonsDataWrapper.MoveFirst
- End If
- End If
- If tempUCaseEvent = "CHANGED" _
- Then
- pvtPersonsDataWrapper.Refresh
-
- pvtPersonsDataWrapper.FindFirst _
- "ObjectID = " & pvtCurrentPerson.ObjectID
-
- If Object.ObjectID = pvtCurrentPerson.ObjectID Then
- RefreshCustomerFields
- End If
- End If
- End If
- If tempObjectType = "Address" Then
- RefreshAddressFields
- End If
- If tempObjectType = "Phone" Then
- RefreshPhoneFields
- End If
- End Sub
- Private Sub RefreshAddressFields()
- On Local Error Resume Next
- ' map the selected Address to an Address in the
- ' Person.Addresses collection
- Set pvtCurrentAddress = _
- pvtCurrentPerson _
- .Addresses _
- (CStr(pvtAddressesDataWrapper.RecordSet("ObjectID")))
- If pvtCurrentAddress Is Nothing Or Err = 3021 Then
- efLine1 = ""
- efLine2 = ""
- efLine3 = ""
- efCity = ""
- lbxStateCodes = ""
- efZipCode = ""
- efZipSupplement = ""
- efZipExtension = ""
- efFormattedAddress = ""
- Exit Sub
- End If
- efLine1 = pvtCurrentAddress.Line1
- efLine2 = pvtCurrentAddress.Line2
- efLine3 = pvtCurrentAddress.Line3
- efCity = pvtCurrentAddress.City
- lbxStateCodes = pvtCurrentAddress.State.StateCode
- efZipCode = pvtCurrentAddress.ZipCode
- efZipSupplement = pvtCurrentAddress.ZipSupplementString
- efZipExtension = pvtCurrentAddress.ZipExtensionString
- efFormattedAddress = pvtCurrentAddress.FormattedAddress
- End Sub
- Sub RefreshCustomerFields()
- On Local Error Resume Next
- ' Set pvtCurrentPerson = _
- ' publicCompany _
- ' .Persons _
- ' (CStr(pvtPersonsDataWrapper.RecordSet("ObjectID")))
-
- ' display the person's detail information
- efCustomerNumber = pvtCurrentPerson.CustomerNumber
- efFirstName = pvtCurrentPerson.FirstName
- efLastName = pvtCurrentPerson.LastName
- efSSN = pvtCurrentPerson.SSN
- efDateOfBirth = Format$(pvtCurrentPerson.DateOfBirth, "mm/dd/yyyy")
- lbxMaritalStatusCodes = pvtCurrentPerson.MaritalStatus
- lbxGenderCodes = pvtCurrentPerson.Sex
- efFormattedName = pvtCurrentPerson.FormattedName
- efAge = pvtCurrentPerson.Age
- End Sub
- Private Sub RefreshPhoneFields()
- On Local Error Resume Next
- ' map the selected Phone to a Phone in the
- ' Person.Phones collection
- Set pvtCurrentPhone = _
- pvtCurrentPerson _
- .Phones _
- (CStr(pvtPhonesDataWrapper.RecordSet("ObjectID")))
- If pvtCurrentPhone Is Nothing Or Err = 3021 Then
- efPhoneNumber = ""
- efUsage = ""
- efFormattedPhoneNumber = ""
- Exit Sub
- End If
- efPhoneNumber = pvtCurrentPhone.PhoneNumber
- efUsage = pvtCurrentPhone.Usage
- efFormattedPhoneNumber = pvtCurrentPhone.FormattedPhoneNumber
- End Sub
- Private Sub RegisterForEvents()
- #If NoEventMgr = False Then
- ObjectManager.RegisterForObjectEvent _
- TriggerObjectType:="Person", _
- RegisterObject:=Me, _
- TriggerEvent:="Changed"
- ObjectManager.RegisterForObjectEvent _
- TriggerObjectType:="Address", _
- RegisterObject:=Me, _
- TriggerEvent:="Changed"
- ObjectManager.RegisterForObjectEvent _
- TriggerObjectType:="Phone", _
- RegisterObject:=Me, _
- TriggerEvent:="Changed"
- #End If
- End Sub
- Private Sub Data1_Validate(Action As Integer, Save As Integer)
- pvtPersonsDataWrapper. _
- Validate _
- Action:=Action, _
- Save:=Save
- End Sub
- Private Sub Data2_Reposition()
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
-
- Set pvtCurrentAddress = _
- pvtAddressesDataWrapper. _
- AbsolutePositionObject
- RefreshAddressFields
- Me.MousePointer = vbArrow
- End Sub
- Private Sub Data2_Validate(Action As Integer, Save As Integer)
- pvtAddressesDataWrapper. _
- Validate _
- Action:=Action, _
- Save:=Save
- End Sub
- Private Sub Data3_Reposition()
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
-
- Set pvtCurrentPhone = _
- pvtPhonesDataWrapper. _
- AbsolutePositionObject
- RefreshPhoneFields
- Me.MousePointer = vbArrow
- End Sub
- Private Sub Data3_Validate(Action As Integer, Save As Integer)
- pvtPhonesDataWrapper. _
- Validate _
- Action:=Action, _
- Save:=Save
- End Sub
- Private Sub DBGrid1_Click()
- End Sub
- Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
- Me.MousePointer = vbArrowHourglass
- ObjectManager.Form_QueryUnload _
- Me, _
- pvtPersonsDataWrapper, _
- pvtAddressesDataWrapper, _
- pvtPhonesDataWrapper
- #If NoEventMgr = False Then
- ObjectManager. _
- UnRegisterForAllEvents _
- RegisterObject:=Me
- #End If
- Me.MousePointer = vbArrow
- End Sub
- Private Sub pbAddNewAddress_Click()
- Dim tempNewAddress As New Address
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- Set pvtCurrentAddress = tempNewAddress
- PopulateCurrentAddress
-
- pvtCurrentPerson.AddAddress _
- Item:=tempNewAddress
-
- pvtAddressesDataWrapper.Rebind _
- Collection:=pvtCurrentPerson.Addresses
- pvtAddressesDataWrapper.FindFirst _
- "ObjectID = " & pvtCurrentAddress.ObjectID
- Me.MousePointer = vbArrow
- End Sub
- Private Sub pbAddNewCustomer_Click()
- Dim tempNewPerson As New Person
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- Set pvtCurrentPerson = tempNewPerson
- PopulateCurrentPerson
-
- publicCompany.AddPerson _
- Item:=tempNewPerson
-
- Data2.Enabled = False
- Data3.Enabled = False
- pvtPersonsDataWrapper.Rebind _
- Collection:=publicCompany.Persons
- pvtPersonsDataWrapper.FindFirst _
- "ObjectID = " & pvtCurrentPerson.ObjectID
- Me.MousePointer = vbArrow
- End Sub
- Private Sub pbAddPhone_Click()
- Dim tempNewPhone As New Phone
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- Set pvtCurrentPhone = tempNewPhone
- PopulateCurrentPhone
-
- pvtCurrentPerson.AddPhone _
- Item:=tempNewPhone
- pvtPhonesDataWrapper.Rebind _
- Collection:=pvtCurrentPerson.Phones
- pvtPhonesDataWrapper.FindFirst _
- "ObjectID = " & pvtCurrentPhone.ObjectID
- Me.MousePointer = vbArrow
- End Sub
- Private Sub pbDeleteAddress_Click()
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- Set pvtCurrentAddress = _
- pvtCurrentPerson _
- .Addresses _
- (CStr(Data2.RecordSet("ObjectID")))
-
- pvtCurrentPerson.Addresses.Remove _
- Item:=pvtCurrentAddress
-
- pvtAddressesDataWrapper.Rebind _
- Collection:=pvtCurrentPerson.Addresses
- pvtAddressesDataWrapper.MoveFirst
- Me.MousePointer = vbArrow
- End Sub
- Private Sub pbDeleteCustomer_Click()
- Dim saveObjectID As String
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- Set pvtCurrentPerson = _
- publicCompany _
- .Persons _
- (CStr(pvtPersonsDataWrapper.RecordSet("ObjectID")))
- publicCompany.Persons.Remove _
- Item:=pvtCurrentPerson
-
- pvtPersonsDataWrapper.Rebind _
- Collection:=publicCompany.Persons
- pvtPersonsDataWrapper.MoveFirst
- Me.MousePointer = vbArrow
- End Sub
- Private Sub pbDeletePhone_Click()
- Dim saveObjectID As String
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- saveObjectID = CStr(pvtCurrentPhone.ObjectID)
- With pvtCurrentPhone
- .PhoneNumber = efPhoneNumber
- .Usage = efUsage
- End With
- pvtCurrentPerson.Phones.Remove _
- Item:=pvtCurrentPhone
-
- pvtPhonesDataWrapper.Rebind _
- Collection:=pvtCurrentPerson.Phones
- pvtPhonesDataWrapper.MoveFirst
- Me.MousePointer = vbArrow
- End Sub
- Private Sub pbOK_Click()
- Set pvtStates = Nothing
- Set pvtGenderCodes = Nothing
- Set pvtMaritalStatusCodes = Nothing
- Unload Me
- End Sub
- Private Sub Data1_Reposition()
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- Data2.Enabled = True
- Data3.Enabled = True
-
- If pvtPersonsDataWrapper Is Nothing Then
- Exit Sub
- End If
- Set pvtCurrentPerson = _
- pvtPersonsDataWrapper. _
- AbsolutePositionObject
- RefreshCustomerFields
- If pvtCurrentPerson Is Nothing Then
- Data2.Enabled = False
- Data3.Enabled = False
- Me.MousePointer = vbArrow
- Exit Sub
- End If
- ' rebind the Wrappers for the contained
- ' collections
- pvtAddressesDataWrapper.Rebind _
- Collection:=pvtCurrentPerson.Addresses
- pvtPhonesDataWrapper.Rebind _
- Collection:=pvtCurrentPerson.Phones
- ' display details of the first Address
- pvtAddressesDataWrapper.MoveFirst
- ' display details of the first Phone
- pvtPhonesDataWrapper.MoveFirst
- Me.MousePointer = vbArrow
- End Sub
- Private Sub Form_Load()
- On Local Error Resume Next
- PopulateStateCodes
- PopulateGenderCodes
- PopulateMaritalStatusCodes
- Data2.Enabled = False
- Data3.Enabled = False
- Set pvtPersonsDataWrapper = _
- ObjectManager. _
- NewVBOFDataWrapper( _
- Collection:=publicCompany.Persons, _
- DataControl:=Data1)
- Set pvtAddressesDataWrapper = _
- ObjectManager. _
- NewVBOFDataWrapper( _
- Collection:=Nothing, _
- DataControl:=Data2)
-
- Set pvtPhonesDataWrapper = _
- ObjectManager. _
- NewVBOFDataWrapper( _
- Collection:=Nothing, _
- DataControl:=Data3)
- pvtPersonsDataWrapper. _
- MoveFirst
- RegisterForEvents
- End Sub
- Private Sub pbUpdateAddress_Click()
- ' update the person's detail information
- Dim saveObjectID As String
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- PopulateCurrentAddress
- pvtCurrentPerson.Addresses.Replace _
- Item:=pvtCurrentAddress, _
- ReplaceWith:=pvtCurrentAddress
-
- pvtAddressesDataWrapper.Rebind _
- Collection:=pvtCurrentPerson.Addresses
- pvtAddressesDataWrapper.FindFirst _
- "ObjectID = " & pvtCurrentAddress.ObjectID
- pvtCurrentAddress. _
- ObjectHasChanged
- Me.MousePointer = vbArrow
- End Sub
- Private Function PopulateCurrentAddress()
- On Local Error Resume Next
- With pvtCurrentAddress
- .Line1 = efLine1
- .Line2 = efLine2
- .Line3 = efLine3
- .City = efCity
- .ZipCode = efZipCode
- .ZipSupplement = efZipSupplement
- .ZipExtension = efZipExtension
- End With
- Set pvtCurrentAddress.State = _
- pvtStatesListBoxWrapper.ListIndexObject
- End Function
- Private Function PopulateCurrentPerson()
- On Local Error Resume Next
- With pvtCurrentPerson
- .CustomerNumber = efCustomerNumber
- .FirstName = efFirstName
- .LastName = efLastName
- .SSN = efSSN
- .DateOfBirth = DateValue(efDateOfBirth)
- .Sex = _
- pvtGenderCodesListBoxWrapper. _
- ListIndexObject.GenderCode
- .MaritalStatus = _
- pvtMaritalStatusCodesListBoxWrapper. _
- ListIndexObject.MaritalStatusCode
- End With
- End Function
- Private Function PopulateCurrentPhone()
- On Local Error Resume Next
- With pvtCurrentPhone
- .PhoneNumber = efPhoneNumber
- .Usage = efUsage
- End With
- End Function
- Private Sub PopulateStateCodes()
- ' instantiate pvtStates as a reference
- ' to pubStates
- Set pvtStates = _
- pubStates
- ' attach the Collection, ListBox and ListBoxWrapper
- Set pvtStatesListBoxWrapper = _
- ObjectManager. _
- NewVBOFListBoxWrapper( _
- Collection:=pvtStates, _
- ListBox:=lbxStateCodes)
- pvtStatesListBoxWrapper. _
- AddItems
- End Sub
- Private Sub pbUpdateCustomer_Click()
- ' update the person's detail information
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- PopulateCurrentPerson
- publicCompany.Persons.Replace _
- Item:=pvtCurrentPerson, _
- ReplaceWith:=pvtCurrentPerson
-
- pvtPersonsDataWrapper.Rebind _
- Collection:=publicCompany.Persons
- pvtPersonsDataWrapper.FindFirst _
- "ObjectID = " & pvtCurrentPerson.ObjectID
-
- pvtCurrentPerson. _
- ObjectHasChanged
-
- Me.MousePointer = vbArrow
- End Sub
- Private Sub pbUpdatePhone_Click()
- ' update the person's Phone information
- Dim saveObjectID As String
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- PopulateCurrentPhone
-
- pvtCurrentPerson.Phones.Replace _
- Item:=pvtCurrentPhone, _
- ReplaceWith:=pvtCurrentPhone
- pvtPhonesDataWrapper.Rebind _
- Collection:=pvtCurrentPerson.Phones
- pvtPhonesDataWrapper.FindFirst _
- "ObjectID = " & pvtCurrentPhone.ObjectID
- pvtCurrentPhone. _
- ObjectHasChanged
-
- Me.MousePointer = vbArrow
- End Sub
-