📄 apivrs.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 = "Apivrs"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Dim OApivrs As Collection
Public Property Get Name() As String
Name = "Apivrs"
End Property
Private Sub Class_Initialize()
Set OApivrs = New Collection
End Sub
Public Sub Add(oApivr As Apivr, Optional Needsave As Integer = 1)
Dim mKey As Integer
Dim vApivr As Apivr
For Each vApivr In OApivrs
If mKey < vApivr.ApivrKey Then
mKey = vApivr.ApivrKey
End If
Next
oApivr.ApivrKey = mKey + 1
If Needsave = 1 Then
oApivr.Save
End If
OApivrs.Add Item:=oApivr, Key:=CStr(mKey + 1)
End Sub
Public Sub Remove(Vindex)
Dim oApivr As Apivr
Set oApivr = Item(Vindex)
OApivrs.Remove (Vindex)
Set oApivr = Nothing
End Sub
Public Property Get Count() As Integer
Count = OApivrs.Count
End Property
Public Function Item(Vindex) As Apivr
Attribute Item.VB_UserMemId = 0
Set Item = OApivrs.Item(Vindex)
End Function
Public Sub ClearAll()
Dim i, Vcount As Integer
Vcount = OApivrs.Count
For i = 1 To Vcount
OApivrs.Remove (1)
Next
End Sub
Public Sub Fillbydb(vApivd As Apivd)
Dim oApivr As Apivr
Dim mRs As DbRs
Dim mKey As Integer
Dim mSqlStr As String
On Error GoTo Errorhandle
ClearAll
mSqlStr = "SELECT APIVR_APIVDNO,APIVR_CGAPNO,APIVRQTY,APIVRNO FROM APIVRREC WHERE APIVR_APIVDNO=" & CStr(vApivd.ApivdNo)
Set mRs = New DbRs
mRs.Fillbydb mSqlStr
mRs.MoveFirst
mKey = 1
Do Until mRs.EOF
Set oApivr = New Apivr
Set oApivr.Apivd = vApivd
oApivr.ApivrKey = mKey
oApivr.BatchLet mRs!Apivr_Apivdno, mRs!Apivr_CgApno, mRs!ApivrQty, mRs!ApivrNo
OApivrs.Add Item:=oApivr, Key:=CStr(mKey)
mRs.MoveNext
mKey = mKey + 1
Loop
Set mRs = Nothing
Exit Sub
Errorhandle:
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 = OApivrs.[_NewEnum]
End Function
Private Sub Class_Terminate()
ClearAll
Set OApivrs = Nothing
End Sub
Public Sub Save()
Dim mNotSaved As Collection
Dim mApivr As Apivr
On Error GoTo Errorhandle
Set mNotSaved = New Collection
For Each mApivr In OApivrs
If mApivr.ApivrId = -1 Then
mNotSaved.Add mApivr
End If
mApivr.Save
Next
Set mNotSaved = Nothing
Exit Sub
Errorhandle:
For Each mApivr In mNotSaved
mApivr.ApivrId = -1
Next
Set mNotSaved = Nothing
Err.Raise vbObjectError + 1, , Err.Description
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -