📄 frmuserquery.frm
字号:
Height = 180
Left = 480
TabIndex = 18
Top = 2520
Width = 900
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "用户姓名:"
Height = 180
Left = 480
TabIndex = 17
Top = 1920
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "用户ID:"
Height = 180
Left = 660
TabIndex = 16
Top = 1320
Width = 720
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "用户权限设置:"
Height = 180
Left = 4440
TabIndex = 14
Top = 960
Width = 1260
End
End
Attribute VB_Name = "frmUserQuery"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rscLibOper As ADODB.Recordset
Dim frmCont As Control
Dim RigS As Variant
'Dim CnLibOoper As clsCon '
Private Sub Display()
Dim num As Integer
Dim StrCheck As String
Dim strENC_Dec1 As String
For Each frmCont In Controls
If TypeOf frmCont Is TextBox Then
Set frmCont.DataSource = rscLibOper
frmCont.Locked = True
End If
Next
txtPassWConf.Visible = False
Label4.Visible = False
txtOperID.DataField = "operid"
txtOperName.DataField = "opername"
If rscLibOper!Password <> Empty Then '解密
strENC_Dec1 = rscLibOper!Password
txtPassword.Text = passEncrypt_Decrypt(strENC_Dec1)
Else
txtPassword.Text = rscLibOper!Password
End If
txtOperAddress.DataField = "address"
txtOperTel.DataField = "tel"
StrCheck = rscLibOper.Fields("rights")
For num = 0 To 6
' Set chkOperRights(num).DataSource = rscLibOper
chkOperRights(num).Enabled = False
Next
For num = 0 To 6
RigS = Mid(StrCheck, num + 1, 1)
chkOperRights(num).Value = RigS
Next
Exit Sub
End Sub
Private Sub chkOperRights_Click(Index As Integer)
Dim i As Integer
RigS = Empty
For i = 0 To 6
RigS = RigS & chkOperRights(i).Value
Next
rscLibOper!rights = RigS
End Sub
Private Sub Form_Load()
Set cnn = New clsCon
cnn.connect (ServerName)
Set rscLibOper = New ADODB.Recordset
rscLibOper.Open "select * from operator", cnn.c, adOpenDynamic, _
adLockPessimistic
ToolbarOPer.Buttons(5).Visible = False
RigS = Empty
Display
End Sub
Private Sub Form_Unload(Cancel As Integer)
' cnn.c.Close
'Set cnn.c = Nothing
End Sub
Private Sub ToolbarOPer_ButtonClick(ByVal Button As MSComctlLib.Button)
Dim num As Integer
Dim strENC_Dec As String
Select Case Button.Index
Case 1 '关闭窗体
' rscLibOper.Close
Unload frmUserQuery
Case 2 '添加记录
rscLibOper.AddNew
AmendFPNL_T
For num = 0 To 6
chkOperRights(num).Enabled = True '权限管理清零
chkOperRights(num).Value = 0
Next
ToolbarOPer.Buttons(2).Enabled = False
ToolbarOPer.Buttons(3).Enabled = False
ToolbarOPer.Buttons(4).Enabled = False
Case 3 '删除记录
Dim KeyDel As Integer
KeyDel = MsgBox("确实要删除这条记录吗?", 49, "系统提示")
If KeyDel = vbOK Then
rscLibOper.Delete
txtPassword.Text = ""
Else
Exit Sub
End If
If rscLibOper.RecordCount = 0 Then Exit Sub
rscLibOper.MoveNext
If rscLibOper.EOF Then rscLibOper.MoveLast
Display
Case 4 '修改记录
AmendFPNL_T
ToolbarOPer.Buttons(2).Enabled = False
txtPassword.Text = passEncrypt_Decrypt(rscLibOper!Password)
txtPassWConf.Text = passEncrypt_Decrypt(rscLibOper!Password)
For num = 0 To 6
chkOperRights(num).Enabled = True '权限管理可用
Next
Case 5 '保存记录 updata
If txtOperID.Text = "" Or txtOperName.Text = "" Then
MsgBox "用户ID 和用户姓名必须填写!", 48, "系统提示"
txtOperID.SetFocus
' End If
ElseIf RigS = Empty Or RigS = "0000000" Then
MsgBox "请选择用户权限!", 48, "系统提示"
' End If
ElseIf txtPassword.Text = txtPassWConf.Text Then
strENC_Dec = txtPassWConf.Text '加密
rscLibOper!Password = passEncrypt_Decrypt(strENC_Dec)
rscLibOper.Update
strENC_Dec = Empty
AmendFPNL_F
Else
txtPassword.Text = Empty
txtPassWConf.Text = Empty
txtPassword.SetFocus
MsgBox "密码验证有误,请重新输入密码," & Chr(13) & "密码最长十位。", 48, "系统提示"
End If
Case 6 '取消操作 '浏览记录
'On Error Resume Next
rscLibOper.CancelUpdate
'Set rscLibOper = New ADODB.Recordset
'rscLibOper.Open "operator", CNnLibrary, adOpenKeyset, _
' adLockPessimistic, adCmdTable
If rscLibOper.RecordCount = 0 Then Exit Sub
rscLibOper.MoveLast
AmendFPNL_F
Display
Case 7 '查询记录
On Error Resume Next
frmInputS.Show 1, frmUserQuery
If operSQLcancel Then Exit Sub
'记录重定位
If optSel = 1 Then
rscLibOper.MoveFirst
rscLibOper.Find "operid='" & OperSQLsTring & "'"
Display
Else
rscLibOper.MoveFirst
rscLibOper.Find "opername ='" & OperSQLsTring & "'"
Display
End If
If Err.Number = 3021 Then
MsgBox "没有该记录!", 48, "系统提示"
rscLibOper.MoveLast
Display
End If
Case 8 '第一条记录
If rscLibOper.RecordCount = 0 Then Exit Sub
rscLibOper.MoveFirst
Display
Case 9 '前移
If rscLibOper.RecordCount = 0 Then Exit Sub
rscLibOper.MovePrevious
If rscLibOper.BOF Then rscLibOper.MoveFirst
Display
Case 10 '后移
If rscLibOper.RecordCount = 0 Then Exit Sub
rscLibOper.MoveNext
If rscLibOper.EOF Then rscLibOper.MoveLast
Display
Case 11 '最后一条记录
If rscLibOper.RecordCount = 0 Then Exit Sub
rscLibOper.MoveLast
Display
End Select
End Sub
Private Sub AmendFPNL_T() '修改钮被点击时
Dim i As Integer
For Each frmCont In Controls
If TypeOf frmCont Is TextBox Then
Set frmCont.DataSource = rscLibOper
frmCont.Locked = False
End If
Next
ToolbarOPer.Buttons(5).Visible = True
For i = 8 To 11
ToolbarOPer.Buttons(i).Enabled = False
Next
txtPassWConf.Visible = True
Label4.Visible = True
txtPassword.Text = ""
End Sub
Private Sub AmendFPNL_F()
Dim i As Integer
For Each frmCont In Controls
If TypeOf frmCont Is TextBox Then
Set frmCont.DataSource = rscLibOper
frmCont.Locked = True
End If
Next
ToolbarOPer.Buttons(5).Visible = False
For i = 8 To 11
ToolbarOPer.Buttons(i).Enabled = True
Next
For i = 0 To 6
chkOperRights(i).Enabled = False
Next
txtPassWConf.Visible = False
txtPassWConf.Text = ""
Label4.Visible = False
ToolbarOPer.Buttons(2).Enabled = True
ToolbarOPer.Buttons(3).Enabled = True
ToolbarOPer.Buttons(4).Enabled = True
End Sub
Private Sub txtOperID_KeyPress(KeyAscii As Integer)
TextKey_Check KeyAscii
End Sub
Private Sub txtOperTel_KeyPress(KeyAscii As Integer)
If Not (IsNumeric(Chr(KeyAscii)) Or KeyAscii = 8) Then
KeyAscii = 0
End If
End Sub
Private Sub txtPassWConf_KeyPress(KeyAscii As Integer)
TextKey_Check KeyAscii
End Sub
Private Sub TextKey_Check(KeyAscii As Integer)
If Not (IsNumeric(Chr(KeyAscii)) Or KeyAscii = 8 _
Or (KeyAscii >= 65 And KeyAscii <= 90) _
Or (KeyAscii >= 97 And KeyAscii <= 122)) Then
KeyAscii = 0
MsgBox "这里只允许输入字母或数字", 48, "系统提示"
End If
End Sub
Private Sub txtPassword_KeyPress(KeyAscii As Integer)
TextKey_Check KeyAscii
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -