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

📄 frmsysusermanage.frm

📁 小区物业管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form SysUserManage 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "系统用户管理"
   ClientHeight    =   2070
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4365
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   2070
   ScaleWidth      =   4365
   Begin VB.TextBox txtPWD 
      DataField       =   "口令"
      DataSource      =   "Adodc1"
      Height          =   270
      Left            =   1080
      MaxLength       =   6
      TabIndex        =   9
      Top             =   600
      Width           =   2175
   End
   Begin VB.CommandButton cmdAdd 
      Caption         =   "添加"
      Height          =   300
      Left            =   3360
      TabIndex        =   8
      Top             =   180
      Width           =   735
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "删除"
      Height          =   300
      Left            =   3360
      TabIndex        =   7
      Top             =   495
      Width           =   735
   End
   Begin VB.CommandButton cmdExit 
      Cancel          =   -1  'True
      Caption         =   "关闭"
      Height          =   300
      Left            =   3360
      TabIndex        =   6
      Top             =   1455
      Width           =   735
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "保存"
      Height          =   300
      Left            =   3360
      TabIndex        =   5
      Top             =   810
      Width           =   735
   End
   Begin VB.CommandButton cmdRefresh 
      Caption         =   "刷新"
      Height          =   300
      Left            =   3360
      TabIndex        =   4
      Top             =   1140
      Width           =   735
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   480
      Top             =   1440
      Width           =   2775
      _ExtentX        =   4895
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   2
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   3
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "DSN=物管数据DSN"
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   "物管数据DSN"
      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.ComboBox cmbStatus 
      DataField       =   "身份"
      DataSource      =   "Adodc1"
      Height          =   300
      ItemData        =   "frmSysUserManage.frx":0000
      Left            =   1080
      List            =   "frmSysUserManage.frx":000A
      TabIndex        =   3
      Text            =   "cmbStatus"
      Top             =   1005
      Width           =   2175
   End
   Begin VB.TextBox txtUser 
      DataField       =   "用户名"
      DataSource      =   "Adodc1"
      Height          =   270
      Left            =   1080
      Locked          =   -1  'True
      MaxLength       =   13
      TabIndex        =   0
      Top             =   195
      Width           =   2175
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "口  令"
      Height          =   180
      Left            =   480
      TabIndex        =   10
      Top             =   645
      Width           =   540
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "身  份"
      Height          =   180
      Left            =   480
      TabIndex        =   2
      Top             =   1065
      Width           =   540
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "用户名"
      Height          =   180
      Left            =   480
      TabIndex        =   1
      Top             =   240
      Width           =   540
   End
End
Attribute VB_Name = "SysUserManage"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim objCopy As New Recordset, isAdding As Boolean
Private Sub Adodc1_MoveComplete(ByVal adReason As EventReasonEnum, _
        ByVal pError As Error, adStatus As EventStatusEnum, ByVal pRecordset As Recordset)
    With Adodc1.Recordset
        If .AbsolutePosition > 0 Then
            Adodc1.Caption = "当前记录:" & .AbsolutePosition & "/" & .RecordCount
        Else
            Adodc1.Caption = "无系统用户数据"
        End If
    End With
End Sub


Private Sub cmdExit_Click()
    Unload Me               '关闭系统用户管理窗体
End Sub

Private Sub Form_Load()
    Set objCopy = Adodc1.Recordset.Clone        '创建Adodc1记录集副本
    cmdRefresh.Value = True                     '执行刷新操作
End Sub

'验证口令输入
Private Sub txtPWD_KeyPress(KeyAscii As Integer)
    If Not (KeyAscii >= vbKey0 And KeyAscii <= vbKey9 _
                Or KeyAscii >= vbKeyA And KeyAscii <= vbKeyZ _
                Or KeyAscii >= vbKeyA And KeyAscii <= vbKeyZ _
                Or KeyAscii = vbKeyBack) Then
        KeyAscii = 0    '输入不是数字、英文字母或退格键,取消输入
    End If
End Sub

'验证用户名输入
Private Sub txtUserName_KeyPress(KeyAscii As Integer)
    If Not (KeyAscii >= Asc("a") And KeyAscii <= Asc("z") _
                Or KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") _
                Or KeyAscii = vbKeyBack) Then
        '如果输入不是英文字母或退格键,则取消输入
        KeyAscii = 0
    End If
End Sub

Private Sub Adodc1_WillChangeRecord(ByVal adReason As EventReasonEnum, _
        ByVal cRecords As Long, adStatus As EventStatusEnum, ByVal pRecordset As Recordset)
    If Trim(txtUser) = "" Then
        MsgBox "用户名不能为空!", vbCritical, "系统用户管理"
        txtUser = "": txtUser.SetFocus
    ElseIf Trim(txtPWD) = "" Then
        MsgBox "口令为空!", vbCritical, "系统用户管理"
        txtPWD = "": txtPWD.SetFocus
    ElseIf Trim(cmbStatus) = "" Then
        MsgBox "用户身份不能为空!", vbCritical, "系统用户管理"
        cmbStatus = "": cmbStatus.SetFocus
    End If
End Sub

Private Sub cmdAdd_Click()
    Adodc1.Recordset.AddNew     '添加新记录
    cmdAdd.Enabled = False      '在保存新记录之前禁用
    cmbStatus.ListIndex = 1
    cmdDelete.Enabled = False: Adodc1.Enabled = False
    txtUser.Locked = False: isAdding = True
End Sub

Private Sub cmdDelete_Click()
    With Adodc1.Recordset
        If Not .EOF Then
            If MsgBox("将删除" & Trim(txtUser) & ",是否继续?", _
                       vbCritical + vbYesNo, "系统用户管理") = vbYes Then
                .Delete
                .MoveNext
                If .EOF And .RecordCount > 0 Then .MoveLast
            End If
        End If
    End With
End Sub

Private Sub cmdRefresh_Click()
    Adodc1.Refresh                                  '刷新记录集
    cmdAdd.Enabled = True                           '启用控件
    cmdDelete.Enabled = True: Adodc1.Enabled = True
    txtUser.Locked = True: isAdding = False
    Set objCopy = Adodc1.Recordset.Clone
End Sub

Private Sub cmdSave_Click()
    If Trim(txtUser) = "" Then
        MsgBox "用户名不能为空!", vbCritical, "系统用户管理"
        txtUser = "": txtUser.SetFocus
    ElseIf Trim(txtPWD) = "" Then
        MsgBox "口令为空!", vbCritical, "系统用户管理"
        txtPWD = "": txtPWD.SetFocus
    ElseIf Trim(cmbStatus) = "" Then
        MsgBox "用户身份不能为空!", vbCritical, "系统用户管理"
        cmbStatus = "": cmbStatus.SetFocus
    Else
        With objCopy
            If .RecordCount > 0 Then
                .MoveFirst
                .Find "用户名='" & Trim(txtUser) & "'"
                If Not .EOF And .AbsolutePosition <> Adodc1.Recordset.AbsolutePosition Then
                    MsgBox "用户名:" & Trim(txtUser) & "已被使用,请使用其他用户名!", _
                    vbCritical, "系统用户管理"
                    txtUser.SetFocus
                    txtUser.SelStart = 0: txtUser.SelLength = Len(txtUser)
                    Exit Sub
                End If
            End If
        End With
        Adodc1.Recordset.Update
        MsgBox "数据保存成功!", vbInformation, "系统用户管理"
        cmdAdd.Enabled = True
        cmdDelete.Enabled = True: Adodc1.Enabled = True
        txtUser.Locked = True: isAdding = False
        Set objCopy = Adodc1.Recordset.Clone
    End If
End Sub

Private Sub txtUser_Change()
    If Trim(txtUser) = "" Or isAdding Then cmdAdd.Enabled = False _
    Else cmdAdd.Enabled = True
End Sub
Private Sub txtPWD_Change()
    If Trim(txtPWD) = "" Or isAdding Then cmdAdd.Enabled = False _
    Else: cmdAdd.Enabled = True
End Sub
Private Sub cmbStatus_Change()
    If Trim(cmbStatus) = "" Or isAdding Then cmdAdd.Enabled = False _
    Else cmdAdd.Enabled = True
End Sub

⌨️ 快捷键说明

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