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

📄 frmempinfo2.frm

📁 员工信息管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{C932BA88-4374-101B-A56C-00AA003668DC}#1.1#0"; "MSMASK32.OCX"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmEmpInfo2 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "员工信息查询"
   ClientHeight    =   6795
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9480
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6795
   ScaleWidth      =   9480
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  '所有者中心
   Begin MSMask.MaskEdBox MskId 
      Height          =   375
      Left            =   1560
      TabIndex        =   2
      Top             =   480
      Width           =   2775
      _ExtentX        =   4895
      _ExtentY        =   661
      _Version        =   393216
      MaxLength       =   20
      Mask            =   "99999999999999999999999999999999999999999999999999999999999999"
      PromptChar      =   " "
   End
   Begin VB.CommandButton Command3 
      Caption         =   "返  回"
      Height          =   375
      Left            =   7800
      TabIndex        =   1
      Top             =   5880
      Width           =   975
   End
   Begin MSFlexGridLib.MSFlexGrid flxShow 
      Height          =   2775
      Left            =   360
      TabIndex        =   18
      Top             =   2760
      Width           =   8775
      _ExtentX        =   15478
      _ExtentY        =   4895
      _Version        =   393216
      ScrollBars      =   2
   End
   Begin VB.Frame Frame1 
      Caption         =   "查询条件"
      Height          =   2415
      Left            =   360
      TabIndex        =   9
      Top             =   120
      Width           =   8775
      Begin VB.ComboBox cboTitle 
         Height          =   300
         Left            =   5640
         Style           =   2  'Dropdown List
         TabIndex        =   8
         Top             =   1800
         Width           =   2775
      End
      Begin VB.ComboBox cboSex 
         Height          =   300
         Left            =   5640
         Style           =   2  'Dropdown List
         TabIndex        =   4
         Top             =   360
         Width           =   2775
      End
      Begin VB.ComboBox cboDuty 
         Height          =   300
         Left            =   5640
         Style           =   2  'Dropdown List
         TabIndex        =   7
         Top             =   1440
         Width           =   2775
      End
      Begin VB.ComboBox cboEdu 
         Height          =   300
         Left            =   5640
         Style           =   2  'Dropdown List
         TabIndex        =   5
         Top             =   720
         Width           =   2775
      End
      Begin VB.CommandButton Command1 
         Caption         =   "开始搜索"
         Default         =   -1  'True
         Height          =   375
         Left            =   2400
         TabIndex        =   0
         Top             =   1800
         Width           =   975
      End
      Begin VB.TextBox Text2 
         Height          =   375
         Left            =   1200
         TabIndex        =   3
         Top             =   840
         Width           =   2775
      End
      Begin VB.ComboBox cboDept 
         Height          =   300
         Left            =   5640
         Style           =   2  'Dropdown List
         TabIndex        =   6
         Top             =   1080
         Width           =   2775
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "职  务:"
         Height          =   180
         Left            =   4680
         TabIndex        =   17
         Top             =   1560
         Width           =   720
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "性  别:"
         Height          =   180
         Left            =   4680
         TabIndex        =   16
         Top             =   480
         Width           =   720
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "学  历:"
         Height          =   180
         Left            =   4680
         TabIndex        =   15
         Top             =   840
         Width           =   720
      End
      Begin VB.Label Label7 
         AutoSize        =   -1  'True
         Caption         =   "职  称:"
         Height          =   180
         Left            =   4680
         TabIndex        =   14
         Top             =   1920
         Width           =   720
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         Caption         =   "以上条件均为可选项"
         Height          =   180
         Left            =   360
         TabIndex        =   13
         Top             =   1920
         Width           =   1620
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "姓  名:"
         Height          =   180
         Left            =   360
         TabIndex        =   12
         Top             =   960
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "工  号:"
         Height          =   180
         Left            =   360
         TabIndex        =   11
         Top             =   480
         Width           =   720
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "部  门:"
         Height          =   180
         Left            =   4680
         TabIndex        =   10
         Top             =   1200
         Width           =   720
      End
   End
   Begin VB.Label Label9 
      AutoSize        =   -1  'True
      Height          =   180
      Left            =   840
      TabIndex        =   19
      Top             =   5880
      Width           =   90
   End
End
Attribute VB_Name = "frmEmpInfo2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim strSql As String
Dim rs As New ADODB.Recordset
Dim i As Integer

Private Sub Command1_Click()
    Dim strId As String
    Dim strName As String
    Dim strDept As String
    Dim strTitle As String
    Dim strDuty As String
    Dim strEdu As String
    Dim strSex As String
    '设制错误陷阱
    On Error GoTo ERR_CONN
    If Trim(MskId) = "" Then
        strId = ""
    Else
        strId = "and a.emp_id= clng('" & MskId & "')"
    End If
    If Trim(Text2) = "" Then
        strName = ""
    Else
        strName = "and a.emp_name='" & Trim(Text2) & "'"
    End If
    If cboDept.ListIndex = 0 Then
        strDept = ""
    Else
        strDept = "and c.dept_name='" & cboDept.Text & "'"
    End If
    If cboTitle.ListIndex = 0 Then
        strTitle = ""
    Else
        strTitle = "and e.title_name='" & cboTitle.Text & "'"
    End If
    If cboDuty.ListIndex = 0 Then
        strDuty = ""
    Else
        strDuty = "and d.duty_name='" & cboDuty.Text & "'"
    End If
    If cboEdu.ListIndex = 0 Then
        strEdu = ""
    Else
        strEdu = "and b.edu_name='" & cboEdu.Text & "'"
    End If
    If cboSex.ListIndex = 0 Then
        strSex = ""
    Else
        strSex = "and a.sex='" & cboSex.Text & "'"
    End If
    '打开一个数据集
    strSql = "select a.emp_id,a.emp_name,a.sex,b.edu_name,c.dept_name,d.duty_name,e.title_name from employee a,education b,department c,duty d,title e where a.edu_id=b.edu_id and a.dept_id=c.dept_id and a.duty_id=d.duty_id  and a.title_id=e.title_id " & strId & "  " & strName & " " & strDept & " " & strTitle & " " & strTitle & "" & strDuty & " " & strEdu & " " & strSex & " order by a.emp_id"
    rs.Open strSql, dbConn, adOpenForwardOnly, adLockReadOnly
    
    If rs.EOF Then
         Label9 = "找到0条记录"
         flxShow.Rows = 1
     
    Else
        '填写数据
        flxShow.Rows = 1
        
        Do While Not rs.EOF
            flxShow.Rows = flxShow.Rows + 1
                
            flxShow.TextMatrix(flxShow.Rows - 1, 0) = rs.Fields(0).Value
            For i = 2 To rs.Fields.Count
                flxShow.TextMatrix(flxShow.Rows - 1, i) = rs.Fields(i - 1).Value
            Next i
            
            rs.MoveNext
        Loop
        Label9 = "找到" & flxShow.Rows - 1 & "条记录"
      
    End If
    rs.Close
    Exit Sub
    
ERR_CONN:
    MsgBox "请检查输入的数据是否有效"
End Sub



Private Sub Command3_Click()
    Unload Me
End Sub

Private Sub Form_Load()
  
    '性别
    cboSex.AddItem ""
    cboSex.AddItem "男"
    cboSex.AddItem "女"
    cboSex.ListIndex = 0
    
    '学历
    strSql = "Select edu_id,edu_name from education Order By edu_id"
    rs.Open strSql, dbConn, adOpenForwardOnly, adLockReadOnly
    cboEdu.AddItem ""
    Do While Not rs.EOF
        cboEdu.AddItem (rs.Fields("edu_name").Value)
        cboEdu.ItemData(cboEdu.NewIndex) = rs.Fields("edu_id").Value
        rs.MoveNext
    Loop
    rs.Close
    cboEdu.ListIndex = 0
    
    '部门
    strSql = "Select dept_id,dept_name from department Order By dept_id"
    rs.Open strSql, dbConn, adOpenForwardOnly, adLockReadOnly
    cboDept.AddItem ""
    Do While Not rs.EOF
        cboDept.AddItem (rs.Fields("dept_name").Value)
        cboDept.ItemData(cboDept.NewIndex) = rs.Fields("dept_id").Value
        rs.MoveNext
    Loop
    rs.Close
    cboDept.ListIndex = 0
    
    '职务
    strSql = "Select duty_id,duty_name from duty Order By duty_id"
    rs.Open strSql, dbConn, adOpenForwardOnly, adLockReadOnly
    cboDuty.AddItem ""
    Do While Not rs.EOF
        cboDuty.AddItem (rs.Fields("duty_name").Value)
        cboDuty.ItemData(cboDuty.NewIndex) = rs.Fields("duty_id").Value
        rs.MoveNext
    Loop
    rs.Close
    cboDuty.ListIndex = 0
    
    '职称
    strSql = "Select title_id,title_name from title Order By title_id"
    rs.Open strSql, dbConn, adOpenForwardOnly, adLockReadOnly
    cboTitle.AddItem ""
    Do While Not rs.EOF
        cboTitle.AddItem (rs.Fields("title_name").Value)
        cboTitle.ItemData(cboTitle.NewIndex) = rs.Fields("title_id").Value
        rs.MoveNext
    Loop
    rs.Close
    cboTitle.ListIndex = 0
    '设置列数
    flxShow.Cols = 8
    '列标题
    flxShow.TextMatrix(0, 0) = "工号"
    flxShow.TextMatrix(0, 1) = ""
    flxShow.TextMatrix(0, 2) = "姓名"
    flxShow.TextMatrix(0, 3) = "性别"
    flxShow.TextMatrix(0, 4) = "学历"
    flxShow.TextMatrix(0, 5) = "部门"
    flxShow.TextMatrix(0, 6) = "职务"
    flxShow.TextMatrix(0, 7) = "职称"
    
    '设置列宽
    flxShow.ColWidth(0) = 1000
    flxShow.ColWidth(1) = 0
    flxShow.ColWidth(2) = 1400
    flxShow.ColWidth(3) = 800
    flxShow.ColWidth(4) = 1400
    flxShow.ColWidth(5) = 1400
    flxShow.ColWidth(6) = 1400
    flxShow.ColWidth(7) = 1410
            
    '设置各列的对齐方式
    For i = 0 To 7
       flxShow.ColAlignment(i) = 0
    Next i
    
    '表头项居中
    flxShow.FillStyle = flexFillRepeat
    flxShow.Col = 0
    flxShow.Row = 0
    flxShow.RowSel = 1
    flxShow.ColSel = flxShow.Cols - 1
    flxShow.CellAlignment = 4
    flxShow.Rows = 1
    '强制跨越整个行选择
    flxShow.SelectionMode = flexSelectionByRow
End Sub

⌨️ 快捷键说明

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