📄 frm_adduser.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form Frm_addUser
Caption = "添加用户"
ClientHeight = 3420
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3420
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 600
Top = 2280
Visible = 0 'False
Width = 2415
_ExtentX = 4260
_ExtentY = 582
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= 3
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "DSN=Adodc1"
OLEDBString = ""
OLEDBFile = ""
DataSourceName = "Adodc1"
OtherAttributes = ""
UserName = "sa"
Password = "sa"
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton Cmd_Cancel
Caption = "取消"
Height = 375
Left = 2760
TabIndex = 8
Top = 2880
Width = 855
End
Begin VB.CommandButton Cmd_OK
Caption = "确定"
Height = 375
Left = 960
TabIndex = 7
Top = 2880
Width = 855
End
Begin VB.Frame Frame1
Caption = "Frame1"
Height = 2535
Left = 240
TabIndex = 0
Top = 120
Width = 4095
Begin VB.OptionButton Option2
Caption = "Option2"
Height = 200
Left = 2600
TabIndex = 12
Top = 1800
Width = 255
End
Begin VB.OptionButton Option1
Caption = "Option1"
Height = 200
Left = 1560
TabIndex = 10
Top = 1800
Width = 255
End
Begin VB.TextBox txtSurePwd
Appearance = 0 'Flat
Height = 300
IMEMode = 3 'DISABLE
Left = 1800
PasswordChar = "*"
TabIndex = 6
Top = 1200
Width = 1500
End
Begin VB.TextBox txtPwd
Appearance = 0 'Flat
Height = 300
IMEMode = 3 'DISABLE
Left = 1800
PasswordChar = "*"
TabIndex = 4
Top = 720
Width = 1500
End
Begin VB.TextBox txtUser
Appearance = 0 'Flat
Height = 300
Left = 1800
TabIndex = 2
Top = 240
Width = 1500
End
Begin VB.Label Label6
Caption = "普通用户"
Height = 255
Left = 2880
TabIndex = 13
Top = 1800
Width = 855
End
Begin VB.Label Label5
Caption = "管理员"
Height = 375
Left = 1920
TabIndex = 11
Top = 1800
Width = 615
End
Begin VB.Label Label4
Caption = "用户类型"
Height = 255
Left = 480
TabIndex = 9
Top = 1800
Width = 855
End
Begin VB.Label Label3
Caption = "确认密码"
Height = 255
Left = 480
TabIndex = 5
Top = 1320
Width = 975
End
Begin VB.Label Label2
Caption = "输入密码"
Height = 255
Left = 480
TabIndex = 3
Top = 840
Width = 735
End
Begin VB.Label Label1
Caption = "输入用户名"
Height = 375
Left = 480
TabIndex = 1
Top = 360
Width = 1095
End
End
End
Attribute VB_Name = "Frm_addUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Cmd_Cancel_Click()
Unload Me
End Sub
Private Sub Cmd_OK_Click()
Dim usertype As Integer
'数据有效性检查
If txtUser = "" Then
MsgBox "请输入用户名"
txtUser.SetFocus
Exit Sub
End If
Adodc1.RecordSource = "SELECT * FROM Users WHERE User_name = '" + Trim(txtUser.Text) + "'"
Adodc1.Refresh
If Adodc1.Recordset.EOF = False Then
MsgBox "已经有此用户,请重新输入"
txtUser.SetFocus
Exit Sub
Else
If txtPwd = "" Then
MsgBox "请输入密码"
txtPwd.SetFocus
Exit Sub
End If
If txtSurePwd = "" Then
MsgBox "请确认密码"
txtSurePwd.SetFocus
Exit Sub
End If
If Option1 = True Then
usertype = 0
ElseIf Option2 = True Then
usertype = 1
Else
MsgBox "请选择用户类型"
Exit Sub
End If
If Len(txtPwd) < 6 Then
MsgBox "密码长度不能小于6"
txtPwd.SetFocus
txtPwd.SelStart = 0
txtPwd.SelLength = Len(txtPwd)
Exit Sub
End If
If txtPwd <> txtSurePwd Then
MsgBox "密码和确认密码不相同,请重新确认"
txtSurePwd.SetFocus
txtSurePwd.SelStart = 0
txtSurePwd.SelLength = Len(txtSurePwd)
Exit Sub
End If
'增加新用户
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields(0).Value = Trim(txtUser.Text)
Adodc1.Recordset.Fields(1).Value = Trim(txtPwd.Text)
Adodc1.Recordset.Fields(2).Value = usertype
Adodc1.Recordset.Update
Adodc1.Refresh
MsgBox "用户增加完成"
Unload Me
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -