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

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

'//本类属性
Public Js_EventID As Long
Public Js_EventDesc As String

'//本类方案

'//保存用户 成功返回:True 失败返回False
Public Function Save(ByRef MsgInfo As String) As Boolean
 On Error GoTo ErrHandle
 Dim BaseObj As New StdRptBase.StdRptBaseCls
 Dim DaCn As New ADODB.Connection
 Dim Sql As String
 DaCn.ConnectionString = BaseObj.getConStr
 DaCn.Open
 DaCn.BeginTrans
 Sql = "delete from Js_Event where Js_EventID=" & Js_EventID
 DaCn.Execute Sql
 Sql = "exec NewEvent "
 Sql = Sql & Js_EventID & ","
 Sql = Sql & "'" & Js_EventDesc & "'"
 DaCn.Execute Sql
 DaCn.CommitTrans
 DaCn.Close
 Set DaCn = Nothing
 Set BaseObj = Nothing
 MsgInfo = "保存事件成功"
 Save = True
 Exit Function
ErrHandle:
 MsgInfo = "保存事件,错误:" & Err.Description
 If DaCn.State = adStateOpen Then DaCn.Close
 Set DaCn = Nothing
 Set BaseObj = Nothing
 Save = False
End Function

'//装载用户信息 成功返回True 失败返回False
Public Function Load(ByVal lgEventID As Long, ByRef MsgInfo As String) As Boolean
 On Error GoTo ErrHandle
 Dim BaseObj As New StdRptBase.StdRptBaseCls
 Dim DaCn As New ADODB.Connection
 Dim DaRs As New ADODB.Recordset
 Dim Sql As String
 Sql = "select Js_EventID,Js_EventDesc from Js_Event where Js_EventID=" & lgEventID
 DaCn.ConnectionString = BaseObj.getConStr
 DaCn.Open
 DaRs.CursorLocation = adUseClient
 DaRs.Open Sql, DaCn, adOpenStatic, adLockReadOnly
 If Not DaRs.EOF Then
  If Not IsNull(DaRs("Js_EventID")) Then Js_EventID = DaRs("Js_EventID")
  If Not IsNull(DaRs("Js_EventDesc")) Then Js_EventDesc = Trim(DaRs("Js_EventDesc"))
 Else
  MsgInfo = "错误的事件"
  DaRs.Close
  DaCn.Close
  Set DaRs = Nothing
  Set DaCn = Nothing
  Set BaseObj = Nothing
  Load = False
  Exit Function
 End If
 DaRs.Close
 DaCn.Close
 Set DaRs = Nothing
 Set DaCn = Nothing
 Set BaseObj = Nothing
 MsgInfo = "装载数据成功"
 Load = True
 Exit Function
ErrHandle:
 MsgInfo = "装载事件,错误:" & Err.Description
 If DaRs.State = adStateOpen Then DaRs.Close
 If DaCn.State = adStateOpen Then DaCn.Close
 Set DaRs = Nothing
 Set DaCn = Nothing
 Set BaseObj = Nothing
 Load = False
End Function

'//删除用户
Public Function Del(ByVal lgEventID As Long, ByRef MsgInfo As String) As Boolean
 On Error GoTo ErrHandle
 Dim DelSign As Long
 Dim BaseObj As New StdRptBase.StdRptBaseCls
 Dim DaCn As New ADODB.Connection
 Dim Sql As String
 '//
 If Load(lgEventID, MsgInfo) = False Then
  Del = False
  Exit Function
 End If
 '//
 If getEventCount(lgEventID) > 0 Then
  MsgInfo = "日志已经记录,拒绝删除"
  Del = False
  Exit Function
 End If
 '//
 DelSign = MsgBox("删除[" & Js_EventDesc & "]?", vbQuestion + vbYesNo + vbDefaultButton2, BaseObj.getMsgInfo)
 If DelSign <> 6 Then
  Set DaCn = Nothing
  Set BaseObj = Nothing
  MsgInfo = "用户取消删除操作"
  Del = False
  Exit Function
 End If
 '//
 Sql = "delete from Js_Event where Js_EventID=" & lgEventID
 DaCn.ConnectionString = BaseObj.getConStr
 DaCn.Open
 DaCn.Execute Sql
 DaCn.Close
 Set DaCn = Nothing
 Set BaseObj = Nothing
 MsgInfo = "删除[" & Js_EventDesc & "]成功"
 Del = True
 Exit Function
ErrHandle:
 If DaCn.State = adStateOpen Then DaCn.Close
 Set DaCn = Nothing
 Set BaseObj = Nothing
 MsgInfo = "删除事件,错误:" & Err.Description
 Del = False
End Function

'//计算指定的用户下面属于多少个用户组
Public Function getEventCount(ByVal lgEventID As Long) As Long
 On Error GoTo ErrHandle
 Dim BaseObj As New StdRptBase.StdRptBaseCls
 Dim DaCn As New ADODB.Connection
 Dim DaRs As New ADODB.Recordset
 Dim Sql As String
 Dim RetValue As Long
 RetValue = 0
 Sql = "select count(*) as EventCount from Js_Log where Js_EventID=" & lgEventID
 DaCn.ConnectionString = BaseObj.getConStr
 DaCn.Open
 DaRs.Open Sql, DaCn, adOpenStatic, adLockReadOnly
 If Not DaRs.EOF And Not IsNull(DaRs("EventCount")) Then
  RetValue = DaRs("EventCount")
 End If
 DaRs.Close
 DaCn.Close
 Set DaRs = Nothing
 Set DaCn = Nothing
 getEventCount = RetValue
 Exit Function
ErrHandle:
 If DaRs.State = adStateOpen Then DaRs.Close
 If DaCn.State = adStateOpen Then DaCn.Close
 Set DaRs = Nothing
 Set DaCn = Nothing
 Set BaseObj = Nothing
 getEventCount = 0
End Function

'//统计当前用户组的数量
Public Function getSum() As Long
 On Error GoTo ErrHandle
 Dim BaseObj As New StdRptBase.StdRptBaseCls
 Dim DaCn As New ADODB.Connection
 Dim DaRs As New ADODB.Recordset
 Dim Sql As String
 Dim RetValue As Long
 Sql = "select count(*) as EventSum from Js_Event"
 DaCn.ConnectionString = BaseObj.getConStr
 DaCn.Open
 DaRs.Open Sql, DaCn, adOpenStatic, adLockReadOnly
 If Not DaRs.EOF And Not IsNull(DaRs("EventSum")) Then
  RetValue = DaRs("EventSum")
 End If
 DaRs.Close
 DaCn.Close
 Set DaRs = Nothing
 Set DaCn = Nothing
 getSum = RetValue
 Exit Function
ErrHandle:
 If DaRs.State = adStateOpen Then DaRs.Close
 If DaCn.State = adStateOpen Then DaCn.Close
 Set DaRs = Nothing
 Set DaCn = Nothing
 Set BaseObj = Nothing
 getSum = 0
End Function




⌨️ 快捷键说明

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