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

📄 formquerypayroll.vb

📁 人事管理系统(VB.NET2005+SQL Server2005)
💻 VB
字号:
Imports CommonDB

Public Class FormQueryPayroll
    Inherits System.Windows.Forms.Form

    Private oPayroll As Payroll

#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 Panel1 As System.Windows.Forms.Panel
    Friend WithEvents Splitter1 As System.Windows.Forms.Splitter
    Friend WithEvents Panel2 As System.Windows.Forms.Panel
    Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
    Friend WithEvents tvEmployee As System.Windows.Forms.TreeView
    Friend WithEvents lblEmployee As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents dgHistoryPayroll As System.Windows.Forms.DataGrid
    Friend WithEvents btnExit As System.Windows.Forms.Button
    Friend WithEvents btnQuery As System.Windows.Forms.Button
    Friend WithEvents Panel3 As System.Windows.Forms.Panel
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(FormQueryPayroll))
        Me.Panel1 = New System.Windows.Forms.Panel
        Me.tvEmployee = New System.Windows.Forms.TreeView
        Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
        Me.Splitter1 = New System.Windows.Forms.Splitter
        Me.Panel2 = New System.Windows.Forms.Panel
        Me.btnExit = New System.Windows.Forms.Button
        Me.GroupBox2 = New System.Windows.Forms.GroupBox
        Me.dgHistoryPayroll = New System.Windows.Forms.DataGrid
        Me.lblEmployee = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.btnQuery = New System.Windows.Forms.Button
        Me.Panel3 = New System.Windows.Forms.Panel
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.Panel1.SuspendLayout()
        Me.Panel2.SuspendLayout()
        Me.GroupBox2.SuspendLayout()
        CType(Me.dgHistoryPayroll, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.Panel3.SuspendLayout()
        Me.SuspendLayout()
        '
        'Panel1
        '
        Me.Panel1.Controls.Add(Me.tvEmployee)
        Me.Panel1.Dock = System.Windows.Forms.DockStyle.Left
        Me.Panel1.Location = New System.Drawing.Point(0, 0)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(200, 430)
        Me.Panel1.TabIndex = 0
        '
        'tvEmployee
        '
        Me.tvEmployee.Dock = System.Windows.Forms.DockStyle.Fill
        Me.tvEmployee.ImageList = Me.ImageList1
        Me.tvEmployee.Location = New System.Drawing.Point(0, 0)
        Me.tvEmployee.Name = "tvEmployee"
        Me.tvEmployee.Size = New System.Drawing.Size(200, 430)
        Me.tvEmployee.TabIndex = 2
        '
        'ImageList1
        '
        Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
        Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
        '
        'Splitter1
        '
        Me.Splitter1.Location = New System.Drawing.Point(200, 0)
        Me.Splitter1.Name = "Splitter1"
        Me.Splitter1.Size = New System.Drawing.Size(3, 430)
        Me.Splitter1.TabIndex = 1
        Me.Splitter1.TabStop = False
        '
        'Panel2
        '
        Me.Panel2.Controls.Add(Me.PictureBox1)
        Me.Panel2.Controls.Add(Me.Panel3)
        Me.Panel2.Controls.Add(Me.btnExit)
        Me.Panel2.Controls.Add(Me.GroupBox2)
        Me.Panel2.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Panel2.Location = New System.Drawing.Point(203, 0)
        Me.Panel2.Name = "Panel2"
        Me.Panel2.Size = New System.Drawing.Size(493, 430)
        Me.Panel2.TabIndex = 2
        '
        'btnExit
        '
        Me.btnExit.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.btnExit.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.btnExit.Location = New System.Drawing.Point(8, 400)
        Me.btnExit.Name = "btnExit"
        Me.btnExit.Size = New System.Drawing.Size(480, 23)
        Me.btnExit.TabIndex = 14
        Me.btnExit.Text = "退  出"
        '
        'GroupBox2
        '
        Me.GroupBox2.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.GroupBox2.Controls.Add(Me.dgHistoryPayroll)
        Me.GroupBox2.Location = New System.Drawing.Point(2, 80)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(488, 312)
        Me.GroupBox2.TabIndex = 13
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = "历史工资记录"
        '
        'dgHistoryPayroll
        '
        Me.dgHistoryPayroll.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.dgHistoryPayroll.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.dgHistoryPayroll.CaptionVisible = False
        Me.dgHistoryPayroll.DataMember = ""
        Me.dgHistoryPayroll.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgHistoryPayroll.Location = New System.Drawing.Point(8, 16)
        Me.dgHistoryPayroll.Name = "dgHistoryPayroll"
        Me.dgHistoryPayroll.ReadOnly = True
        Me.dgHistoryPayroll.Size = New System.Drawing.Size(472, 288)
        Me.dgHistoryPayroll.TabIndex = 0
        '
        'lblEmployee
        '
        Me.lblEmployee.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.lblEmployee.Cursor = System.Windows.Forms.Cursors.Hand
        Me.lblEmployee.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.lblEmployee.ForeColor = System.Drawing.SystemColors.ActiveCaption
        Me.lblEmployee.Location = New System.Drawing.Point(80, 8)
        Me.lblEmployee.Name = "lblEmployee"
        Me.lblEmployee.TabIndex = 11
        Me.lblEmployee.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(24, 8)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(64, 23)
        Me.Label4.TabIndex = 10
        Me.Label4.Text = "当前用户"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'btnQuery
        '
        Me.btnQuery.Location = New System.Drawing.Point(200, 8)
        Me.btnQuery.Name = "btnQuery"
        Me.btnQuery.Size = New System.Drawing.Size(120, 23)
        Me.btnQuery.TabIndex = 15
        Me.btnQuery.Text = "查  询"
        '
        'Panel3
        '
        Me.Panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Panel3.Controls.Add(Me.lblEmployee)
        Me.Panel3.Controls.Add(Me.Label4)
        Me.Panel3.Controls.Add(Me.btnQuery)
        Me.Panel3.Location = New System.Drawing.Point(8, 24)
        Me.Panel3.Name = "Panel3"
        Me.Panel3.Size = New System.Drawing.Size(352, 40)
        Me.Panel3.TabIndex = 16
        '
        'PictureBox1
        '
        Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
        Me.PictureBox1.Location = New System.Drawing.Point(376, 16)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.TabIndex = 17
        Me.PictureBox1.TabStop = False
        '
        'FormQueryPayroll
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.CancelButton = Me.btnExit
        Me.ClientSize = New System.Drawing.Size(696, 430)
        Me.Controls.Add(Me.Panel2)
        Me.Controls.Add(Me.Splitter1)
        Me.Controls.Add(Me.Panel1)
        Me.Name = "FormQueryPayroll"
        Me.Text = "工资查询"
        Me.Panel1.ResumeLayout(False)
        Me.Panel2.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        CType(Me.dgHistoryPayroll, System.ComponentModel.ISupportInitialize).EndInit()
        Me.Panel3.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub InitialTree(Optional ByVal bShowAll As Boolean = False)
        'Initial tvEmployee
        tvEmployee.Nodes.Clear()
        Dim dsCompany As DataSet
        dsCompany = DbBase.DataInterface().Execute4DS("select top 1 id,name from company")
        Dim tnRoot As TreeNode
        tnRoot = New TreeNode(dsCompany.Tables(0).Rows(0).Item("name"))
        tnRoot.Tag = dsCompany.Tables(0).Rows(0).Item("id")
        tnRoot.ImageIndex = 0
        tnRoot.SelectedImageIndex = 0
        Dim dsDeparts As DataSet
        dsDeparts = DbBase.DataInterface().Execute4DS("select number,name from department order by number")
        'Add Deparments to tvEmployee
        Dim iNodeIndex As Integer
        For Each drDepart As DataRow In dsDeparts.Tables(0).Rows
            Dim tnDepart As TreeNode
            tnDepart = New TreeNode(drDepart.Item("name"))
            tnDepart.Tag = drDepart.Item("number")
            tnDepart.ImageIndex = 1
            tnDepart.SelectedImageIndex = 1
            If Microsoft.VisualBasic.Right(drDepart.Item("number"), 1) = "0" Then
                tnRoot.Nodes.Add(tnDepart)
                iNodeIndex = tnDepart.Index
            Else
                Dim dsEmployee As DataSet
                Dim sSql As String
                If bShowAll Then
                    sSql = "select name,number from v_employee where department_number = '" & tnDepart.Tag & "'"
                Else
                    sSql = "select name,number from v_employee where department_number = '" & tnDepart.Tag & "' and status = '在职'"
                End If
                dsEmployee = DbBase.DataInterface().Execute4DS(sSql)
                For Each drEmployee As DataRow In dsEmployee.Tables(0).Rows
                    Dim tnEmployee As TreeNode
                    tnEmployee = New TreeNode(drEmployee.Item("name"), 2, 2)
                    tnEmployee.Tag = drEmployee.Item("number")
                    tnDepart.Nodes.Add(tnEmployee)
                Next
                tnRoot.Nodes.Item(iNodeIndex).Nodes.Add(tnDepart) 'error
            End If
        Next
        tvEmployee.Nodes.Add(tnRoot)
        tvEmployee.ExpandAll()
    End Sub

    Private Sub tvEmployee_MouseDown(ByVal send As Object, ByVal e As MouseEventArgs) Handles tvEmployee.MouseDown
        Dim tnClicked As TreeNode
        tnClicked = tvEmployee.GetNodeAt(New Point(e.X, e.Y))
        If Not tnClicked Is Nothing And Not tnClicked Is tvEmployee.Nodes(0) Then
            tvEmployee.SelectedNode = tnClicked
        End If
    End Sub

    Private Sub tvEmployee_AfterSelect(ByVal send As Object, ByVal e As TreeViewEventArgs) Handles tvEmployee.AfterSelect
        If e.Node.ImageIndex = 2 Then
            lblEmployee.Text = e.Node.Text
            lblEmployee.Tag = e.Node.Tag
            'oPayroll = New Payroll(CStr(e.Node.Tag), Year(Now()), Month(Now()) - 1)
            'QueryPayroll()
        End If
    End Sub

    Private Sub QueryPayroll()
        Dim iEmployeeId As Integer = DbBase.DataInterface.Execute4Value("select id from v_employee where number = '" & lblEmployee.Tag & "'")
        Dim dtHistoryPayroll As DataTable = Payroll.HistoryRecord(iEmployeeId)
        dgHistoryPayroll.DataSource = dtHistoryPayroll.DefaultView
    End Sub

    Private Sub FormAttendance_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
        InitialTree()
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub

    Private Sub btnQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuery.Click
        If lblEmployee.Tag = "" Then
            MessageBox.Show("请选择一个用户!")
        Else
            QueryPayroll()
        End If
    End Sub
End Class

⌨️ 快捷键说明

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