home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form CustomerDetailsDBGridNoDataControl
- Caption = "Customer Details (Pure OO example -- no use of the DataControl, SQL, etc.)"
- ClientHeight = 6030
- ClientLeft = 630
- ClientTop = 1170
- ClientWidth = 8850
- Height = 6435
- Left = 570
- LinkTopic = "Form1"
- ScaleHeight = 6030
- ScaleWidth = 8850
- Top = 825
- Width = 8970
- Begin VB.Frame Frame1
- Caption = "Customer Details"
- Height = 2535
- Left = 4320
- TabIndex = 4
- Top = 0
- Width = 3255
- Begin VB.ComboBox lbxGenderCodes
- Height = 315
- Left = 2400
- Sorted = -1 'True
- TabIndex = 8
- Top = 2160
- Width = 615
- End
- Begin VB.ComboBox lbxMaritalStatusCodes
- Height = 315
- Left = 1200
- Sorted = -1 'True
- TabIndex = 7
- Top = 2160
- Width = 855
- End
- Begin VB.TextBox efSSN
- Height = 285
- Left = 1200
- TabIndex = 11
- Top = 1440
- Width = 1815
- End
- Begin VB.TextBox efLastName
- Height = 285
- Left = 1200
- TabIndex = 10
- Top = 1080
- Width = 1815
- End
- Begin VB.TextBox efFirstName
- Height = 285
- Left = 1200
- TabIndex = 9
- Top = 720
- Width = 1815
- End
- Begin VB.TextBox efDateOfBirth
- Height = 285
- Left = 1200
- TabIndex = 6
- Top = 1800
- Width = 1815
- End
- Begin VB.TextBox efCustomerNumber
- Height = 285
- Left = 1200
- TabIndex = 5
- Top = 360
- Width = 1815
- End
- Begin VB.Label Label1
- Caption = "Marital Status"
- Height = 255
- Index = 4
- Left = 120
- TabIndex = 56
- Top = 2160
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Sex"
- Height = 255
- Index = 11
- Left = 2040
- TabIndex = 55
- Top = 2160
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "SSN"
- Height = 255
- Index = 2
- Left = 120
- TabIndex = 16
- Top = 1440
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Last Name"
- Height = 255
- Index = 1
- Left = 120
- TabIndex = 15
- Top = 1080
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "First Name"
- Height = 255
- Index = 0
- Left = 120
- TabIndex = 14
- Top = 720
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Date Of Birth"
- Height = 255
- Index = 3
- Left = 120
- TabIndex = 13
- Top = 1800
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Cust Number"
- Height = 255
- Index = 12
- Left = 120
- TabIndex = 12
- Top = 360
- Width = 975
- End
- End
- Begin VB.CommandButton pbAddNewCustomer
- Caption = "Add New"
- Height = 375
- Left = 7680
- TabIndex = 3
- Top = 120
- Width = 975
- End
- Begin VB.CommandButton pbUpdateCustomer
- Caption = "Update"
- Height = 375
- Left = 7680
- TabIndex = 2
- Top = 600
- Width = 975
- End
- Begin VB.CommandButton pbDeleteCustomer
- Caption = "Delete"
- Height = 375
- Left = 7680
- TabIndex = 1
- Top = 1080
- Width = 975
- End
- Begin VB.CommandButton pbOK
- Cancel = -1 'True
- Caption = "OK"
- Default = -1 'True
- Height = 375
- Left = 7680
- TabIndex = 0
- Top = 2160
- Width = 975
- End
- Begin TabDlg.SSTab SSTab1
- Height = 3015
- Left = 0
- TabIndex = 17
- Top = 2640
- Width = 8775
- _Version = 65536
- _ExtentX = 15478
- _ExtentY = 5318
- _StockProps = 15
- Caption = "Addresses"
- TabsPerRow = 2
- Tab = 0
- TabOrientation = 0
- Tabs = 2
- Style = 1
- TabMaxWidth = 0
- TabHeight = 529
- TabCaption(0) = "Addresses"
- Tab(0).ControlCount= 7
- Tab(0).ControlEnabled= -1 'True
- Tab(0).Control(0)= "efFormattedAddress"
- Tab(0).Control(1)= "Label1(13)"
- Tab(0).Control(2)= "DBGrid2"
- Tab(0).Control(3)= "pbAddNewAddress"
- Tab(0).Control(4)= "pbUpdateAddress"
- Tab(0).Control(5)= "pbDeleteAddress"
- Tab(0).Control(6)= "Frame2"
- TabCaption(1) = "Phones"
- Tab(1).ControlCount= 7
- Tab(1).ControlEnabled= 0 'False
- Tab(1).Control(0)= "efFormattedPhoneNumber"
- Tab(1).Control(1)= "Label1(21)"
- Tab(1).Control(2)= "DBGrid3"
- Tab(1).Control(3)= "pbAddPhone"
- Tab(1).Control(4)= "pbUpdatePhone"
- Tab(1).Control(5)= "pbDeletePhone"
- Tab(1).Control(6)= "Frame3"
- Begin VB.Frame Frame2
- Caption = "Address Details"
- Height = 2535
- Left = 4320
- TabIndex = 29
- Top = 360
- Width = 3255
- Begin VB.TextBox efZipSupplement
- Height = 285
- Left = 2040
- MaxLength = 4
- TabIndex = 37
- Top = 2160
- Width = 495
- End
- Begin VB.TextBox efZipExtension
- Height = 285
- Left = 2640
- MaxLength = 2
- TabIndex = 36
- Top = 2160
- Width = 375
- End
- Begin VB.TextBox efZipCode
- Height = 285
- Left = 1200
- MaxLength = 5
- TabIndex = 35
- Top = 2160
- Width = 735
- End
- Begin VB.TextBox efCity
- Height = 285
- Left = 1200
- TabIndex = 34
- Top = 1440
- Width = 1815
- End
- Begin VB.TextBox efLine3
- Height = 285
- Left = 1200
- TabIndex = 33
- Top = 1080
- Width = 1815
- End
- Begin VB.TextBox efLine2
- Height = 285
- Left = 1200
- TabIndex = 32
- Top = 720
- Width = 1815
- End
- Begin VB.TextBox efLine1
- Height = 285
- Left = 1200
- TabIndex = 31
- Top = 360
- Width = 1815
- End
- Begin VB.ComboBox lbxStateCodes
- Height = 315
- Left = 1200
- Sorted = -1 'True
- TabIndex = 30
- Top = 1800
- Width = 1815
- End
- Begin VB.Label Label1
- Caption = "Zip Code"
- Height = 255
- Index = 9
- Left = 120
- TabIndex = 43
- Top = 2160
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "State"
- Height = 255
- Index = 8
- Left = 120
- TabIndex = 42
- Top = 1800
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "City"
- Height = 255
- Index = 10
- Left = 120
- TabIndex = 41
- Top = 1440
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Line 3"
- Height = 255
- Index = 7
- Left = 120
- TabIndex = 40
- Top = 1080
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Line 2"
- Height = 255
- Index = 6
- Left = 120
- TabIndex = 39
- Top = 720
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Line 1"
- Height = 255
- Index = 5
- Left = 120
- TabIndex = 38
- Top = 360
- Width = 975
- End
- End
- Begin VB.CommandButton pbDeleteAddress
- Caption = "Delete"
- Height = 375
- Left = 7680
- TabIndex = 28
- Top = 1440
- Width = 975
- End
- Begin VB.CommandButton pbUpdateAddress
- Caption = "Update"
- Height = 375
- Left = 7680
- TabIndex = 27
- Top = 960
- Width = 975
- End
- Begin VB.CommandButton pbAddNewAddress
- Caption = "Add New"
- Height = 375
- Left = 7680
- TabIndex = 26
- Top = 480
- Width = 975
- End
- Begin VB.Frame Frame3
- Caption = "Address Details"
- Height = 2535
- Left = -70680
- TabIndex = 21
- Top = 360
- Width = 3255
- Begin VB.TextBox efPhoneNumber
- Height = 285
- Left = 1200
- TabIndex = 23
- Top = 360
- Width = 1815
- End
- Begin VB.TextBox efUsage
- Height = 285
- Left = 1200
- TabIndex = 22
- Top = 720
- Width = 1815
- End
- Begin VB.Label Label1
- Caption = "Phone Num"
- Height = 255
- Index = 15
- Left = 120
- TabIndex = 25
- Top = 360
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "Usage"
- Height = 255
- Index = 16
- Left = 120
- TabIndex = 24
- Top = 720
- Width = 975
- End
- End
- Begin VB.CommandButton pbDeletePhone
- Caption = "Delete"
- Height = 375
- Left = -67320
- TabIndex = 20
- Top = 1440
- Width = 975
- End
- Begin VB.CommandButton pbUpdatePhone
- Caption = "Update"
- Height = 375
- Left = -67320
- TabIndex = 19
- Top = 960
- Width = 975
- End
- Begin VB.CommandButton pbAddPhone
- Caption = "Add New"
- Height = 375
- Left = -67320
- TabIndex = 18
- Top = 480
- Width = 975
- End
- Begin MSDBGrid.DBGrid DBGrid2
- Height = 1335
- Left = 120
- OleObjectBlob = "DemoNoDC.frx":0000
- TabIndex = 49
- Top = 480
- Width = 4095
- End
- Begin VB.Label Label1
- Caption = "Formatted Address"
- Height = 255
- Index = 13
- Left = 120
- TabIndex = 48
- Top = 1800
- Width = 1575
- End
- Begin VB.Label efFormattedAddress
- BorderStyle = 1 'Fixed Single
- ForeColor = &H00FF0000&
- Height = 855
- Left = 120
- TabIndex = 47
- Top = 2040
- Width = 4095
- End
- Begin MSDBGrid.DBGrid DBGrid3
- Height = 1815
- Left = -74880
- OleObjectBlob = "DemoNoDC.frx":1770
- TabIndex = 46
- Top = 480
- Width = 4095
- End
- Begin VB.Label Label1
- Caption = "Formatted Phone"
- Height = 255
- Index = 21
- Left = -74880
- TabIndex = 45
- Top = 2400
- Width = 1575
- End
- Begin VB.Label efFormattedPhoneNumber
- BorderStyle = 1 'Fixed Single
- ForeColor = &H00FF0000&
- Height = 255
- Left = -74880
- TabIndex = 44
- Top = 2640
- Width = 4095
- End
- End
- Begin VB.Label lblPersonDetails
- AutoSize = -1 'True
- BackColor = &H00C0C0C0&
- BorderStyle = 1 'Fixed Single
- Caption = "lblPersonDetails"
- ForeColor = &H00000080&
- Height = 255
- Left = 0
- TabIndex = 57
- Top = 5760
- Width = 8775
- WordWrap = -1 'True
- End
- Begin MSDBGrid.DBGrid DBGrid1
- Height = 1935
- Left = 0
- OleObjectBlob = "DemoNoDC.frx":2040
- TabIndex = 54
- Top = 0
- Width = 4215
- End
- Begin VB.Label efFormattedName
- BorderStyle = 1 'Fixed Single
- ForeColor = &H00FF0000&
- Height = 255
- Left = 0
- TabIndex = 53
- Top = 2280
- Width = 3495
- End
- Begin VB.Label Label1
- Caption = "Formatted Name"
- Height = 255
- Index = 14
- Left = 0
- TabIndex = 52
- Top = 2040
- Width = 1575
- End
- Begin VB.Label Label1
- Caption = "Age"
- Height = 255
- Index = 17
- Left = 3600
- TabIndex = 51
- Top = 2040
- Width = 375
- End
- Begin VB.Label efAge
- BorderStyle = 1 'Fixed Single
- ForeColor = &H00FF0000&
- Height = 255
- Left = 3600
- TabIndex = 50
- Top = 2280
- Width = 615
- End
- Attribute VB_Name = "CustomerDetailsDBGridNoDataControl"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- ' This example show how the VBOF can
- ' support the VB application withouth the need
- ' for through conventional VB programming
- ' techniques, such as the use of the VB
- ' DataControl
- ' This example expoits the ability of the
- ' VBOFCollection to control
- ' VB DBGrid in an object-oriented manner
- Private pvtCurrentPerson As Person
- Private pvtPersons As VBOFCollection
- Private pvtPersonsDBGridWrapper As VBOFDBGridWrapper
- Private pvtCurrentAddress As Address
- Private pvtAddresses As VBOFCollection
- Private pvtAddressesDBGridWrapper As VBOFDBGridWrapper
- Private pvtCurrentPhone As Phone
- Private pvtPhones As VBOFCollection
- Private pvtPhonesDBGridWrapper As VBOFDBGridWrapper
- 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 DisplayPersonalLineage()
- lblPersonDetails = pvtCurrentPerson.PersonalInformation
- End Sub
- Private Sub DisplayStateCapital()
- If pvtCurrentAddress Is Nothing Then
- Exit Sub
- End If
- If pvtCurrentAddress.State Is Nothing _
- Then
- Exit Sub
- End If
- lblPersonDetails = "Capital city of " & pvtCurrentAddress.State.StateName & " is " & pvtCurrentAddress.State.CapitalCity
- End Sub
- Private Sub GetDBGridWrappers()
- Set pvtAddresses = _
- New VBOFCollection
- Set pvtPhones = _
- New VBOFCollection
- ' attach the Collection, DBGrid and DBGridWrapper
- Set pvtPersonsDBGridWrapper = _
- ObjectManager. _
- NewVBOFDBGridWrapper( _
- Collection:=pvtPersons, _
- DBGrid:=DBGrid1)
- ' attach the Collection, DBGrid and DBGridWrapper
- Set pvtAddressesDBGridWrapper = _
- ObjectManager. _
- NewVBOFDBGridWrapper( _
- Collection:=pvtAddresses, _
- DBGrid:=DBGrid2)
- ' attach the Collection, DBGrid and DBGridWrapper
- Set pvtPhonesDBGridWrapper = _
- ObjectManager. _
- NewVBOFDBGridWrapper( _
- Collection:=pvtPhones, _
- DBGrid:=DBGrid3)
- End Sub
- Private Sub DBGrid1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- DisplayPersonalLineage
- End Sub
- Private Sub DBGrid1_UnboundAddData(ByVal RowBuf As RowBuffer, NewRowBookmark As Variant)
- Dim tempPerson As New Person
- On Local Error Resume Next
- If pvtPersons Is Nothing Then
- Exit Sub
- End If
- Me.MousePointer = vbArrowHourglass
- ' add the new Person to the Collection
- pvtPersonsDBGridWrapper. _
- UnboundAddData _
- RowBuf:=RowBuf, _
- NewRowBookmark:=NewRowBookmark, _
- Sample:=tempPerson
- ' position to the new Person
- Set pvtCurrentPerson = _
- pvtPersons.MostRecentlyAddedObject
-
- Set pvtPersonsDBGridWrapper.BookmarkObject = _
- pvtCurrentPerson
-
- RefreshCustomerFields
- Me.MousePointer = vbArrow
- End Sub
- Private Sub DBGrid1_UnboundDeleteRow(Bookmark As Variant)
- On Local Error Resume Next
- If pvtPersons Is Nothing Then
- Exit Sub
- End If
- Me.MousePointer = vbArrowHourglass
- ' delete the new Person from the Collection
- pvtPersonsDBGridWrapper. _
- UnboundDeleteRow _
- Bookmark:=Bookmark
- ' position to the first Person
- If pvtPersons.Count > 0 Then
- Set pvtCurrentPerson = _
- pvtPersons.Item(1)
- MsgBox "Test code here"
- Set pvtPersonsDBGridWrapper.BookmarkObject = _
- pvtCurrentPerson
-
- RefreshCustomerFields
- End If
- Me.MousePointer = vbArrow
- End Sub
- Private Sub DBGrid1_UnboundWriteData(ByVal RowBuf As RowBuffer, WriteLocation As Variant)
- On Local Error Resume Next
- If pvtPersons Is Nothing Then
- Exit Sub
- End If
- Me.MousePointer = vbArrowHourglass
- ' record the updated Person data
- pvtPersonsDBGridWrapper. _
- UnboundWriteData _
- RowBuf:=RowBuf, _
- WriteLocation:=WriteLocation
- ' position to the new Person
- Set pvtCurrentPerson = _
- pvtPersonsDBGridWrapper. _
- BookmarkObject
-
- RefreshCustomerFields
- Me.MousePointer = vbArrow
- End Sub
- Private Sub DBGrid2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- DisplayStateCapital
- End Sub
- Private Sub DBGrid2_UnboundAddData(ByVal RowBuf As RowBuffer, NewRowBookmark As Variant)
- Dim tempAddress As New Address
- On Local Error Resume Next
- If pvtAddresses Is Nothing Then
- Exit Sub
- End If
- Me.MousePointer = vbArrowHourglass
- ' add the new Address to the Collection
- pvtAddressesDBGridWrapper. _
- UnboundAddData _
- RowBuf:=RowBuf, _
- NewRowBookmark:=NewRowBookmark, _
- Sample:=tempAddress
- ' position to the new Address
- Set pvtCurrentAddress = _
- pvtAddresses.MostRecentlyAddedObject
- Set pvtAddressesDBGridWrapper.BookmarkObject = _
- pvtCurrentAddress
-
- RefreshAddressFields
- Me.MousePointer = vbArrow
- End Sub
- Private Sub DBGrid2_UnboundDeleteRow(Bookmark As Variant)
- On Local Error Resume Next
- If pvtAddresses Is Nothing Then
- Exit Sub
- End If
- Me.MousePointer = vbArrowHourglass
- ' delete the Address from the Collection
- pvtAddressesDBGridWrapper. _
- UnboundDeleteRow _
- Bookmark:=Bookmark
- ' position to the first Address
- If pvtAddresses.Count > 0 Then
- Set pvtCurrentAddress = _
- pvtAddresses.Item(1)
- MsgBox "Test code here"
- Set pvtAddressesDBGridWrapper.BookmarkObject = _
- pvtCurrentAddress
-
- RefreshAddressFields
- End If
- Me.MousePointer = vbArrow
- End Sub
- Private Sub DBGrid2_UnboundWriteData(ByVal RowBuf As RowBuffer, WriteLocation As Variant)
- On Local Error Resume Next
- If pvtAddresses Is Nothing Then
- Exit Sub
- End If
- Me.MousePointer = vbArrowHourglass
- ' update the Address in the Collection
- pvtAddressesDBGridWrapper. _
- UnboundWriteData _
- RowBuf:=RowBuf, _
- WriteLocation:=WriteLocation
- ' position to the updated Address
- Set pvtCurrentAddress = _
- pvtAddressesDBGridWrapper. _
- BookmarkObject
-
- RefreshAddressFields
- Me.MousePointer = vbArrow
- End Sub
- Private Sub DBGrid3_UnboundAddData(ByVal RowBuf As RowBuffer, NewRowBookmark As Variant)
- Dim tempPhone As New Phone
- On Local Error Resume Next
- If pvtPhones Is Nothing Then
- Exit Sub
- End If
- Me.MousePointer = vbArrowHourglass
- ' add the new Address to the Collection
- pvtPhonesDBGridWrapper. _
- UnboundAddData _
- RowBuf:=RowBuf, _
- NewRowBookmark:=NewRowBookmark, _
- Sample:=tempPhone
- ' position to the new Phone
- Set pvtCurrentPhone = _
- pvtPhones.MostRecentlyAddedObject
- pvtPhonesDBGridWrapper.BookmarkObject = _
- pvtCurrentPhone
-
- RefreshPhoneFields
- Me.MousePointer = vbArrow
- End Sub
- Private Sub DBGrid3_UnboundDeleteRow(Bookmark As Variant)
- On Local Error Resume Next
- If pvtPhones Is Nothing Then
- Exit Sub
- End If
- Me.MousePointer = vbArrowHourglass
- ' delete the Phone from the Collection
- pvtPhonesDBGridWrapper. _
- UnboundDeleteRow _
- Bookmark:=Bookmark
- ' position to the first Phone
- If pvtPhones.Count > 0 Then
- Set pvtCurrentPhone = _
- pvtPhones.Item(1)
- pvtPhonesDBGridWrapper.BookmarkObject = _
- pvtCurrentPhone
-
- RefreshPhoneFields
- End If
- Me.MousePointer = vbArrow
- End Sub
- Private Sub DBGrid3_UnboundWriteData(ByVal RowBuf As RowBuffer, WriteLocation As Variant)
- On Local Error Resume Next
- If pvtPhones Is Nothing Then
- Exit Sub
- End If
- Me.MousePointer = vbArrowHourglass
- ' update the Phone in the Collection
- pvtPhonesDBGridWrapper. _
- UnboundWriteData _
- RowBuf:=RowBuf, _
- WriteLocation:=WriteLocation
- ' position to the updated Phone
- Set pvtCurrentPhone = _
- pvtPhonesDBGridWrapper.BookmarkObject
-
- RefreshPhoneFields
- Me.MousePointer = vbArrow
- End Sub
- Private Sub efFormattedAddress_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- DisplayStateCapital
- End Sub
- Private Sub efFormattedName_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- DisplayPersonalLineage
- End Sub
- Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
- Me.MousePointer = vbArrowHourglass
- ObjectManager.Form_QueryUnload _
- Me, _
- pvtPersonsDBGridWrapper, _
- pvtAddressesDBGridWrapper, _
- pvtPhonesDBGridWrapper, _
- pvtStatesListBoxWrapper, _
- pvtGenderCodesListBoxWrapper, _
- pvtMaritalStatusCodesListBoxWrapper
- Set pvtPersons = Nothing
- Set pvtAddresses = Nothing
- Set pvtPhones = Nothing
- Set pvtStates = Nothing
- Set pvtGenderCodes = Nothing
- Set pvtMaritalStatusCodes = Nothing
- #If NoEventMgr = False Then
- ObjectManager. _
- UnRegisterForAllEvents _
- RegisterObject:=Me
- #End If
- Me.MousePointer = vbArrow
- 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" _
- Or tempUCaseEvent = "CHANGED" _
- Then
- pvtPersonsDBGridWrapper.Refresh
-
- If Object.ObjectID = pvtCurrentPerson.ObjectID Then
- RefreshCustomerFields
- End If
- End If
- End If
- If Not pvtPersonsDBGridWrapper Is Nothing Then
- Set pvtPersonsDBGridWrapper.BookmarkObject = _
- pvtCurrentPerson
- End If
- If tempObjectType = "Address" Then
- RefreshAddressFields
- pvtAddressesDBGridWrapper.Refresh
- End If
- If tempObjectType = "Phone" Then
- RefreshPhoneFields
- pvtPhonesDBGridWrapper.Refresh
- End If
- End Sub
- Private Sub DBGrid1_UnboundReadData(ByVal RowBuf As RowBuffer, StartLocation As Variant, ByVal ReadPriorRows As Boolean)
- Me.MousePointer = vbArrowHourglass
- ' populate the Persons DBGrid
- pvtPersonsDBGridWrapper. _
- UnboundReadData _
- RowBuf:=RowBuf, _
- StartLocation:=StartLocation, _
- ReadPriorRows:=ReadPriorRows
- Me.MousePointer = vbArrow
- End Sub
- Private Sub RefreshAddressFields()
- On Local Error Resume Next
- If pvtCurrentAddress Is Nothing Or Err = 3021 Then
- efLine1 = ""
- efLine2 = ""
- efLine3 = ""
- efCity = ""
- lbxStateCodes = ""
- efZipCode = ""
- efZipSupplement = ""
- efZipExtension = ""
- efFormattedAddress = ""
- lblPersonDetails = ""
- 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
- ' DisplayStateCapital
- End Sub
- Sub RefreshCustomerFields()
- On Local Error Resume Next
-
- ' 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
-
- DisplayPersonalLineage
- End Sub
- Private Sub RefreshPhoneFields()
- On Local Error Resume Next
- 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
- ObjectManager.RegisterForObjectEvent _
- TriggerObjectType:="Address", _
- RegisterObject:=Me
- ObjectManager.RegisterForObjectEvent _
- TriggerObjectType:="Phone", _
- RegisterObject:=Me
- ObjectManager.RegisterForCollectionEvent _
- Collection:=pvtPersons, _
- RegisterObject:=Me
- ObjectManager.RegisterForCollectionEvent _
- Collection:=pvtAddresses, _
- RegisterObject:=Me
- ObjectManager.RegisterForCollectionEvent _
- Collection:=pvtPhones, _
- RegisterObject:=Me
- #End If
- End Sub
- Private Sub DBGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
- Dim tempObjectID As Long
- Dim tempBookmark As Variant
- tempBookmark = _
- pvtPersonsDBGridWrapper.Bookmark
- ' display the current Person
- If Not IsNull(tempBookmark) Then
- Set pvtCurrentPerson = _
- pvtPersonsDBGridWrapper. _
- BookmarkObject
-
- RefreshCustomerFields
-
- ' set the addresses collection
- ' (must rebind the wrapper)
- Set pvtAddresses = _
- pvtCurrentPerson.Addresses
- pvtAddressesDBGridWrapper.Rebind _
- Collection:=pvtAddresses
- If pvtAddresses.Count > 0 Then
- Set pvtCurrentAddress = _
- pvtAddresses.Item(1)
- End If
-
- ' set the phones collection
- ' (must rebind the wrapper)
- Set pvtPhones = _
- pvtCurrentPerson.Phones
- pvtPhonesDBGridWrapper.Rebind _
- Collection:=pvtPhones
- If pvtPhones.Count > 0 Then
- Set pvtCurrentPhone = _
- pvtPhones.Item(1)
- End If
- End If
- DisplayPersonalLineage
- End Sub
- Private Sub DBGrid2_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
- If pvtAddresses Is Nothing Then
- Exit Sub
- End If
- If pvtAddresses.Count <= 0 Then
- Exit Sub
- End If
- Set pvtCurrentAddress = _
- pvtAddressesDBGridWrapper. _
- BookmarkObject
-
- If pvtCurrentAddress Is Nothing Then
- Set pvtCurrentAddress = pvtAddresses.Item(1)
- pvtAddressesDBGridWrapper. _
- BookmarkObject = _
- pvtCurrentAddress
- End If
-
- RefreshAddressFields
- End Sub
- Private Sub DBGrid2_UnboundReadData(ByVal RowBuf As RowBuffer, StartLocation As Variant, ByVal ReadPriorRows As Boolean)
- Me.MousePointer = vbArrowHourglass
- If pvtAddresses Is Nothing Then
- Exit Sub
- End If
- ' populate the Address DBGrid
- pvtAddressesDBGridWrapper. _
- UnboundReadData _
- RowBuf:=RowBuf, _
- StartLocation:=StartLocation, _
- ReadPriorRows:=ReadPriorRows
- Me.MousePointer = vbArrow
- End Sub
- Private Sub DBGrid3_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
- If pvtPhones Is Nothing Then
- Exit Sub
- End If
- If pvtPhones.Count <= 0 Then
- Exit Sub
- End If
- Set pvtCurrentPhone = _
- pvtPhonesDBGridWrapper. _
- BookmarkObject
-
- If pvtCurrentPhone Is Nothing Then
- Set pvtCurrentPhone = pvtPhones.Item(1)
-
- Set pvtPhonesDBGridWrapper. _
- BookmarkObject = _
- pvtCurrentPhone
- End If
-
- RefreshPhoneFields
- End Sub
- Private Sub DBGrid3_UnboundReadData(ByVal RowBuf As RowBuffer, StartLocation As Variant, ByVal ReadPriorRows As Boolean)
- Me.MousePointer = vbArrowHourglass
- If pvtPhones Is Nothing Then
- Exit Sub
- End If
- ' populate the Persons DBGrid
- pvtPhonesDBGridWrapper. _
- UnboundReadData _
- RowBuf:=RowBuf, _
- StartLocation:=StartLocation, _
- ReadPriorRows:=ReadPriorRows
- Me.MousePointer = vbArrow
- End Sub
- Private Sub lbxStateCodes_Click()
- Dim tempState As State
- Set tempState = _
- pvtStates.pvtListBoxSelectObject _
- (lbxStateCodes)
- End Sub
- Private Sub Form_Load()
- Set pvtStates = _
- pubStates
- Set pvtGenderCodes = _
- pubGenderCodes
- Set pvtMaritalStatusCodes = _
- pubMaritalStatusCodes
- Set pvtPersons = _
- pubPersons
- GetListBoxWrappers
- GetDBGridWrappers
-
- Set pvtCurrentPerson = _
- pvtPersons.Item(1)
- RegisterForEvents
- End Sub
- Private Sub GetListBoxWrappers()
- ' attach the Collection, ListBox and ListBoxWrapper
- Set pvtStatesListBoxWrapper = _
- ObjectManager. _
- NewVBOFListBoxWrapper( _
- Collection:=pvtStates, _
- ListBox:=lbxStateCodes)
- pvtStatesListBoxWrapper. _
- AddItems
- ' attach the Collection, ListBox and ListBoxWrapper
- Set pvtGenderCodesListBoxWrapper = _
- ObjectManager. _
- NewVBOFListBoxWrapper( _
- Collection:=pvtGenderCodes, _
- ListBox:=lbxGenderCodes)
- pvtGenderCodesListBoxWrapper. _
- AddItems
- ' attach the Collection, ListBox and ListBoxWrapper
- Set pvtMaritalStatusCodesListBoxWrapper = _
- ObjectManager. _
- NewVBOFListBoxWrapper( _
- Collection:=pvtMaritalStatusCodes, _
- ListBox:=lbxMaritalStatusCodes)
- pvtMaritalStatusCodesListBoxWrapper. _
- AddItems
- 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
-
- pvtAddressesDBGridWrapper.Refresh
- Set pvtAddressesDBGridWrapper. _
- BookmarkObject = _
- pvtCurrentAddress
- 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 Sub pbAddNewCustomer_Click()
- Dim tempNewPerson As New Person
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- Set pvtCurrentPerson = tempNewPerson
- PopulateCurrentPerson
- pvtPersons.Add _
- Item:=tempNewPerson
-
- pvtPersonsDBGridWrapper.Refresh
- Set pvtPersonsDBGridWrapper. _
- BookmarkObject = _
- pvtCurrentPerson
-
- RefreshCustomerFields
- Me.MousePointer = vbArrow
- End Sub
- 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 Sub pbAddPhone_Click()
- Dim tempNewPhone As New Phone
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- Set pvtCurrentPhone = tempNewPhone
- PopulateCurrentPhone
-
- pvtCurrentPerson.AddPhone _
- Item:=tempNewPhone
-
- pvtPhonesDBGridWrapper.Refresh
- Set pvtPhonesDBGridWrapper. _
- BookmarkObject = _
- pvtCurrentPhone
- Me.MousePointer = vbArrow
- End Sub
- Private Function PopulateCurrentPhone()
- On Local Error Resume Next
- With pvtCurrentPhone
- .PhoneNumber = efPhoneNumber
- .Usage = efUsage
- End With
- End Function
- Private Sub pbDeleteAddress_Click()
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- pvtAddresses.Remove _
- Item:=pvtCurrentAddress
-
- DBGrid2.Refresh
- Me.MousePointer = vbArrow
- End Sub
- Private Sub pbDeleteCustomer_Click()
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- pvtPersons.Remove _
- Item:=pvtCurrentPerson
-
- DBGrid1.Refresh
- Me.MousePointer = vbArrow
- End Sub
- Private Sub pbDeletePhone_Click()
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- pvtPhones.Remove _
- Item:=pvtCurrentPhone
-
- DBGrid3.Refresh
- Me.MousePointer = vbArrow
- End Sub
- Private Sub pbOK_Click()
- Unload Me
- End Sub
- Private Sub pbUpdateAddress_Click()
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- PopulateCurrentAddress
- pvtAddresses.Replace _
- Item:=pvtCurrentAddress, _
- ReplaceWith:=pvtCurrentAddress
-
- ' trigger the "Changed" event
- ' Note: This typically a responsibility of the BOM.
- ' But in this demo package, if it were, then the
- ' demo window which is based on the DataControl
- ' would do bunches of database I/O and run for
- ' an extraordinary period.
- pvtCurrentAddress. _
- ObjectHasChanged
- pvtAddressesDBGridWrapper.Refresh
- Set pvtAddressesDBGridWrapper. _
- BookmarkObject = _
- pvtCurrentAddress
-
- RefreshAddressFields
- Me.MousePointer = vbArrow
- End Sub
- Private Sub pbUpdateCustomer_Click()
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- PopulateCurrentPerson
- pvtPersons.Replace _
- Item:=pvtCurrentPerson, _
- ReplaceWith:=pvtCurrentPerson
- ' trigger the "Changed" event
- ' Note: This typically a responsibility of the BOM.
- ' But in this demo package, if it were, then the
- ' demo window which is based on the DataControl
- ' would do bunches of database I/O and run for
- ' an extraordinary period.
- pvtCurrentPerson. _
- ObjectHasChanged
- pvtPersonsDBGridWrapper.Refresh
- Set pvtPersonsDBGridWrapper. _
- BookmarkObject = _
- pvtCurrentPerson
-
- RefreshCustomerFields
- Me.MousePointer = vbArrow
- End Sub
- Private Sub pbUpdatePhone_Click()
-
- On Local Error Resume Next
- Me.MousePointer = vbArrowHourglass
- PopulateCurrentPhone
- pvtPhones.Replace _
- Item:=pvtCurrentPhone, _
- ReplaceWith:=pvtCurrentPhone
-
- ' trigger the "Changed" event
- ' Note: This typically a responsibility of the BOM.
- ' But in this demo package, if it were, then the
- ' demo window which is based on the DataControl
- ' would do bunches of database I/O and run for
- ' an extraordinary period.
- pvtCurrentPhone. _
- ObjectHasChanged
- pvtAddressesDBGridWrapper.Refresh
- Set pvtPhonesDBGridWrapper. _
- BookmarkObject = _
- pvtCurrentPhone
-
- RefreshPhoneFields
- Me.MousePointer = vbArrow
- End Sub
-