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

📄 frmempsel.frm

📁 vb与access数据库的操作实例
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "msdatlst.ocx"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "msadodc.ocx"
Begin VB.Form FrmEmpSel 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   3840
   ClientLeft      =   15
   ClientTop       =   15
   ClientWidth     =   5760
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3840
   ScaleWidth      =   5760
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Cmd_Cancel 
      BackColor       =   &H80000004&
      Caption         =   "取 消"
      Height          =   400
      Left            =   3198
      MouseIcon       =   "FrmEmpSel.frx":0000
      MousePointer    =   99  'Custom
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   3240
      Width           =   1300
   End
   Begin VB.CommandButton Cmd_OK 
      BackColor       =   &H80000004&
      Caption         =   "确 定"
      Default         =   -1  'True
      Height          =   400
      Left            =   1263
      MouseIcon       =   "FrmEmpSel.frx":030A
      MousePointer    =   99  'Custom
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   3240
      Width           =   1300
   End
   Begin VB.ComboBox ComboState 
      Height          =   300
      ItemData        =   "FrmEmpSel.frx":0614
      Left            =   3120
      List            =   "FrmEmpSel.frx":062A
      Style           =   2  'Dropdown List
      TabIndex        =   0
      Top             =   120
      Width           =   2415
   End
   Begin MSDataListLib.DataList DataList1 
      Bindings        =   "FrmEmpSel.frx":066A
      Height          =   2370
      Left            =   3120
      TabIndex        =   1
      Top             =   600
      Width           =   2415
      _ExtentX        =   4260
      _ExtentY        =   4180
      _Version        =   393216
      ListField       =   "EmpName"
      BoundColumn     =   "EmpId"
   End
   Begin MSAdodcLib.Adodc AdoEmpNameList 
      Height          =   330
      Left            =   -360
      Top             =   3000
      Visible         =   0   'False
      Width           =   2535
      _ExtentX        =   4471
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   1
      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         =   "AdoEmpNameList"
      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 MSComctlLib.ImageList ImageList3 
      Left            =   0
      Top             =   600
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483628
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   16777215
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   5
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "FrmEmpSel.frx":06A4
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "FrmEmpSel.frx":3036
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "FrmEmpSel.frx":59C8
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "FrmEmpSel.frx":835A
            Key             =   ""
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "FrmEmpSel.frx":ACEC
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.TreeView TreeView1 
      Height          =   2895
      Left            =   120
      TabIndex        =   2
      Top             =   120
      Width           =   2895
      _ExtentX        =   5106
      _ExtentY        =   5106
      _Version        =   393217
      HideSelection   =   0   'False
      LabelEdit       =   1
      Sorted          =   -1  'True
      Style           =   7
      HotTracking     =   -1  'True
      SingleSel       =   -1  'True
      ImageList       =   "ImageList3"
      BorderStyle     =   1
      Appearance      =   1
      MousePointer    =   99
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      MouseIcon       =   "FrmEmpSel.frx":D67E
   End
End
Attribute VB_Name = "FrmEmpSel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Cmd_Cancel_Click()
  Unload Me
End Sub

Private Sub Cmd_OK_Click()
  '将选择员工的数据保存在UpperEmp变量中
  UpperEmp.EmpId = MyEmp.EmpId
  UpperEmp.GetInfo (UpperEmp.EmpId)
  Unload Me
End Sub

Private Sub ComboState_Click()
  '设置ADO控件的连接字符串
  AdoEmpNameList.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
          + App.Path + "\人事.mdb;Persist Security Info=False"
  '根据ComboState的值刷新AdoEmpNameList,并更新DataList1的内容
  AdoEmpNameList.RecordSource = "SELECT EmpId, EmpName FROM Employees WHERE DepId=" _
        + Trim(Str(CurDep.DepId)) + " And State=" + Trim(Str(ComboState.ListIndex + 1))
  AdoEmpNameList.Refresh
  DataList1_Click
End Sub

Private Sub DataList1_Click()
  If DataList1.BoundText = "" Then
    MyEmp.Init
    Exit Sub
  End If
  '读取当前员工信息到Myemp
  MyEmp.GetInfo (DataList1.BoundText)
End Sub

Private Sub Form_Load()
  Dim TmpNode As Node
  '设置默认选择的部门
  FocusDepName = "人事部"
  Focuskey = ""
  '添加并设置根结点
  Set TmpNode = TreeView1.Nodes.Add(, , "a0", "部门信息", 1, 3)
  TmpNode.Selected = True
  TmpNode.ExpandedImage = 2
  '调用函数将所有部门添加到TreeView1中
  Call Add_DepToTree(TreeView1, "a0")
  '设置员工状态为在职
  ComboState.ListIndex = 0
  TreeView1_Click
End Sub

Private Sub TreeView1_Click()
  Dim Focuskey As String
  '根据关键字获取部门信息
  Focuskey = TreeView1.SelectedItem.Key
  CurDep.DepName = TreeView1.SelectedItem.Text
  CurDep.DepId = Val(Right(TreeView1.SelectedItem.Key, Len(TreeView1.SelectedItem.Key) - 1))
  
  If Focuskey = "a0" Then '根结点
    AdoEmpNameList.RecordSource = "SELECT * FROM Employees WHERE DepId<0"
    AdoEmpNameList.Refresh
    DataList1.ReFill
    Exit Sub
  End If
  '如果包含子结点,则设置图像格式
  If CurDep.HaveSon(CurDep.DepId) = False Then
    TreeView1.SelectedItem.ExpandedImage = 4
    TreeView1.SelectedItem.Image = 4
    TreeView1.SelectedItem.SelectedImage = 5
  End If
  '读取CurDep中的所有部门信息
  CurDep.GetInfo (CurDep.DepId)
  '根据选择的部门编号刷新AdoEmpNameList1,从而选择符合条件的员工姓名
  AdoEmpNameList.RecordSource = "SELECT EmpId, EmpName FROM Employees WHERE DepId=" _
        + Trim(Str(CurDep.DepId)) + " And State=" + Trim(Str(ComboState.ListIndex + 1))
  AdoEmpNameList.Refresh
  DataList1.ReFill
  DataList1_Click
End Sub


⌨️ 快捷键说明

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