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

📄 psbms.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 = "PsBms"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Dim OPsBms As Collection

Public Property Get Count() As Integer

Count = OPsBms.Count
    
End Property

Public Sub Add(OPsBm As PsBm)

Dim vKey As Integer, vPsBm As PsBm

For Each vPsBm In OPsBms
   If vPsBm.PsBm_Key > vKey Then
      vKey = vPsBm.PsBm_Key
   End If
Next

vKey = vKey + 1

OPsBm.PsBm_Key = vKey
OPsBms.Add OPsBm, CStr(vKey)

End Sub

Public Function Item(Vindex) As PsBm
Attribute Item.VB_UserMemId = 0

   Set Item = OPsBms.Item(Vindex)

End Function

Public Sub Remove(Vindex, Optional NeedDel As Integer = 1)

If NeedDel = 1 Then
   Dim mPsBm As PsBm
   Set mPsBm = OPsBms(Vindex)
   mPsBm.DbDel
End If
   
OPsBms.Remove (Vindex)
      
End Sub

Public Sub ClearAll()

Dim i, Vcount As Integer
Vcount = OPsBms.Count

For i = 1 To Vcount
   OPsBms.Remove (1)
Next

End Sub

Public Sub Fillbydb(Optional Wherestr As String = "", Optional Orderstr As String = "PsBmCode")
   Dim OPsBm As PsBm
   Dim Rs As DbRs
   Dim SqlStr As String
   Dim vKey As Integer
On Error GoTo ErrorHandle

   ClearAll
   
   SqlStr = "SELECT PsBmCode,PsBmMC,PsBmType,PsBmNO FROM PsBmREC "
   
   If Wherestr <> "" Then
      SqlStr = SqlStr + " where " + Wherestr
   End If
   
   If Orderstr <> "" Then
      SqlStr = SqlStr + " order by " + Orderstr
   End If
   
   Set Rs = New DbRs
   
   Rs.Fillbydb SqlStr
   Rs.MoveFirst
   
   vKey = 1

   Do Until Rs.EOF
      Set OPsBm = New PsBm
      OPsBm.PsBm_Key = vKey
      OPsBm.BatchLet Rs!PsBmCode, Rs!PsBmMc, Rs!PsBmType, Rs!PsBmNo
      OPsBms.Add OPsBm, CStr(vKey)
      Rs.MoveNext
      vKey = vKey + 1
   Loop

   Set Rs = Nothing

Exit Sub
ErrorHandle:
   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 = OPsBms.[_NewEnum]
  
End Function

Private Sub Class_Initialize()

Set OPsBms = New Collection

End Sub

Private Sub Class_Terminate()

Set OPsBms = Nothing

End Sub

Public Property Get Name() As String

Name = "PsBms"

End Property

Public Sub DbSave()
   Dim mNotSaved As Collection
   Dim mPsBm As PsBm
On Error GoTo ErrorHandle
   
   Set mNotSaved = New Collection
   
   gDbCommon.Conn.BeginTrans
   
   For Each mPsBm In OPsBms
      If mPsBm.PsBm_id = -1 Then
         mNotSaved.Add mPsBm
      End If
      mPsBm.DbSave
   Next
   
   gDbCommon.Conn.CommitTrans
   
   Set mNotSaved = Nothing

Exit Sub
ErrorHandle:
   For Each mPsBm In mNotSaved
      mPsBm.PsBm_id = -1
   Next
   Set mNotSaved = Nothing
   gDbCommon.Conn.RollbackTrans
End Sub






⌨️ 快捷键说明

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