?? frm_sys.frm
字號:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Frm_sys
BorderStyle = 3 'Fixed Dialog
Caption = "用戶管理"
ClientHeight = 3645
ClientLeft = 3645
ClientTop = 2925
ClientWidth = 4470
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3645
ScaleWidth = 4470
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command1
Caption = "增加"
Height = 350
Left = 1005
TabIndex = 11
Top = 3240
Width = 795
End
Begin MSComctlLib.ImageList ImageList1
Left = 600
Top = 4530
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 24
ImageHeight = 24
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 1
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Frm_sys.frx":0000
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.ListView ListView1
Height = 1950
Left = 105
TabIndex = 10
Top = 75
Width = 4245
_ExtentX = 7488
_ExtentY = 3440
LabelWrap = -1 'True
HideSelection = -1 'True
_Version = 393217
Icons = "ImageList1"
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 0
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 3630
Top = 5550
Width = 2415
_ExtentX = 4260
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
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 Cmd_Cancel
Caption = "取消"
Height = 350
Left = 3540
TabIndex = 6
Top = 3240
Width = 795
End
Begin VB.CommandButton Cmd_Add
Caption = "保存"
Height = 350
Left = 1845
TabIndex = 4
Top = 3240
Width = 795
End
Begin VB.CommandButton Cmd_Del
Caption = "刪除"
Height = 350
Left = 2685
TabIndex = 5
Top = 3240
Width = 795
End
Begin VB.Frame Frame2
Caption = "用戶信息"
Height = 1095
Left = 135
TabIndex = 0
Top = 2100
Width = 4215
Begin VB.TextBox Text4
Height = 300
IMEMode = 3 'DISABLE
Left = 2985
PasswordChar = "*"
TabIndex = 9
Top = 675
Width = 1095
End
Begin VB.TextBox Text3
Height = 300
IMEMode = 3 'DISABLE
Left = 990
PasswordChar = "*"
TabIndex = 8
Top = 660
Width = 1065
End
Begin VB.TextBox Text1
Height = 300
Left = 1005
TabIndex = 7
Top = 240
Width = 1050
End
Begin VB.Label Label3
Caption = "確認密碼"
Height = 225
Left = 2130
TabIndex = 3
Top = 720
Width = 855
End
Begin VB.Label Label2
Caption = "用戶密碼"
Height = 195
Left = 135
TabIndex = 2
Top = 750
Width = 855
End
Begin VB.Label Label1
Caption = "用戶名稱"
Height = 255
Left = 135
TabIndex = 1
Top = 285
Width = 855
End
End
End
Attribute VB_Name = "Frm_sys"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim a
'用戶注冊信息的事件代碼
Private Sub cmd_add_Click()
If Text1.Text = "" Or Text3.Text = "" Then
MsgBox "輸入的用戶注冊信息不完全!!", , "提示信息"
Else
On Error Resume Next
'判斷注冊的用戶名是否存在
Adodc1.RecordSource = "select * from 用戶信息 where 用戶名='" + Text1 + "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "該用戶名已經存在,請您更換其他用戶名!", 48, "提示信息"
'如果該用戶名存在則重新輸入
Text1.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
Else
If Text3.Text = Text4.Text Then '判斷兩次輸入的密碼是否一致
DB_AdoRs.Open "select * from 用戶信息 where 用戶名='" + Text1.Text + "'", Cnn, adOpenKeyset
If DB_AdoRs.RecordCount > 0 Then
DB_AdoRs.MoveLast
Dim StrId
StrId = Val(DB_AdoRs.Fields("編號")) + 1
Else
StrId = 1
End If
'保存注冊信息
Set DB_AdoRs = Cnn.Execute("insert into 用戶信息 values(" & StrId & ",'" & Text1 & "','" & Text3 & "')")
MsgBox "注冊成功!!", 48, "信息提示"
Adodc1.ConnectionString = MyStrs
Adodc1.RecordSource = "select * from 用戶信息"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
ListView1.Enabled = True
ListView1.ListItems.Clear
Adodc1.Recordset.MoveFirst
'將操作員信息添加到ListView控件當中
Do While Adodc1.Recordset.EOF = False
key = Adodc1.Recordset.Fields("用戶名")
Set itmX = ListView1.ListItems.Add(, , key, 1)
Adodc1.Recordset.MoveNext
Loop
End If
Text1.Text = ""
Text3.Text = ""
Text4.Text = ""
DB_AdoRs.Close
Else
MsgBox "兩次輸入的密碼不一致,請重新輸入", 48, "信息提示"
Text3.Text = ""
Text4.Text = ""
Text3.SetFocus
End If
End If
End If
End Sub
Private Sub cmd_del_Click()
If Text1.Text = "Admin" Then
MsgBox "超級用戶不能夠被刪除", 48, "提示信息"
Else
If Text1.Text = Name1 Then '如果是當前登錄的用戶名,則不允許刪除
MsgBox "不能刪除當前用戶名!!", 48, "提示信息"
Else
a = MsgBox("您確認要刪除該用戶嗎?", 17, "刪除用戶信息提示")
If a = vbOK Then
Adodc1.RecordSource = "select * from 用戶信息 where 用戶名='" + Text1.Text + "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.Delete '如果數據庫中存在該用戶信息,則將其刪除
MsgBox "用戶信息刪除成功", 64, "刪除用戶信息提示"
Adodc1.ConnectionString = MyStrs
Adodc1.RecordSource = "select * from 用戶信息"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
ListView1.Enabled = True
ListView1.ListItems.Clear
Adodc1.Recordset.MoveFirst
Do While Adodc1.Recordset.EOF = False '將操作員信息添加到ListView控件當中
key = Adodc1.Recordset.Fields("用戶名")
Set itmX = ListView1.ListItems.Add(, , key, 1)
Adodc1.Recordset.MoveNext
Loop
End If
Text1.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
Else
MsgBox "當前數據庫中沒有可刪除的用戶信息", , "信息提示"
End If
End If
End If
End If
End Sub
Private Sub Cmd_Cancel_Click()
Unload Me
End Sub
Private Sub Command1_Click()
Text1.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = MyStrs
Adodc1.RecordSource = "select * from 用戶信息"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
ListView1.Enabled = True
'清空ListView控件中的元素信息
ListView1.ListItems.Clear
Adodc1.Recordset.MoveFirst
Do While Adodc1.Recordset.EOF = False
'將操作員信息添加到ListView控件當中
key = Adodc1.Recordset.Fields("用戶名")
Set itmX = ListView1.ListItems.Add(, , key, 1)
Adodc1.Recordset.MoveNext
Loop
Else
ListView1.Enabled = False
End If
End Sub
Private Sub ListView1_Click()
Adodc1.RecordSource = "select * from 用戶信息 where 用戶名='" + ListView1.SelectedItem + "'"
Adodc1.Refresh
On Error Resume Next
If Adodc1.Recordset.RecordCount > 0 Then
Text1.Text = Adodc1.Recordset.Fields("用戶名")
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -