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

📄 frmuserma.frm

📁 this is my first software.
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmUserMa 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "用户管理"
   ClientHeight    =   3285
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6975
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   3285
   ScaleWidth      =   6975
   StartUpPosition =   1  '所有者中心
   Begin VB.CommandButton cmdExit 
      Caption         =   "退出(&X)"
      Height          =   390
      Left            =   6000
      TabIndex        =   13
      Top             =   2790
      Width           =   870
   End
   Begin VB.CommandButton cmdDel 
      Caption         =   "删除(&D)"
      Height          =   390
      Left            =   4920
      TabIndex        =   12
      Top             =   2790
      Width           =   870
   End
   Begin VB.CommandButton cmdModify 
      Caption         =   "修改(&E)"
      Height          =   390
      Left            =   3960
      TabIndex        =   11
      Top             =   2790
      Width           =   870
   End
   Begin VB.Frame Frame1 
      Caption         =   "增加状态"
      Height          =   3135
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   3255
      Begin VB.CommandButton cmdCancle 
         Caption         =   "取消(&C)"
         Height          =   375
         Left            =   1680
         TabIndex        =   6
         Top             =   2640
         Width           =   855
      End
      Begin VB.CommandButton cmdAdd 
         Caption         =   "增加(&A)"
         Default         =   -1  'True
         Height          =   375
         Left            =   480
         TabIndex        =   5
         Top             =   2640
         Width           =   855
      End
      Begin VB.TextBox txtName 
         Height          =   300
         Left            =   1680
         TabIndex        =   4
         ToolTipText     =   "请输入你的真实姓名:"
         Top             =   1920
         Width           =   1215
      End
      Begin VB.TextBox txtPwd2 
         Height          =   300
         IMEMode         =   3  'DISABLE
         Left            =   1680
         MaxLength       =   50
         PasswordChar    =   "*"
         TabIndex        =   3
         Top             =   1440
         Width           =   1215
      End
      Begin VB.TextBox txtPwd 
         Height          =   300
         IMEMode         =   3  'DISABLE
         Left            =   1680
         MaxLength       =   50
         PasswordChar    =   "*"
         TabIndex        =   2
         Top             =   960
         Width           =   1215
      End
      Begin VB.TextBox txtUsername 
         Height          =   300
         Left            =   1680
         TabIndex        =   1
         ToolTipText     =   "由字母或数字组成,不能输入汉字"
         Top             =   480
         Width           =   1215
      End
      Begin VB.Line Line1 
         BorderColor     =   &H00FF8080&
         X1              =   240
         X2              =   3000
         Y1              =   2400
         Y2              =   2400
      End
      Begin VB.Label Label4 
         Caption         =   "姓名(&N):"
         Height          =   255
         Left            =   240
         TabIndex        =   10
         Top             =   1920
         Width           =   855
      End
      Begin VB.Label Label3 
         Caption         =   "确认密码"
         Height          =   255
         Left            =   240
         TabIndex        =   9
         Top             =   1440
         Width           =   855
      End
      Begin VB.Label Label2 
         Caption         =   "密码(&P):"
         Height          =   255
         Left            =   240
         TabIndex        =   8
         Top             =   960
         Width           =   1095
      End
      Begin VB.Label Label1 
         Caption         =   "用户名(&U):"
         Height          =   255
         Left            =   240
         TabIndex        =   7
         Top             =   480
         Width           =   1095
      End
   End
   Begin MSDataGridLib.DataGrid DataGridUser 
      Height          =   2175
      Left            =   3510
      TabIndex        =   14
      Top             =   510
      Width           =   3285
      _ExtentX        =   5794
      _ExtentY        =   3836
      _Version        =   393216
      AllowUpdate     =   0   'False
      HeadLines       =   1
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin MSAdodcLib.Adodc AdodcUser 
      Height          =   330
      Left            =   3480
      Top             =   2400
      Visible         =   0   'False
      Width           =   1500
      _ExtentX        =   2646
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      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.TextBox Text1 
      Enabled         =   0   'False
      Height          =   2250
      Left            =   3480
      Locked          =   -1  'True
      TabIndex        =   15
      TabStop         =   0   'False
      Top             =   480
      Width           =   3375
   End
   Begin VB.Label Label5 
      Caption         =   "现有操作员列表(&L)"
      Height          =   255
      Left            =   3480
      TabIndex        =   16
      Top             =   240
      Width           =   1575
   End
End
Attribute VB_Name = "frmUserMa"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private editmode As Boolean

Private Sub cmdAdd_Click()
    '首先判断各个控件内容是符合要求
    '************************************************
    If txtUsername.Text = "" Then
        MsgBox ("请输入你的用户名!")
        txtUsername.SetFocus
        Exit Sub
    End If
    If txtPwd.Text = "" Then
        MsgBox ("请输入你的密码!")
        txtPwd.SetFocus
        Exit Sub
    End If
    If txtPwd.Text <> txtPwd2.Text Then
        MsgBox ("两次密码输入不一致!请重新输入!")
        txtPwd2.Text = ""
        txtPwd.SetFocus
        SendKeys "{home}+{end}"
        Exit Sub
    End If
    If txtName.Text = "" Then
        MsgBox ("请填入你的真实姓名!")
        Exit Sub
    End If
    '**************************************************
    cn.Open
    Set rs.ActiveConnection = cn
    rs.LockType = adLockOptimistic
    rs.CursorType = adOpenKeyset
    
    If cmdAdd.Caption = "增加(&A)" Then
        rs.Open "用户密码表"
        rs.Find ("用户名 = '" & txtUsername.Text & "'")
        If rs.EOF Then
            rs.Find ("姓名='" & txtName.Text & "'")
            If rs.EOF Then
                rs.AddNew
            Else
                MsgBox "这个用户已经存在,请换一个用户名!"
                txtName.SelStart = 0
                txtName.SelLength = Len(txtName.Text)
                Exit Sub
            End If
        Else
            MsgBox "这个用户名已经存在,请换一个用户名!"
            txtUsername.SelStart = 0
            txtUsername.SelLength = Len(txtUsername.Text)
            
            Exit Sub
        End If
    Else        '此时为修改状态
        rs.Open "select * from 用户密码表 where 用户名 = '" & txtUsername.Text & "'"
    End If
    rs!用户名 = txtUsername.Text
    rs!密码 = txtPwd.Text
    rs!姓名 = txtName.Text
    rs.Update
    rs.Close
    cn.Close
    
    AdodcUser.RecordSource = "select 用户名,姓名 from 用户密码表"
    Set DataGridUser.DataSource = AdodcUser
    AdodcUser.Refresh
    
    If txtUsername.Locked = True Then txtUsername.Locked = False
    cmdCancle_Click     '将各个控件置为初始状态
End Sub

Private Sub cmdCancle_Click()
    txtUsername.Text = ""
    txtPwd.Text = ""
    txtPwd2.Text = ""
    txtName.Text = ""
    txtUsername.SetFocus
    
    If editmode Then
        cmdModify.Enabled = True
        txtUsername.Locked = False
        cmdDel.Enabled = True
        cmdAdd.Caption = "增加(&A)"
    End If
End Sub

Private Sub cmdDel_Click()
    Dim ret As Integer
    ret = MsgBox("真的要删除当前记录吗?", vbYesNo, "提示")
    If ret = vbNo Then
        Exit Sub
    End If
    cn.Open
    Set rs.ActiveConnection = cn
    rs.LockType = adLockOptimistic
    rs.CursorType = adOpenKeyset
    rs.Open "select * from 用户密码表 where 用户名= '" & AdodcUser.Recordset!用户名 & "'"
    rs.Delete
    rs.Update
    rs.Close
    cn.Close
    AdodcUser.RecordSource = "select 用户名,姓名 from 用户密码表"
    Set DataGridUser.DataSource = AdodcUser
    AdodcUser.Refresh
    
End Sub

Private Sub cmdExit_Click()
    Unload Me
End Sub

Private Sub cmdModify_Click()
    cn.Open
    Set rs.ActiveConnection = cn
    rs.LockType = adLockOptimistic
    rs.CursorType = adOpenKeyset
    
    rs.Open "select * from 用户密码表 where 用户名= '" & AdodcUser.Recordset!用户名 & "'"
    
    txtUsername.Text = rs!用户名
    txtPwd.Text = rs!密码
    txtPwd2.Text = rs!密码
    txtName.Text = rs!姓名
    txtUsername.Locked = True
    rs.Close
    cn.Close
    '此时应使删除按钮和修改按钮失效
    cmdDel.Enabled = False
    cmdModify.Enabled = False
    '将增加按钮改为保存
    cmdAdd.Caption = "保存"
    editmode = True
End Sub
Private Sub Form_Load()
    AdodcUser.ConnectionString = connectString
    AdodcUser.RecordSource = "select 用户名,姓名 from 用户密码表"
    Set DataGridUser.DataSource = AdodcUser
    AdodcUser.Refresh
End Sub



⌨️ 快捷键说明

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