📄 adduser.frm
字号:
VERSION 5.00
Begin VB.Form addUser
Caption = "添加用户"
ClientHeight = 3270
ClientLeft = 60
ClientTop = 450
ClientWidth = 4905
LinkTopic = "Form4"
ScaleHeight = 3270
ScaleWidth = 4905
StartUpPosition = 3 '窗口缺省
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access 2000;"
DatabaseName = "C:\Documents and Settings\Administrator\桌面\11.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 615
Left = 4080
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "UserTable"
Top = 2400
Visible = 0 'False
Width = 1140
End
Begin VB.TextBox Text3
Height = 615
IMEMode = 3 'DISABLE
Left = 2040
PasswordChar = "*"
TabIndex = 7
Top = 1680
Width = 1815
End
Begin VB.TextBox Text2
Height = 615
IMEMode = 3 'DISABLE
Left = 2040
PasswordChar = "*"
TabIndex = 6
Top = 960
Width = 1935
End
Begin VB.TextBox Text1
Height = 495
Left = 2040
TabIndex = 5
Top = 240
Width = 1935
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 495
Left = 2040
TabIndex = 4
Top = 2520
Width = 1575
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 495
Left = 240
TabIndex = 2
Top = 2520
Width = 1455
End
Begin VB.Label Label3
Caption = "请确认密码"
Height = 495
Left = 240
TabIndex = 3
Top = 1680
Width = 1455
End
Begin VB.Label Label2
Caption = "请输入密码"
Height = 375
Left = 120
TabIndex = 1
Top = 960
Width = 1455
End
Begin VB.Label Label1
Caption = "请输入用户名"
Height = 495
Left = 240
TabIndex = 0
Top = 240
Width = 1215
End
End
Attribute VB_Name = "addUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
If UserName = Trim(Data1.Recordset.Fields(0)) Then
If Trim(Data1.Recordset.Fields(2)) = 0 Then
Me.Hide
MsgBox "您不是管理员,无权进行此操作!", vbOKOnly + vbExclamation, "警告"
Exit Sub
Else
If Text1.Text = "" Then
MsgBox "请输入用户名!", vbOKOnly + vbExclamation, "警告 "
Text1.SetFocus
Else
txtSQL = "select * from UserTable"
While (Data1.Recordset.EOF = False)
If Data1.Recordset.Fields("UserName").Value = Text1.Text Then
MsgBox "用户已经存在,请重新输入用户名!", vbOKOnly + vbExclamation, "警告 "
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Exit Sub
Else
Data1.Recordset.MoveNext
End If
Wend
End If
End If
End If
If Trim(Text2.Text) <> Trim(Text3.Text) Then
MsgBox "两次输入的密码不一样,请确认!", vbOKOnly + vbExclamation, "警告"
Text2.SetFocus
Text2.Text = ""
Text3.Text = ""
Exit Sub
Else
If Text2.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbExclamation, "警告"
Text2.SetFocus
Text2.Text = ""
Text3.Text = ""
Else
Data1.Recordset.AddNew
Data1.Recordset.Fields("UserName").Value = Text1.Text
Data1.Recordset.Fields("PassWord").Value = Text2.Text
Data1.Recordset.Fields("Type").Value = 0
Data1.Recordset.Update
Me.Hide
MsgBox "添加用户成功!", vbOKOnly + vbExclamation, "添加用户"
End If
End If
End Sub
Private Sub Command2_Click()
Me.Text1.SetFocus
Me.Text1.Text = ""
Me.Text2.Text = ""
Me.Text3.Text = ""
End Sub
Private Sub Form_Load()
Me.Data1.DatabaseName = App.Path + "\11.mdb"
Me.Data1.RecordSource = "UserTable"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -