?? frmuseradmin.frm
字號:
VERSION 5.00
Begin VB.Form frmUserAdmin
BorderStyle = 3 'Fixed Dialog
Caption = "用戶管理"
ClientHeight = 3195
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 6030
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3195
ScaleWidth = 6030
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton DELButton
Caption = "刪除用戶"
Height = 375
Left = 4680
TabIndex = 4
Top = 720
Width = 1215
End
Begin VB.ListBox List1
Height = 2040
Left = 360
TabIndex = 2
Top = 600
Width = 3975
End
Begin VB.CommandButton CancelButton
Caption = "關閉"
Height = 375
Left = 4680
TabIndex = 1
Top = 1200
Width = 1215
End
Begin VB.CommandButton ADDButton
Caption = "添加用戶"
Height = 375
Left = 4680
TabIndex = 0
Top = 240
Width = 1215
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "用戶列表:"
Height = 180
Left = 360
TabIndex = 3
Top = 240
Width = 900
End
End
Attribute VB_Name = "frmUserAdmin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub addButton_Click()
sSQL = "select * from USER_PASSWORD"
rs.CursorLocation = adUseClient
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Open sSQL, cnn
rs.AddNew
userNameEditable = True
frmUserAddEdit.Show 1
End Sub
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub DELButton_Click()
Dim Response As String
If List1.Text <> "" Then
Response = MsgBox("確定要刪除選定的用戶嗎?", vbQuestion + vbOKCancel)
If Response = vbOK Then
sSQL = "select * from USER_PASSWORD where USER_NAME = '" & List1.Text & "'"
rs.CursorLocation = adUseClient
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Open sSQL, cnn
rs.Delete
rs.Close
Form_Activate
End If
Else
MsgBox "請選擇要刪除的用戶!", vbInformation + vbOKOnly
End If
End Sub
Private Sub Form_Activate()
sSQL = "select USER_NAME from USER_PASSWORD"
' 打開連接
Set cnn = New Connection
cnn.Open sConnect
' 使用提供的集合創建 recordset
Set rs = New Recordset
rs.CursorLocation = adUseClient
rs.Open sSQL, cnn, adOpenForwardOnly, adLockReadOnly
loadList
rs.Close
End Sub
Private Sub Form_Terminate()
On Error Resume Next
If Not rs Is Nothing Then
rs.Close
Set rs = Nothing
End If
If Not cnn Is Nothing Then
cnn.Close
Set cnn = Nothing
End If
End Sub
Private Sub loadList()
Dim i As Integer
List1.Clear
For i = 1 To rs.RecordCount
List1.AddItem rs!USER_NAME
rs.MoveNext
Next i
End Sub
Private Sub List1_DblClick()
sSQL = "select * from USER_PASSWORD where USER_NAME = '" & List1.Text & "'"
rs.CursorLocation = adUseClient
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Open sSQL, cnn
frmUserAddEdit.txtUserName = rs!USER_NAME
frmUserAddEdit.txtPassword = rs!USER_PW
Select Case rs!GROUP_ID
Case 1
frmUserAddEdit.Option1.Value = True
Case 2
frmUserAddEdit.Option2.Value = True
Case 3
frmUserAddEdit.Option3.Value = True
Case 4
frmUserAddEdit.Option4.Value = True
Case 5
frmUserAddEdit.Option5.Value = True
End Select
userNameEditable = False
frmUserAddEdit.Show 1
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -