📄 fielddsec.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 = "FieldDsec"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
'//本类属性
Public Js_FieldDsecID As Long
Public Js_FieldTypeID As Long
Public Js_FieldDesc As String
Public Js_FieldDecimal As Long
Public Js_FieldDateFormat As String
Public Js_FieldClassID As Long
Public Js_FieldSelType As Long
'//本类方案
'//保存用户 成功返回: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_FieldDsec where Js_FieldDsecID=" & Js_FieldDsecID
DaCn.Execute Sql
Sql = "exec NewFieldDsec "
Sql = Sql & Js_FieldDsecID & ","
Sql = Sql & Js_FieldTypeID & ","
Sql = Sql & "'" & Js_FieldDesc & "',"
Sql = Sql & Js_FieldDecimal & ","
Sql = Sql & "'" & Js_FieldDateFormat & "',"
Sql = Sql & Js_FieldClassID & ","
Sql = Sql & Js_FieldSelType
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 lgFieldID 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_FieldDsecID,Js_FieldTypeID,Js_FieldDesc,Js_FieldDecimal,Js_FieldDateFormat,Js_FieldClassID,Js_FieldSelType from Js_FieldDsec where Js_FieldDsecID=" & lgFieldID
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_FieldDsecID")) Then Js_FieldDsecID = DaRs("Js_FieldDsecID")
If Not IsNull(DaRs("Js_FieldTypeID")) Then Js_FieldTypeID = DaRs("Js_FieldTypeID")
If Not IsNull(DaRs("Js_FieldDesc")) Then Js_FieldDesc = Trim(DaRs("Js_FieldDesc"))
If Not IsNull(DaRs("Js_FieldDecimal")) Then Js_FieldDecimal = DaRs("Js_FieldDecimal")
If Not IsNull(DaRs("Js_FieldDateFormat")) Then Js_FieldDateFormat = Trim(DaRs("Js_FieldDateFormat"))
If Not IsNull(DaRs("Js_FieldClassID")) Then Js_FieldClassID = DaRs("Js_FieldClassID")
If Not IsNull(DaRs("Js_FieldSelType")) Then Js_FieldSelType = DaRs("Js_FieldSelType")
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 lgFieldID 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(lgFieldID, MsgInfo) = False Then
Del = False
Exit Function
End If
'//
If getFieldCount(lgFieldID) > 0 Then
MsgInfo = "字段类型已经使用,拒绝删除"
Del = False
Exit Function
End If
'//
DelSign = MsgBox("删除[" & Js_FieldDesc & "]?", 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_FieldDsec where Js_FieldDsecID=" & lgFieldID
DaCn.ConnectionString = BaseObj.getConStr
DaCn.Open
DaCn.Execute Sql
DaCn.Close
Set DaCn = Nothing
Set BaseObj = Nothing
MsgInfo = "删除[" & Js_FieldDesc & "]成功"
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 getFieldCount(ByVal lgFieldID 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 FieldCount from Js_UserGroup where Js_FieldDsecID=" & lgFieldID
DaCn.ConnectionString = BaseObj.getConStr
DaCn.Open
DaRs.Open Sql, DaCn, adOpenStatic, adLockReadOnly
If Not DaRs.EOF And Not IsNull(DaRs("FieldCount")) Then
RetValue = DaRs("FieldCount")
End If
DaRs.Close
DaCn.Close
Set DaRs = Nothing
Set DaCn = Nothing
getFieldCount = 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
getFieldCount = 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 FieldSum from Js_FieldDsec"
DaCn.ConnectionString = BaseObj.getConStr
DaCn.Open
DaRs.Open Sql, DaCn, adOpenStatic, adLockReadOnly
If Not DaRs.EOF And Not IsNull(DaRs("FieldSum")) Then
RetValue = DaRs("FieldSum")
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 + -