📄 adduser.frm
字号:
VERSION 5.00
Begin VB.Form frmAdduser
BorderStyle = 1 'Fixed Single
Caption = "添加用户"
ClientHeight = 2445
ClientLeft = 6330
ClientTop = 3675
ClientWidth = 4185
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2445
ScaleWidth = 4185
Begin VB.TextBox Text1
Height = 375
Left = 1320
TabIndex = 4
Top = 240
Width = 2535
End
Begin VB.TextBox Text2
Height = 375
IMEMode = 3 'DISABLE
Left = 1320
MaxLength = 20
PasswordChar = "*"
TabIndex = 3
Top = 720
Width = 2535
End
Begin VB.ComboBox Combo1
Height = 300
ItemData = "adduser.frx":0000
Left = 1320
List = "adduser.frx":000A
TabIndex = 2
Text = "用户类型"
Top = 1200
Width = 2535
End
Begin VB.CommandButton Command1
Caption = "插入"
Height = 375
Left = 600
TabIndex = 1
Top = 1800
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 375
Left = 2520
TabIndex = 0
Top = 1800
Width = 1095
End
Begin VB.Label Label1
Caption = "用户名:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 7
Top = 240
Width = 975
End
Begin VB.Label Label2
Caption = "口 令:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 6
Top = 720
Width = 975
End
Begin VB.Label Label3
Caption = "用户类型:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 5
Top = 1200
Width = 1215
End
End
Attribute VB_Name = "frmAdduser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim Sql As String
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
If Text1.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbExclamation, "提示"
Text1.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "口令不能为空!", vbOKOnly + vbExclamation, "提示"
Text2.SetFocus
Exit Sub
End If
If Combo1.Text <> "超级用户" And Combo1.Text <> "普通用户" Then
MsgBox "请选择用户类型!", vbOKOnly + vbExclamation, "提示"
Combo1.SetFocus
Exit Sub
End If
'插入数据库
'先看数据库中有无此用户
Sql = "select Username from userinfo where Username='" & Trim(Text1.Text) & "'"
If mExecuteSql(Sql, Rs) = False Then
MsgBox "插入失败!", vbOKOnly + vbCritical, "信息"
End If
If Not Rs.EOF Then '有记录说明存在此用户名
MsgBox "此用户已存在!", vbOKOnly + vbExclamation, "重复"
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
Rs.Close
'插入数据库
Dim i As String
If Combo1.Text = "超级用户" Then
i = "0"
Else
i = "1"
End If
Sql = "insert into userinfo(Username,Userpassword,Usertype) values('" & LCase(Text1.Text) & "','" & _
Text2.Text & "','" & _
i & "')"
If mExecuteSql(Sql, Rs) = False Then
MsgBox "添加用户失败,错误未知!", vbOKOnly + vbCritical, "错误"
Exit Sub
End If
'插入列表中
With Userm
.grid.Rows = .grid.Rows + 1
i = .grid.Rows - 1
.grid.TextMatrix(i, 0) = Text1.Text
.grid.TextMatrix(i, 1) = Text2.Text
.grid.TextMatrix(i, 2) = Combo1.Text
End With
MsgBox "插入成功!", vbOKOnly + vbInformation, "成功"
Text1.Text = ""
Text2.Text = ""
Combo1.Text = "用户类型"
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -