⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cgshdhs.cls

📁 初级进销存系统学习,想学数据库编程的可以参考此示例
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "CgShdhs"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'QQ:75347626
'MSN:whailin2000@hotmail.com
Option Explicit
Dim oCgShdhs As Collection

Public Property Get Name() As String
   Name = "CgShdhs"
End Property

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

Public Sub Add(oCgShdh As CgShdh, Optional Needsave As Integer = 1)
   Dim mKey As Integer
   Dim vCgShdh As CgShdh
   For Each vCgShdh In oCgShdhs
      If mKey < vCgShdh.CgShdhKey Then
         mKey = vCgShdh.CgShdhKey
      End If
   Next
   oCgShdh.CgShdhKey = mKey + 1
   If Needsave = 1 Then
      oCgShdh.Save
   End If
   oCgShdhs.Add Item:=oCgShdh, Key:=CStr(mKey + 1)
End Sub

Public Sub Remove(Vindex, Optional Needdel As Integer = 1)
 
   Dim oCgShdh As CgShdh
   Set oCgShdh = Item(Vindex)
   If Needdel = 1 And oCgShdh.CgShdhId = 1 Then
      oCgShdh.Del
   End If
   oCgShdhs.Remove (Vindex)
   Set oCgShdh = Nothing
   
End Sub

Public Property Get Count() As Integer
   Count = oCgShdhs.Count
End Property

Public Function Item(Vindex) As CgShdh
Attribute Item.VB_UserMemId = 0
   Set Item = oCgShdhs.Item(Vindex)
End Function

Public Sub ClearAll()
   Dim I, Vcount As Integer
   Vcount = oCgShdhs.Count
   For I = 1 To Vcount
      oCgShdhs.Remove (1)
   Next
End Sub

Public Sub Fillbydb(Optional vWhereStr As String = "")
   Dim oCgShdh As CgShdh
   Dim Rs As ADODB.Recordset
   Dim mKey As Integer
   Dim mSqlStr As String
On Error GoTo Errorhandle

   ClearAll
   
   mSqlStr = "SELECT CgShdHTYPE,CgShdHDOCNO,CgShdHDAT,CgShdH_KHCODE=KHCODE,CgShdH_KHNO,CgShdHSYSDAT,CgShdHSYSTIME,CgShdHNO FROM CgShdHREC,KHREC WHERE KHNO=CgShdH_KHNO"
   
   If vWhereStr <> "" Then
      mSqlStr = mSqlStr & " AND " & vWhereStr
   End If
   
   mSqlStr = mSqlStr & "  ORDER BY CgShdHDOCNO"
   
   Set Rs = Conn.Execute(mSqlStr)
   
   mKey = 1
   Do Until Rs.EOF
      Set oCgShdh = New CgShdh
      oCgShdh.CgShdhKey = mKey
      oCgShdh.BatchLet Rs!CgShdhType, Rs!CgShdhDocno, Rs!CgShdhDat, Rs!CgShdh_KhCode, Rs!CgShdh_Khno, Rs!CgShdhSysDat, Rs!CgShdhSysTime, Rs!CgShdhNo
      oCgShdhs.Add Item:=oCgShdh, Key:=CStr(mKey)
      Rs.MoveNext
      mKey = mKey + 1
   Loop
   
   Rs.Close
   Set Rs = Nothing

Exit Sub
Errorhandle:
   If Not Rs Is Nothing Then
     Rs.Close
   End If
   Set Rs = Nothing
   Err.Raise vbObjectError + 1, , Err.Description
End Sub

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

Private Sub Class_Terminate()
   ClearAll
   Set oCgShdhs = Nothing
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -