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

📄 frmperson.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 frmPerson 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   4800
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   7005
   Icon            =   "frmPerson.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4800
   ScaleWidth      =   7005
   ShowInTaskbar   =   0   'False
   Begin VB.Frame Frame1 
      Height          =   4575
      Left            =   120
      TabIndex        =   7
      Top             =   120
      Width           =   6735
      Begin VB.Frame Frame2 
         Height          =   2055
         Left            =   3360
         TabIndex        =   8
         Top             =   120
         Width           =   3255
         Begin VB.CheckBox Check1 
            Caption         =   "自动产生编号(&Z)"
            Height          =   255
            Left            =   1320
            TabIndex        =   2
            Top             =   1500
            Width           =   1815
         End
         Begin VB.TextBox Text1 
            Appearance      =   0  'Flat
            BackColor       =   &H00C0FFFF&
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   12
               Charset         =   134
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Index           =   0
            Left            =   1200
            MaxLength       =   3
            TabIndex        =   0
            Top             =   480
            Width           =   1575
         End
         Begin VB.TextBox Text1 
            Appearance      =   0  'Flat
            BackColor       =   &H00C0FFFF&
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   12
               Charset         =   134
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Index           =   1
            Left            =   1200
            MaxLength       =   4
            TabIndex        =   1
            Top             =   960
            Width           =   1575
         End
         Begin VB.Label Label1 
            AutoSize        =   -1  'True
            Caption         =   "编号:"
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   12
               Charset         =   134
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   240
            Index           =   0
            Left            =   360
            TabIndex        =   10
            Top             =   510
            Width           =   600
         End
         Begin VB.Label Label1 
            AutoSize        =   -1  'True
            Caption         =   "姓名:"
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   12
               Charset         =   134
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   240
            Index           =   1
            Left            =   360
            TabIndex        =   9
            Top             =   990
            Width           =   600
         End
      End
      Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
         Height          =   4215
         Left            =   120
         TabIndex        =   6
         Top             =   240
         Width           =   3135
         _ExtentX        =   5530
         _ExtentY        =   7435
         _Version        =   393216
         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
      Begin VB.Frame Frame3 
         Height          =   2295
         Left            =   3360
         TabIndex        =   11
         Top             =   2160
         Width           =   3255
         Begin VB.CommandButton cmdADD 
            Caption         =   "添加(&A)"
            Default         =   -1  'True
            Enabled         =   0   'False
            Height          =   735
            Left            =   360
            TabIndex        =   3
            Top             =   360
            Width           =   1455
         End
         Begin VB.CommandButton cmdDEL 
            Caption         =   "删除(&D)"
            Enabled         =   0   'False
            Height          =   735
            Left            =   360
            TabIndex        =   4
            Top             =   1320
            Width           =   1455
         End
         Begin VB.CommandButton cmdRET 
            Cancel          =   -1  'True
            Caption         =   "返回(&R)"
            Height          =   1695
            Left            =   2040
            TabIndex        =   5
            Top             =   360
            Width           =   855
         End
      End
   End
   Begin MSAdodcLib.Adodc Person 
      Height          =   330
      Left            =   1440
      Top             =   5160
      Width           =   3255
      _ExtentX        =   5741
      _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 = "frmPerson"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim datacount As Integer '数据库的记录数
Dim strtemp1 As String
Dim strtemp2 As String

Private Sub Check1_Click()
  If Check1.Value = 1 Then
    Text1(0).Locked = True
    Text1(1).SetFocus
    Person.RecordSource = "person"
    Person.Refresh
    count1 = Person.Recordset.RecordCount       '判断存在的编号
    If count1 <> 0 Then
      Person.Recordset.MoveFirst
      For i = 0 To count1
        str2 = Right(Str(1000 + i), 3)
        Person.RecordSource = "select * from person where 编号='" & Trim(str2) & "'"
        Person.Refresh
        If Person.Recordset.EOF = True Then
          str1 = Right(Str(1000 + i), 3)
          Exit For
        End If
        str1 = Right(Str(1000 + i), 3)
      Next
    Else
      str1 = "000"
    End If
    Text1(0) = str1
  Else
    Text1(0).Locked = False
    Text1(0).SetFocus
  End If
End Sub

Private Sub cmdadd_Click()      '添加人员
  Person.RecordSource = "select * from person where 编号='" & Trim(Text1(0)) & "'"
  Person.Refresh
  If Person.Recordset.EOF = False Then
    MsgBox "该编号已经存在"
    Text1(0).SetFocus
    Exit Sub
  End If
  Person.RecordSource = "select * from person where 姓名='" & Trim(Text1(1)) & "'"
  Person.Refresh
  If Person.Recordset.EOF = False Then
    aa = MsgBox("人员库中已经有这个名字,是否继续!!", 1 + 32)
    If aa = 2 Then
      Text1(1).SetFocus
      Exit Sub
    End If
  End If
  Person.Recordset.AddNew
  Person.Recordset.Fields(0) = Trim(Text1(0))
  Person.Recordset.Fields(1) = Trim(Text1(1))
  Person.Recordset.Update
  Person.Refresh
  Call flash
  Check1.Value = 0
  MSFlexGrid1.Enabled = True
  strtemp1 = Text1(0)
  strtemp2 = Text1(1)
  Text1(0) = ""
  Text1(1) = ""
  Text1(0).Locked = False
  Text1(0).SetFocus
 '______________________________  判断是否从出库窗体中引用
  If temp1 = 1 Then
  frmOutstorehouse.Text1(5).Text = strtemp1     '将增加的人员返回到出库窗体
  frmOutstorehouse.Text1(6).Text = strtemp2
  temp1 = 0
  End If
End Sub

Private Sub cmddel_Click()      '删除人员
  Person.RecordSource = "select * from person where 编号='" & Trim(Text1(0)) & "'"
  Person.Refresh
  If Person.Recordset.EOF = True Then
    MsgBox "此编号不存在"
  Else
    Person.Recordset.Delete
    Person.Refresh
    Call pdd
    If datacount <> 0 Then
      Call flash
    Else
      MSFlexGrid1.Clear
      Call csf
    End If
    Text1(0) = ""
    Text1(1) = ""
    Text1(0).SetFocus
  End If
End Sub

Private Sub cmdRet_Click()      '返回
  Unload Me
End Sub

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

Private Sub MSFlexGrid1_Click()
  Dim rows As Integer       '行
  rows = MSFlexGrid1.Row
  Text1(0) = MSFlexGrid1.TextMatrix(rows, 0)
  Text1(1) = MSFlexGrid1.TextMatrix(rows, 1)
End Sub

Private Sub MSFlexGrid1_DblClick()
  Call cmddel_Click
End Sub

Private Sub Text1_Change(Index As Integer)
  If Trim(Text1(0)) = "" Or Trim(Text1(1)) = "" Or IsNumeric(Text1(0)) = False Then
    cmdADD.Enabled = False
    cmdDEL.Enabled = False
  Else
    cmdADD.Enabled = True
    cmdDEL.Enabled = True
  End If
End Sub

Private Sub Text1_GotFocus(Index As Integer)
  Text1(Index).BackColor = &HFFC0C0
  Text1(Index).SelStart = 0
  Text1(Index).SelLength = 4
End Sub

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


Private Sub pdd()           '判断数据是否为空
  Person.RecordSource = "Person"
  Person.Refresh
  datacount = Person.Recordset.RecordCount
  If datacount = 0 Then
    MSFlexGrid1.Enabled = False
  Else
    MSFlexGrid1.Enabled = True
  End If
End Sub


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

Private Sub csf()
  MSFlexGrid1.TextMatrix(0, 0) = "编号"
  MSFlexGrid1.TextMatrix(0, 1) = "姓名"
  MSFlexGrid1.ColWidth(0) = 1000
  MSFlexGrid1.ColWidth(1) = 2000
End Sub

⌨️ 快捷键说明

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