Option Strict Off
Imports System.Windows.Forms.DataVisualization.Charting
Public Class 財務報表3
    Dim 選款項 As Boolean
    Private Sub 語言轉換讀取()
        If 系統語言 = "繁體中文" Then : 語言 = "CH" : ElseIf 系統語言 = "English" Then : 語言 = "EN" : ElseIf 系統語言 = "Indonesian" Then : 語言 = "IN" : End If
        Me.Text = 系統語言字典("H001-209-" & 語言) : 表頭(11) = 系統語言字典("H110-118-" & 語言) : 表頭(12) = 系統語言字典(介面 & "-103-" & 語言)
        表頭(14) = 系統語言字典(介面 & "-105-" & 語言) : 表頭(15) = 系統語言字典(介面 & "-106-" & 語言) : 表頭(16) = 系統語言字典(介面 & "-107-" & 語言)
        表頭(17) = 系統語言字典(介面 & "-108-" & 語言) : 表頭(18) = 系統語言字典(介面 & "-109-" & 語言) : 表頭(19) = 系統語言字典(介面 & "-110-" & 語言)
        表頭(20) = 系統語言字典(介面 & "-111-" & 語言) : 表頭(21) = 系統語言字典(介面 & "-112-" & 語言) : 表頭(13) = 系統語言字典(介面 & "-104-" & 語言)
        款項_bt.Text = 系統語言字典("H309-100-" & 語言) : B1.Text = 系統語言字典(介面 & "-105-" & 語言) : B2.Text = 系統語言字典(介面 & "-106-" & 語言)
        稅額_bt.Text = 系統語言字典("H309-101-" & 語言) : B3.Text = 系統語言字典(介面 & "-107-" & 語言) : B4.Text = 系統語言字典(介面 & "-108-" & 語言)
    End Sub
    Private Sub Set_請款清單()
        Dim ds1 As New DataSet : 請款清單_dgv.DataSource = Nothing : ds1.Clear()
        請款清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        請款清單_dgv.ColumnHeadersHeight = 25 : 請款清單_dgv.AllowUserToAddRows = False
        SQL_請款清單() : da.Fill(ds1) : 請款清單_dgv.DataSource = ds1.Tables(0) : conn.Close()
        請款清單_dgv.Columns("期數").FillWeight = 40 : 請款清單_dgv.Columns("稅金").FillWeight = 40
        請款清單_dgv.Columns("本收").FillWeight = 40 : 請款清單_dgv.Columns("稅收").FillWeight = 40

        Dim formatColumns() As Integer = {3, 5, 4, 6}
        For Each colIndex As Integer In formatColumns
            請款清單_dgv.Columns(colIndex).DefaultCellStyle.Format = "#,##0"
            請款清單_dgv.Columns(colIndex).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            請款清單_dgv.Columns(colIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
        Next
        For II As Integer = 0 To 請款清單_dgv.Rows.Count - 1
            If IsDBNull(請款清單_dgv.Rows(II).Cells("本收").Value) = True Then : 請款清單_dgv.Rows(II).Cells("本收").Value = False : End If
            If IsDBNull(請款清單_dgv.Rows(II).Cells("稅收").Value) = True Then : 請款清單_dgv.Rows(II).Cells("稅收").Value = False : End If
        Next
    End Sub
    Private Sub Set_合約清單()
        Set_請款清單() : Set_合約報表計算() : Set_合約報表計算1()
        Dim ds5 As New DataSet : 彙總_dgv.DataSource = Nothing
        彙總_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        彙總_dgv.ColumnHeadersHeight = 25 : 彙總_dgv.AllowUserToAddRows = False
        表頭(9) = "合約號" : 表頭(10) = "合約2%" : SQL_合約彙總()
        da.Fill(ds5) : 彙總_dgv.DataSource = ds5.Tables(0)
        彙總_dgv.Columns("甲方").FillWeight = 40 : 彙總_dgv.Columns("計數").FillWeight = 40

        Dim formatColumns() As Integer = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
        For Each colIndex As Integer In formatColumns
            彙總_dgv.Columns(colIndex).DefaultCellStyle.Format = "#,##0"
            彙總_dgv.Columns(colIndex).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            彙總_dgv.Columns(colIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
        Next
        '---------------------------基本計算----------------------------------------------------------------------------------------------------------------------------------------------
        For i As Integer = 0 To 彙總_dgv.Rows.Count - 1
            If 彙總_dgv.Rows(i).Cells("總報價").Value.ToString = "" Then : 彙總_dgv.Rows(i).Cells("總報價").Value = "0" : End If
            彙總_dgv.Rows(i).Cells("已請款").Value = "0" : 彙總_dgv.Rows(i).Cells("未請款").Value = "0" : 彙總_dgv.Rows(i).Cells("已請稅").Value = "0"
            彙總_dgv.Rows(i).Cells("未請稅").Value = "0" : 彙總_dgv.Rows(i).Cells("已收款").Value = "0" : 彙總_dgv.Rows(i).Cells("已請未收款").Value = "0"
            彙總_dgv.Rows(i).Cells("已收稅").Value = "0" : 彙總_dgv.Rows(i).Cells("已請未收稅").Value = "0" : 彙總_dgv.Rows(i).Cells("計數").Value = "1"
            彙總_dgv.Rows(i).Cells("稅金").Value = CLng(彙總_dgv.Rows(i).Cells("工程總價").Value.ToString) - CLng(彙總_dgv.Rows(i).Cells("總報價").Value.ToString)
            For ii As Integer = 0 To 請款清單_dgv.Rows.Count - 1
                If 彙總_dgv.Rows(i).Cells(0).Value.ToString = 請款清單_dgv.Rows(ii).Cells(0).Value.ToString Then
                    彙總_dgv.Rows(i).Cells("已請款").Value = CLng(彙總_dgv.Rows(i).Cells("已請款").Value.ToString) + CLng(請款清單_dgv.Rows(ii).Cells("請款金額").Value.ToString)
                    彙總_dgv.Rows(i).Cells("已請稅").Value = CLng(彙總_dgv.Rows(i).Cells("已請稅").Value.ToString) + CLng(請款清單_dgv.Rows(ii).Cells("稅額").Value.ToString)
                End If
                If 彙總_dgv.Rows(i).Cells(0).Value.ToString = 請款清單_dgv.Rows(ii).Cells(0).Value.ToString And 請款清單_dgv.Rows(ii).Cells("本收").Value = True Then
                    彙總_dgv.Rows(i).Cells("已收款").Value = CLng(彙總_dgv.Rows(i).Cells("已收款").Value.ToString) + CLng(請款清單_dgv.Rows(ii).Cells("請款金額").Value.ToString)
                End If
                If 彙總_dgv.Rows(i).Cells(0).Value.ToString = 請款清單_dgv.Rows(ii).Cells(0).Value.ToString And 請款清單_dgv.Rows(ii).Cells("稅收").Value = True Then
                    彙總_dgv.Rows(i).Cells("已收稅").Value = CLng(彙總_dgv.Rows(i).Cells("已收稅").Value.ToString) + CLng(請款清單_dgv.Rows(ii).Cells("稅額").Value.ToString)
                End If
            Next
            彙總_dgv.Rows(i).Cells("未請款").Value = CLng(彙總_dgv.Rows(i).Cells("總報價").Value) - (彙總_dgv.Rows(i).Cells("已請款").Value)
            彙總_dgv.Rows(i).Cells("未請稅").Value = CLng(彙總_dgv.Rows(i).Cells("稅金").Value) - (彙總_dgv.Rows(i).Cells("已請稅").Value)
            彙總_dgv.Rows(i).Cells("已請未收款").Value = CLng(彙總_dgv.Rows(i).Cells("已請款").Value) - (彙總_dgv.Rows(i).Cells("已收款").Value)
            彙總_dgv.Rows(i).Cells("已請未收稅").Value = CLng(彙總_dgv.Rows(i).Cells("已請稅").Value) - (彙總_dgv.Rows(i).Cells("已收稅").Value)
            If CLng(彙總_dgv.Rows(i).Cells("未請款").Value) < 0 Then : 彙總_dgv.Rows(i).Cells("未請款").Value = "0" : End If
            If CLng(彙總_dgv.Rows(i).Cells("未請稅").Value) < 0 Then : 彙總_dgv.Rows(i).Cells("未請稅").Value = "0" : End If
        Next
        '---------------------------彙總計算----------------------------------------------------------------------------------------------------------------------------------------------
        合計1_dgv.Rows(0).Cells(1).Value = "0" : 合計2_dgv.Rows(0).Cells("工程總價").Value = "0" : 合計2_dgv.Rows(0).Cells("總報價").Value = "0"
        合計2_dgv.Rows(0).Cells("稅金").Value = "0" : 合計2_dgv.Rows(0).Cells("已請款").Value = "0" : 合計2_dgv.Rows(0).Cells("未請款").Value = "0"
        合計2_dgv.Rows(0).Cells("已請稅").Value = "0" : 合計2_dgv.Rows(0).Cells("未請稅").Value = "0" : 合計2_dgv.Rows(0).Cells("已收款").Value = "0"
        合計2_dgv.Rows(0).Cells("已請未收款").Value = "0" : 合計2_dgv.Rows(0).Cells("已收稅").Value = "0" : 合計2_dgv.Rows(0).Cells("已請未收稅").Value = "0"
        For i As Integer = 0 To 計算_dgv.Rows.Count - 1
            計算_dgv.Rows(i).Cells(表頭(12)).Value = "0" : 計算_dgv.Rows(i).Cells(表頭(13)).Value = "0" : 計算_dgv.Rows(i).Cells("總報價").Value = "0"
            計算_dgv.Rows(i).Cells("稅金").Value = "0" : 計算_dgv.Rows(i).Cells(表頭(14)).Value = "0" : 計算_dgv.Rows(i).Cells(表頭(15)).Value = "0"
            計算_dgv.Rows(i).Cells(表頭(18)).Value = "0" : 計算_dgv.Rows(i).Cells(表頭(19)).Value = "0" : 計算_dgv.Rows(i).Cells(表頭(16)).Value = "0"
            計算_dgv.Rows(i).Cells(表頭(17)).Value = "0" : 計算_dgv.Rows(i).Cells(表頭(20)).Value = "0" : 計算_dgv.Rows(i).Cells(表頭(21)).Value = "0"
            計算1_dgv.Rows(i).Cells(表頭(12)).Value = "0"
            計算2_dgv.Rows(i).Cells(表頭(12)).Value = "0" : 計算2_dgv.Rows(i).Cells(表頭(13)).Value = "0" : 計算2_dgv.Rows(i).Cells("總報價").Value = "0"
            計算2_dgv.Rows(i).Cells("稅金").Value = "0" : 計算2_dgv.Rows(i).Cells(表頭(14)).Value = "0" : 計算2_dgv.Rows(i).Cells(表頭(15)).Value = "0"
            計算2_dgv.Rows(i).Cells(表頭(18)).Value = "0" : 計算2_dgv.Rows(i).Cells(表頭(19)).Value = "0" : 計算2_dgv.Rows(i).Cells(表頭(16)).Value = "0"
            計算2_dgv.Rows(i).Cells(表頭(17)).Value = "0" : 計算2_dgv.Rows(i).Cells(表頭(20)).Value = "0" : 計算2_dgv.Rows(i).Cells(表頭(21)).Value = "0"
            For ii As Integer = 0 To 彙總_dgv.Rows.Count - 1
                If 計算_dgv.Rows(i).Cells(0).Value.ToString = 彙總_dgv.Rows(ii).Cells("甲方").Value.ToString Then
                    計算_dgv.Rows(i).Cells(表頭(12)).Value = CLng(計算_dgv.Rows(i).Cells(表頭(12)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("計數").Value.ToString)
                    計算1_dgv.Rows(i).Cells(表頭(12)).Value = CLng(計算1_dgv.Rows(i).Cells(表頭(12)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("計數").Value.ToString)
                    計算_dgv.Rows(i).Cells(表頭(13)).Value = CLng(計算_dgv.Rows(i).Cells(表頭(13)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("工程總價").Value.ToString)
                    計算_dgv.Rows(i).Cells("總報價").Value = CLng(計算_dgv.Rows(i).Cells("總報價").Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("總報價").Value.ToString)
                    計算_dgv.Rows(i).Cells("稅金").Value = CLng(計算_dgv.Rows(i).Cells("稅金").Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("稅金").Value.ToString)
                    計算_dgv.Rows(i).Cells(表頭(14)).Value = CLng(計算_dgv.Rows(i).Cells(表頭(14)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("已請款").Value.ToString)
                    計算_dgv.Rows(i).Cells(表頭(15)).Value = CLng(計算_dgv.Rows(i).Cells(表頭(15)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("未請款").Value.ToString)
                    計算_dgv.Rows(i).Cells(表頭(18)).Value = CLng(計算_dgv.Rows(i).Cells(表頭(18)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("已請稅").Value.ToString)
                    計算_dgv.Rows(i).Cells(表頭(19)).Value = CLng(計算_dgv.Rows(i).Cells(表頭(19)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("未請稅").Value.ToString)
                    計算_dgv.Rows(i).Cells(表頭(16)).Value = CLng(計算_dgv.Rows(i).Cells(表頭(16)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("已收款").Value.ToString)
                    計算_dgv.Rows(i).Cells(表頭(17)).Value = CLng(計算_dgv.Rows(i).Cells(表頭(17)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("已請未收款").Value.ToString)
                    計算_dgv.Rows(i).Cells(表頭(20)).Value = CLng(計算_dgv.Rows(i).Cells(表頭(20)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("已收稅").Value.ToString)
                    計算_dgv.Rows(i).Cells(表頭(21)).Value = CLng(計算_dgv.Rows(i).Cells(表頭(21)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("已請未收稅").Value.ToString)

                    計算2_dgv.Rows(i).Cells(表頭(13)).Value = CLng(計算2_dgv.Rows(i).Cells(表頭(13)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("工程總價").Value.ToString)
                    計算2_dgv.Rows(i).Cells("總報價").Value = CLng(計算2_dgv.Rows(i).Cells("總報價").Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("總報價").Value.ToString)
                    計算2_dgv.Rows(i).Cells("稅金").Value = CLng(計算2_dgv.Rows(i).Cells("稅金").Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("稅金").Value.ToString)
                    計算2_dgv.Rows(i).Cells(表頭(14)).Value = CLng(計算2_dgv.Rows(i).Cells(表頭(14)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("已請款").Value.ToString)
                    計算2_dgv.Rows(i).Cells(表頭(15)).Value = CLng(計算2_dgv.Rows(i).Cells(表頭(15)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("未請款").Value.ToString)
                    計算2_dgv.Rows(i).Cells(表頭(18)).Value = CLng(計算2_dgv.Rows(i).Cells(表頭(18)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("已請稅").Value.ToString)
                    計算2_dgv.Rows(i).Cells(表頭(19)).Value = CLng(計算2_dgv.Rows(i).Cells(表頭(19)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("未請稅").Value.ToString)
                    計算2_dgv.Rows(i).Cells(表頭(16)).Value = CLng(計算2_dgv.Rows(i).Cells(表頭(16)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("已收款").Value.ToString)
                    計算2_dgv.Rows(i).Cells(表頭(17)).Value = CLng(計算2_dgv.Rows(i).Cells(表頭(17)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("已請未收款").Value.ToString)
                    計算2_dgv.Rows(i).Cells(表頭(20)).Value = CLng(計算2_dgv.Rows(i).Cells(表頭(20)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("已收稅").Value.ToString)
                    計算2_dgv.Rows(i).Cells(表頭(21)).Value = CLng(計算2_dgv.Rows(i).Cells(表頭(21)).Value.ToString) + CLng(彙總_dgv.Rows(ii).Cells("已請未收稅").Value.ToString)
                End If
            Next
            If CLng(計算2_dgv.Rows(i).Cells("總報價").Value.ToString) = 0 Then : 計算2_dgv.Rows(i).Cells("比例1").Value = "0" : Else
                計算2_dgv.Rows(i).Cells("比例1").Value = CLng(計算2_dgv.Rows(i).Cells(表頭(14)).Value.ToString) / CLng(計算2_dgv.Rows(i).Cells("總報價").Value.ToString) * 100
            End If
            If CLng(計算2_dgv.Rows(i).Cells(表頭(14)).Value.ToString) = 0 Then : 計算2_dgv.Rows(i).Cells("比例2").Value = "0" : Else
                計算2_dgv.Rows(i).Cells("比例2").Value = CLng(計算2_dgv.Rows(i).Cells(表頭(16)).Value.ToString) / CLng(計算2_dgv.Rows(i).Cells(表頭(14)).Value.ToString) * 100
            End If
            If CLng(計算2_dgv.Rows(i).Cells("稅金").Value.ToString) = 0 Then : 計算2_dgv.Rows(i).Cells("比例3").Value = "0" : Else
                計算2_dgv.Rows(i).Cells("比例3").Value = CLng(計算2_dgv.Rows(i).Cells(表頭(18)).Value.ToString) / CLng(計算2_dgv.Rows(i).Cells("稅金").Value.ToString) * 100
            End If
            If CLng(計算2_dgv.Rows(i).Cells(表頭(18)).Value.ToString) = 0 Then : 計算2_dgv.Rows(i).Cells("比例4").Value = "0" : Else
                計算2_dgv.Rows(i).Cells("比例4").Value = CLng(計算2_dgv.Rows(i).Cells(表頭(20)).Value.ToString) / CLng(計算2_dgv.Rows(i).Cells(表頭(18)).Value.ToString) * 100
            End If
            合計1_dgv.Rows(0).Cells(1).Value = CLng(合計1_dgv.Rows(0).Cells(1).Value.ToString) + CLng(計算1_dgv.Rows(i).Cells(表頭(12)).Value.ToString)
            合計2_dgv.Rows(0).Cells("工程總價").Value = CLng(合計2_dgv.Rows(0).Cells("工程總價").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(13)).Value.ToString)
            合計2_dgv.Rows(0).Cells("總報價").Value = CLng(合計2_dgv.Rows(0).Cells("總報價").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells("總報價").Value.ToString)
            合計2_dgv.Rows(0).Cells("稅金").Value = CLng(合計2_dgv.Rows(0).Cells("稅金").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells("稅金").Value.ToString)
            合計2_dgv.Rows(0).Cells("已請款").Value = CLng(合計2_dgv.Rows(0).Cells("已請款").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(14)).Value.ToString)
            合計2_dgv.Rows(0).Cells("未請款").Value = CLng(合計2_dgv.Rows(0).Cells("未請款").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(15)).Value.ToString)
            合計2_dgv.Rows(0).Cells("已請稅").Value = CLng(合計2_dgv.Rows(0).Cells("已請稅").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(18)).Value.ToString)
            合計2_dgv.Rows(0).Cells("未請稅").Value = CLng(合計2_dgv.Rows(0).Cells("未請稅").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(19)).Value.ToString)
            合計2_dgv.Rows(0).Cells("已收款").Value = CLng(合計2_dgv.Rows(0).Cells("已收款").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(16)).Value.ToString)
            合計2_dgv.Rows(0).Cells("已請未收款").Value = CLng(合計2_dgv.Rows(0).Cells("已請未收款").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(17)).Value.ToString)
            合計2_dgv.Rows(0).Cells("已收稅").Value = CLng(合計2_dgv.Rows(0).Cells("已收稅").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(20)).Value.ToString)
            合計2_dgv.Rows(0).Cells("已請未收稅").Value = CLng(合計2_dgv.Rows(0).Cells("已請未收稅").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(21)).Value.ToString)
        Next
        合計1_dgv.Rows(0).Cells(0).Value = 系統語言字典(介面 & "-101-" & 語言) : 合計2_dgv.Rows(0).Cells(0).Value = 系統語言字典(介面 & "-102-" & 語言)
        If CLng(合計2_dgv.Rows(0).Cells("總報價").Value.ToString) = 0 Then : 合計2_dgv.Rows(0).Cells("比例1").Value = "0" : Else
            合計2_dgv.Rows(0).Cells("比例1").Value = CLng(合計2_dgv.Rows(0).Cells("已請款").Value.ToString) / CLng(合計2_dgv.Rows(0).Cells("總報價").Value.ToString) * 100
            If CLng(合計2_dgv.Rows(0).Cells("比例1").Value) > 100 Then : 合計2_dgv.Rows(0).Cells("比例1").Value = "100" : End If
        End If
        If CLng(合計2_dgv.Rows(0).Cells("已請款").Value.ToString) = 0 Then : 合計2_dgv.Rows(0).Cells("比例2").Value = "0" : Else
            合計2_dgv.Rows(0).Cells("比例2").Value = CLng(合計2_dgv.Rows(0).Cells("已收款").Value.ToString) / CLng(合計2_dgv.Rows(0).Cells("已請款").Value.ToString) * 100
            If CLng(合計2_dgv.Rows(0).Cells("比例2").Value) > 100 Then : 合計2_dgv.Rows(0).Cells("比例2").Value = "100" : End If
        End If
        If CLng(合計2_dgv.Rows(0).Cells("稅金").Value.ToString) = 0 Then : 合計2_dgv.Rows(0).Cells("比例3").Value = "0" : Else
            合計2_dgv.Rows(0).Cells("比例3").Value = CLng(合計2_dgv.Rows(0).Cells("已請稅").Value.ToString) / CLng(合計2_dgv.Rows(0).Cells("稅金").Value.ToString) * 100
            If CLng(合計2_dgv.Rows(0).Cells("比例3").Value) > 100 Then : 合計2_dgv.Rows(0).Cells("比例3").Value = "100" : End If
        End If
        If CLng(合計2_dgv.Rows(0).Cells("已請稅").Value.ToString) = 0 Then : 合計2_dgv.Rows(0).Cells("比例4").Value = "0" : Else
            合計2_dgv.Rows(0).Cells("比例4").Value = CLng(合計2_dgv.Rows(0).Cells("已收稅").Value.ToString) / CLng(合計2_dgv.Rows(0).Cells("已請稅").Value.ToString) * 100
            If CLng(合計2_dgv.Rows(0).Cells("比例4").Value) > 100 Then : 合計2_dgv.Rows(0).Cells("比例4").Value = "100" : End If
        End If

        計算_dgv.Sort(計算_dgv.Columns(表頭(13)), System.ComponentModel.ListSortDirection.Descending)
        計算1_dgv.Sort(計算1_dgv.Columns(表頭(12)), System.ComponentModel.ListSortDirection.Descending)
        計算2_dgv.Sort(計算2_dgv.Columns(表頭(13)), System.ComponentModel.ListSortDirection.Descending)
        彙總()
    End Sub
    Private Sub Set_合約甲方()
        Dim ds1 As New DataSet : 甲方_dgv.DataSource = Nothing : ds1.Clear()
        甲方_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        甲方_dgv.ColumnHeadersHeight = 25 : 甲方_dgv.AllowUserToAddRows = False
        SQL_合約甲方() : da.Fill(ds1) : 甲方_dgv.DataSource = ds1.Tables(0) : conn.Close()
        If 甲方_dgv.Rows.Count > 19 Then : MGB(系統語言字典(介面 & "-100-" & 語言), 1) : Me.Close() : End If
        For i As Integer = 1 To 20
            Dim 選擇 As CheckBox = CType(Me.Controls.Find("A" & i, True)(0), CheckBox) : 選擇.Visible = False
        Next
        For i As Integer = 0 To 甲方_dgv.Rows.Count - 1
            Dim 選擇 As CheckBox = CType(Me.Controls.Find("A" & i + 1, True)(0), CheckBox) : 選擇.Text = 甲方_dgv.Rows(i).Cells(0).Value.ToString : 選擇.Visible = True
        Next
    End Sub
    Private Sub Set_合約報表計算()
        Dim ds1, ds2, ds3 As New DataSet
        計算_dgv.DataSource = Nothing : 計算1_dgv.DataSource = Nothing : 合計1_dgv.DataSource = Nothing : ds1.Clear() : ds2.Clear() : ds3.Clear()
        計算_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        計算_dgv.ColumnHeadersHeight = 25 : 計算_dgv.AllowUserToAddRows = False
        計算1_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        計算1_dgv.ColumnHeadersHeight = 25 : 計算1_dgv.AllowUserToAddRows = False
        合計1_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        合計1_dgv.ColumnHeadersHeight = 25 : 合計1_dgv.AllowUserToAddRows = False
        合計1_dgv.ColumnHeadersVisible = False
        Dim SSA(19) As String
        Dim checkBoxes() As CheckBox = {A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20}
        For i As Integer = 0 To SSA.Length - 1
            If checkBoxes(i).Checked Then : SSA(i) = " 約號甲方 LIKE N'" & checkBoxes(i).Text & "'" : Else : SSA(i) = "" : End If
        Next
        If SSA.All(Function(s) String.IsNullOrEmpty(s)) Then : SQL2 = "" : Else
            Dim selectedSSA = SSA.Where(Function(s) Not String.IsNullOrEmpty(s)).ToArray()
            SQL2 = "AND (" & String.Join(" OR ", selectedSSA) & ")"
        End If
        SQL_合約報表計算1() : da.Fill(ds1) : da.Fill(ds2) : SQL_合約報表計算2() : da.Fill(ds3)
        計算_dgv.DataSource = ds1.Tables(0) : 計算1_dgv.DataSource = ds2.Tables(0) : 合計1_dgv.DataSource = ds3.Tables(0) : conn.Close()
        計算_dgv.Columns("比例1").Visible = False : 計算_dgv.Columns("比例2").Visible = False
        計算_dgv.Columns("比例3").Visible = False : 計算_dgv.Columns("比例4").Visible = False
        For j As Integer = 2 To 16 : 計算1_dgv.Columns(j).Visible = False : 合計1_dgv.Columns(j).Visible = False : Next
        合計1_dgv.Columns(1).DefaultCellStyle.Format = "#,##0"
        計算1_dgv.Columns(1).DefaultCellStyle.Format = "#,##0" : 計算_dgv.Columns(3).DefaultCellStyle.Format = "#,##0"
        計算_dgv.Columns(1).DefaultCellStyle.Format = "#,##0" : 計算_dgv.Columns(2).DefaultCellStyle.Format = "#,##0"
        Dim formatColumns() As Integer = {4, 5, 6, 7, 8, 9, 10, 11, 12}
        For Each colIndex As Integer In formatColumns : 計算_dgv.Columns(colIndex).DefaultCellStyle.Format = "#,##0" : Next
        Dim alignmentColumns() As Integer = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
        For Each colIndex As Integer In alignmentColumns
            計算_dgv.Columns(colIndex).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            計算1_dgv.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            合計1_dgv.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            計算_dgv.Columns(colIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
            計算1_dgv.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
            合計1_dgv.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
        Next
        '-------------------------合計DGV變形----------------------------------------------------------------------------------------------------------------------
        If IsVerticalScrollBarVisible(計算1_dgv) Then : 合計1_dgv.Size = New Size(計算1_dgv.Size.Width - 17, 合計1_dgv.Size.Height)
        Else : 合計1_dgv.Size = New Size(計算1_dgv.Size.Width, 合計1_dgv.Size.Height) : End If
    End Sub
    Private Function IsVerticalScrollBarVisible(dgv As DataGridView) As Boolean
        Return dgv.FirstDisplayedScrollingRowIndex > 0 OrElse dgv.DisplayedRowCount(False) < dgv.Rows.Count
    End Function
    Private Sub Set_合約報表計算1()
        Dim ds2, ds3 As New DataSet : 計算2_dgv.DataSource = Nothing : 合計2_dgv.DataSource = Nothing : ds2.Clear() : ds3.Clear()
        計算2_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        計算2_dgv.ColumnHeadersHeight = 25 : 計算2_dgv.AllowUserToAddRows = False
        合計2_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        合計2_dgv.ColumnHeadersHeight = 25 : 合計2_dgv.AllowUserToAddRows = False
        合計2_dgv.ColumnHeadersVisible = False
        合計2_dgv.ScrollBars = ScrollBars.None
        Dim SSA(19) As String
        Dim checkBoxes() As CheckBox = {A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20}
        For i As Integer = 0 To SSA.Length - 1
            If checkBoxes(i).Checked Then : SSA(i) = " 約號甲方 LIKE N'" & checkBoxes(i).Text & "'" : Else : SSA(i) = "" : End If
        Next
        If SSA.All(Function(s) String.IsNullOrEmpty(s)) Then : SQL2 = "" : Else
            Dim selectedSSA = SSA.Where(Function(s) Not String.IsNullOrEmpty(s)).ToArray()
            SQL2 = "AND (" & String.Join(" OR ", selectedSSA) & ")"
        End If
        SQL_合約報表計算1() : da.Fill(ds3) : SQL_合約報表計算2() : da.Fill(ds2)
        計算2_dgv.DataSource = ds3.Tables(0) : 合計2_dgv.DataSource = ds2.Tables(0) : conn.Close()
        For i As Integer = 0 To 計算2_dgv.Rows.Count - 1
            計算2_dgv.Rows(i).Cells("比例1").Value = "0" : 計算2_dgv.Rows(i).Cells("比例2").Value = "0"
            計算2_dgv.Rows(i).Cells("比例3").Value = "0" : 計算2_dgv.Rows(i).Cells("比例4").Value = "0"
        Next
        合計2_dgv.Rows(0).Cells("比例1").Value = "0" : 合計2_dgv.Rows(0).Cells("比例2").Value = "0"
        合計2_dgv.Rows(0).Cells("比例3").Value = "0" : 合計2_dgv.Rows(0).Cells("比例4").Value = "0"
        Set_進度條顯示1() : Set_進度條顯示2() : Set_進度條顯示3() : Set_進度條顯示4()
        Set_進度條顯示5() : Set_進度條顯示6() : Set_進度條顯示7() : Set_進度條顯示8()
        計算2_dgv.Columns(1).Visible = False
        計算2_dgv.Columns(3).Visible = False : 計算2_dgv.Columns(4).Visible = False
        計算2_dgv.Columns("比例1").Visible = False : 計算2_dgv.Columns("比例2").Visible = False
        計算2_dgv.Columns("比例3").Visible = False : 計算2_dgv.Columns("比例4").Visible = False
        計算2_dgv.Columns(2).DefaultCellStyle.Format = "#,##0"

        合計2_dgv.Columns(1).Visible = False
        合計2_dgv.Columns(3).Visible = False : 合計2_dgv.Columns(4).Visible = False
        合計2_dgv.Columns("比例1").Visible = False : 合計2_dgv.Columns("比例2").Visible = False
        合計2_dgv.Columns("比例3").Visible = False : 合計2_dgv.Columns("比例4").Visible = False
        合計2_dgv.Columns(2).DefaultCellStyle.Format = "#,##0"

        Dim formatColumns() As Integer = {1, 2, 3, 4, 5, 6, 9, 10, 13, 14, 17, 18}
        For Each colIndex As Integer In formatColumns
            計算2_dgv.Columns(colIndex).DefaultCellStyle.Format = "#,##0"
            計算2_dgv.Columns(colIndex).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            計算2_dgv.Columns(colIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight

            合計2_dgv.Columns(colIndex).DefaultCellStyle.Format = "#,##0"
            合計2_dgv.Columns(colIndex).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            合計2_dgv.Columns(colIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
        Next
        If 深色風格 = False Then
            計算2_dgv.Columns(表頭(14)).DefaultCellStyle.ForeColor = Color.Red : 計算2_dgv.Columns(表頭(15)).DefaultCellStyle.ForeColor = Color.Red
            計算2_dgv.Columns(表頭(16)).DefaultCellStyle.ForeColor = Color.Blue : 計算2_dgv.Columns(表頭(17)).DefaultCellStyle.ForeColor = Color.Blue
            計算2_dgv.Columns(表頭(18)).DefaultCellStyle.ForeColor = Color.Green : 計算2_dgv.Columns(表頭(19)).DefaultCellStyle.ForeColor = Color.Green
            計算2_dgv.Columns(表頭(20)).DefaultCellStyle.ForeColor = Color.Coral : 計算2_dgv.Columns(表頭(21)).DefaultCellStyle.ForeColor = Color.Coral

            合計2_dgv.Columns("已請款").DefaultCellStyle.ForeColor = Color.Red : 合計2_dgv.Columns("未請款").DefaultCellStyle.ForeColor = Color.Red
            合計2_dgv.Columns("已收款").DefaultCellStyle.ForeColor = Color.Blue : 合計2_dgv.Columns("已請未收款").DefaultCellStyle.ForeColor = Color.Blue
            合計2_dgv.Columns("已請稅").DefaultCellStyle.ForeColor = Color.Green : 合計2_dgv.Columns("未請稅").DefaultCellStyle.ForeColor = Color.Green
            合計2_dgv.Columns("已收稅").DefaultCellStyle.ForeColor = Color.Coral : 合計2_dgv.Columns("已請未收稅").DefaultCellStyle.ForeColor = Color.Coral
        Else
            計算2_dgv.Columns(表頭(14)).DefaultCellStyle.ForeColor = Color.LightPink : 計算2_dgv.Columns(表頭(15)).DefaultCellStyle.ForeColor = Color.LightPink
            計算2_dgv.Columns(表頭(16)).DefaultCellStyle.ForeColor = Color.LightBlue : 計算2_dgv.Columns(表頭(17)).DefaultCellStyle.ForeColor = Color.LightBlue
            計算2_dgv.Columns(表頭(18)).DefaultCellStyle.ForeColor = Color.LightGreen : 計算2_dgv.Columns(表頭(19)).DefaultCellStyle.ForeColor = Color.LightGreen
            計算2_dgv.Columns(表頭(20)).DefaultCellStyle.ForeColor = Color.LightCoral : 計算2_dgv.Columns(表頭(21)).DefaultCellStyle.ForeColor = Color.LightCoral

            合計2_dgv.Columns("已請款").DefaultCellStyle.ForeColor = Color.LightPink : 合計2_dgv.Columns("未請款").DefaultCellStyle.ForeColor = Color.LightPink
            合計2_dgv.Columns("已收款").DefaultCellStyle.ForeColor = Color.LightBlue : 合計2_dgv.Columns("已請未收款").DefaultCellStyle.ForeColor = Color.LightBlue
            合計2_dgv.Columns("已請稅").DefaultCellStyle.ForeColor = Color.LightGreen : 合計2_dgv.Columns("未請稅").DefaultCellStyle.ForeColor = Color.LightGreen
            合計2_dgv.Columns("已收稅").DefaultCellStyle.ForeColor = Color.LightCoral : 合計2_dgv.Columns("已請未收稅").DefaultCellStyle.ForeColor = Color.LightCoral
        End If
        '-------------------------合計DGV變形----------------------------------------------------------------------------------------------------------------------
        If IsVerticalScrollBarVisible(計算2_dgv) Then : 合計2_dgv.Size = New Size(計算2_dgv.Size.Width - 17, 合計2_dgv.Size.Height)
        Else : 合計2_dgv.Size = New Size(計算2_dgv.Size.Width, 合計2_dgv.Size.Height) : End If
    End Sub
    Private Sub Set_合約報表計算2()
        Dim ds2, ds3 As New DataSet : 計算3_dgv.DataSource = Nothing : ds3.Clear()
        計算3_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        計算3_dgv.ColumnHeadersHeight = 25 : 計算3_dgv.AllowUserToAddRows = False
        SQL_合約報表計算3() : da.Fill(ds3)
        計算3_dgv.DataSource = ds3.Tables(0) : conn.Close()
        For i As Integer = 0 To 計算3_dgv.Rows.Count - 1
            計算3_dgv.Rows(i).Cells("比例1").Value = "0" : 計算3_dgv.Rows(i).Cells("比例2").Value = "0"
            計算3_dgv.Rows(i).Cells("比例3").Value = "0" : 計算3_dgv.Rows(i).Cells("比例4").Value = "0"
        Next
        Set_進度條顯示9() : Set_進度條顯示10() : Set_進度條顯示11() : Set_進度條顯示12()

        計算3_dgv.Columns(1).Visible = False
        計算3_dgv.Columns(3).Visible = False : 計算3_dgv.Columns(4).Visible = False
        計算3_dgv.Columns("比例1").Visible = False : 計算3_dgv.Columns("比例2").Visible = False
        計算3_dgv.Columns("比例3").Visible = False : 計算3_dgv.Columns("比例4").Visible = False
        計算3_dgv.Columns(2).DefaultCellStyle.Format = "#,##0"

        Dim formatColumns() As Integer = {1, 2, 3, 4, 5, 6, 9, 10, 13, 14, 17, 18}
        For Each colIndex As Integer In formatColumns
            計算3_dgv.Columns(colIndex).DefaultCellStyle.Format = "#,##0"
            計算3_dgv.Columns(colIndex).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            計算3_dgv.Columns(colIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
        Next
        If 深色風格 = False Then
            計算3_dgv.Columns(表頭(14)).DefaultCellStyle.ForeColor = Color.Red : 計算3_dgv.Columns(表頭(15)).DefaultCellStyle.ForeColor = Color.Red
            計算3_dgv.Columns(表頭(16)).DefaultCellStyle.ForeColor = Color.Blue : 計算3_dgv.Columns(表頭(17)).DefaultCellStyle.ForeColor = Color.Blue
            計算3_dgv.Columns(表頭(18)).DefaultCellStyle.ForeColor = Color.Green : 計算3_dgv.Columns(表頭(19)).DefaultCellStyle.ForeColor = Color.Green
            計算3_dgv.Columns(表頭(20)).DefaultCellStyle.ForeColor = Color.Coral : 計算3_dgv.Columns(表頭(21)).DefaultCellStyle.ForeColor = Color.Coral
        Else
            計算3_dgv.Columns(表頭(14)).DefaultCellStyle.ForeColor = Color.LightPink : 計算3_dgv.Columns(表頭(15)).DefaultCellStyle.ForeColor = Color.LightPink
            計算3_dgv.Columns(表頭(16)).DefaultCellStyle.ForeColor = Color.LightBlue : 計算3_dgv.Columns(表頭(17)).DefaultCellStyle.ForeColor = Color.LightBlue
            計算3_dgv.Columns(表頭(18)).DefaultCellStyle.ForeColor = Color.LightGreen : 計算3_dgv.Columns(表頭(19)).DefaultCellStyle.ForeColor = Color.LightGreen
            計算3_dgv.Columns(表頭(20)).DefaultCellStyle.ForeColor = Color.LightCoral : 計算3_dgv.Columns(表頭(21)).DefaultCellStyle.ForeColor = Color.LightCoral
        End If
        '---------------------------基本計算----------------------------------------------------------------------------------------------------------------------------------------------
        For i As Integer = 0 To 計算3_dgv.Rows.Count - 1
            計算3_dgv.Rows(i).Cells(表頭(14)).Value = "0" : 計算3_dgv.Rows(i).Cells(表頭(15)).Value = "0" : 計算3_dgv.Rows(i).Cells(表頭(18)).Value = "0"
            計算3_dgv.Rows(i).Cells(表頭(19)).Value = "0" : 計算3_dgv.Rows(i).Cells(表頭(16)).Value = "0" : 計算3_dgv.Rows(i).Cells(表頭(17)).Value = "0"
            計算3_dgv.Rows(i).Cells(表頭(20)).Value = "0" : 計算3_dgv.Rows(i).Cells(表頭(21)).Value = "0"
            For ii As Integer = 0 To 彙總_dgv.Rows.Count - 1
                If 計算3_dgv.Rows(i).Cells(0).Value.ToString = 彙總_dgv.Rows(ii).Cells(0).Value.ToString Then
                    計算3_dgv.Rows(i).Cells("工程總價").Value = CLng(彙總_dgv.Rows(ii).Cells("工程總價").Value.ToString)
                    計算3_dgv.Rows(i).Cells("總報價").Value = CLng(彙總_dgv.Rows(ii).Cells("總報價").Value.ToString)
                End If
            Next
            計算3_dgv.Rows(i).Cells("稅金").Value = CLng(計算3_dgv.Rows(i).Cells("工程總價").Value.ToString) - CLng(計算3_dgv.Rows(i).Cells("總報價").Value.ToString)

            For ii As Integer = 0 To 請款清單_dgv.Rows.Count - 1
                If 計算3_dgv.Rows(i).Cells(0).Value.ToString = 請款清單_dgv.Rows(ii).Cells(0).Value.ToString Then
                    計算3_dgv.Rows(i).Cells(表頭(14)).Value = CLng(計算3_dgv.Rows(i).Cells(表頭(14)).Value.ToString) + CLng(請款清單_dgv.Rows(ii).Cells("請款金額").Value.ToString)
                    計算3_dgv.Rows(i).Cells(表頭(18)).Value = CLng(計算3_dgv.Rows(i).Cells(表頭(18)).Value.ToString) + CLng(請款清單_dgv.Rows(ii).Cells("稅額").Value.ToString)
                End If
                If 計算3_dgv.Rows(i).Cells(0).Value.ToString = 請款清單_dgv.Rows(ii).Cells(0).Value.ToString And 請款清單_dgv.Rows(ii).Cells("本收").Value = True Then
                    計算3_dgv.Rows(i).Cells(表頭(16)).Value = CLng(計算3_dgv.Rows(i).Cells(表頭(16)).Value.ToString) + CLng(請款清單_dgv.Rows(ii).Cells("請款金額").Value.ToString)
                End If
                If 計算3_dgv.Rows(i).Cells(0).Value.ToString = 請款清單_dgv.Rows(ii).Cells(0).Value.ToString And 請款清單_dgv.Rows(ii).Cells("稅收").Value = True Then
                    計算3_dgv.Rows(i).Cells(表頭(20)).Value = CLng(計算3_dgv.Rows(i).Cells(表頭(20)).Value.ToString) + CLng(請款清單_dgv.Rows(ii).Cells("稅額").Value.ToString)
                End If
            Next
            計算3_dgv.Rows(i).Cells(表頭(15)).Value = CLng(計算3_dgv.Rows(i).Cells("總報價").Value) - (計算3_dgv.Rows(i).Cells(表頭(14)).Value)
            計算3_dgv.Rows(i).Cells(表頭(19)).Value = CLng(計算3_dgv.Rows(i).Cells("稅金").Value) - (計算3_dgv.Rows(i).Cells(表頭(18)).Value)
            計算3_dgv.Rows(i).Cells(表頭(17)).Value = CLng(計算3_dgv.Rows(i).Cells(表頭(14)).Value) - (計算3_dgv.Rows(i).Cells(表頭(16)).Value)
            計算3_dgv.Rows(i).Cells(表頭(21)).Value = CLng(計算3_dgv.Rows(i).Cells(表頭(18)).Value) - (計算3_dgv.Rows(i).Cells(表頭(20)).Value)
            If CLng(計算3_dgv.Rows(i).Cells(表頭(15)).Value) < 0 Then : 計算3_dgv.Rows(i).Cells(表頭(15)).Value = "0" : End If
            If CLng(計算3_dgv.Rows(i).Cells(表頭(19)).Value) < 0 Then : 計算3_dgv.Rows(i).Cells(表頭(19)).Value = "0" : End If
            If CLng(計算3_dgv.Rows(i).Cells("總報價").Value.ToString) = 0 Then : 計算3_dgv.Rows(i).Cells("比例1").Value = "0" : Else
                計算3_dgv.Rows(i).Cells("比例1").Value = CLng(計算3_dgv.Rows(i).Cells(表頭(14)).Value.ToString) / CLng(計算3_dgv.Rows(i).Cells("總報價").Value.ToString) * 100
                If CLng(計算3_dgv.Rows(i).Cells("比例1").Value) > 100 Then : 計算3_dgv.Rows(i).Cells("比例1").Value = "100" : End If
            End If
            If CLng(計算3_dgv.Rows(i).Cells(表頭(14)).Value.ToString) = 0 Then : 計算3_dgv.Rows(i).Cells("比例2").Value = "0" : Else
                計算3_dgv.Rows(i).Cells("比例2").Value = CLng(計算3_dgv.Rows(i).Cells(表頭(16)).Value.ToString) / CLng(計算3_dgv.Rows(i).Cells(表頭(14)).Value.ToString) * 100
                If CLng(計算3_dgv.Rows(i).Cells("比例2").Value) > 100 Then : 計算3_dgv.Rows(i).Cells("比例2").Value = "100" : End If
            End If
            If CLng(計算3_dgv.Rows(i).Cells("稅金").Value.ToString) = 0 Then : 計算3_dgv.Rows(i).Cells("比例3").Value = "0" : Else
                計算3_dgv.Rows(i).Cells("比例3").Value = CLng(計算3_dgv.Rows(i).Cells(表頭(18)).Value.ToString) / CLng(計算3_dgv.Rows(i).Cells("稅金").Value.ToString) * 100
                If CLng(計算3_dgv.Rows(i).Cells("比例3").Value) > 100 Then : 計算3_dgv.Rows(i).Cells("比例3").Value = "100" : End If
            End If
            If CLng(計算3_dgv.Rows(i).Cells(表頭(18)).Value.ToString) = 0 Then : 計算3_dgv.Rows(i).Cells("比例4").Value = "0" : Else
                計算3_dgv.Rows(i).Cells("比例4").Value = CLng(計算3_dgv.Rows(i).Cells(表頭(20)).Value.ToString) / CLng(計算3_dgv.Rows(i).Cells(表頭(18)).Value.ToString) * 100
                If CLng(計算3_dgv.Rows(i).Cells("比例4").Value) > 100 Then : 計算3_dgv.Rows(i).Cells("比例4").Value = "100" : End If
            End If : RadTrackBar1.Maximum = 計算3_dgv.Rows.Count : RadTrackBar1.Value = 1
            If 計算3_dgv.Rows.Count > 10 Then : RadTrackBar1.Visible = True : Else : RadTrackBar1.Visible = False : End If
        Next
        '-------------------------合計DGV變形----------------------------------------------------------------------------------------------------------------------
        If IsVerticalScrollBarVisible(計算3_dgv) Then : 合計2_dgv.Size = New Size(計算3_dgv.Size.Width - 17, 合計2_dgv.Size.Height)
        Else : 合計2_dgv.Size = New Size(計算3_dgv.Size.Width, 合計2_dgv.Size.Height) : End If
    End Sub
    Private Sub Set_進度條顯示1()
        Dim Col As New DataGridViewProgressColumn With {
            .Width = 30,
            .DataPropertyName = "請款比例"
        }
        Col.HeaderText = "Percent (%)" : Col.Name = "容量" : Col.DataPropertyName = "比例1" : 計算2_dgv.Columns.Insert(8, Col)
    End Sub
    Private Sub Set_進度條顯示2()
        Dim Col As New DataGridViewProgressColumn With {
            .Width = 30,
            .DataPropertyName = "請款比例"
        }
        Col.HeaderText = "Percent (%)" : Col.Name = "容量" : Col.DataPropertyName = "比例2" : 計算2_dgv.Columns.Insert(12, Col)
    End Sub
    Private Sub Set_進度條顯示3()
        Dim Col As New DataGridViewProgressColumn With {
            .Width = 30,
            .DataPropertyName = "請款比例"
        }
        Col.HeaderText = "Percent (%)" : Col.Name = "容量" : Col.DataPropertyName = "比例3" : 計算2_dgv.Columns.Insert(16, Col)
    End Sub
    Private Sub Set_進度條顯示4()
        Dim Col As New DataGridViewProgressColumn With {
            .Width = 30,
            .DataPropertyName = "請款比例"
        }
        Col.HeaderText = "Percent (%)" : Col.Name = "容量" : Col.DataPropertyName = "比例4" : 計算2_dgv.Columns.Insert(20, Col)
    End Sub
    Private Sub Set_進度條顯示5()
        Dim Col As New DataGridViewProgressColumn With {
            .Width = 30,
            .DataPropertyName = "請款比例"
        }
        Col.HeaderText = "Percent (%)" : Col.Name = "容量" : Col.DataPropertyName = "比例1" : 合計2_dgv.Columns.Insert(8, Col)
    End Sub
    Private Sub Set_進度條顯示6()
        Dim Col As New DataGridViewProgressColumn With {
            .Width = 30,
            .DataPropertyName = "請款比例"
        }
        Col.HeaderText = "Percent (%)" : Col.Name = "容量" : Col.DataPropertyName = "比例2" : 合計2_dgv.Columns.Insert(12, Col)
    End Sub
    Private Sub Set_進度條顯示7()
        Dim Col As New DataGridViewProgressColumn With {
            .Width = 30,
            .DataPropertyName = "請款比例"
        }
        Col.HeaderText = "Percent (%)" : Col.Name = "容量" : Col.DataPropertyName = "比例3" : 合計2_dgv.Columns.Insert(16, Col)
    End Sub
    Private Sub Set_進度條顯示8()
        Dim Col As New DataGridViewProgressColumn With {
            .Width = 30,
            .DataPropertyName = "請款比例"
        }
        Col.HeaderText = "Percent (%)" : Col.Name = "容量" : Col.DataPropertyName = "比例4" : 合計2_dgv.Columns.Insert(20, Col)
    End Sub
    Private Sub Set_進度條顯示9()
        Dim Col As New DataGridViewProgressColumn With {
            .Width = 30,
            .DataPropertyName = "請款比例"
        }
        Col.HeaderText = "Percent (%)" : Col.Name = "容量" : Col.DataPropertyName = "比例1" : 計算3_dgv.Columns.Insert(8, Col)
    End Sub
    Private Sub Set_進度條顯示10()
        Dim Col As New DataGridViewProgressColumn With {
            .Width = 30,
            .DataPropertyName = "請款比例"
        }
        Col.HeaderText = "Percent (%)" : Col.Name = "容量" : Col.DataPropertyName = "比例2" : 計算3_dgv.Columns.Insert(12, Col)
    End Sub
    Private Sub Set_進度條顯示11()
        Dim Col As New DataGridViewProgressColumn With {
            .Width = 30,
            .DataPropertyName = "請款比例"
        }
        Col.HeaderText = "Percent (%)" : Col.Name = "容量" : Col.DataPropertyName = "比例3" : 計算3_dgv.Columns.Insert(16, Col)
    End Sub
    Private Sub Set_進度條顯示12()
        Dim Col As New DataGridViewProgressColumn With {
            .Width = 30,
            .DataPropertyName = "請款比例"
        }
        Col.HeaderText = "Percent (%)" : Col.Name = "容量" : Col.DataPropertyName = "比例4" : 計算3_dgv.Columns.Insert(20, Col)
    End Sub
    Private Sub 彙總()
        Chart3.Series.Clear() : Chart1.ChartAreas.Clear() : Chart1.ChartAreas.Add(0)
        Chart3.Series.Add(表頭(12)) : Chart3.Series(表頭(12)).ChartType = SeriesChartType.Pie
        Chart3.Series(表頭(12)).IsValueShownAsLabel = True : Chart3.Series(表頭(12)).IsVisibleInLegend = True : Chart3.Series(表頭(12)).IsXValueIndexed = True
        Chart3.ChartAreas(0).BackColor = Color.Transparent : Chart3.Legends(0).BackColor = Color.Transparent
        For i As Integer = 0 To 計算1_dgv.Rows.Count - 1
            Chart3.Series(表頭(12)).Points.AddXY(計算1_dgv.Rows(i).Cells(0).Value.ToString, Format(計算1_dgv.Rows(i).Cells(表頭(12)).Value, "#,##0"))
        Next

        Chart1.Series.Clear()
        If 選款項 = True Then
            If B1.Checked = True Then : Chart1.Series.Add(表頭(14)) : Chart1.Series(表頭(14)).ChartType = SeriesChartType.Column : End If
            If B2.Checked = True Then : Chart1.Series.Add(表頭(15)) : Chart1.Series(表頭(15)).ChartType = SeriesChartType.Column : End If
            If B3.Checked = True Then : Chart1.Series.Add(表頭(16)) : Chart1.Series(表頭(16)).ChartType = SeriesChartType.Column : End If
            If B4.Checked = True Then : Chart1.Series.Add(表頭(17)) : Chart1.Series(表頭(17)).ChartType = SeriesChartType.Column : End If
        Else
            If B1.Checked = True Then : Chart1.Series.Add(表頭(18)) : Chart1.Series(表頭(18)).ChartType = SeriesChartType.Column : End If
            If B2.Checked = True Then : Chart1.Series.Add(表頭(19)) : Chart1.Series(表頭(19)).ChartType = SeriesChartType.Column : End If
            If B3.Checked = True Then : Chart1.Series.Add(表頭(20)) : Chart1.Series(表頭(20)).ChartType = SeriesChartType.Column : End If
            If B4.Checked = True Then : Chart1.Series.Add(表頭(21)) : Chart1.Series(表頭(21)).ChartType = SeriesChartType.Column : End If
        End If
        Chart1.ChartAreas(0).BackColor = Color.Transparent : Chart1.Legends(0).BackColor = Color.Transparent
        Chart1.ChartAreas(0).AxisY.LabelStyle.Font = New Font("Arial", 8) : Chart1.ChartAreas(0).AxisY.LabelStyle.Format = "#,##0" & " M"
        For i As Integer = 0 To 計算2_dgv.Rows.Count - 1
            If 選款項 = True Then
                If B1.Checked = True Then : Chart1.Series(表頭(14)).Points.AddXY(計算2_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算2_dgv.Rows(i).Cells(表頭(14)).Value.ToString) / 1000000) : End If
                If B2.Checked = True Then : Chart1.Series(表頭(15)).Points.AddXY(計算2_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算2_dgv.Rows(i).Cells(表頭(15)).Value.ToString) / 1000000) : End If
                If B3.Checked = True Then : Chart1.Series(表頭(16)).Points.AddXY(計算2_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算2_dgv.Rows(i).Cells(表頭(16)).Value.ToString) / 1000000) : End If
                If B4.Checked = True Then : Chart1.Series(表頭(17)).Points.AddXY(計算2_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算2_dgv.Rows(i).Cells(表頭(17)).Value.ToString) / 1000000) : End If
            Else
                If B1.Checked = True Then : Chart1.Series(表頭(18)).Points.AddXY(計算2_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算2_dgv.Rows(i).Cells(表頭(18)).Value.ToString) / 1000000) : End If
                If B2.Checked = True Then : Chart1.Series(表頭(19)).Points.AddXY(計算2_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算2_dgv.Rows(i).Cells(表頭(19)).Value.ToString) / 1000000) : End If
                If B3.Checked = True Then : Chart1.Series(表頭(20)).Points.AddXY(計算2_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算2_dgv.Rows(i).Cells(表頭(20)).Value.ToString) / 1000000) : End If
                If B4.Checked = True Then : Chart1.Series(表頭(21)).Points.AddXY(計算2_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算2_dgv.Rows(i).Cells(表頭(21)).Value.ToString) / 1000000) : End If
            End If
        Next

        If 深色風格 = False Then
            Chart3.Series(表頭(12)).LabelForeColor = Color.Blue
            If 選款項 = True Then
                If B1.Checked = True Then : Chart1.Series(表頭(14)).LabelForeColor = Color.Blue : End If
                If B2.Checked = True Then : Chart1.Series(表頭(15)).LabelForeColor = Color.Blue : End If
                If B3.Checked = True Then : Chart1.Series(表頭(16)).LabelForeColor = Color.Blue : End If
                If B4.Checked = True Then : Chart1.Series(表頭(17)).LabelForeColor = Color.Blue : End If
            Else
                If B1.Checked = True Then : Chart1.Series(表頭(18)).LabelForeColor = Color.Blue : End If
                If B2.Checked = True Then : Chart1.Series(表頭(19)).LabelForeColor = Color.Blue : End If
                If B3.Checked = True Then : Chart1.Series(表頭(20)).LabelForeColor = Color.Blue : End If
                If B4.Checked = True Then : Chart1.Series(表頭(21)).LabelForeColor = Color.Blue : End If
            End If
            Chart3.Legends(0).ForeColor = Color.Black : Chart1.Legends(0).ForeColor = Color.Black
            Chart1.ChartAreas(0).AxisX.MajorGrid.LineColor = Color.Black : Chart1.ChartAreas(0).AxisY.MajorGrid.LineColor = Color.Black
            Chart1.ChartAreas(0).AxisX.LineColor = Color.Black : Chart1.ChartAreas(0).AxisY.LineColor = Color.Black
            Chart1.ChartAreas(0).AxisX.LabelStyle.ForeColor = Color.Black : Chart1.ChartAreas(0).AxisY.LabelStyle.ForeColor = Color.Black
        Else
            Chart3.Series(表頭(12)).LabelForeColor = Color.White
            If 選款項 = True Then
                If B1.Checked = True Then : Chart1.Series(表頭(14)).LabelForeColor = Color.White : End If
                If B2.Checked = True Then : Chart1.Series(表頭(15)).LabelForeColor = Color.White : End If
                If B3.Checked = True Then : Chart1.Series(表頭(16)).LabelForeColor = Color.White : End If
                If B4.Checked = True Then : Chart1.Series(表頭(17)).LabelForeColor = Color.White : End If
            Else
                If B1.Checked = True Then : Chart1.Series(表頭(18)).LabelForeColor = Color.White : End If
                If B2.Checked = True Then : Chart1.Series(表頭(19)).LabelForeColor = Color.White : End If
                If B3.Checked = True Then : Chart1.Series(表頭(20)).LabelForeColor = Color.White : End If
                If B4.Checked = True Then : Chart1.Series(表頭(21)).LabelForeColor = Color.White : End If
            End If
            Chart3.Legends(0).ForeColor = Color.White : Chart1.Legends(0).ForeColor = Color.White
            Chart1.ChartAreas(0).AxisX.MajorGrid.LineColor = Color.White : Chart1.ChartAreas(0).AxisY.MajorGrid.LineColor = Color.White
            Chart1.ChartAreas(0).AxisX.LineColor = Color.White : Chart1.ChartAreas(0).AxisY.LineColor = Color.White
            Chart1.ChartAreas(0).AxisX.LabelStyle.ForeColor = Color.White : Chart1.ChartAreas(0).AxisY.LabelStyle.ForeColor = Color.White
        End If
    End Sub
    Private Sub RadTrackBar1_ValueChanged(sender As Object, e As EventArgs) Handles RadTrackBar1.RangeValueChanged
        If 首次開啟 = True Then : Else
            If RadTrackBar1.Maximum >= 10 Then : If RadTrackBar1.Value > RadTrackBar1.Maximum - 9 Then : RadTrackBar1.Value = RadTrackBar1.Maximum - 9 : End If : 彙總1() : Else : 彙總1() : End If
        End If
    End Sub
    Private Sub 彙總1()
        Chart1.Series.Clear() : Chart1.ChartAreas.Clear() : Chart1.ChartAreas.Add(0)
        If 選款項 = True Then
            If B1.Checked = True Then : Chart1.Series.Add(表頭(14)) : Chart1.Series(表頭(14)).ChartType = SeriesChartType.Column : End If
            If B2.Checked = True Then : Chart1.Series.Add(表頭(15)) : Chart1.Series(表頭(15)).ChartType = SeriesChartType.Column : End If
            If B3.Checked = True Then : Chart1.Series.Add(表頭(16)) : Chart1.Series(表頭(16)).ChartType = SeriesChartType.Column : End If
            If B4.Checked = True Then : Chart1.Series.Add(表頭(17)) : Chart1.Series(表頭(17)).ChartType = SeriesChartType.Column : End If
        Else
            If B1.Checked = True Then : Chart1.Series.Add(表頭(18)) : Chart1.Series(表頭(18)).ChartType = SeriesChartType.Column : End If
            If B2.Checked = True Then : Chart1.Series.Add(表頭(19)) : Chart1.Series(表頭(19)).ChartType = SeriesChartType.Column : End If
            If B3.Checked = True Then : Chart1.Series.Add(表頭(20)) : Chart1.Series(表頭(20)).ChartType = SeriesChartType.Column : End If
            If B4.Checked = True Then : Chart1.Series.Add(表頭(21)) : Chart1.Series(表頭(21)).ChartType = SeriesChartType.Column : End If
        End If
        Chart1.ChartAreas(0).BackColor = Color.Transparent : Chart1.Legends(0).BackColor = Color.Transparent
        Chart1.ChartAreas(0).AxisY.LabelStyle.Font = New Font("Arial", 8) : Chart1.ChartAreas(0).AxisY.LabelStyle.Format = "#,##0" & " M"

        Dim 位置1, 位置2 As Integer
        If RadTrackBar1.Maximum <= 10 Then : 位置1 = 1 : 位置2 = RadTrackBar1.Maximum
        Else : 位置1 = RadTrackBar1.Value : 位置2 = RadTrackBar1.Value + 9 : End If
        For i As Integer = 位置1 - 1 To 位置2 - 1
            If 選款項 = True Then
                If B1.Checked = True Then : Chart1.Series(表頭(14)).Points.AddXY(計算3_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算3_dgv.Rows(i).Cells(表頭(14)).Value.ToString) / 1000000) : End If
                If B2.Checked = True Then : Chart1.Series(表頭(15)).Points.AddXY(計算3_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算3_dgv.Rows(i).Cells(表頭(15)).Value.ToString) / 1000000) : End If
                If B3.Checked = True Then : Chart1.Series(表頭(16)).Points.AddXY(計算3_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算3_dgv.Rows(i).Cells(表頭(16)).Value.ToString) / 1000000) : End If
                If B4.Checked = True Then : Chart1.Series(表頭(17)).Points.AddXY(計算3_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算3_dgv.Rows(i).Cells(表頭(17)).Value.ToString) / 1000000) : End If
            Else
                If B1.Checked = True Then : Chart1.Series(表頭(18)).Points.AddXY(計算3_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算3_dgv.Rows(i).Cells(表頭(18)).Value.ToString) / 1000000) : End If
                If B2.Checked = True Then : Chart1.Series(表頭(19)).Points.AddXY(計算3_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算3_dgv.Rows(i).Cells(表頭(19)).Value.ToString) / 1000000) : End If
                If B3.Checked = True Then : Chart1.Series(表頭(20)).Points.AddXY(計算3_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算3_dgv.Rows(i).Cells(表頭(20)).Value.ToString) / 1000000) : End If
                If B4.Checked = True Then : Chart1.Series(表頭(21)).Points.AddXY(計算3_dgv.Rows(i).Cells(0).Value.ToString, CLng(計算3_dgv.Rows(i).Cells(表頭(21)).Value.ToString) / 1000000) : End If
            End If
        Next

        If 深色風格 = False Then
            Chart3.Series(表頭(12)).LabelForeColor = Color.Blue
            If 選款項 = True Then
                If B1.Checked = True Then : Chart1.Series(表頭(14)).LabelForeColor = Color.Blue : End If
                If B2.Checked = True Then : Chart1.Series(表頭(15)).LabelForeColor = Color.Blue : End If
                If B3.Checked = True Then : Chart1.Series(表頭(16)).LabelForeColor = Color.Blue : End If
                If B4.Checked = True Then : Chart1.Series(表頭(17)).LabelForeColor = Color.Blue : End If
            Else
                If B1.Checked = True Then : Chart1.Series(表頭(18)).LabelForeColor = Color.Blue : End If
                If B2.Checked = True Then : Chart1.Series(表頭(19)).LabelForeColor = Color.Blue : End If
                If B3.Checked = True Then : Chart1.Series(表頭(20)).LabelForeColor = Color.Blue : End If
                If B4.Checked = True Then : Chart1.Series(表頭(21)).LabelForeColor = Color.Blue : End If
            End If
            Chart3.Legends(0).ForeColor = Color.Black : Chart1.Legends(0).ForeColor = Color.Black
            Chart1.ChartAreas(0).AxisX.MajorGrid.LineColor = Color.Black : Chart1.ChartAreas(0).AxisY.MajorGrid.LineColor = Color.Black
            Chart1.ChartAreas(0).AxisX.LineColor = Color.Black : Chart1.ChartAreas(0).AxisY.LineColor = Color.Black
            Chart1.ChartAreas(0).AxisX.LabelStyle.ForeColor = Color.Black : Chart1.ChartAreas(0).AxisY.LabelStyle.ForeColor = Color.Black
        Else
            Chart3.Series(表頭(12)).LabelForeColor = Color.White
            If 選款項 = True Then
                If B1.Checked = True Then : Chart1.Series(表頭(14)).LabelForeColor = Color.White : End If
                If B2.Checked = True Then : Chart1.Series(表頭(15)).LabelForeColor = Color.White : End If
                If B3.Checked = True Then : Chart1.Series(表頭(16)).LabelForeColor = Color.White : End If
                If B4.Checked = True Then : Chart1.Series(表頭(17)).LabelForeColor = Color.White : End If
            Else
                If B1.Checked = True Then : Chart1.Series(表頭(18)).LabelForeColor = Color.White : End If
                If B2.Checked = True Then : Chart1.Series(表頭(19)).LabelForeColor = Color.White : End If
                If B3.Checked = True Then : Chart1.Series(表頭(20)).LabelForeColor = Color.White : End If
                If B4.Checked = True Then : Chart1.Series(表頭(21)).LabelForeColor = Color.White : End If
            End If
            Chart3.Legends(0).ForeColor = Color.White : Chart1.Legends(0).ForeColor = Color.White
            Chart1.ChartAreas(0).AxisX.MajorGrid.LineColor = Color.White : Chart1.ChartAreas(0).AxisY.MajorGrid.LineColor = Color.White
            Chart1.ChartAreas(0).AxisX.LineColor = Color.White : Chart1.ChartAreas(0).AxisY.LineColor = Color.White
            Chart1.ChartAreas(0).AxisX.LabelStyle.ForeColor = Color.White : Chart1.ChartAreas(0).AxisY.LabelStyle.ForeColor = Color.White
        End If
    End Sub
    Private Sub 收款狀態報表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        HX_PGS_ERP_SYS.WindowState = 2 : Me.MdiParent = HX_PGS_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True : 首次開啟 = True
        HX_PGS_ERP_SYS.MaximizeBox = False : HX_PGS_ERP_SYS.MinimizeBox = False
        分母 = 100 : 分段1 = 0.35 : 分段2 = 0.34 : 分段3 = 0.65 : 分段4 = 0.64 : 進度條後墜 = " %"
        風格() : H(310) = True : 介面 = "H310" : 語言轉換讀取() : 顯示說明(999, False)
        Panel1.SendToBack() : Panel2.BringToFront() : Panel4.BringToFront() : 計算2_dgv.Visible = True : 計算3_dgv.Visible = False
        RadTrackBar1.Visible = False
        If 登入人級別 = "00" Then
            縮放2_bt.Visible = True : 清單_bt.Visible = True : 圖表_bt.Visible = True
        Else
            縮放2_bt.Visible = False : 清單_bt.Visible = False : 圖表_bt.Visible = False
        End If
        MyMod.清單字體大小調整()
        合計1_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
        合計2_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
        計算3_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
        計算2_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
        計算1_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
        計算_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
        甲方_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
        彙總_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
        請款清單_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
    End Sub
    Private Sub 收款狀態報表_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
        Set_合約甲方() : 選款項 = True : Set_合約清單() : 首次開啟 = False
    End Sub
    Private Sub 收款確認表_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed
        HX_PGS_ERP_SYS.WindowState = 0 : HX_PGS_ERP_SYS.MaximizeBox = True : HX_PGS_ERP_SYS.MinimizeBox = True
        HX_PGS_ERP_SYS.WindowState = 0 : H(310) = False : MyMod.虛擬桌面開啟()
    End Sub
    Private Sub 系統說明_bt_Click(sender As Object, e As EventArgs) Handles 系統說明_bt.Click
        介面 = "H310"
    End Sub
    Private Sub 語轉扭_bt_Click(sender As Object, e As EventArgs) Handles 語轉扭_bt.Click
        H(310) = True : 介面 = "H310" : 語言轉換讀取()
    End Sub
    Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
        timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
    End Sub
    Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
        timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
    End Sub
    Private Sub 彙總_dgv_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles 彙總_dgv.CellFormatting
        If e.Value IsNot Nothing Then
            If IsNumeric(Val(e.Value.ToString)) = True And Val(e.Value.ToString) < 0 Then
                If 深色風格 = False Then : e.CellStyle.ForeColor = Color.Red : Else : e.CellStyle.ForeColor = Color.LightPink : End If
            End If
        End If
    End Sub
    Private Sub 計算2_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 計算2_dgv.MouseUp
        'If 清單_dgv.SelectedCells.Count = 1 Then : MsgBox(清單_dgv.SelectedCells(0).ColumnIndex & "  " & 清單_dgv.SelectedCells(0).RowIndex) : End If
        If 計算2_dgv.SelectedCells.Count > 0 Then
            If 計算2_dgv.SelectedCells(0).ColumnIndex = 0 Then
                PA = 計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells(0).Value.ToString : Set_合約報表計算2()
                計算2_dgv.Visible = False : 計算3_dgv.Visible = True
                合計2_dgv.Rows(0).Cells("工程總價").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells(表頭(13)).Value.ToString)
                合計2_dgv.Rows(0).Cells("總報價").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells("總報價").Value.ToString)
                合計2_dgv.Rows(0).Cells("稅金").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells("稅金").Value.ToString)
                合計2_dgv.Rows(0).Cells("已請款").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells(表頭(14)).Value.ToString)
                合計2_dgv.Rows(0).Cells("未請款").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells(表頭(15)).Value.ToString)
                合計2_dgv.Rows(0).Cells("已請稅").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells(表頭(18)).Value.ToString)
                合計2_dgv.Rows(0).Cells("未請稅").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells(表頭(19)).Value.ToString)
                合計2_dgv.Rows(0).Cells("已收款").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells(表頭(16)).Value.ToString)
                合計2_dgv.Rows(0).Cells("已請未收款").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells(表頭(17)).Value.ToString)
                合計2_dgv.Rows(0).Cells("已收稅").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells(表頭(20)).Value.ToString)
                合計2_dgv.Rows(0).Cells("已請未收稅").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells(表頭(21)).Value.ToString)
                合計2_dgv.Rows(0).Cells("比例1").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells("比例1").Value.ToString)
                合計2_dgv.Rows(0).Cells("比例2").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells("比例2").Value.ToString)
                合計2_dgv.Rows(0).Cells("比例3").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells("比例3").Value.ToString)
                合計2_dgv.Rows(0).Cells("比例4").Value = CLng(計算2_dgv.Rows(計算2_dgv.SelectedCells(0).RowIndex).Cells("比例4").Value.ToString)
                彙總1()
                A1.Enabled = False : A2.Enabled = False : A3.Enabled = False : A4.Enabled = False : A5.Enabled = False : A6.Enabled = False : A7.Enabled = False : A8.Enabled = False
                A9.Enabled = False : A10.Enabled = False : A11.Enabled = False : A12.Enabled = False : A13.Enabled = False : A14.Enabled = False : A15.Enabled = False : A16.Enabled = False
                A17.Enabled = False : A18.Enabled = False : A19.Enabled = False : A20.Enabled = False
            End If
        End If
    End Sub
    Private Sub 回首頁_bt_Click(sender As Object, e As EventArgs) Handles 回首頁_bt.Click
        計算2_dgv.Visible = True : 計算3_dgv.Visible = False
        合計2_dgv.Rows(0).Cells("工程總價").Value = "0" : 合計2_dgv.Rows(0).Cells("總報價").Value = "0"
        合計2_dgv.Rows(0).Cells("稅金").Value = "0" : 合計2_dgv.Rows(0).Cells("已請款").Value = "0" : 合計2_dgv.Rows(0).Cells("未請款").Value = "0"
        合計2_dgv.Rows(0).Cells("已請稅").Value = "0" : 合計2_dgv.Rows(0).Cells("未請稅").Value = "0" : 合計2_dgv.Rows(0).Cells("已收款").Value = "0"
        合計2_dgv.Rows(0).Cells("已請未收款").Value = "0" : 合計2_dgv.Rows(0).Cells("已收稅").Value = "0" : 合計2_dgv.Rows(0).Cells("已請未收稅").Value = "0"
        For i As Integer = 0 To 計算_dgv.Rows.Count - 1
            合計2_dgv.Rows(0).Cells("工程總價").Value = CLng(合計2_dgv.Rows(0).Cells("工程總價").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(13)).Value.ToString)
            合計2_dgv.Rows(0).Cells("總報價").Value = CLng(合計2_dgv.Rows(0).Cells("總報價").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells("總報價").Value.ToString)
            合計2_dgv.Rows(0).Cells("稅金").Value = CLng(合計2_dgv.Rows(0).Cells("稅金").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells("稅金").Value.ToString)
            合計2_dgv.Rows(0).Cells("已請款").Value = CLng(合計2_dgv.Rows(0).Cells("已請款").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(14)).Value.ToString)
            合計2_dgv.Rows(0).Cells("未請款").Value = CLng(合計2_dgv.Rows(0).Cells("未請款").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(15)).Value.ToString)
            合計2_dgv.Rows(0).Cells("已請稅").Value = CLng(合計2_dgv.Rows(0).Cells("已請稅").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(18)).Value.ToString)
            合計2_dgv.Rows(0).Cells("未請稅").Value = CLng(合計2_dgv.Rows(0).Cells("未請稅").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(19)).Value.ToString)
            合計2_dgv.Rows(0).Cells("已收款").Value = CLng(合計2_dgv.Rows(0).Cells("已收款").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(16)).Value.ToString)
            合計2_dgv.Rows(0).Cells("已請未收款").Value = CLng(合計2_dgv.Rows(0).Cells("已請未收款").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(17)).Value.ToString)
            合計2_dgv.Rows(0).Cells("已收稅").Value = CLng(合計2_dgv.Rows(0).Cells("已收稅").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(20)).Value.ToString)
            合計2_dgv.Rows(0).Cells("已請未收稅").Value = CLng(合計2_dgv.Rows(0).Cells("已請未收稅").Value.ToString) + CLng(計算2_dgv.Rows(i).Cells(表頭(21)).Value.ToString)
        Next
        If CLng(合計2_dgv.Rows(0).Cells("總報價").Value.ToString) = 0 Then : 合計2_dgv.Rows(0).Cells("比例1").Value = "0" : Else
            合計2_dgv.Rows(0).Cells("比例1").Value = CLng(合計2_dgv.Rows(0).Cells("已請款").Value.ToString) / CLng(合計2_dgv.Rows(0).Cells("總報價").Value.ToString) * 100
            If CLng(合計2_dgv.Rows(0).Cells("比例1").Value) > 100 Then : 合計2_dgv.Rows(0).Cells("比例1").Value = "100" : End If
        End If
        If CLng(合計2_dgv.Rows(0).Cells("已請款").Value.ToString) = 0 Then : 合計2_dgv.Rows(0).Cells("比例2").Value = "0" : Else
            合計2_dgv.Rows(0).Cells("比例2").Value = CLng(合計2_dgv.Rows(0).Cells("已收款").Value.ToString) / CLng(合計2_dgv.Rows(0).Cells("已請款").Value.ToString) * 100
            If CLng(合計2_dgv.Rows(0).Cells("比例2").Value) > 100 Then : 合計2_dgv.Rows(0).Cells("比例2").Value = "100" : End If
        End If
        If CLng(合計2_dgv.Rows(0).Cells("稅金").Value.ToString) = 0 Then : 合計2_dgv.Rows(0).Cells("比例3").Value = "0" : Else
            合計2_dgv.Rows(0).Cells("比例3").Value = CLng(合計2_dgv.Rows(0).Cells("已請稅").Value.ToString) / CLng(合計2_dgv.Rows(0).Cells("稅金").Value.ToString) * 100
            If CLng(合計2_dgv.Rows(0).Cells("比例3").Value) > 100 Then : 合計2_dgv.Rows(0).Cells("比例3").Value = "100" : End If
        End If
        If CLng(合計2_dgv.Rows(0).Cells("已請稅").Value.ToString) = 0 Then : 合計2_dgv.Rows(0).Cells("比例4").Value = "0" : Else
            合計2_dgv.Rows(0).Cells("比例4").Value = CLng(合計2_dgv.Rows(0).Cells("已收稅").Value.ToString) / CLng(合計2_dgv.Rows(0).Cells("已請稅").Value.ToString) * 100
            If CLng(合計2_dgv.Rows(0).Cells("比例4").Value) > 100 Then : 合計2_dgv.Rows(0).Cells("比例4").Value = "100" : End If
        End If : 彙總() : RadTrackBar1.Visible = False
        A1.Enabled = True : A2.Enabled = True : A3.Enabled = True : A4.Enabled = True : A5.Enabled = True : A6.Enabled = True : A7.Enabled = True : A8.Enabled = True
        A9.Enabled = True : A10.Enabled = True : A11.Enabled = True : A12.Enabled = True : A13.Enabled = True : A14.Enabled = True : A15.Enabled = True : A16.Enabled = True
        A17.Enabled = True : A18.Enabled = True : A19.Enabled = True : A20.Enabled = True
        '-------------------------合計DGV變形----------------------------------------------------------------------------------------------------------------------
        If IsVerticalScrollBarVisible(計算2_dgv) Then : 合計2_dgv.Size = New Size(計算2_dgv.Size.Width - 17, 合計2_dgv.Size.Height)
        Else : 合計2_dgv.Size = New Size(計算2_dgv.Size.Width, 合計2_dgv.Size.Height) : End If
    End Sub
    Private Sub 款項_bt_Click(sender As Object, e As EventArgs) Handles 款項_bt.Click
        If 計算2_dgv.Visible = True And 計算3_dgv.Visible = False Then : 選款項 = True : 彙總() : Else : 選款項 = True : 彙總1() : End If
    End Sub
    Private Sub 稅額_bt_Click(sender As Object, e As EventArgs) Handles 稅額_bt.Click
        If 計算2_dgv.Visible = True And 計算3_dgv.Visible = False Then : 選款項 = False : 彙總() : Else : 選款項 = False : 彙總1() : End If
    End Sub
    Private Sub 縮放2_bt_Click(sender As Object, e As EventArgs) Handles 縮放2_bt.Click
        Panel2.SendToBack() : Panel3.BringToFront() : Panel2.Visible = False : Panel3.Visible = True
    End Sub
    Private Sub 縮放1_bt_Click(sender As Object, e As EventArgs) Handles 縮放1_bt.Click
        Panel2.BringToFront() : Panel3.SendToBack() : Panel2.Visible = True : Panel3.Visible = False
    End Sub
    Private Sub 圖表_bt_Click(sender As Object, e As EventArgs) Handles 圖表_bt.Click
        Panel4.BringToFront() : 計算_dgv.SendToBack()
    End Sub
    Private Sub 清單_bt_Click(sender As Object, e As EventArgs) Handles 清單_bt.Click
        Panel4.SendToBack() : 計算_dgv.BringToFront()
    End Sub
    Private Sub B1_CheckedChanged(sender As Object, e As EventArgs) Handles B1.Click
        If 計算2_dgv.Visible = True And 計算3_dgv.Visible = False Then : 彙總() : Else : 彙總1() : End If
    End Sub
    Private Sub B2_CheckedChanged(sender As Object, e As EventArgs) Handles B2.Click
        If 計算2_dgv.Visible = True And 計算3_dgv.Visible = False Then : 彙總() : Else : 彙總1() : End If
    End Sub
    Private Sub B3_CheckedChanged(sender As Object, e As EventArgs) Handles B3.Click
        If 計算2_dgv.Visible = True And 計算3_dgv.Visible = False Then : 彙總() : Else : 彙總1() : End If
    End Sub
    Private Sub B4_CheckedChanged(sender As Object, e As EventArgs) Handles B4.Click
        If 計算2_dgv.Visible = True And 計算3_dgv.Visible = False Then : 彙總() : Else : 彙總1() : End If
    End Sub
    Private Sub A1_CheckedChanged(sender As Object, e As EventArgs) Handles A1.Click
        Set_合約清單()
    End Sub
    Private Sub A2_CheckedChanged(sender As Object, e As EventArgs) Handles A2.Click
        Set_合約清單()
    End Sub
    Private Sub A3_CheckedChanged(sender As Object, e As EventArgs) Handles A3.Click
        Set_合約清單()
    End Sub
    Private Sub A4_CheckedChanged(sender As Object, e As EventArgs) Handles A4.Click
        Set_合約清單()
    End Sub
    Private Sub A5_CheckedChanged(sender As Object, e As EventArgs) Handles A5.Click
        Set_合約清單()
    End Sub
    Private Sub A6_CheckedChanged(sender As Object, e As EventArgs) Handles A6.Click
        Set_合約清單()
    End Sub
    Private Sub A7_CheckedChanged(sender As Object, e As EventArgs) Handles A7.Click
        Set_合約清單()
    End Sub
    Private Sub A8_CheckedChanged(sender As Object, e As EventArgs) Handles A8.Click
        Set_合約清單()
    End Sub
    Private Sub A9_CheckedChanged(sender As Object, e As EventArgs) Handles A9.Click
        Set_合約清單()
    End Sub
    Private Sub A10_CheckedChanged(sender As Object, e As EventArgs) Handles A10.Click
        Set_合約清單()
    End Sub
    Private Sub A11_CheckedChanged(sender As Object, e As EventArgs) Handles A11.Click
        Set_合約清單()
    End Sub
    Private Sub A12_CheckedChanged(sender As Object, e As EventArgs) Handles A12.Click
        Set_合約清單()
    End Sub
    Private Sub A13_CheckedChanged(sender As Object, e As EventArgs) Handles A13.Click
        Set_合約清單()
    End Sub
    Private Sub A14_CheckedChanged(sender As Object, e As EventArgs) Handles A14.Click
        Set_合約清單()
    End Sub
    Private Sub A15_CheckedChanged(sender As Object, e As EventArgs) Handles A15.Click
        Set_合約清單()
    End Sub
    Private Sub A16_CheckedChanged(sender As Object, e As EventArgs) Handles A16.Click
        Set_合約清單()
    End Sub
    Private Sub A17_CheckedChanged(sender As Object, e As EventArgs) Handles A17.Click
        Set_合約清單()
    End Sub
    Private Sub A18_CheckedChanged(sender As Object, e As EventArgs) Handles A18.Click
        Set_合約清單()
    End Sub
    Private Sub A19_CheckedChanged(sender As Object, e As EventArgs) Handles A19.Click
        Set_合約清單()
    End Sub
    Private Sub A20_CheckedChanged(sender As Object, e As EventArgs) Handles A20.Click
        Set_合約清單()
    End Sub

    Private Sub 風格()
        If 深色風格 = False Then
            Me.BackColor = SystemColors.Control
            '----------------黑-------------------------------------------
            語轉扭_bt.BackColor = Color.White
            系統說明_bt.BackColor = Color.White : 縮放1_bt.BackColor = Color.White : 縮放2_bt.BackColor = Color.White : 圖表_bt.BackColor = Color.White
            清單_bt.BackColor = Color.White : 回首頁_bt.BackColor = Color.Black
            For i As Integer = 1 To 20 : Dim 選擇 As CheckBox = CType(Me.Controls.Find("A" & i, True)(0), CheckBox) : 選擇.ForeColor = Color.Black : Next
            For i As Integer = 1 To 4 : Dim 選擇 As CheckBox = CType(Me.Controls.Find("B" & i, True)(0), CheckBox) : 選擇.ForeColor = Color.Black : Next
            款項_bt.BackColor = Color.White : 款項_bt.ForeColor = Color.Black : 稅額_bt.BackColor = Color.White : 稅額_bt.ForeColor = Color.Black

            計算3_dgv.EnableHeadersVisualStyles = True : 計算3_dgv.BackgroundColor = Color.White : 計算3_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
            計算3_dgv.DefaultCellStyle.BackColor = Color.White : 計算3_dgv.DefaultCellStyle.ForeColor = Color.Black : 計算3_dgv.DefaultCellStyle.SelectionBackColor = Color.White
            計算3_dgv.DefaultCellStyle.SelectionForeColor = Color.Black
            合計1_dgv.EnableHeadersVisualStyles = True : 合計1_dgv.BackgroundColor = Color.White : 合計1_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
            合計1_dgv.DefaultCellStyle.BackColor = Color.White : 合計1_dgv.DefaultCellStyle.ForeColor = Color.Black : 合計1_dgv.DefaultCellStyle.SelectionBackColor = Color.White
            合計1_dgv.DefaultCellStyle.SelectionForeColor = Color.Black
            合計2_dgv.EnableHeadersVisualStyles = True : 合計2_dgv.BackgroundColor = Color.White : 合計2_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
            合計2_dgv.DefaultCellStyle.BackColor = Color.White : 合計2_dgv.DefaultCellStyle.ForeColor = Color.Black : 合計2_dgv.DefaultCellStyle.SelectionBackColor = Color.White
            合計2_dgv.DefaultCellStyle.SelectionForeColor = Color.Black
            計算2_dgv.EnableHeadersVisualStyles = True : 計算2_dgv.BackgroundColor = Color.White : 計算2_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
            計算2_dgv.DefaultCellStyle.BackColor = Color.White : 計算2_dgv.DefaultCellStyle.ForeColor = Color.Black : 計算2_dgv.DefaultCellStyle.SelectionBackColor = Color.White
            計算2_dgv.DefaultCellStyle.SelectionForeColor = Color.Black
            計算1_dgv.EnableHeadersVisualStyles = True : 計算1_dgv.BackgroundColor = Color.White : 計算1_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
            計算1_dgv.DefaultCellStyle.BackColor = Color.White : 計算1_dgv.DefaultCellStyle.ForeColor = Color.Black : 計算1_dgv.DefaultCellStyle.SelectionBackColor = Color.White
            計算1_dgv.DefaultCellStyle.SelectionForeColor = Color.Black
            計算_dgv.EnableHeadersVisualStyles = True : 計算_dgv.BackgroundColor = Color.White : 計算_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
            計算_dgv.DefaultCellStyle.BackColor = Color.White : 計算_dgv.DefaultCellStyle.ForeColor = Color.Black
            甲方_dgv.EnableHeadersVisualStyles = True : 甲方_dgv.BackgroundColor = Color.White : 甲方_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
            甲方_dgv.DefaultCellStyle.BackColor = Color.White : 甲方_dgv.DefaultCellStyle.ForeColor = Color.Black
            請款清單_dgv.EnableHeadersVisualStyles = True : 請款清單_dgv.BackgroundColor = Color.White : 請款清單_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
            請款清單_dgv.DefaultCellStyle.BackColor = Color.White : 請款清單_dgv.DefaultCellStyle.ForeColor = Color.Black
            彙總_dgv.EnableHeadersVisualStyles = True : 彙總_dgv.BackgroundColor = Color.White : 彙總_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
            彙總_dgv.DefaultCellStyle.BackColor = Color.White : 彙總_dgv.DefaultCellStyle.ForeColor = Color.Black
        Else
            Me.BackColor = Color.Black
            '----------------黑-------------------------------------------
            語轉扭_bt.BackColor = Color.DimGray
            系統說明_bt.BackColor = Color.DimGray : 縮放1_bt.BackColor = Color.DimGray : 縮放2_bt.BackColor = Color.DimGray : 圖表_bt.BackColor = Color.DimGray
            清單_bt.BackColor = Color.DimGray : 回首頁_bt.BackColor = Color.DimGray
            For i As Integer = 1 To 20 : Dim 選擇 As CheckBox = CType(Me.Controls.Find("A" & i, True)(0), CheckBox) : 選擇.ForeColor = Color.White : Next
            For i As Integer = 1 To 4 : Dim 選擇 As CheckBox = CType(Me.Controls.Find("B" & i, True)(0), CheckBox) : 選擇.ForeColor = Color.White : Next
            款項_bt.BackColor = Color.DimGray : 款項_bt.ForeColor = Color.White : 稅額_bt.BackColor = Color.DimGray : 稅額_bt.ForeColor = Color.White

            計算3_dgv.EnableHeadersVisualStyles = False : 計算3_dgv.BackgroundColor = Color.DimGray : 計算3_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
            計算3_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 計算3_dgv.DefaultCellStyle.BackColor = Color.Black : 計算3_dgv.DefaultCellStyle.ForeColor = Color.White
            計算3_dgv.DefaultCellStyle.SelectionBackColor = Color.Black
            合計1_dgv.EnableHeadersVisualStyles = False : 合計1_dgv.BackgroundColor = Color.DimGray : 合計1_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
            合計1_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 合計1_dgv.DefaultCellStyle.BackColor = Color.Black : 合計1_dgv.DefaultCellStyle.ForeColor = Color.White
            合計1_dgv.DefaultCellStyle.SelectionBackColor = Color.Black
            合計2_dgv.EnableHeadersVisualStyles = False : 合計2_dgv.BackgroundColor = Color.DimGray : 合計2_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
            合計2_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 合計2_dgv.DefaultCellStyle.BackColor = Color.Black : 合計2_dgv.DefaultCellStyle.ForeColor = Color.White
            合計2_dgv.DefaultCellStyle.SelectionBackColor = Color.Black
            計算2_dgv.EnableHeadersVisualStyles = False : 計算2_dgv.BackgroundColor = Color.DimGray : 計算2_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
            計算2_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 計算2_dgv.DefaultCellStyle.BackColor = Color.Black : 計算2_dgv.DefaultCellStyle.ForeColor = Color.White
            計算2_dgv.DefaultCellStyle.SelectionBackColor = Color.Black
            計算1_dgv.EnableHeadersVisualStyles = False : 計算1_dgv.BackgroundColor = Color.DimGray : 計算1_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
            計算1_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 計算1_dgv.DefaultCellStyle.BackColor = Color.Black : 計算1_dgv.DefaultCellStyle.ForeColor = Color.White
            計算1_dgv.DefaultCellStyle.SelectionBackColor = Color.Black
            計算_dgv.EnableHeadersVisualStyles = False : 計算_dgv.BackgroundColor = Color.DimGray : 計算_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
            計算_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 計算_dgv.DefaultCellStyle.BackColor = Color.Black : 計算_dgv.DefaultCellStyle.ForeColor = Color.White
            甲方_dgv.EnableHeadersVisualStyles = False : 甲方_dgv.BackgroundColor = Color.DimGray : 甲方_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
            甲方_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 甲方_dgv.DefaultCellStyle.BackColor = Color.Black : 甲方_dgv.DefaultCellStyle.ForeColor = Color.White
            請款清單_dgv.EnableHeadersVisualStyles = False : 請款清單_dgv.BackgroundColor = Color.DimGray : 請款清單_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
            請款清單_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 請款清單_dgv.DefaultCellStyle.BackColor = Color.Black : 請款清單_dgv.DefaultCellStyle.ForeColor = Color.White
            彙總_dgv.EnableHeadersVisualStyles = False : 彙總_dgv.BackgroundColor = Color.DimGray : 彙總_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
            彙總_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 彙總_dgv.DefaultCellStyle.BackColor = Color.Black : 彙總_dgv.DefaultCellStyle.ForeColor = Color.White
        End If
    End Sub
End Class