📄 frmadduser.frm
字号:
VERSION 5.00
Begin VB.Form frmAddUser
Caption = "添加用户"
ClientHeight = 4320
ClientLeft = 60
ClientTop = 345
ClientWidth = 5970
LinkTopic = "Form1"
ScaleHeight = 4320
ScaleWidth = 5970
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Caption = "添加用户"
Height = 3855
Left = 240
TabIndex = 0
Top = 240
Width = 5535
Begin VB.TextBox Text6
Height = 375
Left = 1200
TabIndex = 14
Top = 2640
Width = 3135
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 1080
TabIndex = 12
Top = 3360
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "返回"
Height = 375
Left = 3360
TabIndex = 11
Top = 3360
Width = 1215
End
Begin VB.TextBox Text2
Height = 375
Left = 1200
TabIndex = 5
Top = 720
Width = 1575
End
Begin VB.TextBox Text4
Height = 375
Left = 1200
TabIndex = 4
Top = 1680
Width = 1575
End
Begin VB.TextBox Text3
Height = 375
Left = 1200
TabIndex = 3
Top = 1200
Width = 1575
End
Begin VB.TextBox Text5
Height = 375
Left = 1200
TabIndex = 2
Top = 2160
Width = 1575
End
Begin VB.TextBox Text1
Height = 375
Left = 1200
TabIndex = 1
Top = 240
Width = 1575
End
Begin VB.Label Label7
Caption = "密码长度为3~8数字或英文字母"
Height = 255
Left = 2880
TabIndex = 15
Top = 1320
Width = 2535
End
Begin VB.Label Label6
Caption = "联系地址:"
Height = 255
Left = 360
TabIndex = 13
Top = 2760
Width = 855
End
Begin VB.Label Label1
Caption = "用户名:"
Height = 255
Left = 360
TabIndex = 10
Top = 360
Width = 735
End
Begin VB.Label Label2
Caption = "用户编号:"
Height = 255
Left = 360
TabIndex = 9
Top = 840
Width = 855
End
Begin VB.Label Label3
Caption = "密码:"
Height = 255
Left = 360
TabIndex = 8
Top = 1320
Width = 855
End
Begin VB.Label Label4
Caption = "确认密码:"
Height = 255
Left = 360
TabIndex = 7
Top = 1800
Width = 855
End
Begin VB.Label Label5
Caption = "联系电话:"
Height = 255
Left = 360
TabIndex = 6
Top = 2280
Width = 855
End
End
End
Attribute VB_Name = "frmAddUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim strempl As String
Dim rs_empl As New ADODB.Recordset
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "请输入用户名!", vbOKOnly + vbInformation, "提示"
Text1.SetFocus
Exit Sub
ElseIf Text2.Text = "" Then
MsgBox "请输入用户编号!", vbOKOnly + vbInformation, "提示"
Text2.SetFocus
Exit Sub
ElseIf Text3.Text = "" Then
MsgBox "请输入密码!", vbOKOnly + vbInformation, "提示"
Text3.SetFocus
Exit Sub
ElseIf Text4.Text = "" Then
MsgBox "请输入确认密码!", vbOKOnly + vbInformation, "提示"
Text4.SetFocus
Exit Sub
ElseIf Text5.Text = "" Then
MsgBox "请输入联系电话!", vbOKOnly + vbInformation, "提示"
Text5.SetFocus
Exit Sub
ElseIf Text6.Text = "" Then
MsgBox "请输入联系地址!", vbOKOnly + vbInformation, "提示"
Text6.SetFocus
Exit Sub
End If
If Len(Text3.Text) < 3 Or Len(Text3.Text) > 8 Then
MsgBox "密码长度不符合要求!", vbOKOnly + vbInformation, "提示"
Text3.Text = ""
Text3.SetFocus
Exit Sub
End If
If Text3.Text <> Text4.Text Then
MsgBox "两次输入的密码不一致!", vbOKOnly + vbInformation, "注意"
Text3.Text = ""
Text4.Text = ""
Text3.SetFocus
Exit Sub
End If
strempl = "select * from employee where 员工编号='" & Text2.Text & "'"
rs_empl.Open strempl, cnn, adOpenKeyset, adLockOptimistic
If rs_empl.EOF = True Then
rs_empl.AddNew
rs_empl.Fields("员工编号") = Text2.Text
rs_empl.Fields("员工密码") = Text3.Text
rs_empl.Fields("员工姓名") = Text1.Text
rs_empl.Fields("员工电话") = Text5.Text
rs_empl.Fields("员工地址") = Text6.Text
rs_empl.Update
rs_empl.Close
Else
MsgBox "该用户名已存在,请重新输入!", vbOKOnly + vbInformation, "注意"
rs_empl.Close
Exit Sub
End If
MsgBox "添加用户成功!", vbOKOnly + vbInformation, ""
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -