📄 添加新用户.frm
字号:
VERSION 5.00
Begin VB.Form 新用户添加
Caption = "添加新用户"
ClientHeight = 5535
ClientLeft = 4560
ClientTop = 2445
ClientWidth = 7350
LinkTopic = "Form2"
Picture = "添加新用户.frx":0000
ScaleHeight = 5535
ScaleWidth = 7350
Begin VB.ComboBox quanxian
Height = 300
Left = 2520
TabIndex = 9
Top = 2880
Width = 2295
End
Begin VB.CommandButton canl
Caption = "取消"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 3120
TabIndex = 7
Top = 3960
Width = 1215
End
Begin VB.CommandButton ok
Caption = "确认"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 720
TabIndex = 6
Top = 3960
Width = 1215
End
Begin VB.TextBox Text3
Height = 495
Left = 2520
TabIndex = 5
Top = 2040
Width = 2295
End
Begin VB.TextBox Text2
Height = 495
Left = 2520
TabIndex = 4
Top = 1200
Width = 2295
End
Begin VB.TextBox Text1
Height = 495
Left = 2520
TabIndex = 3
Top = 480
Width = 2295
End
Begin VB.Label Label4
Caption = "选择级别"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 240
TabIndex = 8
Top = 2880
Width = 1815
End
Begin VB.Label Label3
Caption = "请确认密码"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 240
TabIndex = 2
Top = 2040
Width = 1815
End
Begin VB.Label Label2
Caption = "请输入密码"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 240
TabIndex = 1
Top = 1320
Width = 1815
End
Begin VB.Label Label1
Caption = "请输入用户名"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 240
TabIndex = 0
Top = 480
Width = 1935
End
End
Attribute VB_Name = "新用户添加"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim mycon As ADODB.Connection
Dim myres As ADODB.Recordset
Dim myres1 As ADODB.Recordset
Private Sub canl_Click()
Unload Me
canl.Caption = "取消"
系统主页.Show
mycon.Close
Set mycon = Nothing
End Sub
Private Sub ok_Click()
If myres.Fields("权限") <> "高级" Then
MsgBox "你的权限不够,不能添加新用户!", vbOKOnly + vbExclamation, ""
Exit Sub
End If
If Trim(Text1.Text) = "" Then
MsgBox "用户名不能为空", vbOKOnly + vbExclamation, ""
Exit Sub
Text1.SetFocus
End If
If Trim(Text2.Text) = "" Then
MsgBox "密码不能为空", vbOKOnly + vbExclamation, ""
Exit Sub
Text2.SetFocus
End If
If Trim(Text2.Text) <> Trim(Text3.Text) Then
MsgBox "两次密码不一致", vbOKOnly + vbExclamation, ""
Text2.SetFocus
Text2.Text = ""
Text3.Text = ""
Exit Sub
End If
Set myres1 = mycon.Execute("select * from 管理员信息 where 用户名='" & Text1.Text & "'")
If myres1.EOF And myres1.BOF Then
mycon.Execute ("insert into 管理员信息 values('" & Text1.Text & "','" & Text2.Text & "','" & quanxian.Text & "')")
MsgBox "添加新用户成功!", vbOKOnly + vbExclamation, ""
canl.Caption = "退出"
Else
MsgBox "用户名已存在,请重新选择用户名!", vbOKOnly + vbExclamation, ""
Exit Sub
Text1.SetFocus
End If
End Sub
Private Sub Form_Load()
Set mycon = New ADODB.Connection
mycon.Open "dsn=my", "sa"
Set myres = New ADODB.Recordset
myres.Open "select * from 管理员信息 where 用户名='" & yonghuming & "'", mycon, adOpenDynamic, adLockOptimistic
quanxian.AddItem "高级"
quanxian.AddItem "低级"
quanxian.Text = ""
Text2.Text = "": Text2.PasswordChar = "*"
Text3.Text = "": Text3.PasswordChar = "*"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -