📄 adduser.frm
字号:
VERSION 5.00
Begin VB.Form addUser
BorderStyle = 1 'Fixed Single
Caption = "注册用户"
ClientHeight = 2640
ClientLeft = 45
ClientTop = 330
ClientWidth = 3255
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2640
ScaleWidth = 3255
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
Caption = "用户信息"
Height = 1935
Left = 120
TabIndex = 2
Top = 120
Width = 3015
Begin VB.TextBox Text1
Height = 300
Left = 1440
TabIndex = 5
Top = 360
Width = 1215
End
Begin VB.TextBox Text2
Height = 300
Left = 1440
TabIndex = 4
Top = 840
Width = 1215
End
Begin VB.TextBox Text3
Height = 300
IMEMode = 3 'DISABLE
Left = 1440
PasswordChar = "*"
TabIndex = 3
Top = 1320
Width = 1215
End
Begin VB.Label Label1
Caption = "用户编号:"
Height = 255
Left = 360
TabIndex = 8
Top = 410
Width = 1095
End
Begin VB.Label Label2
Caption = "用 户 名:"
Height = 255
Left = 360
TabIndex = 7
Top = 890
Width = 1095
End
Begin VB.Label Label3
Caption = "密 码:"
Height = 255
Left = 360
TabIndex = 6
Top = 1370
Width = 1095
End
End
Begin VB.CommandButton Command1
Caption = "保存数据(&S)"
Height = 375
Left = 240
TabIndex = 1
ToolTipText = "注册新用户"
Top = 2160
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "返回(&B)"
Height = 375
Left = 1800
TabIndex = 0
Top = 2160
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()
Dim MRC As ADODB.Recordset
Dim mrc1 As ADODB.Recordset
Dim MsgText As String
Dim txtSQL As String
Dim txtSQL1 As String
If Not Testtxt(Text1.Text) Then
MsgBox "请输入用户编号!", vbOKOnly + vbApplicationModal, "成绩管理系统"
Text1.SetFocus
Exit Sub
End If
If Not Testtxt(Text2.Text) Then
MsgBox "请输入用户名!", vbOKOnly + vbApplicationModal, "成绩管理系统"
Text2.SetFocus
Exit Sub
End If
If Not Testtxt(Text3.Text) Then
MsgBox "请输入密码!", vbOKOnly + vbApplicationModal, "成绩管理系统"
Combo1.SetFocus
Exit Sub
End If
'---------------------下面一段代码用于保证表[userLogin]和[userinfo]之间的参照完整型-------------------
txtSQL1 = "select * from userinfo where userID='" & Text1.Text & "'"
txtSQL = "select * from userlogin"
Set mrc1 = ExecuteSQL(txtSQL1, MsgText)
If (mrc1.EOF) Then
MsgBox "您的用户编号是'" & Text1.Text & "',[用户信息表]中没有您的记录,您无法注册成为系统的合法用户!", vbOKOnly + vbCritical, "警告"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Exit Sub
'-----------------------------------------------------------------------------------------------------
Else
Set MRC = ExecuteSQL(txtSQL, MsgText)
'---------------------下面一段代码用于保证表[userLogin]中每条记录的用户编号和用户名均不相同-------------------
While (MRC.EOF = False)
If ((Trim(MRC.Fields(0)) = Trim(Text1.Text)) And (Trim(MRC.Fields(1)) <> Trim(Text2.Text))) Then
MsgBox "用户编号'" & Text1.Text & "'已经存在,请正确填写您的用户编号!", vbOKOnly + vbExclamation, "成绩管理系统"
Text1.Text = ""
Text1.SetFocus
Exit Sub
ElseIf ((Trim(MRC.Fields(0)) <> Trim(Text1.Text)) And (Trim(MRC.Fields(1)) = Trim(Text2.Text))) Then
MsgBox "用户名'" & Text2.Text & "'已经存在,请重新选择用户名!", vbOKOnly + vbExclamation, "成绩管理系统"
Text2.Text = ""
Text2.SetFocus
Exit Sub
'---------------------------------------------------------------------------------------------------------
Else
MRC.MoveNext
End If
Wend
MRC.Close
End If
'=======================================使用INSERT语句添加数据========================================================================================
txtSQL = "insert into userlogin values('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "','No Authority',1,'Student')"
Set MRC = ExecuteSQL(txtSQL, MsgText)
Call Module1.JUDGE(MsgText, addUser)
mrc1.Close
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
'======================================================================================================================================================
End Sub
Private Sub Command2_Click()
frmLogin.Show
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -