?? frmregme.frm
字號:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form FrmRegMe
BorderStyle = 3 'Fixed Dialog
Caption = "創建會員帳號"
ClientHeight = 4485
ClientLeft = 45
ClientTop = 330
ClientWidth = 7290
Icon = "FrmRegMe.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4485
ScaleWidth = 7290
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 5760
Top = 3840
Visible = 0 'False
Width = 1215
_ExtentX = 2143
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton CmdClose
Cancel = -1 'True
Caption = "關閉(&C)"
Height = 375
Left = 4440
TabIndex = 8
Top = 3840
Width = 1095
End
Begin VB.TextBox TxtUName
Height = 390
Left = 1560
TabIndex = 1
Top = 720
Width = 2655
End
Begin VB.OptionButton OptionMan
Caption = "男"
Height = 255
Left = 1560
TabIndex = 10
Top = 1320
Value = -1 'True
Width = 495
End
Begin VB.OptionButton OptionFemail
Caption = "女"
Height = 255
Left = 2280
TabIndex = 9
Top = 1320
Width = 495
End
Begin VB.TextBox TxtUDanWei
Height = 390
Left = 1560
TabIndex = 2
Top = 1680
Width = 2655
End
Begin VB.TextBox TxtUDiZhi
Height = 390
Left = 1560
TabIndex = 3
Top = 2160
Width = 2655
End
Begin VB.TextBox TxtUMail
Height = 390
Left = 1560
TabIndex = 4
Top = 2640
Width = 2655
End
Begin VB.TextBox TxtUDianHua
Height = 390
Left = 1560
TabIndex = 5
Top = 3120
Width = 2655
End
Begin VB.TextBox TxtUMemo
Height = 3255
Left = 4440
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 6
Top = 255
Width = 2655
End
Begin VB.CommandButton CmdRegMe
Caption = "創建(&D)"
Height = 375
Left = 1560
TabIndex = 7
Top = 3840
Width = 1095
End
Begin VB.TextBox TxtCard
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 1
EndProperty
Height = 390
Left = 1560
TabIndex = 0
Top = 240
Width = 2655
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "姓名:"
Height = 180
Left = 750
TabIndex = 18
Top = 810
Width = 540
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "性別:"
Height = 180
Left = 750
TabIndex = 17
Top = 1275
Width = 540
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "單位:"
Height = 180
Left = 750
TabIndex = 16
Top = 1770
Width = 540
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "地址:"
Height = 180
Left = 750
TabIndex = 15
Top = 2250
Width = 540
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "E-mail:"
Height = 180
Left = 570
TabIndex = 14
Top = 2730
Width = 720
End
Begin VB.Label Label29
AutoSize = -1 'True
Caption = "電話:"
Height = 180
Left = 750
TabIndex = 13
Top = 3210
Width = 540
End
Begin VB.Label Label30
AutoSize = -1 'True
Caption = "人生格言:"
Height = 180
Left = 3360
TabIndex = 12
Top = 1320
Width = 900
End
Begin VB.Label Label31
AutoSize = -1 'True
Caption = "會員帳(卡)號:"
Height = 180
Left = 120
TabIndex = 11
Top = 330
Width = 1260
End
End
Attribute VB_Name = "FrmRegMe"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Function checkUserID(UID As String) As Boolean
Dim userDB As Database
Dim userRD As Recordset
Dim dbName As String
Dim STRSQL As String
Screen.MousePointer = 11
On Error GoTo errEnd
dbName = App.Path
If Right(dbName, 1) <> "\" Then dbName = dbName + "\"
dbName = dbName + "DataBase\WFSSDataBase.mdb"
STRSQL = "select [用戶身份] from [Admin] where [用戶ID]=""" & UID & """"
'打開數據庫
Set userDB = DBEngine.Workspaces(0).OpenDatabase(dbName, False, True)
'檢索用戶,驗證密碼
Set userRD = userDB.OpenRecordset(STRSQL, dbOpenSnapshot)
If userRD.RecordCount > 0 Then
'關閉數據庫
userRD.Close
Set userRD = Nothing
userDB.Close
Set userDB = Nothing
checkUserID = True
Screen.MousePointer = vbDefault
Else
'關閉數據庫
userRD.Close
Set userRD = Nothing
userDB.Close
Set userDB = Nothing
Screen.MousePointer = vbDefault
checkUserID = False
End If
Exit Function
errEnd:
Screen.MousePointer = vbDefault
MsgBox Err.Description, vbOKOnly + vbExclamation, "創建會員帳號"
Err.Clear
'關閉數據庫
userRD.Close
Set userRD = Nothing
userDB.Close
Set userDB = Nothing
End Function
Private Sub CmdClose_Click()
Unload Me
End Sub
Private Sub CmdRegMe_Click()
On Error GoTo errEnd
If TxtCard.Text = "" Then
MsgBox "請填寫會員卡號!", vbOKOnly + vbExclamation, "會員注冊"
TxtCard.SetFocus
Exit Sub
End If
If TxtUName.Text = "" Then
MsgBox "請填寫會員的姓名!", vbOKOnly + vbExclamation, "會員注冊"
TxtUName.SetFocus
Exit Sub
End If
If TxtUDanWei.Text = "" Then
MsgBox "請填寫會員所在單位!", vbOKOnly + vbExclamation, "會員注冊"
TxtUDanWei.SetFocus
Exit Sub
End If
If TxtUDiZhi.Text = "" Then
MsgBox "請填寫會員的地址!", vbOKOnly + vbExclamation, "會員注冊"
TxtUDiZhi.SetFocus
Exit Sub
End If
If TxtUMail.Text = "" Then TxtUMail.Text = "無"
If TxtUDianHua.Text = "" Then TxtUDianHua.Text = "無"
If TxtUMemo.Text = "" Then TxtUMemo.Text = "無"
If checkUserID(TxtCard.Text) Then
MsgBox "這個會員卡號已經被注冊!請另選一個!", vbOKOnly + vbExclamation, "會員注冊"
TxtCard.SelStart = 0
TxtCard.SelLength = Len(TxtCard.Text)
TxtCard.SetFocus
Exit Sub
End If
BeginTrans
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "會員表"
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset!會員卡號 = TxtCard.Text
Adodc1.Recordset!會員等級 = "☆☆☆☆☆"
Adodc1.Recordset!姓名 = TxtUName.Text
If OptionMan.Value Then
Adodc1.Recordset!性別 = "男"
Else
Adodc1.Recordset!性別 = "女"
End If
Adodc1.Recordset!地址 = TxtUDiZhi.Text
Adodc1.Recordset!單位 = TxtUDanWei.Text
Adodc1.Recordset!電子郵件 = TxtUMail.Text
Adodc1.Recordset!電話 = TxtUDianHua.Text
Adodc1.Recordset!人生格言 = TxtUMemo.Text
Adodc1.Recordset!注冊日期 = Now()
Adodc1.Recordset.Update
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "Admin"
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset!用戶ID = TxtCard.Text
Adodc1.Recordset!用戶密碼 = TxtCard.Text
Adodc1.Recordset!用戶身份 = "會員"
Adodc1.Recordset.Update
CommitTrans
MsgBox "恭喜你,注冊成功!" & vbCrLf & "會員的帳號和密碼就是你填寫的會員卡號!" & vbCrLf & "請會員自行修改密碼或立即修改密碼。", vbOKOnly + vbQuestion, "注冊成功"
TxtCard.Text = ""
TxtUName.Text = ""
TxtUDanWei.Text = ""
TxtUDiZhi.Text = ""
TxtUMail.Text = ""
TxtUDianHua.Text = ""
TxtUMemo.Text = ""
Exit Sub
errEnd:
Rollback
MsgBox "注冊失敗,操作數據庫發生錯誤!", vbOKOnly + vbExclamation, "注冊失敗"
End Sub
Private Sub Form_Load()
Dim dbName As String
Dim connSTR As String
On Error GoTo errEnd
dbName = App.Path
If Right(dbName, 1) <> "\" Then dbName = dbName + "\"
dbName = dbName + "DataBase\WFSSDataBase.mdb"
connSTR = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbName & ";Persist Security Info=False"
Adodc1.ConnectionString = connSTR
Exit Sub
errEnd:
MsgBox Err.Description, vbOKOnly + vbExclamation, "打開數據庫出錯"
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -