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

📄 frmgztj.vb

📁 一个实际的商业项目
💻 VB
📖 第 1 页 / 共 2 页
字号:
Imports System.Data.OleDb
Public Class frmGztj
    Inherits System.Windows.Forms.Form

    Dim WithEvents cnData As New OleDbConnection
    Dim cmdSQL As New OleDbCommand

    Dim dt As DataTable = New DataTable("Gongzi")
    Dim douYfgz As Decimal
    Dim strstr As String



#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 Panel2 As System.Windows.Forms.Panel
    Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents txtDay As System.Windows.Forms.TextBox
    Friend WithEvents btnExcel As System.Windows.Forms.Button
    Friend WithEvents btnRe As System.Windows.Forms.Button
    Friend WithEvents btnTable As System.Windows.Forms.Button
    Friend WithEvents cbMonth As System.Windows.Forms.ComboBox
    Friend WithEvents txtYear As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Panel1 = New System.Windows.Forms.Panel
        Me.txtDay = New System.Windows.Forms.TextBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.btnExcel = New System.Windows.Forms.Button
        Me.btnRe = New System.Windows.Forms.Button
        Me.btnTable = New System.Windows.Forms.Button
        Me.Label2 = New System.Windows.Forms.Label
        Me.cbMonth = New System.Windows.Forms.ComboBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.txtYear = New System.Windows.Forms.TextBox
        Me.Panel2 = New System.Windows.Forms.Panel
        Me.DataGrid1 = New System.Windows.Forms.DataGrid
        Me.Panel1.SuspendLayout()
        Me.Panel2.SuspendLayout()
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'Panel1
        '
        Me.Panel1.Controls.Add(Me.txtDay)
        Me.Panel1.Controls.Add(Me.Label3)
        Me.Panel1.Controls.Add(Me.btnExcel)
        Me.Panel1.Controls.Add(Me.btnRe)
        Me.Panel1.Controls.Add(Me.btnTable)
        Me.Panel1.Controls.Add(Me.Label2)
        Me.Panel1.Controls.Add(Me.cbMonth)
        Me.Panel1.Controls.Add(Me.Label1)
        Me.Panel1.Controls.Add(Me.txtYear)
        Me.Panel1.Dock = System.Windows.Forms.DockStyle.Top
        Me.Panel1.Location = New System.Drawing.Point(0, 0)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(672, 64)
        Me.Panel1.TabIndex = 0
        '
        'txtDay
        '
        Me.txtDay.Location = New System.Drawing.Point(232, 32)
        Me.txtDay.Name = "txtDay"
        Me.txtDay.Size = New System.Drawing.Size(32, 21)
        Me.txtDay.TabIndex = 8
        Me.txtDay.Text = "30"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(176, 32)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(56, 23)
        Me.Label3.TabIndex = 7
        Me.Label3.Text = "出勤天数"
        '
        'btnExcel
        '
        Me.btnExcel.Location = New System.Drawing.Point(504, 32)
        Me.btnExcel.Name = "btnExcel"
        Me.btnExcel.Size = New System.Drawing.Size(120, 23)
        Me.btnExcel.TabIndex = 6
        Me.btnExcel.Text = "导出到Excel"
        '
        'btnRe
        '
        Me.btnRe.Location = New System.Drawing.Point(384, 32)
        Me.btnRe.Name = "btnRe"
        Me.btnRe.TabIndex = 5
        Me.btnRe.Text = "重新计算"
        '
        'btnTable
        '
        Me.btnTable.Location = New System.Drawing.Point(296, 32)
        Me.btnTable.Name = "btnTable"
        Me.btnTable.TabIndex = 4
        Me.btnTable.Text = "生成报表"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(144, 32)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(16, 23)
        Me.Label2.TabIndex = 3
        Me.Label2.Text = "月"
        '
        'cbMonth
        '
        Me.cbMonth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cbMonth.Items.AddRange(New Object() {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"})
        Me.cbMonth.Location = New System.Drawing.Point(104, 32)
        Me.cbMonth.Name = "cbMonth"
        Me.cbMonth.Size = New System.Drawing.Size(40, 20)
        Me.cbMonth.TabIndex = 2
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(88, 32)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(16, 23)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "年"
        '
        'txtYear
        '
        Me.txtYear.Location = New System.Drawing.Point(48, 32)
        Me.txtYear.Name = "txtYear"
        Me.txtYear.Size = New System.Drawing.Size(40, 21)
        Me.txtYear.TabIndex = 0
        Me.txtYear.Text = ""
        '
        'Panel2
        '
        Me.Panel2.Controls.Add(Me.DataGrid1)
        Me.Panel2.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Panel2.DockPadding.Bottom = 40
        Me.Panel2.DockPadding.Left = 40
        Me.Panel2.DockPadding.Right = 40
        Me.Panel2.Location = New System.Drawing.Point(0, 64)
        Me.Panel2.Name = "Panel2"
        Me.Panel2.Size = New System.Drawing.Size(672, 366)
        Me.Panel2.TabIndex = 1
        '
        'DataGrid1
        '
        Me.DataGrid1.CaptionText = "月工资表"
        Me.DataGrid1.DataMember = ""
        Me.DataGrid1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGrid1.Location = New System.Drawing.Point(40, 0)
        Me.DataGrid1.Name = "DataGrid1"
        Me.DataGrid1.Size = New System.Drawing.Size(592, 326)
        Me.DataGrid1.TabIndex = 0
        '
        'frmGztj
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(672, 430)
        Me.Controls.Add(Me.Panel2)
        Me.Controls.Add(Me.Panel1)
        Me.Name = "frmGztj"
        Me.ShowInTaskbar = False
        Me.Text = "工资月报表"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
        Me.Panel1.ResumeLayout(False)
        Me.Panel2.ResumeLayout(False)
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Function DotTwo(ByVal dou As Decimal) As Decimal
        Return (Math.Round(dou * 100)) / 100
    End Function

    Public Sub Exports2Excel2(ByVal Dtg As DataGrid)
        If Dtg.VisibleRowCount > 0 Then
            Try
                Me.Cursor = Cursors.WaitCursor
                Dim datav As New DataView
                If TypeOf Dtg.DataSource Is DataView Then
                    datav = CType(Dtg.DataSource, DataView)
                ElseIf TypeOf Dtg.DataSource Is DataSet Then
                    datav = CType(Dtg.DataSource, DataSet).Tables(0).DefaultView
                ElseIf TypeOf Dtg.DataSource Is DataTable Then
                    datav = CType(Dtg.DataSource, DataTable).DefaultView
                End If
                Dim i, j As Integer
                Dim rows As Integer = datav.Table.Rows.Count
                Dim cols As Integer = datav.Table.Columns.Count
                Dim DataArray(rows - 1, cols - 1) As Object
                Dim myExcel As Excel.Application = New Excel.Application
                For i = 0 To rows - 1
                    For j = 0 To cols - 1

                        If datav.Table.Rows(i).IsNull(j) Then
                            DataArray(i, j) = ""
                        Else

                            DataArray(i, j) = datav.Table.Rows(i).Item(j)

                        End If




                    Next
                Next
                myExcel.Application.Workbooks.Add(True)
                myExcel.Visible = True
                For j = 0 To cols - 1



                    myExcel.Cells(1, j + 1) = datav.Table.Columns(j).ColumnName

                Next
                myExcel.Range("A2").Resize(rows, cols).Value = DataArray

            Catch exp As Exception
                MessageBox.Show("数据导出失败!请查看是否已经安装了Excel", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)

                'MessageBox.Show(exp.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
            Finally
                Me.Cursor = Cursors.Default
            End Try
        Else
            MessageBox.Show("没有数据!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If
    End Sub

    Private Sub AddAll()
        Dim dr As DataRow
        Dim douSq As Decimal
        Dim douSds As Decimal
        Dim douSf As Decimal
        Dim rd As OleDbDataReader

        For Each dr In dt.Rows
            cmdSQL.CommandText = "select Jbgz,lao,yi,ye from Ryzl " & _
                                 "where Gh = '" & dr("工号").ToString & "'"
            rd = cmdSQL.ExecuteReader
            If rd.Read Then
                dr("基本工资") = rd.GetDecimal(0)
                dr("三金") = -(rd.GetDecimal(1) + rd.GetDecimal(2) + rd.GetDecimal(3))
            End If
            rd.Close()
            'dr("基本工资") = cmdSQL.ExecuteScalar()
            dr("基本工资") = DotTwo((CType(dr("基本工资"), Decimal) * CType(dr("实际出勤"), Decimal) / CType(dr("应该出勤"), Decimal)))

            douSq = 0
            douSq += CType(dr("基本工资"), Decimal) + CType(dr("计件工资"), Decimal)
            cmdSQL.CommandText = "select Xmmc from Gzxm where Type ='SQ'"
            rd = cmdSQL.ExecuteReader()
            Do While rd.Read
                douSq += CType(dr(Trim(rd.GetString(0))), Decimal)
            Loop
            rd.Close()
            dr("应发工资") = DotTwo(douSq + douYfgz)
            dr("税前小计") = DotTwo(douSq)
            douSf = douSq

            douSds = 0
            douSq = douSq - 1200
            If douSq <= 0 Then
                douSds = 0
            Else
                If douSq > 0 And douSq <= 500 Then
                    douSds = CType(douSq * 0.05, Decimal)
                ElseIf douSq > 500 And douSq <= 2000 Then
                    douSds = CType(douSq * 0.1 - 25, Decimal)
                ElseIf douSq > 2000 And douSq <= 5000 Then
                    douSds = CType(douSq * 0.15 - 125, Decimal)
                ElseIf douSq > 5000 And douSq <= 20000 Then
                    douSds = CType(douSq * 0.2 - 375, Decimal)
                ElseIf douSq > 20000 And douSq <= 40000 Then
                    douSds = CType(douSq * 0.25 - 1375, Decimal)
                ElseIf douSq > 40000 And douSq <= 60000 Then
                    douSds = CType(douSq * 0.3 - 3375, Decimal)
                ElseIf douSq > 60000 And douSq <= 80000 Then
                    douSds = CType(douSq * 0.35 - 6375, Decimal)
                ElseIf douSq > 80000 And douSq <= 100000 Then
                    douSds = CType(douSq * 0.4 - 10375, Decimal)
                ElseIf douSq > 100000 Then
                    douSds = CType(douSq * 0.45 - 15375, Decimal)
                End If
            End If
            dr("个人所得税") = -DotTwo(douSds)
            douSf = douSf - douSds
            cmdSQL.CommandText = "select Xmmc from Gzxm where Type ='SH'"
            rd = cmdSQL.ExecuteReader()
            Do While rd.Read
                douSf += CType(dr(Trim(rd.GetString(0))), Decimal)
            Loop
            douSf += CType(dr("三金"), Decimal)
            rd.Close()
            dr("实发") = DotTwo(douSf)

⌨️ 快捷键说明

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