📄 logonprecept.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 = "LogonPrecept"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
'//本类属性
Public Js_LogonPreceptID As Long
Public Js_LogonPreceptParentID As Long
Public Js_LogonPreceptNumber As String
Public Js_LogonPreceptType As Long
Public Js_LogonPreceptValue As String
Public Js_LogonPreceptDesc As String
Public Js_LogonPreceptLevel As Long
Public Js_LogonPreceptDetail As Long
Public Js_LogonPreceptUseSign As Long
Public Js_LogonPreceptUserID As Long
Public Js_LogonPreceptDate As String
Public Js_LogonPreceptTime 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_LogonPrecept where Js_LogonPreceptID=" & Js_LogonPreceptID
DaCn.Execute Sql
Sql = "exec NewLogonPrecept "
Sql = Sql & Js_LogonPreceptID & ","
Sql = Sql & Js_LogonPreceptParentID & ","
Sql = Sql & "'" & Js_LogonPreceptNumber & "',"
Sql = Sql & Js_LogonPreceptType & ","
Sql = Sql & "'" & Js_LogonPreceptValue & "',"
Sql = Sql & "'" & Js_LogonPreceptDesc & "',"
Sql = Sql & Js_LogonPreceptLevel & ","
Sql = Sql & Js_LogonPreceptDetail & ","
Sql = Sql & Js_LogonPreceptUseSign & ","
Sql = Sql & Js_LogonPreceptUserID & ","
Sql = Sql & "'" & Js_LogonPreceptDate & "',"
Sql = Sql & "'" & Js_LogonPreceptTime & "'"
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 lgLogonID 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_LogonPreceptID,Js_LogonPreceptParentID,Js_LogonPreceptNumber,Js_LogonPreceptType,Js_LogonPreceptValue,Js_LogonPreceptDesc,Js_LogonPreceptLevel,Js_LogonPreceptDetail,Js_LogonPreceptUseSign,Js_LogonPreceptUserID,Js_LogonPreceptDate,Js_LogonPreceptTime from Js_LogonPrecept where Js_LogonPreceptID=" & lgLogonID
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_LogonPreceptID")) Then Js_LogonPreceptID = DaRs("Js_LogonPreceptID")
If Not IsNull(DaRs("Js_LogonPreceptParentID")) Then Js_LogonPreceptParentID = DaRs("Js_LogonPreceptParentID")
If Not IsNull(DaRs("Js_LogonPreceptNumber")) Then Js_LogonPreceptNumber = Trim(DaRs("Js_LogonPreceptNumber"))
If Not IsNull(DaRs("Js_LogonPreceptType")) Then Js_LogonPreceptType = DaRs("Js_LogonPreceptType")
If Not IsNull(DaRs("Js_LogonPreceptValue")) Then Js_LogonPreceptValue = Trim(DaRs("Js_LogonPreceptValue"))
If Not IsNull(DaRs("Js_LogonPreceptDesc")) Then Js_LogonPreceptDesc = Trim(DaRs("Js_LogonPreceptDesc"))
If Not IsNull(DaRs("Js_LogonPreceptLevel")) Then Js_LogonPreceptLevel = DaRs("Js_LogonPreceptLevel")
If Not IsNull(DaRs("Js_LogonPreceptDetail")) Then Js_LogonPreceptDetail = DaRs("Js_LogonPreceptDetail")
If Not IsNull(DaRs("Js_LogonPreceptUseSign")) Then Js_LogonPreceptUseSign = DaRs("Js_LogonPreceptUseSign")
If Not IsNull(DaRs("Js_LogonPreceptUserID")) Then Js_LogonPreceptUserID = DaRs("Js_LogonPreceptUserID")
If Not IsNull(DaRs("Js_LogonPreceptDate")) Then Js_LogonPreceptDate = Trim(DaRs("Js_LogonPreceptDate"))
If Not IsNull(DaRs("Js_LogonPreceptTime")) Then Js_LogonPreceptTime = Trim(DaRs("Js_LogonPreceptTime"))
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 lgLogonID 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(lgLogonID, MsgInfo) = False Then
Del = False
Exit Function
End If
'//
If getLogonCount(lgLogonID) > 0 Then
MsgInfo = "本方案已经被使用,拒绝删除"
Del = False
Exit Function
End If
'//
DelSign = MsgBox("删除[" & Js_LogonPreceptDesc & "]?", 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_LogonPrecept where Js_LogonPreceptID=" & lgLogonID
DaCn.ConnectionString = BaseObj.getConStr
DaCn.Open
DaCn.Execute Sql
DaCn.Close
Set DaCn = Nothing
Set BaseObj = Nothing
MsgInfo = "删除[" & Js_LogonPreceptDesc & "]成功"
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 getLogonCount(ByVal lgLogonID 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 LogonCount from Js_User where Js_LogonPreceptID=" & lgLogonID
DaCn.ConnectionString = BaseObj.getConStr
DaCn.Open
DaRs.Open Sql, DaCn, adOpenStatic, adLockReadOnly
If Not DaRs.EOF And Not IsNull(DaRs("LogonCount")) Then
RetValue = DaRs("LogonCount")
End If
DaRs.Close
DaCn.Close
Set DaRs = Nothing
Set DaCn = Nothing
getLogonCount = 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
getLogonCount = 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 LogonSum from Js_LogonPrecept"
DaCn.ConnectionString = BaseObj.getConStr
DaCn.Open
DaRs.Open Sql, DaCn, adOpenStatic, adLockReadOnly
If Not DaRs.EOF And Not IsNull(DaRs("LogonSum")) Then
RetValue = DaRs("LogonSum")
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 + -