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

📄 xssods.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 = "XsSods"
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 OXsSods As Collection

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

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

Public Sub Add(oXsSod As XsSod, Optional Needsave As Integer = 1)
   Dim mKey As Integer
   Dim vXsSod As XsSod
   For Each vXsSod In OXsSods
      If mKey < vXsSod.XsSodKey Then
         mKey = vXsSod.XsSodKey
      End If
   Next
   oXsSod.XsSodKey = mKey + 1
   If Needsave = 1 Then
      oXsSod.Save
   End If
   OXsSods.Add Item:=oXsSod, Key:=CStr(mKey + 1)
End Sub

Public Sub Remove(Vindex, Optional Needdel As Integer = 1)
 
   Dim oXsSod As XsSod
   Set oXsSod = Item(Vindex)
   If Needdel = 1 And oXsSod.XsSodId = 1 Then
      oXsSod.Del
   End If
   OXsSods.Remove (Vindex)
   Set oXsSod = Nothing
   
End Sub

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

Public Function Item(Vindex) As XsSod
Attribute Item.VB_UserMemId = 0
   Set Item = OXsSods.Item(Vindex)
End Function

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

Public Sub Fillbydb(vXsSodh As XsSodh)
   Dim oXsSod As XsSod
   Dim mRs As ADODB.Recordset
   Dim mKey As Integer
On Error GoTo Errorhandle

   ClearAll
   Set mRs = Conn.Execute("SELECT XSSOD_XSSODHNO,XSSOD_HWBMCODE=HWBMCODE,XSSOD_HWBMNO,XSSODQTY,XSSODPRICE,XSSODAMT,XSSODOQTY,XSSODDDAT,XSSODBZ,XSSODSYSDAT,XSSODSYSTIME,XSSODNO FROM XSSODREC,HWBMREC WHERE XSSOD_XSSODHNO=" & CStr(vXsSodh.XsSodhNo) & " AND HWBMNO=XSSOD_HWBMNO")
   
   mKey = 1
   Do Until mRs.EOF
      Set oXsSod = New XsSod
      Set oXsSod.XsSodh = vXsSodh
      oXsSod.XsSodKey = mKey
      oXsSod.BatchLet mRs!XsSod_XsSodhno, mRs!XsSod_HwBmCode, mRs!XsSod_HwBmno, mRs!XsSodQty, mRs!XsSodPrice, mRs!XsSodAmt, mRs!XsSodOQty, mRs!XsSodDDat, mRs!XsSodBz, mRs!XsSodSysDat, mRs!XsSodSysTime, mRs!XsSodNo
      OXsSods.Add Item:=oXsSod, Key:=CStr(mKey)
      mRs.MoveNext
      mKey = mKey + 1
   Loop
   
   mRs.Close
   Set mRs = Nothing

Exit Sub
Errorhandle:
   If Not mRs Is Nothing Then
     mRs.Close
   End If
   Set mRs = 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 = OXsSods.[_NewEnum]
End Function

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

Public Sub Save(vXsSodh As XsSodh)
   Dim mNotSaved As Collection
   Dim mXsSod As XsSod
On Error GoTo Errorhandle
   
   Set mNotSaved = New Collection
   
   For Each mXsSod In vXsSodh.XsSods
      If mXsSod.XsSodId = -1 Then
         mNotSaved.Add mXsSod
      End If
      mXsSod.Save
   Next
   
   Set mNotSaved = Nothing
   
Exit Sub
Errorhandle:
   For Each mXsSod In mNotSaved
      mXsSod.XsSodId = -1
   Next
   Set mNotSaved = Nothing
   Err.Raise vbObjectError + 1, , Err.Description
End Sub

⌨️ 快捷键说明

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