VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "CAuthors"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Collection" ,"CAuthor"
Attribute VB_Ext_KEY = "Member0" ,"CAuthor"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Private mCol As Collection
Private m_dcnDB As ADODB.Connection
Private WithEvents objNewMember  As CAuthor
Attribute objNewMember.VB_VarHelpID = -1
'触发事件的模块需有相应的事件代码，事件的触发才会展现
Public Function Add(AuthorName As String, YearBorn As Integer, Optional sKey As String) As CAuthor
    'Dim objNewMember As CAuthor
    Set objNewMember = New CAuthor

    objNewMember.Init m_dcnDB
    objNewMember.AuthorName = AuthorName
    objNewMember.YearBorn = YearBorn
    objNewMember.Save
    'download by http://www.codefans.net
    If Len(sKey) = 0 Then
        mCol.Add objNewMember
    Else
        mCol.Add objNewMember, sKey
    End If

    Set Add = objNewMember
    Set objNewMember = Nothing

End Function

Public Property Get Item(vntIndexKey As Variant) As CAuthor
Attribute Item.VB_UserMemId = 0
  Set Item = mCol(vntIndexKey)
End Property



Public Property Get Count() As Long
    Count = mCol.Count
End Property


Public Sub Remove(vntIndexKey As Variant)
    mCol.Remove vntIndexKey
End Sub


Public Property Get NewEnum() As IUnknown
Attribute NewEnum.VB_UserMemId = -4
Attribute NewEnum.VB_MemberFlags = "40"
    Set NewEnum = mCol.[_NewEnum]
End Property


Private Sub Class_Initialize()
    Set mCol = New Collection
End Sub


Private Sub Class_Terminate()
    Set mCol = Nothing
End Sub

Public Sub Init(dcnDB As ADODB.Connection)
    Set m_dcnDB = dcnDB
End Sub
'自定义事件代码
Private Sub objNewMember_InvalidData(strReason As String)
    MsgBox strReason, vbExclamation, "CAuthor Data Error!!!"
End Sub
'自定义事件代码
Private Sub objNewMember_ValidData()
    MsgBox "Add RecordSet OK!!1"
End Sub
