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

📄 frmpeoplequery.vb

📁 使用的人力资源管理系统
💻 VB
字号:
Public Class frmPeopleQuery
    Inherits System.Windows.Forms.Form
    Private dvResult As DataView
#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents grbPepQuery As System.Windows.Forms.GroupBox
    Friend WithEvents lblNameCode As System.Windows.Forms.Label
    Friend WithEvents txbNameCode As System.Windows.Forms.TextBox
    Friend WithEvents lblName As System.Windows.Forms.Label
    Friend WithEvents lblNature As System.Windows.Forms.Label
    Friend WithEvents lblSex As System.Windows.Forms.Label
    Friend WithEvents lblCity As System.Windows.Forms.Label
    Friend WithEvents txbName As System.Windows.Forms.TextBox
    Friend WithEvents cbbSex As System.Windows.Forms.ComboBox
    Friend WithEvents cbbNature As System.Windows.Forms.ComboBox
    Friend WithEvents cbbCity As System.Windows.Forms.ComboBox
    Friend WithEvents btnSearch As System.Windows.Forms.Button
    Friend WithEvents dgdPepInfo As System.Windows.Forms.DataGrid
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.grbPepQuery = New System.Windows.Forms.GroupBox
        Me.btnSearch = New System.Windows.Forms.Button
        Me.cbbCity = New System.Windows.Forms.ComboBox
        Me.cbbNature = New System.Windows.Forms.ComboBox
        Me.cbbSex = New System.Windows.Forms.ComboBox
        Me.txbName = New System.Windows.Forms.TextBox
        Me.txbNameCode = New System.Windows.Forms.TextBox
        Me.lblCity = New System.Windows.Forms.Label
        Me.lblSex = New System.Windows.Forms.Label
        Me.lblNature = New System.Windows.Forms.Label
        Me.lblName = New System.Windows.Forms.Label
        Me.lblNameCode = New System.Windows.Forms.Label
        Me.dgdPepInfo = New System.Windows.Forms.DataGrid
        Me.grbPepQuery.SuspendLayout()
        CType(Me.dgdPepInfo, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'grbPepQuery
        '
        Me.grbPepQuery.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.grbPepQuery.Controls.Add(Me.btnSearch)
        Me.grbPepQuery.Controls.Add(Me.cbbCity)
        Me.grbPepQuery.Controls.Add(Me.cbbNature)
        Me.grbPepQuery.Controls.Add(Me.cbbSex)
        Me.grbPepQuery.Controls.Add(Me.txbName)
        Me.grbPepQuery.Controls.Add(Me.txbNameCode)
        Me.grbPepQuery.Controls.Add(Me.lblCity)
        Me.grbPepQuery.Controls.Add(Me.lblSex)
        Me.grbPepQuery.Controls.Add(Me.lblNature)
        Me.grbPepQuery.Controls.Add(Me.lblName)
        Me.grbPepQuery.Controls.Add(Me.lblNameCode)
        Me.grbPepQuery.Location = New System.Drawing.Point(0, 16)
        Me.grbPepQuery.Name = "grbPepQuery"
        Me.grbPepQuery.Size = New System.Drawing.Size(488, 72)
        Me.grbPepQuery.TabIndex = 0
        Me.grbPepQuery.TabStop = False
        '
        'btnSearch
        '
        Me.btnSearch.Location = New System.Drawing.Point(292, 41)
        Me.btnSearch.Name = "btnSearch"
        Me.btnSearch.Size = New System.Drawing.Size(48, 23)
        Me.btnSearch.TabIndex = 11
        Me.btnSearch.Text = "查询"
        '
        'cbbCity
        '
        Me.cbbCity.Items.AddRange(New Object() {"北京", "河北", "河南", "山西", "其他"})
        Me.cbbCity.Location = New System.Drawing.Point(192, 42)
        Me.cbbCity.Name = "cbbCity"
        Me.cbbCity.Size = New System.Drawing.Size(56, 20)
        Me.cbbCity.TabIndex = 10
        '
        'cbbNature
        '
        Me.cbbNature.Items.AddRange(New Object() {"汉族", "壮族", "满族", "苗族", "其他"})
        Me.cbbNature.Location = New System.Drawing.Point(72, 42)
        Me.cbbNature.Name = "cbbNature"
        Me.cbbNature.Size = New System.Drawing.Size(56, 20)
        Me.cbbNature.TabIndex = 9
        '
        'cbbSex
        '
        Me.cbbSex.Items.AddRange(New Object() {"男", "女"})
        Me.cbbSex.Location = New System.Drawing.Point(328, 13)
        Me.cbbSex.Name = "cbbSex"
        Me.cbbSex.Size = New System.Drawing.Size(56, 20)
        Me.cbbSex.TabIndex = 8
        '
        'txbName
        '
        Me.txbName.Location = New System.Drawing.Point(192, 13)
        Me.txbName.Name = "txbName"
        Me.txbName.Size = New System.Drawing.Size(56, 21)
        Me.txbName.TabIndex = 7
        Me.txbName.Text = ""
        '
        'txbNameCode
        '
        Me.txbNameCode.Location = New System.Drawing.Point(72, 13)
        Me.txbNameCode.Name = "txbNameCode"
        Me.txbNameCode.Size = New System.Drawing.Size(56, 21)
        Me.txbNameCode.TabIndex = 5
        Me.txbNameCode.Text = ""
        '
        'lblCity
        '
        Me.lblCity.Location = New System.Drawing.Point(160, 48)
        Me.lblCity.Name = "lblCity"
        Me.lblCity.Size = New System.Drawing.Size(32, 16)
        Me.lblCity.TabIndex = 4
        Me.lblCity.Text = "籍贯"
        '
        'lblSex
        '
        Me.lblSex.Location = New System.Drawing.Point(288, 19)
        Me.lblSex.Name = "lblSex"
        Me.lblSex.Size = New System.Drawing.Size(32, 16)
        Me.lblSex.TabIndex = 3
        Me.lblSex.Text = "性别"
        '
        'lblNature
        '
        Me.lblNature.Location = New System.Drawing.Point(38, 48)
        Me.lblNature.Name = "lblNature"
        Me.lblNature.Size = New System.Drawing.Size(32, 16)
        Me.lblNature.TabIndex = 2
        Me.lblNature.Text = "民族"
        '
        'lblName
        '
        Me.lblName.Location = New System.Drawing.Point(160, 19)
        Me.lblName.Name = "lblName"
        Me.lblName.Size = New System.Drawing.Size(32, 16)
        Me.lblName.TabIndex = 1
        Me.lblName.Text = "姓名"
        '
        'lblNameCode
        '
        Me.lblNameCode.Location = New System.Drawing.Point(14, 19)
        Me.lblNameCode.Name = "lblNameCode"
        Me.lblNameCode.Size = New System.Drawing.Size(56, 16)
        Me.lblNameCode.TabIndex = 0
        Me.lblNameCode.Text = "姓名简码"
        '
        'dgdPepInfo
        '
        Me.dgdPepInfo.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.dgdPepInfo.CaptionVisible = False
        Me.dgdPepInfo.DataMember = ""
        Me.dgdPepInfo.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgdPepInfo.Location = New System.Drawing.Point(0, 88)
        Me.dgdPepInfo.Name = "dgdPepInfo"
        Me.dgdPepInfo.Size = New System.Drawing.Size(488, 184)
        Me.dgdPepInfo.TabIndex = 1
        '
        'frmPeopleQuery
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(488, 273)
        Me.Controls.Add(Me.dgdPepInfo)
        Me.Controls.Add(Me.grbPepQuery)
        Me.Name = "frmPeopleQuery"
        Me.Text = "职员信息查询"
        Me.grbPepQuery.ResumeLayout(False)
        CType(Me.dgdPepInfo, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmPeopleQuery_Load(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load
        '获得数据
        LoadData()
        '定义DataGridTableStyle
        Dim ts As New DataGridTableStyle
        Dim aColumnTextColumn As DataGridTextBoxColumn
        Dim numCols As Integer = dvResult.Table.Columns.Count
        Dim i As Integer
        For i = 0 To numCols - 1
            aColumnTextColumn = New DataGridTextBoxColumn
            aColumnTextColumn.MappingName = _
            dvResult.Table.Columns(i).ColumnName
            aColumnTextColumn.HeaderText = _
            dvResult.Table.Columns(i).ColumnName
            aColumnTextColumn.NullText = ""
            If i = 1 Or i = 4 Then
                aColumnTextColumn.Width = 40
            End If
            ts.GridColumnStyles.Add(aColumnTextColumn)
        Next
        ts.AlternatingBackColor = Color.LightGray
        ts.MappingName = dvResult.Table.TableName
        Me.dgdPepInfo.TableStyles.Add(ts)
        dgdPepInfo.DataSource = dvResult
    End Sub
    Private Sub LoadData()
        Dim db As DataBase = New DataBase
        '组合查询语句
        Dim strSQL As String = "select 姓名,性别,出生日期,"
        strSQL += "籍贯,民族,办公电话,婚姻状况,单位名称,文化程度"
        strSQL += " from 职员基本信息表 as a, 组织机构编码表 as b"
        strSQL += " where a.单位编号=b.单位编号"
        Dim strCondition As String = ""
        If txbNameCode.Text.Trim.Length > 0 Then
            strCondition += " and 姓名简码 like '%"
            strCondition += txbNameCode.Text.Trim + "%'"
        End If
        If Me.txbName.Text.Trim.Length > 0 Then
            strCondition += " and 姓名 like '%"
            strCondition += txbName.Text.Trim + "%"
        End If
        If Me.cbbSex.Text.Trim.Length > 0 Then
            strCondition += " and 性别 like '%"
            strCondition += cbbSex.Text.Trim + "%'"
        End If
        If Me.cbbNature.Text.Trim.Length > 0 Then
            strCondition += " and 民族 like '%"
            strCondition += cbbNature.Text.Trim + "%'"
        End If
        If Me.cbbCity.Text.Trim.Length > 0 Then
            strCondition += " and 籍贯 like '%"
            strCondition += cbbCity.Text.Trim + "%'"
        End If
        If strCondition.Trim.Length > 0 Then
            strSQL += strCondition
        End If
        dvResult = db.RunSelectSQL(strSQL)
        dvResult.AllowDelete = False
        dvResult.AllowNew = False
        dvResult.AllowEdit = False
    End Sub

    Private Sub btnSearch_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btnSearch.Click
        '加载数据
        LoadData()
        '设置数据源
        dgdPepInfo.DataSource = dvResult
    End Sub
End Class

⌨️ 快捷键说明

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