📄 cwarnings.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 = "CWarnings"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Private mCol As Collection
Public Sub Add(objWarn As CWarning)
mCol.Add objWarn, "A" & objWarn.ID
End Sub
Public Property Get Item(vntIndexKey As Variant) As CWarning
Set Item = mCol(vntIndexKey)
End Property
Public Property Get Count() As Long
Count = mCol.Count
End Property
Public Sub Remove(vntIndexKey As Variant)
mCol.Remove vntIndexKey
End Sub
Public Property Get NewEnum() As IUnknown
Set NewEnum = mCol.[_NewEnum]
End Property
Public Sub Clear()
Dim i As Long
For i = mCol.Count To 1 Step -1
mCol.Remove i
Next i
End Sub
Private Sub Class_Initialize()
Set mCol = New Collection
End Sub
Private Sub Class_Terminate()
Set mCol = Nothing
End Sub
Public Function Find(Optional ByVal lngID As Long = 0, _
Optional ByVal lngTypeId As Long = 0) As CWarnings
Dim strSQL As String
strSQL = "Select Warning.*,WarnType.WTypeName from Warning left outer join WarnType "
strSQL = strSQL & " ON Warning.TypeID=WarnType.WTypeID Where "
If lngID <> 0 Then strSQL = strSQL & "Warning.WarnId=" & lngID & " and "
If lngTypeId <> 0 Then strSQL = strSQL & "Warning.TypeID=" & lngTypeId & " and "
strSQL = strSQL & "Warning.WarnId>0"
On Error Resume Next
Dim rs As Recordset
Set rs = g_Conn.Execute(strSQL)
Dim i As Long
Dim objWarn As CWarning
For i = 1 To rs.RecordCount
Set objWarn = New CWarning
With objWarn
.ID = rs("WarnId").Value
.ClientID = rs("ClientId").Value
.Msg = Trim(rs("Msg").Value)
.ShowDate = rs("ShowDate").Value
.TypeID = rs("TypeId").Value
.TypeName = rs("WTypeName").Value
End With
Me.Add objWarn
Set objWarn = Nothing
rs.MoveNext
Next i
Set rs = Nothing
Set Find = Me
End Function
Public Function FindByDate(Optional ByVal intYear As Integer = 0, _
Optional ByVal intMonth As Integer = 0, _
Optional ByVal intDay As Integer = 0, _
Optional ByVal IncludeBirthdayWarn As Boolean = True) As CWarnings
If intYear < 0 Then intYear = 0
If intMonth < 0 Then intMonth = 0
If intDay < 0 Then intDay = 0
Dim strSQL As String
strSQL = "Select Warning.*,WarnType.WTypeName from Warning left outer join WarnType "
strSQL = strSQL & " ON Warning.TypeID=WarnType.WTypeID Where "
If intYear + intMonth + intDay <> 0 Then
strSQL = strSQL & "("
End If
If intYear <> 0 Then strSQL = strSQL & "Year(ShowDate)=" & intYear & " and "
If intMonth <> 0 Then strSQL = strSQL & "Month(ShowDate)=" & intMonth & " and "
If intDay <> 0 Then strSQL = strSQL & "Day(ShowDate)=" & intDay & " and "
If intYear + intMonth + intDay <> 0 Then
strSQL = strSQL & " Warning.TypeID > 0 "
strSQL = strSQL & ") "
End If
If intYear + intMonth + intDay <> 0 And IncludeBirthdayWarn Then
strSQL = strSQL & " OR ("
End If
If intMonth <> 0 Then strSQL = strSQL & "Month(ShowDate)=" & intMonth & " and "
If intDay <> 0 Then strSQL = strSQL & "Day(ShowDate)=" & intDay & " and "
If intYear + intMonth + intDay <> 0 And IncludeBirthdayWarn Then
strSQL = strSQL & " Warning.TypeID = 1 "
strSQL = strSQL & ") "
End If
strSQL = strSQL & " AND Warning.WarnId > 0"
On Error Resume Next
Dim rs As Recordset
Set rs = g_Conn.Execute(strSQL)
Dim i As Long
Dim objWarn As CWarning
For i = 1 To rs.RecordCount
Set objWarn = New CWarning
With objWarn
.ID = rs("WarnId").Value
.ClientID = rs("ClientId").Value
.Msg = Trim(rs("Msg").Value)
.ShowDate = rs("ShowDate").Value
.TypeID = rs("TypeId").Value
.TypeName = rs("WTypeName").Value
End With
Me.Add objWarn
Set objWarn = Nothing
rs.MoveNext
Next i
Set rs = Nothing
Set FindByDate = Me
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -