📄 adduser.frm
字号:
VERSION 5.00
Begin VB.Form adduser
BorderStyle = 3 'Fixed Dialog
Caption = "新用户登录"
ClientHeight = 2595
ClientLeft = 3585
ClientTop = 3150
ClientWidth = 3990
Icon = "adduser.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2595
ScaleWidth = 3990
ShowInTaskbar = 0 'False
Begin VB.TextBox Text3
BackColor = &H00C0FFFF&
Height = 390
IMEMode = 3 'DISABLE
Left = 1200
PasswordChar = "*"
TabIndex = 7
Top = 1440
Width = 2535
End
Begin VB.TextBox Text2
BackColor = &H00C0FFFF&
Height = 390
IMEMode = 3 'DISABLE
Left = 1200
PasswordChar = "*"
TabIndex = 5
Top = 840
Width = 2535
End
Begin VB.TextBox Text1
BackColor = &H00C0FFFF&
Height = 375
Left = 1200
TabIndex = 3
Top = 240
Width = 2535
End
Begin VB.CommandButton CancelButton
Cancel = -1 'True
Caption = "取消"
Height = 375
Left = 2880
TabIndex = 1
Top = 2040
Width = 855
End
Begin VB.CommandButton OKButton
Caption = "确定"
Default = -1 'True
Height = 375
Left = 1800
TabIndex = 0
Top = 2040
Width = 855
End
Begin VB.Image Image1
Height = 480
Left = 4200
Picture = "adduser.frx":08CA
Top = 360
Width = 480
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "验证:"
Height = 180
Left = 240
TabIndex = 6
Top = 1560
Width = 540
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "密码:"
Height = 180
Left = 240
TabIndex = 4
Top = 960
Width = 540
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "新用户名:"
Height = 180
Left = 240
TabIndex = 2
Top = 360
Width = 900
End
End
Attribute VB_Name = "adduser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public upok As Boolean
Private Sub CancelButton_Click()
Unload Me
upok = False
End Sub
Private Sub okButton_Click()
On Error GoTo errh
Dim adu As ADODB.Recordset
Set adu = New ADODB.Recordset
'Dim adu As New Recordset
If Trim(Text1.Text) <> Empty Then
Dim sqladu As String
sqladu = "SELECT Username FROM 技术人员 WHERE Username =" & "'" & Trim(Text1.Text) & "'"
Call adu.open(sqladu, cn, adOpenKeyset, adLockOptimistic, -1)
'Set adu = cn.Execute("SELECT Username FROM 技术人员 WHERE Username =" & "'" & Trim(Text1.Text) & "'")
If adu.EOF Then
adu.Close '用户名未使用
Else
MsgBox "该用户名已使用!", , adduser.Caption
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Exit Sub
End If
If Trim(Text2.Text) <> Empty Then
If Trim(Text3.Text) = Trim(Text2.Text) Then
adu.LockType = adLockOptimistic
adu.CursorType = adOpenKeyset
adu.open "技术人员", cn, , , adCmdTable
adu.AddNew
adu.Fields("Password").Value = Trim(Text2.Text)
adu.Fields("UserName").Value = Trim(Text1.Text)
adu.Update
adu.Close
Me.Hide
upok = True
MsgBox "新用户添加成功", , adduser.Caption
Else
MsgBox "密码错误,请重新输入!", , adduser.Caption
Text2.Text = ""
Text3.Text = ""
End If
Else
MsgBox "密码不能为空,请输入密码!", , adduser.Caption
Text2.Text = ""
Text3.Text = ""
End If
Else
MsgBox "用户名不能为空", , adduser.Caption
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End If
Exit Sub
errh:
MsgBox Err.Description
End Sub
Private Sub Form_Load()
MakeCenter adduser
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -