📄 frmadduser.frm
字号:
VERSION 5.00
Begin VB.Form 添加用户
BorderStyle = 1 'Fixed Single
Caption = "添加用户"
ClientHeight = 4080
ClientLeft = 30
ClientTop = 330
ClientWidth = 7185
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
Picture = "frmAdduser.frx":0000
ScaleHeight = 4080
ScaleWidth = 7185
Begin VB.OptionButton OpManag
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "管理员"
ForeColor = &H80000008&
Height = 255
Left = 4080
TabIndex = 10
Top = 2280
Width = 1215
End
Begin VB.OptionButton OpComm
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "一般用户"
ForeColor = &H80000008&
Height = 255
Left = 2760
Picture = "frmAdduser.frx":46C2
TabIndex = 9
Top = 2280
Value = -1 'True
Width = 1335
End
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 375
Left = 4440
TabIndex = 7
Top = 3600
Width = 1335
End
Begin VB.CommandButton cmdOK
Caption = "确认"
Height = 375
Left = 1560
TabIndex = 6
Top = 3600
Width = 1335
End
Begin VB.TextBox Text1
Height = 375
IMEMode = 3 'DISABLE
Index = 2
Left = 2760
PasswordChar = "*"
TabIndex = 3
Top = 1440
Width = 2175
End
Begin VB.TextBox Text1
Height = 375
IMEMode = 3 'DISABLE
Index = 1
Left = 2760
PasswordChar = "*"
TabIndex = 2
Top = 720
Width = 2175
End
Begin VB.TextBox Text1
Height = 375
Index = 0
Left = 2760
TabIndex = 0
Top = 0
Width = 2175
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "用户类型:"
Height = 375
Left = 1320
TabIndex = 8
Top = 2280
Width = 1335
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "请确认密码:"
Height = 375
Left = 1320
TabIndex = 5
Top = 1680
Width = 1455
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "请输入密码:"
Height = 375
Left = 1320
TabIndex = 4
Top = 840
Width = 1455
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "请输入用户名:"
Height = 375
Left = 1320
TabIndex = 1
Top = 120
Width = 1710
End
End
Attribute VB_Name = "添加用户"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim txtSQL As String
Dim mrc As ADODB.Recordset
Dim MsgText As String
If UserName <> "Admin" Then
'判断用户的权限
MsgBox "只有超级管理员才有此权限!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
If Trim(Text1(0).Text) = "" Then
'判断用户名输入是否为空
MsgBox "请输入用户名称!", vbOKOnly + vbExclamation, "警告"
Exit Sub
Text1(0).SetFocus
Else
txtSQL = "select * from Manager "
Set mrc = ExecuteSQL(txtSQL, MsgText)
While (mrc.EOF = False)
If Trim(mrc.Fields(0)) = Trim(Text1(0)) Then
'判断是否有重复记录
MsgBox "用户已经存在,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
Text1(0).SetFocus
Text1(0).Text = ""
Text1(1).Text = ""
Text1(2).Text = ""
Exit Sub
Else
mrc.MoveNext
End If
Wend
End If
If Trim(Text1(1).Text) <> Trim(Text1(2).Text) Then
'判断两次所输入的密码是否一致
MsgBox "两次输入密码不一样,请确认!", vbOKOnly + vbExclamation, "警告"
Text1(1).SetFocus
Text1(1).Text = ""
Text1(2).Text = ""
Exit Sub
Else
If Text1(1).Text = "" Then
'判断密码输入是否为空
MsgBox "密码不能为空!", vbOKOnly + vbExclamation, "警告"
Text1(1).SetFocus
Text1(1).Text = ""
Text1(2).Text = ""
Else
mrc.AddNew
'添加用户
mrc.Fields(0) = Trim(Text1(0).Text)
mrc.Fields(1) = Trim(Text1(1).Text)
If OpComm.Value = True Then
mrc.Fields(2) = 0
Else
mrc.Fields(2) = 1
End If
mrc.Update
mrc.Close
Me.Hide
MsgBox "添加用户成功!", vbOKOnly + vbExclamation, "添加用户"
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -