⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmuseradmin.frm

📁 这是我们公司的题库管理系统
💻 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 + -