📄 usergroup.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 = "UserGroup"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
'//本类属性
Public Js_GroupID As Long
Public Js_ParentID As Long
Public Js_Number As String
Public Js_GroupName As String
Public Js_UserList As String
Public Js_Admin As Long
Public Js_RightID As Long
Public Js_Desc As String
Public Js_Level As Long
Public Js_Detail As Long
Public Js_UseSign As Long
Public Js_UserID As Long
Public Js_Date As String
Public Js_Time 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
Sql = "delete from Js_UserGroup where Js_GroupID=" & Js_GroupID
DaCn.ConnectionString = BaseObj.getConStr
DaCn.Open
DaCn.BeginTrans
DaCn.Execute Sql
Sql = "exec NewUserGroup "
Sql = Sql & Js_GroupID & ","
Sql = Sql & Js_ParentID & ","
Sql = Sql & "'" & Js_Number & "',"
Sql = Sql & "'" & Js_GroupName & "',"
Sql = Sql & "'" & Js_UserList & "',"
Sql = Sql & Js_Admin & ","
Sql = Sql & Js_RightID & ","
Sql = Sql & "'" & Js_Desc & "',"
Sql = Sql & Js_Level & ","
Sql = Sql & Js_Detail & ","
Sql = Sql & Js_UseSign & ","
Sql = Sql & Js_UserID & ","
Sql = Sql & "'" & Js_Date & "',"
Sql = Sql & "'" & Js_Time & "'"
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 UserGroupID 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_GroupID,Js_ParentID,Js_Number,Js_GroupName,Js_UserList,Js_Admin,Js_RightID,Js_Desc,Js_Level,Js_Detail,Js_UseSign,Js_UserID,Js_Date,Js_Time from Js_UserGroup where Js_GroupID=" & UserGroupID
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_GroupID")) Then Js_GroupID = DaRs("Js_GroupID")
If Not IsNull(DaRs("Js_ParentID")) Then Js_ParentID = DaRs("Js_ParentID")
If Not IsNull(DaRs("Js_Number")) Then Js_Number = Trim(DaRs("Js_Number"))
If Not IsNull(DaRs("Js_GroupName")) Then Js_GroupName = Trim(DaRs("Js_GroupName"))
If Not IsNull(DaRs("Js_UserList")) Then Js_UserList = Trim(DaRs("Js_UserList"))
If Not IsNull(DaRs("Js_Admin")) Then Js_Admin = DaRs("Js_Admin")
If Not IsNull(DaRs("Js_RightID")) Then Js_RightID = DaRs("Js_RightID")
If Not IsNull(DaRs("Js_Desc")) Then Js_Desc = Trim(DaRs("Js_Desc"))
If Not IsNull(DaRs("Js_Level")) Then Js_Level = DaRs("Js_Level")
If Not IsNull(DaRs("Js_Detail")) Then Js_Detail = DaRs("Js_Detail")
If Not IsNull(DaRs("Js_UseSign")) Then Js_UseSign = DaRs("Js_UseSign")
If Not IsNull(DaRs("Js_UserID")) Then Js_UserID = DaRs("Js_UserID")
If Not IsNull(DaRs("Js_Date")) Then Js_Date = Trim(DaRs("Js_Date"))
If Not IsNull(DaRs("Js_Time")) Then Js_Time = Trim(DaRs("Js_Time"))
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 UserGroupID 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(UserGroupID, MsgInfo) = False Then
Del = False
Exit Function
End If
'//
DelSign = MsgBox("删除[" & Js_GroupName & "]?", vbQuestion + vbYesNo + vbDefaultButton2, BaseObj.getMsgInfo)
If DelSign <> 6 Then
Set DaCn = Nothing
Set BaseObj = Nothing
MsgInfo = "用户取消删除操作"
Del = False
Exit Function
End If
'//
If getUserCount(UserGroupID) > 0 Then
Set DaCn = Nothing
Set BaseObj = Nothing
MsgInfo = "用户组[" & Js_GroupName & "]包含用户,拒绝删除"
Del = False
Exit Function
End If
'//
Sql = "delete from Js_UserGroup where Js_GroupID=" & UserGroupID
DaCn.ConnectionString = BaseObj.getConStr
DaCn.Open
DaCn.Execute Sql
DaCn.Close
Set DaCn = Nothing
Set BaseObj = Nothing
MsgInfo = "删除[" & Js_GroupName & "]成功"
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 getUserCount(ByVal UserGroupID 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 UserCount from js_user where js_usergrouplist like '%|" & UserGroupID & "|%'"
DaCn.ConnectionString = BaseObj.getConStr
DaCn.Open
DaRs.Open Sql, DaCn, adOpenStatic, adLockReadOnly
If Not DaRs.EOF And Not IsNull(DaRs("UserCount")) Then
RetValue = DaRs("UserCount")
End If
DaRs.Close
DaCn.Close
Set DaRs = Nothing
Set DaCn = Nothing
getUserCount = 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
getUserCount = 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 GroupSum from Js_UserGroup"
DaCn.ConnectionString = BaseObj.getConStr
DaCn.Open
DaRs.Open Sql, DaCn, adOpenStatic, adLockReadOnly
If Not DaRs.EOF And Not IsNull(DaRs("GroupSum")) Then
RetValue = DaRs("GroupSum")
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 + -