📄 hwdws.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 = "HwDws"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Dim OHwDws As Collection
Public Property Get Count() As Integer
Count = OHwDws.Count
End Property
Public Sub Add(OHwDw As HwDw)
Dim vKey As Integer, vHwDw As HwDw
For Each vHwDw In OHwDws
If vHwDw.HwDw_Key > vKey Then
vKey = vHwDw.HwDw_Key
End If
Next
vKey = vKey + 1
OHwDw.HwDw_Key = vKey
OHwDws.Add OHwDw, CStr(vKey)
End Sub
Public Function Item(Vindex) As HwDw
Attribute Item.VB_UserMemId = 0
Set Item = OHwDws.Item(Vindex)
End Function
Public Sub Remove(Vindex, Optional NeedDel As Integer = 1)
If NeedDel = 1 Then
Dim mHwDw As HwDw
Set mHwDw = OHwDws(Vindex)
mHwDw.DbDel
End If
OHwDws.Remove (Vindex)
End Sub
Public Sub ClearAll()
Dim i, Vcount As Integer
Vcount = OHwDws.Count
For i = 1 To Vcount
OHwDws.Remove (1)
Next
End Sub
Public Sub Fillbydb(Optional Wherestr As String = "", Optional Orderstr As String = "HwDwCode")
Dim OHwDw As HwDw
Dim Rs As DbRs
Dim SqlStr As String
Dim vKey As Integer
On Error GoTo ErrorHandle
ClearAll
SqlStr = "SELECT HwDwCode,HwDwMC,HwDwISSTOP,HwDwNO FROM HwDwREC "
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 OHwDw = New HwDw
OHwDw.HwDw_Key = vKey
OHwDw.BatchLet Rs!HwDwCode, Rs!HwDwMc, Rs!HwDwIsStop, Rs!HwDwNo
OHwDws.Add OHwDw, 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 = OHwDws.[_NewEnum]
End Function
Private Sub Class_Initialize()
Set OHwDws = New Collection
End Sub
Private Sub Class_Terminate()
Set OHwDws = Nothing
End Sub
Public Property Get Name() As String
Name = "HwDws"
End Property
Public Sub DbSave()
Dim mNotSaved As Collection
Dim mHwDw As HwDw
On Error GoTo ErrorHandle
Set mNotSaved = New Collection
gDbCommon.Conn.BeginTrans
For Each mHwDw In OHwDws
If mHwDw.HwDw_id = -1 Then
mNotSaved.Add mHwDw
End If
mHwDw.DbSave
Next
gDbCommon.Conn.CommitTrans
Set mNotSaved = Nothing
Exit Sub
ErrorHandle:
For Each mHwDw In mNotSaved
mHwDw.HwDw_id = -1
Next
Set mNotSaved = Nothing
gDbCommon.Conn.RollbackTrans
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -