home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Power Pack / Visual_Basic4_Power_Pack.bin / vb4files / vbof / democust.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-11-20  |  34.5 KB  |  1,062 lines

  1. VERSION 4.00
  2. Begin VB.Form CustomerDetailsDataControl 
  3.    Caption         =   "Customer Details (Supports the DataControl within the VBObjectFrameWorkCollection)"
  4.    ClientHeight    =   6000
  5.    ClientLeft      =   75
  6.    ClientTop       =   330
  7.    ClientWidth     =   8865
  8.    Height          =   6405
  9.    Left            =   15
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6000
  12.    ScaleWidth      =   8865
  13.    Top             =   -15
  14.    Width           =   8985
  15.    Begin VB.Data Data3 
  16.       Caption         =   "Data3"
  17.       Connect         =   "Access"
  18.       DatabaseName    =   "DemoVBFW.mdb"
  19.       Exclusive       =   0   'False
  20.       Height          =   300
  21.       Left            =   8040
  22.       Options         =   0
  23.       ReadOnly        =   -1  'True
  24.       RecordsetType   =   1  'Dynaset
  25.       RecordSource    =   "Phones"
  26.       Top             =   1920
  27.       Visible         =   0   'False
  28.       Width           =   1140
  29.    End
  30.    Begin VB.CommandButton pbOK 
  31.       Cancel          =   -1  'True
  32.       Caption         =   "OK"
  33.       Default         =   -1  'True
  34.       Height          =   375
  35.       Left            =   7800
  36.       TabIndex        =   11
  37.       Top             =   2280
  38.       Width           =   975
  39.    End
  40.    Begin VB.CommandButton pbDeleteCustomer 
  41.       Caption         =   "Delete"
  42.       Height          =   375
  43.       Left            =   7800
  44.       TabIndex        =   10
  45.       Top             =   1200
  46.       Width           =   975
  47.    End
  48.    Begin VB.CommandButton pbUpdateCustomer 
  49.       Caption         =   "Update"
  50.       Height          =   375
  51.       Left            =   7800
  52.       TabIndex        =   9
  53.       Top             =   720
  54.       Width           =   975
  55.    End
  56.    Begin VB.CommandButton pbAddNewCustomer 
  57.       Caption         =   "Add New"
  58.       Height          =   375
  59.       Left            =   7800
  60.       TabIndex        =   8
  61.       Top             =   240
  62.       Width           =   975
  63.    End
  64.    Begin VB.Frame Frame1 
  65.       Caption         =   "Customer Details"
  66.       Height          =   2535
  67.       Left            =   4440
  68.       TabIndex        =   31
  69.       Top             =   120
  70.       Width           =   3255
  71.       Begin VB.ComboBox lbxGenderCodes 
  72.          Height          =   315
  73.          Left            =   2400
  74.          Sorted          =   -1  'True
  75.          TabIndex        =   7
  76.          Top             =   2160
  77.          Width           =   615
  78.       End
  79.       Begin VB.ComboBox lbxMaritalStatusCodes 
  80.          Height          =   315
  81.          Left            =   1200
  82.          Sorted          =   -1  'True
  83.          TabIndex        =   6
  84.          Top             =   2160
  85.          Width           =   855
  86.       End
  87.       Begin VB.TextBox efCustomerNumber 
  88.          Height          =   285
  89.          Left            =   1200
  90.          TabIndex        =   1
  91.          Top             =   360
  92.          Width           =   1815
  93.       End
  94.       Begin VB.TextBox efDateOfBirth 
  95.          Height          =   285
  96.          Left            =   1200
  97.          TabIndex        =   5
  98.          Top             =   1800
  99.          Width           =   1815
  100.       End
  101.       Begin VB.TextBox efFirstName 
  102.          Height          =   285
  103.          Left            =   1200
  104.          TabIndex        =   2
  105.          Top             =   720
  106.          Width           =   1815
  107.       End
  108.       Begin VB.TextBox efLastName 
  109.          Height          =   285
  110.          Left            =   1200
  111.          TabIndex        =   3
  112.          Top             =   1080
  113.          Width           =   1815
  114.       End
  115.       Begin VB.TextBox efSSN 
  116.          Height          =   285
  117.          Left            =   1200
  118.          TabIndex        =   4
  119.          Top             =   1440
  120.          Width           =   1815
  121.       End
  122.       Begin VB.Label Label1 
  123.          Caption         =   "Cust Number"
  124.          Height          =   255
  125.          Index           =   12
  126.          Left            =   120
  127.          TabIndex        =   38
  128.          Top             =   360
  129.          Width           =   975
  130.       End
  131.       Begin VB.Label Label1 
  132.          Caption         =   "Sex"
  133.          Height          =   255
  134.          Index           =   11
  135.          Left            =   2040
  136.          TabIndex        =   37
  137.          Top             =   2160
  138.          Width           =   375
  139.       End
  140.       Begin VB.Label Label1 
  141.          Caption         =   "Marital Status"
  142.          Height          =   255
  143.          Index           =   4
  144.          Left            =   120
  145.          TabIndex        =   36
  146.          Top             =   2160
  147.          Width           =   975
  148.       End
  149.       Begin VB.Label Label1 
  150.          Caption         =   "Date Of Birth"
  151.          Height          =   255
  152.          Index           =   3
  153.          Left            =   120
  154.          TabIndex        =   35
  155.          Top             =   1800
  156.          Width           =   975
  157.       End
  158.       Begin VB.Label Label1 
  159.          Caption         =   "First Name"
  160.          Height          =   255
  161.          Index           =   0
  162.          Left            =   120
  163.          TabIndex        =   34
  164.          Top             =   720
  165.          Width           =   975
  166.       End
  167.       Begin VB.Label Label1 
  168.          Caption         =   "Last Name"
  169.          Height          =   255
  170.          Index           =   1
  171.          Left            =   120
  172.          TabIndex        =   33
  173.          Top             =   1080
  174.          Width           =   975
  175.       End
  176.       Begin VB.Label Label1 
  177.          Caption         =   "SSN"
  178.          Height          =   255
  179.          Index           =   2
  180.          Left            =   120
  181.          TabIndex        =   32
  182.          Top             =   1440
  183.          Width           =   975
  184.       End
  185.    End
  186.    Begin VB.Data Data2 
  187.       Caption         =   "Data2"
  188.       Connect         =   "Access"
  189.       DatabaseName    =   "DemoVBFW.mdb"
  190.       Exclusive       =   0   'False
  191.       Height          =   300
  192.       Left            =   8040
  193.       Options         =   0
  194.       ReadOnly        =   -1  'True
  195.       RecordsetType   =   1  'Dynaset
  196.       RecordSource    =   "Addresses"
  197.       Top             =   1680
  198.       Visible         =   0   'False
  199.       Width           =   1140
  200.    End
  201.    Begin VB.Data Data1 
  202.       Caption         =   "Data1"
  203.       Connect         =   "Access"
  204.       DatabaseName    =   "DemoVBFW.mdb"
  205.       Exclusive       =   0   'False
  206.       Height          =   300
  207.       Left            =   8040
  208.       Options         =   0
  209.       ReadOnly        =   -1  'True
  210.       RecordsetType   =   1  'Dynaset
  211.       RecordSource    =   "Persons"
  212.       Top             =   1440
  213.       Visible         =   0   'False
  214.       Width           =   1140
  215.    End
  216.    Begin TabDlg.SSTab SSTab1 
  217.       Height          =   3135
  218.       Left            =   120
  219.       TabIndex        =   12
  220.       Top             =   2760
  221.       Width           =   8775
  222.       _Version        =   65536
  223.       _ExtentX        =   15478
  224.       _ExtentY        =   5530
  225.       _StockProps     =   15
  226.       Caption         =   "Phones"
  227.       TabsPerRow      =   2
  228.       Tab             =   1
  229.       TabOrientation  =   0
  230.       Tabs            =   2
  231.       Style           =   1
  232.       TabMaxWidth     =   0
  233.       TabHeight       =   529
  234.       TabCaption(0)   =   "Addresses"
  235.       Tab(0).ControlCount=   7
  236.       Tab(0).ControlEnabled=   0   'False
  237.       Tab(0).Control(0)=   "DBGrid2"
  238.       Tab(0).Control(1)=   "Label1(13)"
  239.       Tab(0).Control(2)=   "efFormattedAddress"
  240.       Tab(0).Control(3)=   "Frame2"
  241.       Tab(0).Control(4)=   "pbDeleteAddress"
  242.       Tab(0).Control(5)=   "pbUpdateAddress"
  243.       Tab(0).Control(6)=   "pbAddNewAddress"
  244.       TabCaption(1)   =   "Phones"
  245.       Tab(1).ControlCount=   7
  246.       Tab(1).ControlEnabled=   -1  'True
  247.       Tab(1).Control(0)=   "DBGrid3"
  248.       Tab(1).Control(1)=   "Label1(21)"
  249.       Tab(1).Control(2)=   "efFormattedPhoneNumber"
  250.       Tab(1).Control(3)=   "Frame3"
  251.       Tab(1).Control(4)=   "pbDeletePhone"
  252.       Tab(1).Control(5)=   "pbUpdatePhone"
  253.       Tab(1).Control(6)=   "pbAddPhone"
  254.       Begin VB.CommandButton pbAddPhone 
  255.          Caption         =   "Add New"
  256.          Height          =   375
  257.          Left            =   7680
  258.          TabIndex        =   28
  259.          Top             =   480
  260.          Width           =   975
  261.       End
  262.       Begin VB.CommandButton pbUpdatePhone 
  263.          Caption         =   "Update"
  264.          Height          =   375
  265.          Left            =   7680
  266.          TabIndex        =   29
  267.          Top             =   960
  268.          Width           =   975
  269.       End
  270.       Begin VB.CommandButton pbDeletePhone 
  271.          Caption         =   "Delete"
  272.          Height          =   375
  273.          Left            =   7680
  274.          TabIndex        =   30
  275.          Top             =   1440
  276.          Width           =   975
  277.       End
  278.       Begin VB.Frame Frame3 
  279.          Caption         =   "Address Details"
  280.          Height          =   2655
  281.          Left            =   4320
  282.          TabIndex        =   50
  283.          Top             =   360
  284.          Width           =   3255
  285.          Begin VB.TextBox efUsage 
  286.             Height          =   285
  287.             Left            =   1200
  288.             TabIndex        =   27
  289.             Top             =   720
  290.             Width           =   1815
  291.          End
  292.          Begin VB.TextBox efPhoneNumber 
  293.             Height          =   285
  294.             Left            =   1200
  295.             TabIndex        =   26
  296.             Top             =   360
  297.             Width           =   1815
  298.          End
  299.          Begin VB.Label Label1 
  300.             Caption         =   "Usage"
  301.             Height          =   255
  302.             Index           =   16
  303.             Left            =   120
  304.             TabIndex        =   52
  305.             Top             =   720
  306.             Width           =   975
  307.          End
  308.          Begin VB.Label Label1 
  309.             Caption         =   "Phone Num"
  310.             Height          =   255
  311.             Index           =   15
  312.             Left            =   120
  313.             TabIndex        =   51
  314.             Top             =   360
  315.             Width           =   975
  316.          End
  317.       End
  318.       Begin VB.CommandButton pbAddNewAddress 
  319.          Caption         =   "Add New"
  320.          Height          =   375
  321.          Left            =   -67320
  322.          TabIndex        =   22
  323.          Top             =   480
  324.          Width           =   975
  325.       End
  326.       Begin VB.CommandButton pbUpdateAddress 
  327.          Caption         =   "Update"
  328.          Height          =   375
  329.          Left            =   -67320
  330.          TabIndex        =   23
  331.          Top             =   960
  332.          Width           =   975
  333.       End
  334.       Begin VB.CommandButton pbDeleteAddress 
  335.          Caption         =   "Delete"
  336.          Height          =   375
  337.          Left            =   -67320
  338.          TabIndex        =   24
  339.          Top             =   1440
  340.          Width           =   975
  341.       End
  342.       Begin VB.Frame Frame2 
  343.          Caption         =   "Address Details"
  344.          Height          =   2655
  345.          Left            =   -70680
  346.          TabIndex        =   39
  347.          Top             =   360
  348.          Width           =   3255
  349.          Begin VB.ComboBox lbxStateCodes 
  350.             Height          =   315
  351.             Left            =   1200
  352.             Sorted          =   -1  'True
  353.             TabIndex        =   18
  354.             Top             =   1800
  355.             Width           =   1815
  356.          End
  357.          Begin VB.TextBox efLine1 
  358.             Height          =   285
  359.             Left            =   1200
  360.             TabIndex        =   14
  361.             Top             =   360
  362.             Width           =   1815
  363.          End
  364.          Begin VB.TextBox efLine2 
  365.             Height          =   285
  366.             Left            =   1200
  367.             TabIndex        =   15
  368.             Top             =   720
  369.             Width           =   1815
  370.          End
  371.          Begin VB.TextBox efLine3 
  372.             Height          =   285
  373.             Left            =   1200
  374.             TabIndex        =   16
  375.             Top             =   1080
  376.             Width           =   1815
  377.          End
  378.          Begin VB.TextBox efCity 
  379.             Height          =   285
  380.             Left            =   1200
  381.             TabIndex        =   17
  382.             Top             =   1440
  383.             Width           =   1815
  384.          End
  385.          Begin VB.TextBox efZipCode 
  386.             Height          =   285
  387.             Left            =   1200
  388.             MaxLength       =   5
  389.             TabIndex        =   19
  390.             Top             =   2160
  391.             Width           =   735
  392.          End
  393.          Begin VB.TextBox efZipExtension 
  394.             Height          =   285
  395.             Left            =   2640
  396.             MaxLength       =   2
  397.             TabIndex        =   21
  398.             Top             =   2160
  399.             Width           =   375
  400.          End
  401.          Begin VB.TextBox efZipSupplement 
  402.             Height          =   285
  403.             Left            =   2040
  404.             MaxLength       =   4
  405.             TabIndex        =   20
  406.             Top             =   2160
  407.             Width           =   495
  408.          End
  409.          Begin VB.Label Label1 
  410.             Caption         =   "Line 1"
  411.             Height          =   255
  412.             Index           =   5
  413.             Left            =   120
  414.             TabIndex        =   45
  415.             Top             =   360
  416.             Width           =   975
  417.          End
  418.          Begin VB.Label Label1 
  419.             Caption         =   "Line 2"
  420.             Height          =   255
  421.             Index           =   6
  422.             Left            =   120
  423.             TabIndex        =   44
  424.             Top             =   720
  425.             Width           =   975
  426.          End
  427.          Begin VB.Label Label1 
  428.             Caption         =   "Line 3"
  429.             Height          =   255
  430.             Index           =   7
  431.             Left            =   120
  432.             TabIndex        =   43
  433.             Top             =   1080
  434.             Width           =   975
  435.          End
  436.          Begin VB.Label Label1 
  437.             Caption         =   "City"
  438.             Height          =   255
  439.             Index           =   10
  440.             Left            =   120
  441.             TabIndex        =   42
  442.             Top             =   1440
  443.             Width           =   975
  444.          End
  445.          Begin VB.Label Label1 
  446.             Caption         =   "State"
  447.             Height          =   255
  448.             Index           =   8
  449.             Left            =   120
  450.             TabIndex        =   41
  451.             Top             =   1800
  452.             Width           =   975
  453.          End
  454.          Begin VB.Label Label1 
  455.             Caption         =   "Zip Code"
  456.             Height          =   255
  457.             Index           =   9
  458.             Left            =   120
  459.             TabIndex        =   40
  460.             Top             =   2160
  461.             Width           =   975
  462.          End
  463.       End
  464.       Begin VB.Label efFormattedPhoneNumber 
  465.          BorderStyle     =   1  'Fixed Single
  466.          ForeColor       =   &H00FF0000&
  467.          Height          =   255
  468.          Left            =   120
  469.          TabIndex        =   54
  470.          Top             =   2760
  471.          Width           =   4095
  472.       End
  473.       Begin VB.Label Label1 
  474.          Caption         =   "Formatted Phone"
  475.          Height          =   255
  476.          Index           =   21
  477.          Left            =   120
  478.          TabIndex        =   53
  479.          Top             =   2520
  480.          Width           =   1575
  481.       End
  482.       Begin MSDBGrid.DBGrid DBGrid3 
  483.          Bindings        =   "DemoCust.frx":0000
  484.          Height          =   1935
  485.          Left            =   120
  486.          OleObjectBlob   =   "DemoCust.frx":000E
  487.          TabIndex        =   25
  488.          Top             =   480
  489.          Width           =   4095
  490.       End
  491.       Begin VB.Label efFormattedAddress 
  492.          BorderStyle     =   1  'Fixed Single
  493.          ForeColor       =   &H00FF0000&
  494.          Height          =   975
  495.          Left            =   -74880
  496.          TabIndex        =   47
  497.          Top             =   2040
  498.          Width           =   4095
  499.       End
  500.       Begin VB.Label Label1 
  501.          Caption         =   "Formatted Address"
  502.          Height          =   255
  503.          Index           =   13
  504.          Left            =   -74880
  505.          TabIndex        =   46
  506.          Top             =   1800
  507.          Width           =   1575
  508.       End
  509.       Begin MSDBGrid.DBGrid DBGrid2 
  510.          Bindings        =   "DemoCust.frx":08E2
  511.          Height          =   1215
  512.          Left            =   -74880
  513.          OleObjectBlob   =   "DemoCust.frx":08F0
  514.          TabIndex        =   13
  515.          Top             =   480
  516.          Width           =   4095
  517.       End
  518.    End
  519.    Begin VB.Label efAge 
  520.       BorderStyle     =   1  'Fixed Single
  521.       ForeColor       =   &H00FF0000&
  522.       Height          =   255
  523.       Left            =   3720
  524.       TabIndex        =   56
  525.       Top             =   2400
  526.       Width           =   615
  527.    End
  528.    Begin VB.Label Label1 
  529.       Caption         =   "Age"
  530.       Height          =   255
  531.       Index           =   17
  532.       Left            =   3720
  533.       TabIndex        =   55
  534.       Top             =   2160
  535.       Width           =   375
  536.    End
  537.    Begin VB.Label Label1 
  538.       Caption         =   "Formatted Name"
  539.       Height          =   255
  540.       Index           =   14
  541.       Left            =   120
  542.       TabIndex        =   49
  543.       Top             =   2160
  544.       Width           =   1575
  545.    End
  546.    Begin VB.Label efFormattedName 
  547.       BorderStyle     =   1  'Fixed Single
  548.       ForeColor       =   &H00FF0000&
  549.       Height          =   255
  550.       Left            =   120
  551.       TabIndex        =   48
  552.       Top             =   2400
  553.       Width           =   3495
  554.    End
  555.    Begin MSDBGrid.DBGrid DBGrid1 
  556.       Bindings        =   "DemoCust.frx":0FF8
  557.       Height          =   1935
  558.       Left            =   120
  559.       OleObjectBlob   =   "DemoCust.frx":1006
  560.       TabIndex        =   0
  561.       Top             =   120
  562.       Width           =   4215
  563.    End
  564. Attribute VB_Name = "CustomerDetailsDataControl"
  565. Attribute VB_Creatable = False
  566. Attribute VB_Exposed = False
  567. Option Explicit
  568. ' This example show how the VBOFW can
  569. '   support the VB application through conventional
  570. '   VB programming techniques, including the use of
  571. '   the VB DataControl, via the
  572. '   VBOFWDataWrapper
  573. Private pvtCurrentPerson As Person
  574. Private pvtPersonsDataWrapper As VBOFDataWrapper
  575. Private pvtCurrentAddress As Address
  576. Private pvtAddressesDataWrapper As VBOFDataWrapper
  577. Private pvtCurrentPhone As Phone
  578. Private pvtPhonesDataWrapper As VBOFDataWrapper
  579. Private pvtStates As VBOFCollection
  580. Private pvtStatesListBoxWrapper As VBOFListBoxWrapper
  581. Private pvtGenderCodes As VBOFCollection
  582. Private pvtGenderCodesListBoxWrapper As VBOFListBoxWrapper
  583. Private pvtMaritalStatusCodes As VBOFCollection
  584. Private pvtMaritalStatusCodesListBoxWrapper As VBOFListBoxWrapper
  585. Public ObjectManager As VBOFObjectManager
  586. Private Sub PopulateGenderCodes()
  587. ' instantiate pvtGenderCodes as a
  588. '   reference to pvtGenderCodes
  589.     Set pvtGenderCodes = _
  590.         pubGenderCodes
  591. ' attach the Collection, ListBox and ListBoxWrapper
  592.     Set pvtGenderCodesListBoxWrapper = _
  593.         ObjectManager. _
  594.             NewVBOFListBoxWrapper( _
  595.             Collection:=pvtGenderCodes, _
  596.             ListBox:=lbxGenderCodes)
  597.     pvtGenderCodesListBoxWrapper. _
  598.         AddItems
  599. End Sub
  600. Private Sub PopulateMaritalStatusCodes()
  601. ' instantiate pvtMaritalStatusCodes as a
  602. '   reference to pubMaritalStatusCodes
  603.     Set pvtMaritalStatusCodes = _
  604.         pubMaritalStatusCodes
  605. ' attach the Collection, ListBox and ListBoxWrapper
  606.     Set pvtMaritalStatusCodesListBoxWrapper = _
  607.         ObjectManager. _
  608.             NewVBOFListBoxWrapper( _
  609.             Collection:=pvtMaritalStatusCodes, _
  610.             ListBox:=lbxMaritalStatusCodes)
  611.     pvtMaritalStatusCodesListBoxWrapper. _
  612.         AddItems
  613. End Sub
  614. Public Sub ObjectEventCallBack(Optional Event As Variant, Optional Object As Variant)
  615.     Dim tempObjectType As String
  616.     Dim tempUCaseEvent As String
  617.     On Local Error Resume Next
  618.     tempObjectType = TypeName(Object)
  619.     tempUCaseEvent = UCase$(Event)
  620.     If tempObjectType = "Person" Then
  621.         
  622.         If tempUCaseEvent = "REMOVEDITEM" _
  623.         Or tempUCaseEvent = "REPLACEDITEM" _
  624.         Then
  625.             pvtPersonsDataWrapper.Refresh
  626.             
  627.             If Object.ObjectID = pvtCurrentPerson.ObjectID Then
  628.                 pvtPersonsDataWrapper.MoveFirst
  629.             End If
  630.         End If
  631.         If tempUCaseEvent = "CHANGED" _
  632.         Then
  633.             pvtPersonsDataWrapper.Refresh
  634.             
  635.             pvtPersonsDataWrapper.FindFirst _
  636.                 "ObjectID = " & pvtCurrentPerson.ObjectID
  637.                
  638.             If Object.ObjectID = pvtCurrentPerson.ObjectID Then
  639.                 RefreshCustomerFields
  640.             End If
  641.         End If
  642.     End If
  643.     If tempObjectType = "Address" Then
  644.         RefreshAddressFields
  645.     End If
  646.     If tempObjectType = "Phone" Then
  647.         RefreshPhoneFields
  648.     End If
  649. End Sub
  650. Private Sub RefreshAddressFields()
  651.     On Local Error Resume Next
  652. ' map the selected Address to an Address in the
  653. '   Person.Addresses collection
  654.     Set pvtCurrentAddress = _
  655.         pvtCurrentPerson _
  656.             .Addresses _
  657.             (CStr(pvtAddressesDataWrapper.RecordSet("ObjectID")))
  658.     If pvtCurrentAddress Is Nothing Or Err = 3021 Then
  659.         efLine1 = ""
  660.         efLine2 = ""
  661.         efLine3 = ""
  662.         efCity = ""
  663.         lbxStateCodes = ""
  664.         efZipCode = ""
  665.         efZipSupplement = ""
  666.         efZipExtension = ""
  667.         efFormattedAddress = ""
  668.         Exit Sub
  669.     End If
  670.     efLine1 = pvtCurrentAddress.Line1
  671.     efLine2 = pvtCurrentAddress.Line2
  672.     efLine3 = pvtCurrentAddress.Line3
  673.     efCity = pvtCurrentAddress.City
  674.     lbxStateCodes = pvtCurrentAddress.State.StateCode
  675.     efZipCode = pvtCurrentAddress.ZipCode
  676.     efZipSupplement = pvtCurrentAddress.ZipSupplementString
  677.     efZipExtension = pvtCurrentAddress.ZipExtensionString
  678.     efFormattedAddress = pvtCurrentAddress.FormattedAddress
  679. End Sub
  680. Sub RefreshCustomerFields()
  681.     On Local Error Resume Next
  682. '    Set pvtCurrentPerson = _
  683. '        publicCompany _
  684. '            .Persons _
  685. '            (CStr(pvtPersonsDataWrapper.RecordSet("ObjectID")))
  686.         
  687. ' display the person's detail information
  688.     efCustomerNumber = pvtCurrentPerson.CustomerNumber
  689.     efFirstName = pvtCurrentPerson.FirstName
  690.     efLastName = pvtCurrentPerson.LastName
  691.     efSSN = pvtCurrentPerson.SSN
  692.     efDateOfBirth = Format$(pvtCurrentPerson.DateOfBirth, "mm/dd/yyyy")
  693.     lbxMaritalStatusCodes = pvtCurrentPerson.MaritalStatus
  694.     lbxGenderCodes = pvtCurrentPerson.Sex
  695.     efFormattedName = pvtCurrentPerson.FormattedName
  696.     efAge = pvtCurrentPerson.Age
  697. End Sub
  698. Private Sub RefreshPhoneFields()
  699.     On Local Error Resume Next
  700. ' map the selected Phone to a Phone in the
  701. '   Person.Phones collection
  702.     Set pvtCurrentPhone = _
  703.         pvtCurrentPerson _
  704.             .Phones _
  705.             (CStr(pvtPhonesDataWrapper.RecordSet("ObjectID")))
  706.     If pvtCurrentPhone Is Nothing Or Err = 3021 Then
  707.         efPhoneNumber = ""
  708.         efUsage = ""
  709.         efFormattedPhoneNumber = ""
  710.         Exit Sub
  711.     End If
  712.     efPhoneNumber = pvtCurrentPhone.PhoneNumber
  713.     efUsage = pvtCurrentPhone.Usage
  714.     efFormattedPhoneNumber = pvtCurrentPhone.FormattedPhoneNumber
  715. End Sub
  716. Private Sub RegisterForEvents()
  717. #If NoEventMgr = False Then
  718.     ObjectManager.RegisterForObjectEvent _
  719.         TriggerObjectType:="Person", _
  720.         RegisterObject:=Me, _
  721.         TriggerEvent:="Changed"
  722.     ObjectManager.RegisterForObjectEvent _
  723.         TriggerObjectType:="Address", _
  724.         RegisterObject:=Me, _
  725.         TriggerEvent:="Changed"
  726.     ObjectManager.RegisterForObjectEvent _
  727.         TriggerObjectType:="Phone", _
  728.         RegisterObject:=Me, _
  729.         TriggerEvent:="Changed"
  730. #End If
  731. End Sub
  732. Private Sub Data1_Validate(Action As Integer, Save As Integer)
  733.     pvtPersonsDataWrapper. _
  734.         Validate _
  735.             Action:=Action, _
  736.             Save:=Save
  737. End Sub
  738. Private Sub Data2_Reposition()
  739.     On Local Error Resume Next
  740.     Me.MousePointer = vbArrowHourglass
  741.         
  742.     Set pvtCurrentAddress = _
  743.         pvtAddressesDataWrapper. _
  744.             AbsolutePositionObject
  745.     RefreshAddressFields
  746.     Me.MousePointer = vbArrow
  747. End Sub
  748. Private Sub Data2_Validate(Action As Integer, Save As Integer)
  749.     pvtAddressesDataWrapper. _
  750.         Validate _
  751.             Action:=Action, _
  752.             Save:=Save
  753. End Sub
  754. Private Sub Data3_Reposition()
  755.     On Local Error Resume Next
  756.     Me.MousePointer = vbArrowHourglass
  757.         
  758.     Set pvtCurrentPhone = _
  759.         pvtPhonesDataWrapper. _
  760.             AbsolutePositionObject
  761.     RefreshPhoneFields
  762.     Me.MousePointer = vbArrow
  763. End Sub
  764. Private Sub Data3_Validate(Action As Integer, Save As Integer)
  765.     pvtPhonesDataWrapper. _
  766.         Validate _
  767.             Action:=Action, _
  768.             Save:=Save
  769. End Sub
  770. Private Sub DBGrid1_Click()
  771. End Sub
  772. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  773.     Me.MousePointer = vbArrowHourglass
  774.     ObjectManager.Form_QueryUnload _
  775.         Me, _
  776.         pvtPersonsDataWrapper, _
  777.         pvtAddressesDataWrapper, _
  778.         pvtPhonesDataWrapper
  779. #If NoEventMgr = False Then
  780.     ObjectManager. _
  781.         UnRegisterForAllEvents _
  782.         RegisterObject:=Me
  783. #End If
  784.     Me.MousePointer = vbArrow
  785. End Sub
  786. Private Sub pbAddNewAddress_Click()
  787.     Dim tempNewAddress As New Address
  788.         
  789.     On Local Error Resume Next
  790.     Me.MousePointer = vbArrowHourglass
  791.     Set pvtCurrentAddress = tempNewAddress
  792.     PopulateCurrentAddress
  793.             
  794.     pvtCurrentPerson.AddAddress _
  795.         Item:=tempNewAddress
  796.         
  797.     pvtAddressesDataWrapper.Rebind _
  798.         Collection:=pvtCurrentPerson.Addresses
  799.     pvtAddressesDataWrapper.FindFirst _
  800.         "ObjectID = " & pvtCurrentAddress.ObjectID
  801.     Me.MousePointer = vbArrow
  802. End Sub
  803. Private Sub pbAddNewCustomer_Click()
  804.     Dim tempNewPerson As New Person
  805.         
  806.     On Local Error Resume Next
  807.     Me.MousePointer = vbArrowHourglass
  808.     Set pvtCurrentPerson = tempNewPerson
  809.     PopulateCurrentPerson
  810.         
  811.     publicCompany.AddPerson _
  812.         Item:=tempNewPerson
  813.         
  814.     Data2.Enabled = False
  815.     Data3.Enabled = False
  816.     pvtPersonsDataWrapper.Rebind _
  817.         Collection:=publicCompany.Persons
  818.     pvtPersonsDataWrapper.FindFirst _
  819.         "ObjectID = " & pvtCurrentPerson.ObjectID
  820.     Me.MousePointer = vbArrow
  821. End Sub
  822. Private Sub pbAddPhone_Click()
  823.     Dim tempNewPhone As New Phone
  824.         
  825.     On Local Error Resume Next
  826.     Me.MousePointer = vbArrowHourglass
  827.     Set pvtCurrentPhone = tempNewPhone
  828.     PopulateCurrentPhone
  829.             
  830.     pvtCurrentPerson.AddPhone _
  831.         Item:=tempNewPhone
  832.     pvtPhonesDataWrapper.Rebind _
  833.         Collection:=pvtCurrentPerson.Phones
  834.     pvtPhonesDataWrapper.FindFirst _
  835.         "ObjectID = " & pvtCurrentPhone.ObjectID
  836.     Me.MousePointer = vbArrow
  837. End Sub
  838. Private Sub pbDeleteAddress_Click()
  839.     On Local Error Resume Next
  840.     Me.MousePointer = vbArrowHourglass
  841.     Set pvtCurrentAddress = _
  842.         pvtCurrentPerson _
  843.             .Addresses _
  844.             (CStr(Data2.RecordSet("ObjectID")))
  845.            
  846.     pvtCurrentPerson.Addresses.Remove _
  847.         Item:=pvtCurrentAddress
  848.         
  849.     pvtAddressesDataWrapper.Rebind _
  850.         Collection:=pvtCurrentPerson.Addresses
  851.     pvtAddressesDataWrapper.MoveFirst
  852.     Me.MousePointer = vbArrow
  853. End Sub
  854. Private Sub pbDeleteCustomer_Click()
  855.     Dim saveObjectID As String
  856.     On Local Error Resume Next
  857.     Me.MousePointer = vbArrowHourglass
  858.     Set pvtCurrentPerson = _
  859.         publicCompany _
  860.             .Persons _
  861.             (CStr(pvtPersonsDataWrapper.RecordSet("ObjectID")))
  862.     publicCompany.Persons.Remove _
  863.         Item:=pvtCurrentPerson
  864.         
  865.     pvtPersonsDataWrapper.Rebind _
  866.         Collection:=publicCompany.Persons
  867.     pvtPersonsDataWrapper.MoveFirst
  868.     Me.MousePointer = vbArrow
  869. End Sub
  870. Private Sub pbDeletePhone_Click()
  871.     Dim saveObjectID As String
  872.     On Local Error Resume Next
  873.     Me.MousePointer = vbArrowHourglass
  874.     saveObjectID = CStr(pvtCurrentPhone.ObjectID)
  875.     With pvtCurrentPhone
  876.         .PhoneNumber = efPhoneNumber
  877.         .Usage = efUsage
  878.     End With
  879.     pvtCurrentPerson.Phones.Remove _
  880.         Item:=pvtCurrentPhone
  881.         
  882.     pvtPhonesDataWrapper.Rebind _
  883.         Collection:=pvtCurrentPerson.Phones
  884.     pvtPhonesDataWrapper.MoveFirst
  885.     Me.MousePointer = vbArrow
  886. End Sub
  887. Private Sub pbOK_Click()
  888.     Set pvtStates = Nothing
  889.     Set pvtGenderCodes = Nothing
  890.     Set pvtMaritalStatusCodes = Nothing
  891.     Unload Me
  892. End Sub
  893. Private Sub Data1_Reposition()
  894.         
  895.     On Local Error Resume Next
  896.     Me.MousePointer = vbArrowHourglass
  897.     Data2.Enabled = True
  898.     Data3.Enabled = True
  899.         
  900.     If pvtPersonsDataWrapper Is Nothing Then
  901.         Exit Sub
  902.     End If
  903.     Set pvtCurrentPerson = _
  904.         pvtPersonsDataWrapper. _
  905.             AbsolutePositionObject
  906.     RefreshCustomerFields
  907.     If pvtCurrentPerson Is Nothing Then
  908.         Data2.Enabled = False
  909.         Data3.Enabled = False
  910.         Me.MousePointer = vbArrow
  911.         Exit Sub
  912.     End If
  913. ' rebind the Wrappers for the contained
  914. '   collections
  915.     pvtAddressesDataWrapper.Rebind _
  916.         Collection:=pvtCurrentPerson.Addresses
  917.     pvtPhonesDataWrapper.Rebind _
  918.         Collection:=pvtCurrentPerson.Phones
  919. ' display details of the first Address
  920.     pvtAddressesDataWrapper.MoveFirst
  921. ' display details of the first Phone
  922.     pvtPhonesDataWrapper.MoveFirst
  923.     Me.MousePointer = vbArrow
  924. End Sub
  925. Private Sub Form_Load()
  926.     On Local Error Resume Next
  927.     PopulateStateCodes
  928.     PopulateGenderCodes
  929.     PopulateMaritalStatusCodes
  930.     Data2.Enabled = False
  931.     Data3.Enabled = False
  932.     Set pvtPersonsDataWrapper = _
  933.         ObjectManager. _
  934.             NewVBOFDataWrapper( _
  935.                 Collection:=publicCompany.Persons, _
  936.                 DataControl:=Data1)
  937.     Set pvtAddressesDataWrapper = _
  938.         ObjectManager. _
  939.             NewVBOFDataWrapper( _
  940.                 Collection:=Nothing, _
  941.                 DataControl:=Data2)
  942.                 
  943.     Set pvtPhonesDataWrapper = _
  944.         ObjectManager. _
  945.             NewVBOFDataWrapper( _
  946.                 Collection:=Nothing, _
  947.                 DataControl:=Data3)
  948.     pvtPersonsDataWrapper. _
  949.         MoveFirst
  950.     RegisterForEvents
  951. End Sub
  952. Private Sub pbUpdateAddress_Click()
  953. ' update the person's detail information
  954.     Dim saveObjectID As String
  955.         
  956.     On Local Error Resume Next
  957.     Me.MousePointer = vbArrowHourglass
  958.     PopulateCurrentAddress
  959.     pvtCurrentPerson.Addresses.Replace _
  960.         Item:=pvtCurrentAddress, _
  961.         ReplaceWith:=pvtCurrentAddress
  962.         
  963.     pvtAddressesDataWrapper.Rebind _
  964.         Collection:=pvtCurrentPerson.Addresses
  965.     pvtAddressesDataWrapper.FindFirst _
  966.         "ObjectID = " & pvtCurrentAddress.ObjectID
  967.     pvtCurrentAddress. _
  968.         ObjectHasChanged
  969.     Me.MousePointer = vbArrow
  970. End Sub
  971. Private Function PopulateCurrentAddress()
  972.     On Local Error Resume Next
  973.     With pvtCurrentAddress
  974.         .Line1 = efLine1
  975.         .Line2 = efLine2
  976.         .Line3 = efLine3
  977.         .City = efCity
  978.         .ZipCode = efZipCode
  979.         .ZipSupplement = efZipSupplement
  980.         .ZipExtension = efZipExtension
  981.     End With
  982.     Set pvtCurrentAddress.State = _
  983.         pvtStatesListBoxWrapper.ListIndexObject
  984. End Function
  985. Private Function PopulateCurrentPerson()
  986.     On Local Error Resume Next
  987.     With pvtCurrentPerson
  988.         .CustomerNumber = efCustomerNumber
  989.         .FirstName = efFirstName
  990.         .LastName = efLastName
  991.         .SSN = efSSN
  992.         .DateOfBirth = DateValue(efDateOfBirth)
  993.         .Sex = _
  994.             pvtGenderCodesListBoxWrapper. _
  995.                 ListIndexObject.GenderCode
  996.         .MaritalStatus = _
  997.             pvtMaritalStatusCodesListBoxWrapper. _
  998.                 ListIndexObject.MaritalStatusCode
  999.     End With
  1000. End Function
  1001. Private Function PopulateCurrentPhone()
  1002.     On Local Error Resume Next
  1003.     With pvtCurrentPhone
  1004.         .PhoneNumber = efPhoneNumber
  1005.         .Usage = efUsage
  1006.     End With
  1007. End Function
  1008. Private Sub PopulateStateCodes()
  1009. ' instantiate pvtStates as a reference
  1010. '   to pubStates
  1011.     Set pvtStates = _
  1012.         pubStates
  1013. ' attach the Collection, ListBox and ListBoxWrapper
  1014.     Set pvtStatesListBoxWrapper = _
  1015.         ObjectManager. _
  1016.             NewVBOFListBoxWrapper( _
  1017.             Collection:=pvtStates, _
  1018.             ListBox:=lbxStateCodes)
  1019.     pvtStatesListBoxWrapper. _
  1020.         AddItems
  1021. End Sub
  1022. Private Sub pbUpdateCustomer_Click()
  1023. ' update the person's detail information
  1024.         
  1025.     On Local Error Resume Next
  1026.     Me.MousePointer = vbArrowHourglass
  1027.     PopulateCurrentPerson
  1028.     publicCompany.Persons.Replace _
  1029.         Item:=pvtCurrentPerson, _
  1030.         ReplaceWith:=pvtCurrentPerson
  1031.         
  1032.     pvtPersonsDataWrapper.Rebind _
  1033.         Collection:=publicCompany.Persons
  1034.     pvtPersonsDataWrapper.FindFirst _
  1035.         "ObjectID = " & pvtCurrentPerson.ObjectID
  1036.         
  1037.     pvtCurrentPerson. _
  1038.         ObjectHasChanged
  1039.         
  1040.     Me.MousePointer = vbArrow
  1041. End Sub
  1042. Private Sub pbUpdatePhone_Click()
  1043. ' update the person's Phone information
  1044.     Dim saveObjectID As String
  1045.         
  1046.     On Local Error Resume Next
  1047.     Me.MousePointer = vbArrowHourglass
  1048.     PopulateCurrentPhone
  1049.             
  1050.     pvtCurrentPerson.Phones.Replace _
  1051.         Item:=pvtCurrentPhone, _
  1052.         ReplaceWith:=pvtCurrentPhone
  1053.     pvtPhonesDataWrapper.Rebind _
  1054.         Collection:=pvtCurrentPerson.Phones
  1055.     pvtPhonesDataWrapper.FindFirst _
  1056.         "ObjectID = " & pvtCurrentPhone.ObjectID
  1057.     pvtCurrentPhone. _
  1058.         ObjectHasChanged
  1059.         
  1060.     Me.MousePointer = vbArrow
  1061. End Sub
  1062.