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

📄 userform.frm

📁 运动会管理系统 运动会管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form UserForm 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "用户浏览窗口"
   ClientHeight    =   6060
   ClientLeft      =   45
   ClientTop       =   405
   ClientWidth     =   8490
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   6060
   ScaleWidth      =   8490
   Begin VB.Frame Frame1 
      Caption         =   "编辑区域"
      Height          =   5535
      Left            =   120
      TabIndex        =   2
      Top             =   240
      Width           =   3255
      Begin VB.CommandButton delBnt 
         Caption         =   "删除"
         Height          =   375
         Left            =   840
         TabIndex        =   11
         Top             =   3600
         Width           =   1215
      End
      Begin VB.CommandButton editBnt 
         Caption         =   "修改"
         Height          =   375
         Left            =   840
         TabIndex        =   10
         Top             =   3000
         Width           =   1215
      End
      Begin VB.CommandButton addBnt 
         Caption         =   "添加"
         Height          =   375
         Left            =   840
         TabIndex        =   9
         Top             =   2400
         Width           =   1215
      End
      Begin VB.TextBox txtPwd 
         Height          =   270
         IMEMode         =   3  'DISABLE
         Left            =   1320
         PasswordChar    =   "*"
         TabIndex        =   8
         Top             =   1440
         Width           =   1815
      End
      Begin VB.TextBox txtLoginName 
         Height          =   270
         Left            =   1320
         TabIndex        =   7
         Top             =   960
         Width           =   1815
      End
      Begin VB.TextBox txtUserName 
         Height          =   270
         Left            =   1320
         TabIndex        =   6
         Top             =   480
         Width           =   1815
      End
      Begin VB.Label Label3 
         Caption         =   "登录密码:"
         Height          =   255
         Left            =   120
         TabIndex        =   5
         Top             =   1440
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "登录名:"
         Height          =   255
         Left            =   120
         TabIndex        =   4
         Top             =   960
         Width           =   855
      End
      Begin VB.Label Label1 
         Caption         =   "用户名:"
         Height          =   255
         Left            =   120
         TabIndex        =   3
         Top             =   480
         Width           =   975
      End
   End
   Begin VB.Frame userlist 
      Caption         =   "系统用户列表"
      Height          =   5535
      Left            =   3480
      TabIndex        =   0
      Top             =   240
      Width           =   4815
      Begin MSFlexGridLib.MSFlexGrid MSF 
         Height          =   5175
         Left            =   120
         TabIndex        =   1
         Top             =   240
         Width           =   4455
         _ExtentX        =   7858
         _ExtentY        =   9128
         _Version        =   393216
         SelectionMode   =   1
      End
   End
End
Attribute VB_Name = "UserForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Sub classshowtitle()
 Dim i As Integer
 MSF.Clear
  With MSF
    .Cols = 4
    .TextMatrix(0, 1) = "用户名"
    .TextMatrix(0, 2) = "登录名"
    .TextMatrix(0, 3) = "登录密码"
    .ColWidth(0) = 100
    .ColWidth(1) = 1300
    .ColWidth(2) = 1200
    
    .FixedRows = 1
    For i = 1 To 3
      .ColAlignment(i) = 0
    Next i
    .FillStyle = flexFillSingle
    .Col = 0
    .Row = 0
    .RowSel = 1
    .ColSel = .Cols - 1
    .CellAlignment = 4
    .Row = 1
    End With
End Sub

Public Sub classshowdata()
Dim j As Integer
Dim i As Integer

Dim mrc1 As ADODB.Recordset
  strSql = "select * from user_info"
  Set mrc1 = ExecuteSQL(Trim(strSql))
  If mrc1.EOF = False Then
   mrc1.MoveFirst
   With MSF
    .Rows = 1
    Do While Not mrc1.EOF
     .Rows = .Rows + 1
     For i = 1 To mrc1.Fields.Count - 1
      .TextMatrix(.Rows - 1, i) = mrc1.Fields(i)
     Next i
     mrc1.MoveNext
    Loop
    mrc1.Close
 End With
 End If
End Sub

Private Sub addBnt_Click()
    If UserForm.txtUserName = "" Then
        MsgBox "用户名不能为空!", vbExclamation + vbOKOnly, "警告"
        UserForm.txtUserName.SetFocus
        Exit Sub
    Else
        strSql = "select * from user_info where user_info_name = '" & Trim(UserForm.txtUserName) & "'"
        Set rs = ExecuteSQL(strSql)
        If rs.EOF = False Then
         MsgBox "用户名已经存在!", vbExclamation + vbOKOnly, "警告"
         UserForm.txtUserName.SetFocus
         rs.Close
         Exit Sub
        End If
    End If
    If UserForm.txtLoginName = "" Then
        MsgBox "登录名不能为空!", vbExclamation + vbOKOnly, "警告"
        UserForm.txtLoginName.SetFocus
        Exit Sub
    Else
        strSql = "select * from user_info where user_info_loginname = '" & Trim(UserForm.txtLoginName) & "'"
        Set rs = ExecuteSQL(strSql)
        If rs.EOF = False Then
         MsgBox "登录名已经存在!", vbExclamation + vbOKOnly, "警告"
         UserForm.txtLoginName.SetFocus
         rs.Close
         Exit Sub
        End If
    End If
    If UserForm.txtPwd = "" Then
        MsgBox "密码不能为空!", vbExclamation + vbOKOnly, "警告"
        UserForm.txtPwd.SetFocus
        Exit Sub
    End If
    strSql = "insert into user_info (user_info_name,user_info_loginname,user_info_pwd) values('" & Trim(UserForm.txtUserName) & "','" & Trim(UserForm.txtLoginName) & "','" & Trim(UserForm.txtPwd) & "')"
    If ExecuteUpdateSQL(strSql) = True Then
        MsgBox "添加用户成功!", vbExclamation + vbOKOnly, "警告"
        UserForm.classshowdata
    Else
        MsgBox "添加用户失败!", vbExclamation + vbOKOnly, "警告"
    End If
End Sub

Private Sub delBnt_Click()
    If UserForm.txtUserName = "" Then
        MsgBox "用户名不能为空!", vbExclamation + vbOKOnly, "警告"
        UserForm.txtUserName.SetFocus
        Exit Sub
    Else
        strSql = "select * from user_info where user_info_name = '" & Trim(UserForm.txtUserName) & "'"
        Set rs = ExecuteSQL(strSql)
        If rs.EOF = True Then
         MsgBox "用户名不存在!", vbExclamation + vbOKOnly, "警告"
         UserForm.txtUserName.SetFocus
         rs.Close
         Exit Sub
        End If
    End If
    
    If MsgBox("确认删除用户" & UserForm.txtUserName, vbExclamation + vbOKCancel, "警告") = vbOK Then
        strSql = "delete from user_info where user_info_name = '" & Trim(UserForm.txtUserName) & "'"
        If ExecuteUpdateSQL(strSql) = True Then
            MsgBox "删除用户成功!", vbExclamation + vbOKOnly, "警告"
            UserForm.classshowdata
        Else
            MsgBox "删除用户失败!", vbExclamation + vbOKOnly, "警告"
        End If
    End If
End Sub

Private Sub editBnt_Click()
    If UserForm.txtUserName = "" Then
        MsgBox "用户名不能为空!", vbExclamation + vbOKOnly, "警告"
        UserForm.txtUserName.SetFocus
        Exit Sub
    Else
        strSql = "select * from user_info where user_info_name = '" & Trim(UserForm.txtUserName) & "'"
        Set rs = ExecuteSQL(strSql)
        If rs.EOF = True Then
         MsgBox "用户名不存在!", vbExclamation + vbOKOnly, "警告"
         UserForm.txtUserName.SetFocus
         rs.Close
         Exit Sub
        End If
    End If
    If UserForm.txtLoginName = "" Then
        MsgBox "登录名不能为空!", vbExclamation + vbOKOnly, "警告"
        UserForm.txtLoginName.SetFocus
        Exit Sub
    End If
    If UserForm.txtPwd = "" Then
        MsgBox "密码不能为空!", vbExclamation + vbOKOnly, "警告"
        UserForm.txtPwd.SetFocus
        Exit Sub
    End If
    
    strSql = "update user_info set user_info_loginname = '" & Trim(UserForm.txtLoginName) & "',user_info_pwd = '" & Trim(UserForm.txtPwd) & "' where user_info_name = '" & Trim(UserForm.txtUserName) & "'"
    If ExecuteUpdateSQL(strSql) = True Then
        MsgBox "修改用户信息成功!", vbExclamation + vbOKOnly, "警告"
        UserForm.classshowdata
    Else
        MsgBox "修改用户信息失败!", vbExclamation + vbOKOnly, "警告"
    End If
End Sub

Private Sub MSF_Click()
    UserForm.txtUserName = MSF.TextMatrix(MSF.RowSel, 1)
    UserForm.txtLoginName = MSF.TextMatrix(MSF.RowSel, 2)
    UserForm.txtPwd = MSF.TextMatrix(MSF.RowSel, 3)
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -