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

📄 frmoperater.frm

📁 使用vb来编制仓库管理方面的绝佳例子
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmOperater 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   4335
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   8415
   Icon            =   "frmOperater.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4335
   ScaleWidth      =   8415
   ShowInTaskbar   =   0   'False
   Begin VB.Frame MODIFrame 
      Height          =   2775
      Left            =   5880
      TabIndex        =   12
      Top             =   120
      Width           =   2415
      Begin VB.Frame Frame2 
         Caption         =   "姓名"
         Height          =   615
         Left            =   120
         TabIndex        =   13
         Top             =   240
         Width           =   2175
         Begin VB.TextBox Text1 
            BackColor       =   &H00FFC0C0&
            Height          =   270
            Index           =   0
            Left            =   240
            MaxLength       =   4
            TabIndex        =   0
            Top             =   240
            Width           =   1695
         End
      End
      Begin VB.Frame Frame4 
         Caption         =   "密码"
         Height          =   615
         Left            =   120
         TabIndex        =   14
         Top             =   960
         Width           =   2175
         Begin VB.TextBox Text1 
            BackColor       =   &H00FFC0C0&
            Height          =   270
            IMEMode         =   3  'DISABLE
            Index           =   1
            Left            =   240
            MaxLength       =   12
            PasswordChar    =   "*"
            TabIndex        =   1
            Top             =   240
            Width           =   1695
         End
      End
      Begin VB.Frame Frame5 
         Caption         =   "权限"
         Height          =   975
         Left            =   120
         TabIndex        =   15
         Top             =   1680
         Width           =   2175
         Begin VB.OptionButton Option1 
            Caption         =   "操作员"
            Height          =   180
            Index           =   1
            Left            =   480
            TabIndex        =   3
            Top             =   600
            Value           =   -1  'True
            Width           =   1335
         End
         Begin VB.OptionButton Option1 
            Caption         =   "管理员"
            Height          =   180
            Index           =   0
            Left            =   480
            TabIndex        =   2
            Top             =   240
            Width           =   1455
         End
      End
   End
   Begin VB.Frame Frame3 
      Height          =   1335
      Left            =   5880
      TabIndex        =   11
      Top             =   2880
      Width           =   2415
      Begin VB.CommandButton cmdRET 
         Caption         =   "返回(&R)"
         Height          =   495
         Left            =   1200
         TabIndex        =   7
         Top             =   720
         Width           =   1095
      End
      Begin VB.CommandButton cmdMODI 
         Caption         =   "修改(&M)"
         Enabled         =   0   'False
         Height          =   495
         Left            =   120
         TabIndex        =   6
         Top             =   720
         Width           =   1095
      End
      Begin VB.CommandButton cmdDel 
         Caption         =   "删除(&D)"
         Enabled         =   0   'False
         Height          =   495
         Left            =   1200
         TabIndex        =   5
         Top             =   240
         Width           =   1095
      End
      Begin VB.CommandButton cmdAdd 
         Caption         =   "添加(&A)"
         Enabled         =   0   'False
         Height          =   495
         Left            =   120
         TabIndex        =   4
         Top             =   240
         Width           =   1095
      End
      Begin VB.CommandButton cmdCancel 
         Caption         =   "取消(&C)"
         Height          =   495
         Left            =   120
         TabIndex        =   8
         Top             =   240
         Width           =   1095
      End
   End
   Begin VB.Frame Frame1 
      Height          =   4095
      Left            =   120
      TabIndex        =   10
      Top             =   120
      Width           =   5655
      Begin MSFlexGridLib.MSFlexGrid List 
         Height          =   3735
         Left            =   120
         TabIndex        =   9
         Top             =   240
         Width           =   5415
         _ExtentX        =   9551
         _ExtentY        =   6588
         _Version        =   393216
         Cols            =   3
         FixedCols       =   0
         BackColor       =   12648447
         ForeColor       =   255
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
   End
   Begin MSAdodcLib.Adodc Operater 
      Height          =   330
      Left            =   2520
      Top             =   4680
      Width           =   3015
      _ExtentX        =   5318
      _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         =   "操作员"
      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
End
Attribute VB_Name = "frmOperater"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim row1 As Integer               '选择某条记录
Dim pd As Integer                 '判断是否选中某一项记录
Dim datacount As Integer          '判断数据库中是否有记录

Private Sub cmdadd_Click()        '添加操作员
  operater.RecordSource = "select * from operater where 姓名='" & Trim(Text1(0)) & "'"
  operater.Refresh
  If operater.Recordset.EOF = False Then
    MsgBox "该操作员已经存在!!!"
  Else
    If Option1(0).Value = True Then
      czqx = 1
    Else
      czqx = 2
    End If
    operater.Recordset.AddNew
    operater.Recordset.Fields(0) = Trim(Text1(0))
    operater.Recordset.Fields(1) = Trim(Text1(1))
    operater.Recordset.Fields(2) = czqx
    operater.Recordset.Update
    operater.Refresh
  End If
  List.Enabled = True
  Call flash
  Text1(0) = ""
  Text1(1) = ""
  Option1(1).Value = True
  Text1(0).SetFocus
End Sub

Private Sub cmdCancel_Click()     '取消
  Text1(0) = ""
  Text1(1) = ""
  Text1(0).SetFocus
  Text1(0).Locked = False
  Text1(0).TabStop = True
  pd = 0
  cmdADD.Visible = True
  cmdCancel.Enabled = False
  cmdCancel.Visible = False
End Sub

Private Sub cmddel_Click()          '删除操作员信息
  operater.RecordSource = "select * from operater where 姓名='" & Trim(Text1(0)) & "'"
  operater.Refresh
  If operater.Recordset.EOF = True Then
    MsgBox "没有这个操作员!!"
    Text1(0).SetFocus
  Else
    aa = MsgBox("是否删除操作员【" & Text1(0) & "】的信息", 1 + 32)
    If aa = 1 Then
      operater.Recordset.Delete
      operater.Recordset.Update
      operater.Refresh
      Call csf
      Call pdd
      If datacount <> 0 Then Call flash
    End If
    Call cmdCancel_Click
  End If
End Sub

Private Sub cmdMODI_Click()         '修改操作员信息
  If Trim(Text1(1)) = "" Then
    MsgBox "密码不能为空!!!"
    Text1(1).SetFocus
    Exit Sub
  Else
    aa = MsgBox("就是否修改此操作员的信息", 1 + 32)
    If aa = 1 Then
      operater.RecordSource = "select * from operater where 姓名='" & Trim(Text1(0)) & "'"
      operater.Refresh
      operater.Recordset.Fields(1) = Text1(1)
      If Option1(0).Value = True Then
        operater.Recordset.Fields(2) = 1
      Else
        operater.Recordset.Fields(2) = 2
      End If
      operater.Recordset.Update
      operater.Refresh
      Call flash
    End If
  End If
  Call cmdCancel_Click
End Sub

Private Sub cmdRet_Click()        '返回
  pd = 0
  Unload frmOperater
End Sub

Private Sub Form_Load()           '初始化
  Me.Top = (Mainform.Height - Me.Height) / 2 - 800
  Me.Left = (Mainform.Width - Me.Width) / 2
  Me.Caption = "仓库管理系统→" & "操作员设置"
  operater.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Storehouse.mdb;Persist Security Info=False"
  Call csf
  Call pdd
  If datacount <> 0 Then Call flash
End Sub

Private Sub List_Click()          '选中某一条记录
  pd = 1
  row1 = List.Row
  Text1(0) = List.TextMatrix(row1, 0)
  Text1(1) = ""
  If List.TextMatrix(row1, 2) = 1 Then
    Option1(0).Value = True
  Else
    Option1(1).Value = True
  End If
  cmdMODI.Enabled = True
  cmdDEL.Enabled = True
  cmdADD.Enabled = False
  cmdADD.Visible = False
  cmdCancel.Enabled = True
  cmdCancel.Visible = True
  Text1(0).Locked = True
  Text1(0).TabStop = False
  Text1(1).SetFocus
End Sub

Private Sub Text1_Change(Index As Integer)      '判断输入是否为空
  If Trim(Text1(0)) = "" Or Trim(Text1(1)) = "" Then
    cmdADD.Enabled = False
    cmdDEL.Enabled = False
  Else
    If pd = 1 Then
      cmdDEL.Enabled = True
    Else
      cmdADD.Enabled = True
      cmdDEL.Enabled = True
    End If
  End If
End Sub

Private Sub Text1_GotFocus(Index As Integer)
  If Text1(Index).TabStop = True Then
    Text1(Index).BackColor = &HC0FFFF
    Text1(Index).SelStart = 0
    Text1(Index).SelLength = 12
  End If
End Sub

Private Sub Text1_LostFocus(Index As Integer)
  Text1(Index).BackColor = &HFFC0C0
End Sub

Private Sub pdd()             '判断数据库中是否有记录
  operater.RecordSource = "select * from operater"
  operater.Refresh
  datacount = operater.Recordset.RecordCount
  If datacount = 0 Then
    List.Enabled = False
  Else
    List.Enabled = True
  End If
End Sub

Private Sub flash()           '刷新列表
Dim roww As Integer           ''行
  roww = 1
  List.Clear
  List.rows = 1
  Call csf
  operater.RecordSource = "operater"
  operater.Refresh
  operater.Recordset.MoveFirst
  Do While operater.Recordset.EOF = False
    List.rows = List.rows + 1
    List.TextMatrix(roww, 0) = operater.Recordset.Fields(0)
    List.TextMatrix(roww, 1) = operater.Recordset.Fields(1)
    List.TextMatrix(roww, 2) = operater.Recordset.Fields(2)
    roww = roww + 1
    operater.Recordset.MoveNext
  Loop
End Sub

Private Sub csf()             '列表初始化
  List.TextMatrix(0, 0) = "姓名"
  List.TextMatrix(0, 1) = "密码"
  List.TextMatrix(0, 2) = "权限"
  List.ColWidth(0) = 1500
  List.ColWidth(1) = 2500
  List.ColWidth(2) = 1000
End Sub

⌨️ 快捷键说明

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