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

📄 frmuser.frm

📁 一个用VB写的服装进销存源码
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmuser 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "用户管理"
   ClientHeight    =   5310
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   6240
   Icon            =   "frmuser.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5310
   ScaleWidth      =   6240
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin VB.Frame Frame1 
      Height          =   5235
      Left            =   120
      TabIndex        =   2
      Top             =   0
      Width           =   6015
      Begin VB.CommandButton cmdedit 
         Caption         =   "修改(&E)"
         Height          =   375
         Left            =   4560
         TabIndex        =   6
         Top             =   3720
         Width           =   1215
      End
      Begin VB.CheckBox chkifguanli 
         Caption         =   "是否是管理员"
         Height          =   180
         Left            =   4440
         TabIndex        =   4
         Top             =   2880
         Width           =   1455
      End
      Begin VB.TextBox txtName 
         Height          =   300
         Left            =   4140
         MaxLength       =   20
         TabIndex        =   0
         Top             =   540
         Width           =   1635
      End
      Begin VB.TextBox txtPass 
         Height          =   300
         IMEMode         =   3  'DISABLE
         Left            =   4140
         MaxLength       =   20
         PasswordChar    =   "*"
         TabIndex        =   1
         Top             =   1320
         Width           =   1635
      End
      Begin VB.TextBox txtRPass 
         Height          =   300
         IMEMode         =   3  'DISABLE
         Left            =   4140
         MaxLength       =   20
         PasswordChar    =   "*"
         TabIndex        =   3
         Top             =   2100
         Width           =   1635
      End
      Begin VB.CommandButton cmdAdd 
         Caption         =   "添加(&A)"
         Height          =   345
         Left            =   4560
         TabIndex        =   5
         Top             =   3240
         Width           =   1215
      End
      Begin VB.CommandButton cmdDel 
         Caption         =   "删除(&D)"
         Height          =   345
         Left            =   4560
         TabIndex        =   7
         Top             =   4200
         Width           =   1215
      End
      Begin VB.CommandButton cmdClose 
         Caption         =   "关闭(&C)"
         Height          =   345
         Left            =   4560
         TabIndex        =   8
         Top             =   4680
         Width           =   1215
      End
      Begin MSFlexGridLib.MSFlexGrid Grid1 
         Height          =   4515
         Left            =   180
         TabIndex        =   9
         Top             =   540
         Width           =   3555
         _ExtentX        =   6271
         _ExtentY        =   7964
         _Version        =   393216
         Cols            =   3
         FocusRect       =   0
         SelectionMode   =   1
         Appearance      =   0
         FormatString    =   "用户名    |密码      |        权限"
      End
      Begin VB.CommandButton cmdqueren 
         Caption         =   "确认(&E)"
         Height          =   375
         Left            =   4560
         TabIndex        =   14
         Top             =   3720
         Width           =   1215
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "用户名:"
         Height          =   180
         Index           =   0
         Left            =   4140
         TabIndex        =   13
         Top             =   240
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "密码:"
         Height          =   180
         Index           =   3
         Left            =   4140
         TabIndex        =   12
         Top             =   1020
         Width           =   540
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "重复密码:"
         Height          =   180
         Left            =   4140
         TabIndex        =   11
         Top             =   1800
         Width           =   900
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "用户列表"
         Height          =   180
         Left            =   180
         TabIndex        =   10
         Top             =   240
         Width           =   720
      End
   End
End
Attribute VB_Name = "frmuser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub fuzhiGrid() '定义赋值函数
    Dim rs As New ADODB.Recordset
    Dim i As Integer
    
    rs.open "select * from [admin]", cn
    Grid1.rows = rs.RecordCount + 1
    For i = 1 To rs.RecordCount
        Grid1.TextMatrix(i, 0) = rs!caozuoyuan
        Grid1.TextMatrix(i, 1) = "******"
        If rs!isguanli = True Then
            Grid1.TextMatrix(i, 2) = "管理员"
        Else
            Grid1.TextMatrix(i, 2) = "操作员"
        End If
        rs.MoveNext
    Next i
End Sub



Private Sub cmdadd_Click() '添加用户
    Dim rs As New ADODB.Recordset
'    txtName.Text = ""
'    txtPass.Text = ""
'    txtRPass.Text = ""
'    chkifguanli.Value = 0
    txtName.Enabled = True
    txtPass.Enabled = True
    txtRPass.Enabled = True
    chkifguanli.Enabled = True
On Error GoTo 10
    If Trim(txtName.Text) = "" Then
        MsgBox "用户名不能为空,请输入用户名。", 48, "提示信息"
        txtName.SetFocus
        Exit Sub
    End If
    If txtPass.Text = "" Then
        MsgBox "密码不能为空,请输入密码。", 48, "提示信息"
        txtPass.SetFocus
        Exit Sub
    End If
    If txtPass.Text <> txtRPass.Text Then
        MsgBox "您两次输入的密码不一致,请输入密码。", 48, "提示信息"
        txtPass.SetFocus
        Exit Sub
    End If
    If Len(txtPass.Text) > 16 Then
        MsgBox "密码要求输入1-16个字符,您的密码输入太长,请输入密码。", 48, "提示信息"
        txtPass.SetFocus
        Exit Sub
    End If
    
    rs.open "select * from admin where caozuoyuan='" & Trim(txtName.Text) & "'", cn, adOpenDynamic, adLockOptimistic
    If rs.RecordCount > 0 Then
        MsgBox "已经存在用户名[" & Trim(txtName.Text) & "],请重新输入。", 48, "提示信息"
        txtName.SetFocus
        Exit Sub
    End If
    rs.AddNew
    rs!caozuoyuan = Trim(txtName.Text)
    rs!mima = MD5(txtPass)
    rs!isguanli = chkifguanli.Value
    rs.Update
    Call fuzhiGrid
    txtName.Text = ""
    txtPass.Text = ""
    txtRPass.Text = ""
    Exit Sub
10:
    MsgBox Err.Description
End Sub

Private Sub cmdclose_Click()
    Unload Me
End Sub

Private Sub cmddel_Click()
    Dim rs As New ADODB.Recordset
    Dim sql As String
'    sql = "select * from admin order by ID desc"
'    rs.open sql, cn, adOpenDynamic, adLockOptimistic
'    caozuoyuan = rs!caozuoyuan
'    If Grid1.TextMatrix(Grid1.Row, 0) = caozuoyuan Then
'        MsgBox "不能删除当前登录的用户。", 48, "提示信息"
'        Exit Sub
'    End If
    If Grid1.TextMatrix(Grid1.Row, 0) = frmmain.lblxianshi.Caption Then
        MsgBox "当前登陆用户不能删除!", 48, "信息提示"
        Exit Sub
    End If
    If MsgBox("您确实要删除用户[" & Grid1.TextMatrix(Grid1.Row, 0) & "]吗?", 36, "警告") = vbNo Then
        Exit Sub
    End If
    cn.Execute "delete from admin where caozuoyuan='" & Grid1.TextMatrix(Grid1.Row, 0) & "'"
    Grid1.RemoveItem Grid1.Row
End Sub

Private Sub cmdedit_Click()
    cmdedit.Visible = False
    cmdqueren.Visible = True
    txtName.Enabled = True
    chkifguanli.Enabled = True
    txtName.SetFocus
End Sub

Private Sub cmdqueren_Click()
    Dim i As Integer
    i = Grid1.Row
    txtName.Enabled = True
    chkifguanli.Enabled = True
'    txtPass.Enabled = True
'    txtRPass.Enabled = True
    If Trim(txtName.Text) = "" Then
        MsgBox "请选择要修改的用户!", 48, "信息提示"
        Exit Sub
    End If
    Dim rs As New ADODB.Recordset
    Dim sql As String
    sql = "select * from admin where caozuoyuan='" & Grid1.TextMatrix(i, 0) & "'"
    rs.open sql, cn, adOpenDynamic, adLockOptimistic
    If rs.RecordCount > 1 Then
        MsgBox "用户名有重复,请重新输入!", 48, "信息提示"
        Exit Sub
    End If
    rs!caozuoyuan = Trim(txtName.Text)
    If chkifguanli.Value = 1 Then
        rs!isguanli = True
        Else
        rs!isguanli = False
    End If
    rs.Update
    MsgBox "修改成功!", 48, "信息提示"
    Call fuzhiGrid

End Sub

Private Sub Form_Load()
    Call fuzhiGrid
    txtName.Enabled = False
    txtPass.Enabled = False
    txtRPass.Enabled = False
    chkifguanli.Enabled = False
    cmdqueren.Visible = False
End Sub

Private Sub Grid1_Click() '表格单击事件
    txtName.Enabled = False
    txtPass.Enabled = False
    txtRPass.Enabled = False
    chkifguanli.Enabled = False
    cmdedit.Visible = True
    cmdqueren.Visible = False
    Dim i As Integer
    i = Grid1.Row
    Dim rs As New ADODB.Recordset
    Dim sql As String
    sql = "select * from admin"
    rs.open sql, cn, adOpenDynamic, adLockOptimistic
    rs.Move i - 1
    txtName.Text = Grid1.TextMatrix(i, 0)
    rs.Close
    If Grid1.TextMatrix(i, 2) = "管理员" Then
    chkifguanli.Value = 1
    Else
    chkifguanli.Value = 0
    End If
End Sub
Private Sub txtName_KeyPress(KeyAscii As Integer)
    If Trim(txtName.Text) <> "" And KeyAscii = 13 Then
        txtPass.SetFocus
    End If
End Sub
Private Sub txtPass_KeyPress(KeyAscii As Integer)
    If Trim(txtPass.Text) <> "" And KeyAscii = 13 Then
        txtRPass.SetFocus
    End If
End Sub
Private Sub txtRPass_KeyPress(KeyAscii As Integer)
    If Trim(txtRPass.Text) <> "" And KeyAscii = 13 Then
        chkifguanli.SetFocus
    End If
End Sub

⌨️ 快捷键说明

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