?? 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 + -