Option Strict Off Public Class 營運成本收支_決算表 ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet : ReadOnly ds2 As New DataSet : ReadOnly ds3 As New DataSet : ReadOnly ds4 As New DataSet : ReadOnly ds5 As New DataSet ReadOnly ds6 As New DataSet : ReadOnly ds7 As New DataSet : ReadOnly ds8 As New DataSet : ReadOnly ds9 As New DataSet : ReadOnly ds10 As New DataSet : ReadOnly ds11 As New DataSet ReadOnly ds12 As New DataSet : ReadOnly ds13 As New DataSet Private ReadOnly 列高 As Integer = 35 Private Sub Set_清單() ds2.Clear() DataGridView2.DataSource = Nothing : DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView2.ColumnHeadersHeight = 50 : DataGridView2.AllowUserToAddRows = False : DataGridView2.RowTemplate.Height = 列高 SQL_營運成本收支_決算表年清單() da.Fill(ds2) : DataGridView2.DataSource = ds2.Tables(0) : conn.Close() TextBox61.Text = "0" : TextBox62.Text = "0" : TextBox63.Text = "0" : TextBox64.Text = "0" : TextBox77.Text = "0" : TextBox78.Text = "0" : TextBox91.Text = "0" : TextBox104.Text = "0" For i As Integer = 0 To DataGridView2.Rows.Count - 1 If DataGridView2.Rows(i).Cells("主項金額").Value.ToString = "" Then : DataGridView2.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView2.Rows(i).Cells("子項金額").Value.ToString = "" Then : DataGridView2.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView2.Rows(i).Cells("細項金額").Value.ToString = "" Then : DataGridView2.Rows(i).Cells("細項金額").Value = 0 : End If If DataGridView2.Rows(i).Cells("主項彙總").Value.ToString = "" Then : DataGridView2.Rows(i).Cells("主項彙總").Value = 0 : End If If DataGridView2.Rows(i).Cells("子項彙總").Value.ToString = "" Then : DataGridView2.Rows(i).Cells("子項彙總").Value = 0 : End If If DataGridView2.Rows(i).Cells("細項彙總").Value.ToString = "" Then : DataGridView2.Rows(i).Cells("細項彙總").Value = 0 : End If If DataGridView2.Rows(i).Cells("抵銷").Value = True Then DataGridView2.Rows(i).Cells("主項彙總").Value = DataGridView2.Rows(i).Cells("主項彙總").Value * -1 DataGridView2.Rows(i).Cells("子項彙總").Value = DataGridView2.Rows(i).Cells("子項彙總").Value * -1 DataGridView2.Rows(i).Cells("細項彙總").Value = DataGridView2.Rows(i).Cells("細項彙總").Value * -1 End If If DataGridView2.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView2.Rows(i).Cells("主項彙總").Value = 0 : End If If DataGridView2.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView2.Rows(i).Cells("子項彙總").Value = 0 : End If If DataGridView2.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView2.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView2.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView2.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView2.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView2.Rows(i).Cells("子項").Value = "" : End If If DataGridView2.Rows(i).Cells("層級").Value.ToString <> "3" Then : DataGridView2.Rows(i).Cells("子細項").Value = "" : End If If i = 0 Then : Else If DataGridView2.Rows(i).Cells("第一階").Value.ToString = DataGridView2.Rows(i - 1).Cells("第一階").Value.ToString Then : DataGridView2.Rows(i).Cells("主項").Value = "" : End If If DataGridView2.Rows(i).Cells("第二階").Value.ToString = DataGridView2.Rows(i - 1).Cells("第二階").Value.ToString Then : DataGridView2.Rows(i).Cells("子項").Value = "" : End If End If If ComboBox2.Text = "" Then : ElseIf ComboBox2.Text <> "" And CheckBox1.Checked = False Then : TextBox61.Text = "0" : TextBox61.Visible = False : Else : TextBox61.Visible = True If DataGridView2.Rows(i).Cells("第一階").Value.ToString = ComboBox2.Text Then : TextBox61.Text = Val(TextBox61.Text) + DataGridView2.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox3.Text = "" Then : ElseIf ComboBox3.Text <> "" And CheckBox2.Checked = False Then : TextBox62.Text = "0" : TextBox62.Visible = False : Else : TextBox62.Visible = True If DataGridView2.Rows(i).Cells("第一階").Value.ToString = ComboBox3.Text Then : TextBox62.Text = Val(TextBox62.Text) + DataGridView2.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox4.Text = "" Then : ElseIf ComboBox4.Text <> "" And CheckBox3.Checked = False Then : TextBox63.Text = "0" : TextBox63.Visible = False : Else : TextBox63.Visible = True If DataGridView2.Rows(i).Cells("第一階").Value.ToString = ComboBox4.Text Then : TextBox63.Text = Val(TextBox63.Text) + DataGridView2.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox5.Text = "" Then : ElseIf ComboBox5.Text <> "" And CheckBox4.Checked = False Then : TextBox77.Text = "0" : TextBox77.Visible = False : Else : TextBox77.Visible = True If DataGridView2.Rows(i).Cells("第一階").Value.ToString = ComboBox5.Text Then : TextBox77.Text = Val(TextBox77.Text) + DataGridView2.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox6.Text = "" Then : ElseIf ComboBox6.Text <> "" And CheckBox5.Checked = False Then : TextBox78.Text = "0" : TextBox78.Visible = False : Else : TextBox78.Visible = True If DataGridView2.Rows(i).Cells("第一階").Value.ToString = ComboBox6.Text Then : TextBox78.Text = Val(TextBox78.Text) + DataGridView2.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox7.Text = "" Then : ElseIf ComboBox7.Text <> "" And CheckBox6.Checked = False Then : TextBox91.Text = "0" : TextBox91.Visible = False : Else : TextBox91.Visible = True If DataGridView2.Rows(i).Cells("第一階").Value.ToString = ComboBox7.Text Then : TextBox91.Text = Val(TextBox91.Text) + DataGridView2.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox8.Text = "" Then : ElseIf ComboBox8.Text <> "" And CheckBox7.Checked = False Then : TextBox104.Text = "0" : TextBox104.Visible = False : Else : TextBox104.Visible = True If DataGridView2.Rows(i).Cells("第一階").Value.ToString = ComboBox8.Text Then : TextBox104.Text = Val(TextBox104.Text) + DataGridView2.Rows(i).Cells("主項金額").Value : End If : End If Next TextBox64.Text = Val(TextBox61.Text) + Val(TextBox62.Text) + Val(TextBox63.Text) + Val(TextBox77.Text) + Val(TextBox78.Text) + Val(TextBox91.Text) + Val(TextBox104.Text) End Sub Private Sub Set_清單1() DataGridView1.DataSource = Nothing : ds.Clear() : DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView1.ColumnHeadersHeight = 50 : DataGridView1.AllowUserToAddRows = False : DataGridView1.RowTemplate.Height = 列高 PA = "01" : SQL_營運成本收支_決算表月清單() da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() TextBox1.Text = "0" : TextBox2.Text = "0" : TextBox3.Text = "0" : TextBox4.Text = "0" : TextBox30.Text = "0" : TextBox76.Text = "0" : TextBox90.Text = "0" : TextBox103.Text = "0" For i As Integer = 0 To DataGridView1.Rows.Count - 1 If DataGridView1.Rows(i).Cells("主項金額").Value.ToString = "" Then : DataGridView1.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView1.Rows(i).Cells("子項金額").Value.ToString = "" Then : DataGridView1.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView1.Rows(i).Cells("細項金額").Value.ToString = "" Then : DataGridView1.Rows(i).Cells("細項金額").Value = 0 : End If If DataGridView1.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView1.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView1.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView1.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView1.Rows(i).Cells("主項金額").Value.ToString <> "0" Then : DataGridView1.Rows(i).Cells("金額").Value = DataGridView1.Rows(i).Cells("主項金額").Value ElseIf DataGridView1.Rows(i).Cells("子項金額").Value.ToString <> "0" Then : DataGridView1.Rows(i).Cells("金額").Value = DataGridView1.Rows(i).Cells("子項金額").Value ElseIf DataGridView1.Rows(i).Cells("細項金額").Value.ToString <> "0" Then : DataGridView1.Rows(i).Cells("金額").Value = DataGridView1.Rows(i).Cells("細項金額").Value Else : DataGridView1.Rows(i).Cells("金額").Value = 0 : End If DataGridView1.Rows(i).Cells("彙總").Value = DataGridView1.Rows(i).Cells("金額").Value If DataGridView1.Rows(i).Cells("抵銷").Value = True Then : DataGridView1.Rows(i).Cells("彙總").Value = DataGridView1.Rows(i).Cells("彙總").Value * -1 : End If If ComboBox2.Text = "" Then : Else If DataGridView1.Rows(i).Cells("第一階").Value.ToString = ComboBox2.Text Then : TextBox1.Text = Val(TextBox1.Text) + DataGridView1.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox3.Text = "" Then : Else If DataGridView1.Rows(i).Cells("第一階").Value.ToString = ComboBox3.Text Then : TextBox2.Text = Val(TextBox2.Text) + DataGridView1.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox4.Text = "" Then : Else If DataGridView1.Rows(i).Cells("第一階").Value.ToString = ComboBox4.Text Then : TextBox3.Text = Val(TextBox3.Text) + DataGridView1.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox5.Text = "" Then : Else If DataGridView1.Rows(i).Cells("第一階").Value.ToString = ComboBox5.Text Then : TextBox76.Text = Val(TextBox76.Text) + DataGridView1.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox6.Text = "" Then : Else If DataGridView1.Rows(i).Cells("第一階").Value.ToString = ComboBox6.Text Then : TextBox90.Text = Val(TextBox90.Text) + DataGridView1.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox7.Text = "" Then : Else If DataGridView1.Rows(i).Cells("第一階").Value.ToString = ComboBox7.Text Then : TextBox103.Text = Val(TextBox103.Text) + DataGridView1.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox8.Text = "" Then : Else If DataGridView1.Rows(i).Cells("第一階").Value.ToString = ComboBox8.Text Then : TextBox30.Text = Val(TextBox30.Text) + DataGridView1.Rows(i).Cells("主項金額").Value : End If : End If Next TextBox4.Text = Val(TextBox30.Text) + Val(TextBox1.Text) + Val(TextBox2.Text) + Val(TextBox3.Text) + Val(TextBox76.Text) + Val(TextBox90.Text) + Val(TextBox103.Text) End Sub Private Sub Set_清單2() DataGridView3.DataSource = Nothing : ds1.Clear() : DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView3.ColumnHeadersHeight = 50 : DataGridView3.AllowUserToAddRows = False : DataGridView3.RowTemplate.Height = 列高 PA = "02" : SQL_營運成本收支_決算表月清單() da.Fill(ds1) : DataGridView3.DataSource = ds1.Tables(0) : conn.Close() TextBox5.Text = "0" : TextBox6.Text = "0" : TextBox7.Text = "0" : TextBox8.Text = "0" : TextBox29.Text = "0" : TextBox75.Text = "0" : TextBox89.Text = "0" : TextBox102.Text = "0" For i As Integer = 0 To DataGridView3.Rows.Count - 1 If DataGridView3.Rows(i).Cells("主項金額").Value.ToString = "" Then : DataGridView3.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView3.Rows(i).Cells("子項金額").Value.ToString = "" Then : DataGridView3.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView3.Rows(i).Cells("細項金額").Value.ToString = "" Then : DataGridView3.Rows(i).Cells("細項金額").Value = 0 : End If If DataGridView3.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView3.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView3.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView3.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView3.Rows(i).Cells("主項金額").Value.ToString <> "0" Then : DataGridView3.Rows(i).Cells("金額").Value = DataGridView3.Rows(i).Cells("主項金額").Value ElseIf DataGridView3.Rows(i).Cells("子項金額").Value.ToString <> "0" Then : DataGridView3.Rows(i).Cells("金額").Value = DataGridView3.Rows(i).Cells("子項金額").Value ElseIf DataGridView3.Rows(i).Cells("細項金額").Value.ToString <> "0" Then : DataGridView3.Rows(i).Cells("金額").Value = DataGridView3.Rows(i).Cells("細項金額").Value Else : DataGridView3.Rows(i).Cells("金額").Value = 0 : End If DataGridView3.Rows(i).Cells("彙總").Value = DataGridView3.Rows(i).Cells("金額").Value If DataGridView3.Rows(i).Cells("抵銷").Value = True Then : DataGridView3.Rows(i).Cells("彙總").Value = DataGridView3.Rows(i).Cells("彙總").Value * -1 : End If If ComboBox2.Text = "" Then : Else If DataGridView3.Rows(i).Cells("第一階").Value.ToString = ComboBox2.Text Then : TextBox5.Text = Val(TextBox5.Text) + DataGridView3.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox3.Text = "" Then : Else If DataGridView3.Rows(i).Cells("第一階").Value.ToString = ComboBox3.Text Then : TextBox6.Text = Val(TextBox6.Text) + DataGridView3.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox4.Text = "" Then : Else If DataGridView3.Rows(i).Cells("第一階").Value.ToString = ComboBox4.Text Then : TextBox7.Text = Val(TextBox7.Text) + DataGridView3.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox5.Text = "" Then : Else If DataGridView3.Rows(i).Cells("第一階").Value.ToString = ComboBox5.Text Then : TextBox75.Text = Val(TextBox75.Text) + DataGridView3.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox6.Text = "" Then : Else If DataGridView3.Rows(i).Cells("第一階").Value.ToString = ComboBox6.Text Then : TextBox89.Text = Val(TextBox89.Text) + DataGridView3.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox7.Text = "" Then : Else If DataGridView3.Rows(i).Cells("第一階").Value.ToString = ComboBox7.Text Then : TextBox102.Text = Val(TextBox102.Text) + DataGridView3.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox8.Text = "" Then : Else If DataGridView3.Rows(i).Cells("第一階").Value.ToString = ComboBox8.Text Then : TextBox29.Text = Val(TextBox29.Text) + DataGridView3.Rows(i).Cells("主項金額").Value : End If : End If Next TextBox8.Text = Val(TextBox29.Text) + Val(TextBox5.Text) + Val(TextBox6.Text) + Val(TextBox7.Text) + Val(TextBox75.Text) + Val(TextBox89.Text) + Val(TextBox102.Text) End Sub Private Sub Set_清單3() DataGridView4.DataSource = Nothing : ds3.Clear() : DataGridView4.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView4.ColumnHeadersHeight = 50 : DataGridView4.AllowUserToAddRows = False : DataGridView4.RowTemplate.Height = 列高 PA = "03" : SQL_營運成本收支_決算表月清單() da.Fill(ds3) : DataGridView4.DataSource = ds3.Tables(0) : conn.Close() TextBox9.Text = "0" : TextBox10.Text = "0" : TextBox11.Text = "0" : TextBox12.Text = "0" : TextBox28.Text = "0" : TextBox74.Text = "0" : TextBox88.Text = "0" : TextBox101.Text = "0" For i As Integer = 0 To DataGridView4.Rows.Count - 1 If DataGridView4.Rows(i).Cells("主項金額").Value.ToString = "" Then : DataGridView4.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView4.Rows(i).Cells("子項金額").Value.ToString = "" Then : DataGridView4.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView4.Rows(i).Cells("細項金額").Value.ToString = "" Then : DataGridView4.Rows(i).Cells("細項金額").Value = 0 : End If If DataGridView4.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView4.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView4.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView4.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView4.Rows(i).Cells("主項金額").Value.ToString <> "0" Then : DataGridView4.Rows(i).Cells("金額").Value = DataGridView4.Rows(i).Cells("主項金額").Value ElseIf DataGridView4.Rows(i).Cells("子項金額").Value.ToString <> "0" Then : DataGridView4.Rows(i).Cells("金額").Value = DataGridView4.Rows(i).Cells("子項金額").Value ElseIf DataGridView4.Rows(i).Cells("細項金額").Value.ToString <> "0" Then : DataGridView4.Rows(i).Cells("金額").Value = DataGridView4.Rows(i).Cells("細項金額").Value Else : DataGridView4.Rows(i).Cells("金額").Value = 0 : End If DataGridView4.Rows(i).Cells("彙總").Value = DataGridView4.Rows(i).Cells("金額").Value If DataGridView4.Rows(i).Cells("抵銷").Value = True Then : DataGridView4.Rows(i).Cells("彙總").Value = DataGridView4.Rows(i).Cells("彙總").Value * -1 : End If If ComboBox2.Text = "" Then : Else If DataGridView4.Rows(i).Cells("第一階").Value.ToString = ComboBox2.Text Then : TextBox9.Text = Val(TextBox9.Text) + DataGridView4.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox3.Text = "" Then : Else If DataGridView4.Rows(i).Cells("第一階").Value.ToString = ComboBox3.Text Then : TextBox10.Text = Val(TextBox10.Text) + DataGridView4.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox4.Text = "" Then : Else If DataGridView4.Rows(i).Cells("第一階").Value.ToString = ComboBox4.Text Then : TextBox11.Text = Val(TextBox11.Text) + DataGridView4.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox5.Text = "" Then : Else If DataGridView4.Rows(i).Cells("第一階").Value.ToString = ComboBox5.Text Then : TextBox74.Text = Val(TextBox74.Text) + DataGridView4.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox6.Text = "" Then : Else If DataGridView4.Rows(i).Cells("第一階").Value.ToString = ComboBox6.Text Then : TextBox88.Text = Val(TextBox88.Text) + DataGridView4.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox7.Text = "" Then : Else If DataGridView4.Rows(i).Cells("第一階").Value.ToString = ComboBox7.Text Then : TextBox101.Text = Val(TextBox101.Text) + DataGridView4.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox8.Text = "" Then : Else If DataGridView4.Rows(i).Cells("第一階").Value.ToString = ComboBox8.Text Then : TextBox28.Text = Val(TextBox28.Text) + DataGridView4.Rows(i).Cells("主項金額").Value : End If : End If Next TextBox12.Text = Val(TextBox28.Text) + Val(TextBox9.Text) + Val(TextBox10.Text) + Val(TextBox11.Text) + Val(TextBox74.Text) + Val(TextBox88.Text) + Val(TextBox101.Text) End Sub Private Sub Set_清單4() DataGridView5.DataSource = Nothing : ds4.Clear() : DataGridView5.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView5.ColumnHeadersHeight = 50 : DataGridView5.AllowUserToAddRows = False : DataGridView5.RowTemplate.Height = 列高 PA = "04" : SQL_營運成本收支_決算表月清單() da.Fill(ds4) : DataGridView5.DataSource = ds4.Tables(0) : conn.Close() TextBox13.Text = "0" : TextBox14.Text = "0" : TextBox15.Text = "0" : TextBox16.Text = "0" : TextBox27.Text = "0" : TextBox73.Text = "0" : TextBox87.Text = "0" : TextBox100.Text = "0" For i As Integer = 0 To DataGridView5.Rows.Count - 1 If DataGridView5.Rows(i).Cells("主項金額").Value.ToString = "" Then : DataGridView5.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView5.Rows(i).Cells("子項金額").Value.ToString = "" Then : DataGridView5.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView5.Rows(i).Cells("細項金額").Value.ToString = "" Then : DataGridView5.Rows(i).Cells("細項金額").Value = 0 : End If If DataGridView5.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView5.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView5.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView5.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView5.Rows(i).Cells("主項金額").Value.ToString <> "0" Then : DataGridView5.Rows(i).Cells("金額").Value = DataGridView5.Rows(i).Cells("主項金額").Value ElseIf DataGridView5.Rows(i).Cells("子項金額").Value.ToString <> "0" Then : DataGridView5.Rows(i).Cells("金額").Value = DataGridView5.Rows(i).Cells("子項金額").Value ElseIf DataGridView5.Rows(i).Cells("細項金額").Value.ToString <> "0" Then : DataGridView5.Rows(i).Cells("金額").Value = DataGridView5.Rows(i).Cells("細項金額").Value Else : DataGridView5.Rows(i).Cells("金額").Value = 0 : End If DataGridView5.Rows(i).Cells("彙總").Value = DataGridView5.Rows(i).Cells("金額").Value If DataGridView5.Rows(i).Cells("抵銷").Value = True Then : DataGridView5.Rows(i).Cells("彙總").Value = DataGridView5.Rows(i).Cells("彙總").Value * -1 : End If If ComboBox2.Text = "" Then : Else If DataGridView5.Rows(i).Cells("第一階").Value.ToString = ComboBox2.Text Then : TextBox13.Text = Val(TextBox13.Text) + DataGridView5.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox3.Text = "" Then : Else If DataGridView5.Rows(i).Cells("第一階").Value.ToString = ComboBox3.Text Then : TextBox14.Text = Val(TextBox14.Text) + DataGridView5.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox4.Text = "" Then : Else If DataGridView5.Rows(i).Cells("第一階").Value.ToString = ComboBox4.Text Then : TextBox15.Text = Val(TextBox15.Text) + DataGridView5.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox5.Text = "" Then : Else If DataGridView5.Rows(i).Cells("第一階").Value.ToString = ComboBox5.Text Then : TextBox73.Text = Val(TextBox73.Text) + DataGridView5.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox6.Text = "" Then : Else If DataGridView5.Rows(i).Cells("第一階").Value.ToString = ComboBox6.Text Then : TextBox87.Text = Val(TextBox87.Text) + DataGridView5.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox7.Text = "" Then : Else If DataGridView5.Rows(i).Cells("第一階").Value.ToString = ComboBox7.Text Then : TextBox100.Text = Val(TextBox100.Text) + DataGridView5.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox8.Text = "" Then : Else If DataGridView5.Rows(i).Cells("第一階").Value.ToString = ComboBox8.Text Then : TextBox27.Text = Val(TextBox27.Text) + DataGridView5.Rows(i).Cells("主項金額").Value : End If : End If Next TextBox16.Text = Val(TextBox27.Text) + Val(TextBox13.Text) + Val(TextBox14.Text) + Val(TextBox15.Text) + Val(TextBox73.Text) + Val(TextBox87.Text) + Val(TextBox100.Text) End Sub Private Sub Set_清單5() DataGridView6.DataSource = Nothing : ds5.Clear() : DataGridView6.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView6.ColumnHeadersHeight = 50 : DataGridView6.AllowUserToAddRows = False : DataGridView6.RowTemplate.Height = 列高 PA = "05" : SQL_營運成本收支_決算表月清單() da.Fill(ds5) : DataGridView6.DataSource = ds5.Tables(0) : conn.Close() TextBox17.Text = "0" : TextBox18.Text = "0" : TextBox19.Text = "0" : TextBox20.Text = "0" : TextBox26.Text = "0" : TextBox72.Text = "0" : TextBox86.Text = "0" : TextBox99.Text = "0" For i As Integer = 0 To DataGridView6.Rows.Count - 1 If DataGridView6.Rows(i).Cells("主項金額").Value.ToString = "" Then : DataGridView6.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView6.Rows(i).Cells("子項金額").Value.ToString = "" Then : DataGridView6.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView6.Rows(i).Cells("細項金額").Value.ToString = "" Then : DataGridView6.Rows(i).Cells("細項金額").Value = 0 : End If If DataGridView6.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView6.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView6.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView6.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView6.Rows(i).Cells("主項金額").Value.ToString <> "0" Then : DataGridView6.Rows(i).Cells("金額").Value = DataGridView6.Rows(i).Cells("主項金額").Value ElseIf DataGridView6.Rows(i).Cells("子項金額").Value.ToString <> "0" Then : DataGridView6.Rows(i).Cells("金額").Value = DataGridView6.Rows(i).Cells("子項金額").Value ElseIf DataGridView6.Rows(i).Cells("細項金額").Value.ToString <> "0" Then : DataGridView6.Rows(i).Cells("金額").Value = DataGridView6.Rows(i).Cells("細項金額").Value Else : DataGridView6.Rows(i).Cells("金額").Value = 0 : End If DataGridView6.Rows(i).Cells("彙總").Value = DataGridView6.Rows(i).Cells("金額").Value If DataGridView6.Rows(i).Cells("抵銷").Value = True Then : DataGridView6.Rows(i).Cells("彙總").Value = DataGridView6.Rows(i).Cells("彙總").Value * -1 : End If If ComboBox2.Text = "" Then : Else If DataGridView6.Rows(i).Cells("第一階").Value.ToString = ComboBox2.Text Then : TextBox17.Text = Val(TextBox17.Text) + DataGridView6.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox3.Text = "" Then : Else If DataGridView6.Rows(i).Cells("第一階").Value.ToString = ComboBox3.Text Then : TextBox18.Text = Val(TextBox18.Text) + DataGridView6.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox4.Text = "" Then : Else If DataGridView6.Rows(i).Cells("第一階").Value.ToString = ComboBox4.Text Then : TextBox19.Text = Val(TextBox19.Text) + DataGridView6.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox5.Text = "" Then : Else If DataGridView6.Rows(i).Cells("第一階").Value.ToString = ComboBox5.Text Then : TextBox72.Text = Val(TextBox72.Text) + DataGridView6.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox6.Text = "" Then : Else If DataGridView6.Rows(i).Cells("第一階").Value.ToString = ComboBox6.Text Then : TextBox86.Text = Val(TextBox86.Text) + DataGridView6.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox7.Text = "" Then : Else If DataGridView6.Rows(i).Cells("第一階").Value.ToString = ComboBox7.Text Then : TextBox99.Text = Val(TextBox99.Text) + DataGridView6.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox8.Text = "" Then : Else If DataGridView6.Rows(i).Cells("第一階").Value.ToString = ComboBox8.Text Then : TextBox26.Text = Val(TextBox26.Text) + DataGridView6.Rows(i).Cells("主項金額").Value : End If : End If Next TextBox20.Text = Val(TextBox17.Text) + Val(TextBox18.Text) + Val(TextBox19.Text) + Val(TextBox26.Text) + Val(TextBox72.Text) + Val(TextBox86.Text) + Val(TextBox99.Text) End Sub Private Sub Set_清單6() DataGridView7.DataSource = Nothing : ds6.Clear() : DataGridView7.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView7.ColumnHeadersHeight = 50 : DataGridView7.AllowUserToAddRows = False : DataGridView7.RowTemplate.Height = 列高 PA = "06" : SQL_營運成本收支_決算表月清單() da.Fill(ds6) : DataGridView7.DataSource = ds6.Tables(0) : conn.Close() TextBox21.Text = "0" : TextBox22.Text = "0" : TextBox23.Text = "0" : TextBox24.Text = "0" : TextBox25.Text = "0" : TextBox71.Text = "0" : TextBox85.Text = "0" : TextBox98.Text = "0" For i As Integer = 0 To DataGridView7.Rows.Count - 1 If DataGridView7.Rows(i).Cells("主項金額").Value.ToString = "" Then : DataGridView7.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView7.Rows(i).Cells("子項金額").Value.ToString = "" Then : DataGridView7.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView7.Rows(i).Cells("細項金額").Value.ToString = "" Then : DataGridView7.Rows(i).Cells("細項金額").Value = 0 : End If If DataGridView7.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView7.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView7.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView7.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView7.Rows(i).Cells("主項金額").Value.ToString <> "0" Then : DataGridView7.Rows(i).Cells("金額").Value = DataGridView7.Rows(i).Cells("主項金額").Value ElseIf DataGridView7.Rows(i).Cells("子項金額").Value.ToString <> "0" Then : DataGridView7.Rows(i).Cells("金額").Value = DataGridView7.Rows(i).Cells("子項金額").Value ElseIf DataGridView7.Rows(i).Cells("細項金額").Value.ToString <> "0" Then : DataGridView7.Rows(i).Cells("金額").Value = DataGridView7.Rows(i).Cells("細項金額").Value Else : DataGridView7.Rows(i).Cells("金額").Value = 0 : End If DataGridView7.Rows(i).Cells("彙總").Value = DataGridView7.Rows(i).Cells("金額").Value If DataGridView7.Rows(i).Cells("抵銷").Value = True Then : DataGridView7.Rows(i).Cells("彙總").Value = DataGridView7.Rows(i).Cells("彙總").Value * -1 : End If If ComboBox2.Text = "" Then : Else If DataGridView7.Rows(i).Cells("第一階").Value.ToString = ComboBox2.Text Then : TextBox21.Text = Val(TextBox21.Text) + DataGridView7.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox3.Text = "" Then : Else If DataGridView7.Rows(i).Cells("第一階").Value.ToString = ComboBox3.Text Then : TextBox22.Text = Val(TextBox22.Text) + DataGridView7.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox4.Text = "" Then : Else If DataGridView7.Rows(i).Cells("第一階").Value.ToString = ComboBox4.Text Then : TextBox23.Text = Val(TextBox23.Text) + DataGridView7.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox5.Text = "" Then : Else If DataGridView7.Rows(i).Cells("第一階").Value.ToString = ComboBox5.Text Then : TextBox71.Text = Val(TextBox71.Text) + DataGridView7.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox6.Text = "" Then : Else If DataGridView7.Rows(i).Cells("第一階").Value.ToString = ComboBox6.Text Then : TextBox85.Text = Val(TextBox85.Text) + DataGridView7.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox7.Text = "" Then : Else If DataGridView7.Rows(i).Cells("第一階").Value.ToString = ComboBox7.Text Then : TextBox98.Text = Val(TextBox98.Text) + DataGridView7.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox8.Text = "" Then : Else If DataGridView7.Rows(i).Cells("第一階").Value.ToString = ComboBox8.Text Then : TextBox25.Text = Val(TextBox25.Text) + DataGridView7.Rows(i).Cells("主項金額").Value : End If : End If Next TextBox24.Text = Val(TextBox21.Text) + Val(TextBox22.Text) + Val(TextBox23.Text) + Val(TextBox25.Text) + Val(TextBox71.Text) + Val(TextBox85.Text) + Val(TextBox98.Text) End Sub Private Sub Set_清單7() DataGridView8.DataSource = Nothing : ds7.Clear() : DataGridView8.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView8.ColumnHeadersHeight = 50 : DataGridView8.AllowUserToAddRows = False : DataGridView8.RowTemplate.Height = 列高 PA = "07" : SQL_營運成本收支_決算表月清單() da.Fill(ds7) : DataGridView8.DataSource = ds7.Tables(0) : conn.Close() TextBox31.Text = "0" : TextBox32.Text = "0" : TextBox33.Text = "0" : TextBox34.Text = "0" : TextBox35.Text = "0" : TextBox70.Text = "0" : TextBox84.Text = "0" : TextBox97.Text = "0" For i As Integer = 0 To DataGridView8.Rows.Count - 1 If DataGridView8.Rows(i).Cells("主項金額").Value.ToString = "" Then : DataGridView8.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView8.Rows(i).Cells("子項金額").Value.ToString = "" Then : DataGridView8.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView8.Rows(i).Cells("細項金額").Value.ToString = "" Then : DataGridView8.Rows(i).Cells("細項金額").Value = 0 : End If If DataGridView8.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView8.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView8.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView8.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView8.Rows(i).Cells("主項金額").Value.ToString <> "0" Then : DataGridView8.Rows(i).Cells("金額").Value = DataGridView8.Rows(i).Cells("主項金額").Value ElseIf DataGridView8.Rows(i).Cells("子項金額").Value.ToString <> "0" Then : DataGridView8.Rows(i).Cells("金額").Value = DataGridView8.Rows(i).Cells("子項金額").Value ElseIf DataGridView8.Rows(i).Cells("細項金額").Value.ToString <> "0" Then : DataGridView8.Rows(i).Cells("金額").Value = DataGridView8.Rows(i).Cells("細項金額").Value Else : DataGridView8.Rows(i).Cells("金額").Value = 0 : End If DataGridView8.Rows(i).Cells("彙總").Value = DataGridView8.Rows(i).Cells("金額").Value If DataGridView8.Rows(i).Cells("抵銷").Value = True Then : DataGridView8.Rows(i).Cells("彙總").Value = DataGridView8.Rows(i).Cells("彙總").Value * -1 : End If If ComboBox2.Text = "" Then : Else If DataGridView8.Rows(i).Cells("第一階").Value.ToString = ComboBox2.Text Then : TextBox35.Text = Val(TextBox35.Text) + DataGridView8.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox3.Text = "" Then : Else If DataGridView8.Rows(i).Cells("第一階").Value.ToString = ComboBox3.Text Then : TextBox34.Text = Val(TextBox34.Text) + DataGridView8.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox4.Text = "" Then : Else If DataGridView8.Rows(i).Cells("第一階").Value.ToString = ComboBox4.Text Then : TextBox33.Text = Val(TextBox33.Text) + DataGridView8.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox5.Text = "" Then : Else If DataGridView8.Rows(i).Cells("第一階").Value.ToString = ComboBox5.Text Then : TextBox70.Text = Val(TextBox70.Text) + DataGridView8.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox6.Text = "" Then : Else If DataGridView8.Rows(i).Cells("第一階").Value.ToString = ComboBox6.Text Then : TextBox84.Text = Val(TextBox84.Text) + DataGridView8.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox7.Text = "" Then : Else If DataGridView8.Rows(i).Cells("第一階").Value.ToString = ComboBox7.Text Then : TextBox97.Text = Val(TextBox97.Text) + DataGridView8.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox8.Text = "" Then : Else If DataGridView8.Rows(i).Cells("第一階").Value.ToString = ComboBox8.Text Then : TextBox31.Text = Val(TextBox31.Text) + DataGridView8.Rows(i).Cells("主項金額").Value : End If : End If Next TextBox32.Text = Val(TextBox35.Text) + Val(TextBox34.Text) + Val(TextBox33.Text) + Val(TextBox31.Text) + Val(TextBox70.Text) + Val(TextBox84.Text) + Val(TextBox97.Text) End Sub Private Sub Set_清單8() DataGridView9.DataSource = Nothing : ds8.Clear() : DataGridView9.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView9.ColumnHeadersHeight = 50 : DataGridView9.AllowUserToAddRows = False : DataGridView9.RowTemplate.Height = 列高 PA = "08" : SQL_營運成本收支_決算表月清單() da.Fill(ds8) : DataGridView9.DataSource = ds8.Tables(0) : conn.Close() TextBox36.Text = "0" : TextBox37.Text = "0" : TextBox38.Text = "0" : TextBox39.Text = "0" : TextBox40.Text = "0" : TextBox69.Text = "0" : TextBox83.Text = "0" : TextBox96.Text = "0" For i As Integer = 0 To DataGridView9.Rows.Count - 1 If DataGridView9.Rows(i).Cells("主項金額").Value.ToString = "" Then : DataGridView9.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView9.Rows(i).Cells("子項金額").Value.ToString = "" Then : DataGridView9.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView9.Rows(i).Cells("細項金額").Value.ToString = "" Then : DataGridView9.Rows(i).Cells("細項金額").Value = 0 : End If If DataGridView9.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView9.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView9.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView9.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView9.Rows(i).Cells("主項金額").Value.ToString <> "0" Then : DataGridView9.Rows(i).Cells("金額").Value = DataGridView9.Rows(i).Cells("主項金額").Value ElseIf DataGridView9.Rows(i).Cells("子項金額").Value.ToString <> "0" Then : DataGridView9.Rows(i).Cells("金額").Value = DataGridView9.Rows(i).Cells("子項金額").Value ElseIf DataGridView9.Rows(i).Cells("細項金額").Value.ToString <> "0" Then : DataGridView9.Rows(i).Cells("金額").Value = DataGridView9.Rows(i).Cells("細項金額").Value Else : DataGridView9.Rows(i).Cells("金額").Value = 0 : End If DataGridView9.Rows(i).Cells("彙總").Value = DataGridView9.Rows(i).Cells("金額").Value If DataGridView9.Rows(i).Cells("抵銷").Value = True Then : DataGridView9.Rows(i).Cells("彙總").Value = DataGridView9.Rows(i).Cells("彙總").Value * -1 : End If If ComboBox2.Text = "" Then : Else If DataGridView9.Rows(i).Cells("第一階").Value.ToString = ComboBox2.Text Then : TextBox40.Text = Val(TextBox40.Text) + DataGridView9.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox3.Text = "" Then : Else If DataGridView9.Rows(i).Cells("第一階").Value.ToString = ComboBox3.Text Then : TextBox39.Text = Val(TextBox39.Text) + DataGridView9.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox4.Text = "" Then : Else If DataGridView9.Rows(i).Cells("第一階").Value.ToString = ComboBox4.Text Then : TextBox38.Text = Val(TextBox38.Text) + DataGridView9.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox5.Text = "" Then : Else If DataGridView9.Rows(i).Cells("第一階").Value.ToString = ComboBox5.Text Then : TextBox69.Text = Val(TextBox69.Text) + DataGridView9.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox6.Text = "" Then : Else If DataGridView9.Rows(i).Cells("第一階").Value.ToString = ComboBox6.Text Then : TextBox83.Text = Val(TextBox83.Text) + DataGridView9.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox7.Text = "" Then : Else If DataGridView9.Rows(i).Cells("第一階").Value.ToString = ComboBox7.Text Then : TextBox96.Text = Val(TextBox96.Text) + DataGridView9.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox8.Text = "" Then : Else If DataGridView9.Rows(i).Cells("第一階").Value.ToString = ComboBox8.Text Then : TextBox36.Text = Val(TextBox36.Text) + DataGridView9.Rows(i).Cells("主項金額").Value : End If : End If Next TextBox37.Text = Val(TextBox40.Text) + Val(TextBox39.Text) + Val(TextBox38.Text) + Val(TextBox36.Text) + Val(TextBox69.Text) + Val(TextBox83.Text) + Val(TextBox96.Text) End Sub Private Sub Set_清單9() DataGridView10.DataSource = Nothing : ds9.Clear() : DataGridView10.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView10.ColumnHeadersHeight = 50 : DataGridView10.AllowUserToAddRows = False : DataGridView10.RowTemplate.Height = 列高 PA = "09" : SQL_營運成本收支_決算表月清單() da.Fill(ds9) : DataGridView10.DataSource = ds9.Tables(0) : conn.Close() TextBox41.Text = "0" : TextBox42.Text = "0" : TextBox43.Text = "0" : TextBox44.Text = "0" : TextBox45.Text = "0" : TextBox68.Text = "0" : TextBox82.Text = "0" : TextBox95.Text = "0" For i As Integer = 0 To DataGridView10.Rows.Count - 1 If DataGridView10.Rows(i).Cells("主項金額").Value.ToString = "" Then : DataGridView10.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView10.Rows(i).Cells("子項金額").Value.ToString = "" Then : DataGridView10.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView10.Rows(i).Cells("細項金額").Value.ToString = "" Then : DataGridView10.Rows(i).Cells("細項金額").Value = 0 : End If If DataGridView10.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView10.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView10.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView10.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView10.Rows(i).Cells("主項金額").Value.ToString <> "0" Then : DataGridView10.Rows(i).Cells("金額").Value = DataGridView10.Rows(i).Cells("主項金額").Value ElseIf DataGridView10.Rows(i).Cells("子項金額").Value.ToString <> "0" Then : DataGridView10.Rows(i).Cells("金額").Value = DataGridView10.Rows(i).Cells("子項金額").Value ElseIf DataGridView10.Rows(i).Cells("細項金額").Value.ToString <> "0" Then : DataGridView10.Rows(i).Cells("金額").Value = DataGridView10.Rows(i).Cells("細項金額").Value Else : DataGridView10.Rows(i).Cells("金額").Value = 0 : End If DataGridView10.Rows(i).Cells("彙總").Value = DataGridView10.Rows(i).Cells("金額").Value If DataGridView10.Rows(i).Cells("抵銷").Value = True Then : DataGridView10.Rows(i).Cells("彙總").Value = DataGridView10.Rows(i).Cells("彙總").Value * -1 : End If If ComboBox2.Text = "" Then : Else If DataGridView10.Rows(i).Cells("第一階").Value.ToString = ComboBox2.Text Then : TextBox45.Text = Val(TextBox45.Text) + DataGridView10.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox3.Text = "" Then : Else If DataGridView10.Rows(i).Cells("第一階").Value.ToString = ComboBox3.Text Then : TextBox44.Text = Val(TextBox44.Text) + DataGridView10.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox4.Text = "" Then : Else If DataGridView10.Rows(i).Cells("第一階").Value.ToString = ComboBox4.Text Then : TextBox43.Text = Val(TextBox43.Text) + DataGridView10.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox5.Text = "" Then : Else If DataGridView10.Rows(i).Cells("第一階").Value.ToString = ComboBox5.Text Then : TextBox68.Text = Val(TextBox68.Text) + DataGridView10.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox6.Text = "" Then : Else If DataGridView10.Rows(i).Cells("第一階").Value.ToString = ComboBox6.Text Then : TextBox82.Text = Val(TextBox82.Text) + DataGridView10.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox7.Text = "" Then : Else If DataGridView10.Rows(i).Cells("第一階").Value.ToString = ComboBox7.Text Then : TextBox95.Text = Val(TextBox95.Text) + DataGridView10.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox8.Text = "" Then : Else If DataGridView10.Rows(i).Cells("第一階").Value.ToString = ComboBox8.Text Then : TextBox41.Text = Val(TextBox41.Text) + DataGridView10.Rows(i).Cells("主項金額").Value : End If : End If Next TextBox42.Text = Val(TextBox45.Text) + Val(TextBox44.Text) + Val(TextBox43.Text) + Val(TextBox41.Text) + Val(TextBox68.Text) + Val(TextBox82.Text) + Val(TextBox95.Text) End Sub Private Sub Set_清單10() DataGridView11.DataSource = Nothing : ds10.Clear() : DataGridView11.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView11.ColumnHeadersHeight = 50 : DataGridView11.AllowUserToAddRows = False : DataGridView11.RowTemplate.Height = 列高 PA = "10" : SQL_營運成本收支_決算表月清單() da.Fill(ds10) : DataGridView11.DataSource = ds10.Tables(0) : conn.Close() TextBox46.Text = "0" : TextBox47.Text = "0" : TextBox48.Text = "0" : TextBox49.Text = "0" : TextBox50.Text = "0" : TextBox67.Text = "0" : TextBox81.Text = "0" : TextBox94.Text = "0" For i As Integer = 0 To DataGridView11.Rows.Count - 1 If DataGridView11.Rows(i).Cells("主項金額").Value.ToString = "" Then : DataGridView11.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView11.Rows(i).Cells("子項金額").Value.ToString = "" Then : DataGridView11.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView11.Rows(i).Cells("細項金額").Value.ToString = "" Then : DataGridView11.Rows(i).Cells("細項金額").Value = 0 : End If If DataGridView11.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView11.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView11.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView11.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView11.Rows(i).Cells("主項金額").Value.ToString <> "0" Then : DataGridView11.Rows(i).Cells("金額").Value = DataGridView11.Rows(i).Cells("主項金額").Value ElseIf DataGridView11.Rows(i).Cells("子項金額").Value.ToString <> "0" Then : DataGridView11.Rows(i).Cells("金額").Value = DataGridView11.Rows(i).Cells("子項金額").Value ElseIf DataGridView11.Rows(i).Cells("細項金額").Value.ToString <> "0" Then : DataGridView11.Rows(i).Cells("金額").Value = DataGridView11.Rows(i).Cells("細項金額").Value Else : DataGridView11.Rows(i).Cells("金額").Value = 0 : End If DataGridView11.Rows(i).Cells("彙總").Value = DataGridView11.Rows(i).Cells("金額").Value If DataGridView11.Rows(i).Cells("抵銷").Value = True Then : DataGridView11.Rows(i).Cells("彙總").Value = DataGridView11.Rows(i).Cells("彙總").Value * -1 : End If If ComboBox2.Text = "" Then : Else If DataGridView11.Rows(i).Cells("第一階").Value.ToString = ComboBox2.Text Then : TextBox50.Text = Val(TextBox50.Text) + DataGridView11.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox3.Text = "" Then : Else If DataGridView11.Rows(i).Cells("第一階").Value.ToString = ComboBox3.Text Then : TextBox49.Text = Val(TextBox49.Text) + DataGridView11.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox4.Text = "" Then : Else If DataGridView11.Rows(i).Cells("第一階").Value.ToString = ComboBox4.Text Then : TextBox48.Text = Val(TextBox48.Text) + DataGridView11.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox5.Text = "" Then : Else If DataGridView11.Rows(i).Cells("第一階").Value.ToString = ComboBox5.Text Then : TextBox67.Text = Val(TextBox67.Text) + DataGridView11.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox6.Text = "" Then : Else If DataGridView11.Rows(i).Cells("第一階").Value.ToString = ComboBox6.Text Then : TextBox81.Text = Val(TextBox81.Text) + DataGridView11.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox7.Text = "" Then : Else If DataGridView11.Rows(i).Cells("第一階").Value.ToString = ComboBox7.Text Then : TextBox94.Text = Val(TextBox94.Text) + DataGridView11.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox8.Text = "" Then : Else If DataGridView11.Rows(i).Cells("第一階").Value.ToString = ComboBox8.Text Then : TextBox46.Text = Val(TextBox46.Text) + DataGridView11.Rows(i).Cells("主項金額").Value : End If : End If Next TextBox47.Text = Val(TextBox50.Text) + Val(TextBox49.Text) + Val(TextBox48.Text) + Val(TextBox46.Text) + Val(TextBox67.Text) + Val(TextBox81.Text) + Val(TextBox94.Text) End Sub Private Sub Set_清單11() DataGridView12.DataSource = Nothing : ds11.Clear() : DataGridView12.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView12.ColumnHeadersHeight = 50 : DataGridView12.AllowUserToAddRows = False : DataGridView12.RowTemplate.Height = 列高 PA = "11" : SQL_營運成本收支_決算表月清單() da.Fill(ds11) : DataGridView12.DataSource = ds11.Tables(0) : conn.Close() TextBox51.Text = "0" : TextBox52.Text = "0" : TextBox53.Text = "0" : TextBox54.Text = "0" : TextBox55.Text = "0" : TextBox66.Text = "0" : TextBox80.Text = "0" : TextBox93.Text = "0" For i As Integer = 0 To DataGridView12.Rows.Count - 1 If DataGridView12.Rows(i).Cells("主項金額").Value.ToString = "" Then : DataGridView12.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView12.Rows(i).Cells("子項金額").Value.ToString = "" Then : DataGridView12.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView12.Rows(i).Cells("細項金額").Value.ToString = "" Then : DataGridView12.Rows(i).Cells("細項金額").Value = 0 : End If If DataGridView12.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView12.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView12.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView12.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView12.Rows(i).Cells("主項金額").Value.ToString <> "0" Then : DataGridView12.Rows(i).Cells("金額").Value = DataGridView12.Rows(i).Cells("主項金額").Value ElseIf DataGridView12.Rows(i).Cells("子項金額").Value.ToString <> "0" Then : DataGridView12.Rows(i).Cells("金額").Value = DataGridView12.Rows(i).Cells("子項金額").Value ElseIf DataGridView12.Rows(i).Cells("細項金額").Value.ToString <> "0" Then : DataGridView12.Rows(i).Cells("金額").Value = DataGridView12.Rows(i).Cells("細項金額").Value Else : DataGridView12.Rows(i).Cells("金額").Value = 0 : End If DataGridView12.Rows(i).Cells("彙總").Value = DataGridView12.Rows(i).Cells("金額").Value If DataGridView12.Rows(i).Cells("抵銷").Value = True Then : DataGridView12.Rows(i).Cells("彙總").Value = DataGridView12.Rows(i).Cells("彙總").Value * -1 : End If If ComboBox2.Text = "" Then : Else If DataGridView12.Rows(i).Cells("第一階").Value.ToString = ComboBox2.Text Then : TextBox55.Text = Val(TextBox55.Text) + DataGridView12.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox3.Text = "" Then : Else If DataGridView12.Rows(i).Cells("第一階").Value.ToString = ComboBox3.Text Then : TextBox54.Text = Val(TextBox54.Text) + DataGridView12.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox4.Text = "" Then : Else If DataGridView12.Rows(i).Cells("第一階").Value.ToString = ComboBox4.Text Then : TextBox53.Text = Val(TextBox53.Text) + DataGridView12.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox5.Text = "" Then : Else If DataGridView12.Rows(i).Cells("第一階").Value.ToString = ComboBox5.Text Then : TextBox66.Text = Val(TextBox66.Text) + DataGridView12.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox6.Text = "" Then : Else If DataGridView12.Rows(i).Cells("第一階").Value.ToString = ComboBox6.Text Then : TextBox80.Text = Val(TextBox80.Text) + DataGridView12.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox7.Text = "" Then : Else If DataGridView12.Rows(i).Cells("第一階").Value.ToString = ComboBox7.Text Then : TextBox93.Text = Val(TextBox93.Text) + DataGridView12.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox8.Text = "" Then : Else If DataGridView12.Rows(i).Cells("第一階").Value.ToString = ComboBox8.Text Then : TextBox51.Text = Val(TextBox51.Text) + DataGridView12.Rows(i).Cells("主項金額").Value : End If : End If Next TextBox52.Text = Val(TextBox55.Text) + Val(TextBox54.Text) + Val(TextBox53.Text) + Val(TextBox51.Text) + Val(TextBox66.Text) + Val(TextBox80.Text) + Val(TextBox93.Text) End Sub Private Sub Set_清單12() DataGridView13.DataSource = Nothing : ds12.Clear() : DataGridView13.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView13.ColumnHeadersHeight = 50 : DataGridView13.AllowUserToAddRows = False : DataGridView13.RowTemplate.Height = 列高 PA = "12" : SQL_營運成本收支_決算表月清單() da.Fill(ds12) : DataGridView13.DataSource = ds12.Tables(0) : conn.Close() TextBox56.Text = "0" : TextBox57.Text = "0" : TextBox58.Text = "0" : TextBox59.Text = "0" : TextBox60.Text = "0" : TextBox65.Text = "0" : TextBox79.Text = "0" : TextBox92.Text = "0" For i As Integer = 0 To DataGridView13.Rows.Count - 1 If DataGridView13.Rows(i).Cells("主項金額").Value.ToString = "" Then : DataGridView13.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView13.Rows(i).Cells("子項金額").Value.ToString = "" Then : DataGridView13.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView13.Rows(i).Cells("細項金額").Value.ToString = "" Then : DataGridView13.Rows(i).Cells("細項金額").Value = 0 : End If If DataGridView13.Rows(i).Cells("層級").Value.ToString <> "1" Then : DataGridView13.Rows(i).Cells("主項金額").Value = 0 : End If If DataGridView13.Rows(i).Cells("層級").Value.ToString <> "2" Then : DataGridView13.Rows(i).Cells("子項金額").Value = 0 : End If If DataGridView13.Rows(i).Cells("主項金額").Value.ToString <> "0" Then : DataGridView13.Rows(i).Cells("金額").Value = DataGridView13.Rows(i).Cells("主項金額").Value ElseIf DataGridView13.Rows(i).Cells("子項金額").Value.ToString <> "0" Then : DataGridView13.Rows(i).Cells("金額").Value = DataGridView13.Rows(i).Cells("子項金額").Value ElseIf DataGridView13.Rows(i).Cells("細項金額").Value.ToString <> "0" Then : DataGridView13.Rows(i).Cells("金額").Value = DataGridView13.Rows(i).Cells("細項金額").Value Else : DataGridView13.Rows(i).Cells("金額").Value = 0 : End If DataGridView13.Rows(i).Cells("彙總").Value = DataGridView13.Rows(i).Cells("金額").Value If DataGridView13.Rows(i).Cells("抵銷").Value = True Then : DataGridView13.Rows(i).Cells("彙總").Value = DataGridView13.Rows(i).Cells("彙總").Value * -1 : End If If ComboBox2.Text = "" Then : Else If DataGridView13.Rows(i).Cells("第一階").Value.ToString = ComboBox2.Text Then : TextBox60.Text = Val(TextBox60.Text) + DataGridView13.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox3.Text = "" Then : Else If DataGridView13.Rows(i).Cells("第一階").Value.ToString = ComboBox3.Text Then : TextBox59.Text = Val(TextBox59.Text) + DataGridView13.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox4.Text = "" Then : Else If DataGridView13.Rows(i).Cells("第一階").Value.ToString = ComboBox4.Text Then : TextBox58.Text = Val(TextBox58.Text) + DataGridView13.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox5.Text = "" Then : Else If DataGridView13.Rows(i).Cells("第一階").Value.ToString = ComboBox5.Text Then : TextBox65.Text = Val(TextBox65.Text) + DataGridView13.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox6.Text = "" Then : Else If DataGridView13.Rows(i).Cells("第一階").Value.ToString = ComboBox6.Text Then : TextBox79.Text = Val(TextBox79.Text) + DataGridView13.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox7.Text = "" Then : Else If DataGridView13.Rows(i).Cells("第一階").Value.ToString = ComboBox7.Text Then : TextBox92.Text = Val(TextBox92.Text) + DataGridView13.Rows(i).Cells("主項金額").Value : End If : End If If ComboBox8.Text = "" Then : Else If DataGridView13.Rows(i).Cells("第一階").Value.ToString = ComboBox8.Text Then : TextBox56.Text = Val(TextBox56.Text) + DataGridView13.Rows(i).Cells("主項金額").Value : End If : End If Next TextBox57.Text = Val(TextBox60.Text) + Val(TextBox59.Text) + Val(TextBox58.Text) + Val(TextBox56.Text) + Val(TextBox65.Text) + Val(TextBox79.Text) + Val(TextBox92.Text) End Sub Private Sub Set_清單13() DataGridView14.DataSource = Nothing : ds13.Clear() : DataGridView14.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView14.ColumnHeadersHeight = 50 : DataGridView14.AllowUserToAddRows = False SQL_財務決算表合計預設() da.Fill(ds13) : DataGridView14.DataSource = ds13.Tables(0) : conn.Close() End Sub Private Sub ComboBox1下拉表單資料載入() PA = "%%" : SQL_年份清單查詢() ComboBox1.Items.Clear() : While (dr.Read()) : ComboBox1.Items.Add(dr("年份")) : End While : conn.Close() End Sub Private Sub ComboBox2下拉表單資料載入() SQL_營運成本收支_決算表_會計科目() ComboBox2.Items.Clear() : ComboBox3.Items.Clear() : ComboBox4.Items.Clear() : ComboBox5.Items.Clear() : ComboBox6.Items.Clear() : ComboBox7.Items.Clear() : ComboBox8.Items.Clear() While (dr.Read()) ComboBox2.Items.Add(dr("會計科目")) : ComboBox3.Items.Add(dr("會計科目")) : ComboBox4.Items.Add(dr("會計科目")) : ComboBox5.Items.Add(dr("會計科目")) ComboBox6.Items.Add(dr("會計科目")) : ComboBox7.Items.Add(dr("會計科目")) : ComboBox8.Items.Add(dr("會計科目")) End While : conn.Close() End Sub Private Sub 格式設定() For i As Integer = 1 To 13 Dim DataGridViewOO As DataGridView = CType(Me.Controls.Find("DataGridView" + i.ToString(), True)(0), DataGridView) If i = 2 Then DataGridViewOO.Columns(0).FillWeight = 50 : DataGridViewOO.Columns(1).Visible = False : DataGridViewOO.Columns(2).Visible = False : DataGridViewOO.Columns(3).FillWeight = 90 DataGridViewOO.Columns(4).FillWeight = 90 : DataGridViewOO.Columns(5).FillWeight = 120 : DataGridViewOO.Columns(6).Visible = False : DataGridViewOO.Columns(7).Visible = False DataGridViewOO.Columns(8).Visible = False : DataGridViewOO.Columns(9).Visible = False : DataGridViewOO.Columns(10).FillWeight = 80 : DataGridViewOO.Columns(11).FillWeight = 80 DataGridViewOO.Columns(12).FillWeight = 80 DataGridViewOO.Columns(10).DefaultCellStyle.Format = "#,##0" : DataGridViewOO.Columns(11).DefaultCellStyle.Format = "#,##0" : DataGridViewOO.Columns(12).DefaultCellStyle.Format = "#,##0" DataGridViewOO.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight DataGridViewOO.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight DataGridViewOO.Columns(11).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight DataGridViewOO.Columns(11).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight DataGridViewOO.Columns(12).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight DataGridViewOO.Columns(12).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight DataGridViewOO.Columns(0).ReadOnly = True : DataGridViewOO.Columns(1).ReadOnly = True : DataGridViewOO.Columns(2).ReadOnly = True : DataGridViewOO.Columns(3).ReadOnly = True DataGridViewOO.Columns(4).ReadOnly = True : DataGridViewOO.Columns(5).ReadOnly = True : DataGridViewOO.Columns(10).ReadOnly = True : DataGridViewOO.Columns(11).ReadOnly = True DataGridViewOO.Columns(12).ReadOnly = True Else DataGridViewOO.Columns(0).FillWeight = 20 : DataGridViewOO.Columns(1).Visible = False : DataGridViewOO.Columns(2).Visible = False : DataGridViewOO.Columns(3).Visible = False DataGridViewOO.Columns(4).Visible = False : DataGridViewOO.Columns(5).Visible = False : DataGridViewOO.Columns(6).Visible = False : DataGridViewOO.Columns(7).Visible = False DataGridViewOO.Columns(9).Visible = False : DataGridViewOO.Columns(8).Visible = False : DataGridViewOO.Columns(10).Visible = False : DataGridViewOO.Columns(11).FillWeight = 75 DataGridViewOO.Columns(11).DefaultCellStyle.Format = "#,##0" DataGridViewOO.Columns(11).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight DataGridViewOO.Columns(11).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight DataGridViewOO.Columns(11).ReadOnly = True End If Next If TextBox111.Text = "貸" Then TextBox61.Text = Val(TextBox61.Text) * -1 : TextBox1.Text = Val(TextBox1.Text) * -1 : TextBox5.Text = Val(TextBox5.Text) * -1 : TextBox9.Text = Val(TextBox9.Text) * -1 TextBox13.Text = Val(TextBox13.Text) * -1 : TextBox17.Text = Val(TextBox17.Text) * -1 : TextBox21.Text = Val(TextBox21.Text) * -1 : TextBox35.Text = Val(TextBox35.Text) * -1 TextBox40.Text = Val(TextBox40.Text) * -1 : TextBox45.Text = Val(TextBox45.Text) * -1 : TextBox50.Text = Val(TextBox50.Text) * -1 : TextBox55.Text = Val(TextBox55.Text) * -1 TextBox60.Text = Val(TextBox60.Text) * -1 TextBox61.ForeColor = Color.Red : TextBox1.ForeColor = Color.Red : TextBox5.ForeColor = Color.Red : TextBox9.ForeColor = Color.Red : TextBox13.ForeColor = Color.Red TextBox17.ForeColor = Color.Red : TextBox21.ForeColor = Color.Red : TextBox35.ForeColor = Color.Red : TextBox40.ForeColor = Color.Red : TextBox45.ForeColor = Color.Red TextBox50.ForeColor = Color.Red : TextBox55.ForeColor = Color.Red : TextBox60.ForeColor = Color.Red ElseIf TextBox111.Text = "借" Then TextBox61.ForeColor = Color.Blue : TextBox1.ForeColor = Color.Blue : TextBox5.ForeColor = Color.Blue : TextBox9.ForeColor = Color.Blue : TextBox13.ForeColor = Color.Blue TextBox17.ForeColor = Color.Blue : TextBox21.ForeColor = Color.Blue : TextBox35.ForeColor = Color.Blue : TextBox40.ForeColor = Color.Blue : TextBox45.ForeColor = Color.Blue TextBox50.ForeColor = Color.Blue : TextBox55.ForeColor = Color.Blue : TextBox60.ForeColor = Color.Blue ElseIf TextBox111.Text = "" Then TextBox61.ForeColor = Color.Black : TextBox1.ForeColor = Color.Black : TextBox5.ForeColor = Color.Black : TextBox9.ForeColor = Color.Black : TextBox13.ForeColor = Color.Black TextBox17.ForeColor = Color.Black : TextBox21.ForeColor = Color.Black : TextBox35.ForeColor = Color.Black : TextBox40.ForeColor = Color.Black : TextBox45.ForeColor = Color.Black TextBox50.ForeColor = Color.Black : TextBox55.ForeColor = Color.Black : TextBox60.ForeColor = Color.Black End If If TextBox110.Text = "貸" Then TextBox62.Text = Val(TextBox62.Text) * -1 : TextBox2.Text = Val(TextBox2.Text) * -1 : TextBox6.Text = Val(TextBox6.Text) * -1 : TextBox10.Text = Val(TextBox10.Text) * -1 TextBox14.Text = Val(TextBox14.Text) * -1 : TextBox18.Text = Val(TextBox18.Text) * -1 : TextBox22.Text = Val(TextBox22.Text) * -1 : TextBox34.Text = Val(TextBox34.Text) * -1 TextBox39.Text = Val(TextBox39.Text) * -1 : TextBox44.Text = Val(TextBox44.Text) * -1 : TextBox49.Text = Val(TextBox49.Text) * -1 : TextBox54.Text = Val(TextBox54.Text) * -1 TextBox59.Text = Val(TextBox59.Text) * -1 TextBox62.ForeColor = Color.Red : TextBox2.ForeColor = Color.Red : TextBox6.ForeColor = Color.Red : TextBox10.ForeColor = Color.Red : TextBox14.ForeColor = Color.Red TextBox18.ForeColor = Color.Red : TextBox22.ForeColor = Color.Red : TextBox34.ForeColor = Color.Red : TextBox39.ForeColor = Color.Red : TextBox44.ForeColor = Color.Red TextBox49.ForeColor = Color.Red : TextBox54.ForeColor = Color.Red : TextBox59.ForeColor = Color.Red ElseIf TextBox110.Text = "借" Then TextBox62.ForeColor = Color.Blue : TextBox2.ForeColor = Color.Blue : TextBox6.ForeColor = Color.Blue : TextBox10.ForeColor = Color.Blue : TextBox14.ForeColor = Color.Blue TextBox18.ForeColor = Color.Blue : TextBox22.ForeColor = Color.Blue : TextBox34.ForeColor = Color.Blue : TextBox39.ForeColor = Color.Blue : TextBox44.ForeColor = Color.Blue TextBox49.ForeColor = Color.Blue : TextBox54.ForeColor = Color.Blue : TextBox59.ForeColor = Color.Blue ElseIf TextBox110.Text = "" Then TextBox62.ForeColor = Color.Black : TextBox2.ForeColor = Color.Black : TextBox6.ForeColor = Color.Black : TextBox10.ForeColor = Color.Black : TextBox14.ForeColor = Color.Black TextBox18.ForeColor = Color.Black : TextBox22.ForeColor = Color.Black : TextBox34.ForeColor = Color.Black : TextBox39.ForeColor = Color.Black : TextBox44.ForeColor = Color.Black TextBox49.ForeColor = Color.Black : TextBox54.ForeColor = Color.Black : TextBox59.ForeColor = Color.Black End If If TextBox109.Text = "貸" Then TextBox63.Text = Val(TextBox63.Text) * -1 : TextBox3.Text = Val(TextBox3.Text) * -1 : TextBox7.Text = Val(TextBox7.Text) * -1 : TextBox11.Text = Val(TextBox11.Text) * -1 TextBox15.Text = Val(TextBox15.Text) * -1 : TextBox19.Text = Val(TextBox19.Text) * -1 : TextBox23.Text = Val(TextBox23.Text) * -1 : TextBox33.Text = Val(TextBox33.Text) * -1 TextBox38.Text = Val(TextBox38.Text) * -1 : TextBox43.Text = Val(TextBox43.Text) * -1 : TextBox48.Text = Val(TextBox48.Text) * -1 : TextBox53.Text = Val(TextBox53.Text) * -1 TextBox58.Text = Val(TextBox58.Text) * -1 TextBox63.ForeColor = Color.Red : TextBox3.ForeColor = Color.Red : TextBox7.ForeColor = Color.Red : TextBox11.ForeColor = Color.Red : TextBox15.ForeColor = Color.Red TextBox19.ForeColor = Color.Red : TextBox23.ForeColor = Color.Red : TextBox33.ForeColor = Color.Red : TextBox38.ForeColor = Color.Red : TextBox43.ForeColor = Color.Red TextBox48.ForeColor = Color.Red : TextBox53.ForeColor = Color.Red : TextBox58.ForeColor = Color.Red ElseIf TextBox109.Text = "借" Then TextBox63.ForeColor = Color.Blue : TextBox3.ForeColor = Color.Blue : TextBox7.ForeColor = Color.Blue : TextBox11.ForeColor = Color.Blue : TextBox15.ForeColor = Color.Blue TextBox19.ForeColor = Color.Blue : TextBox23.ForeColor = Color.Blue : TextBox33.ForeColor = Color.Blue : TextBox38.ForeColor = Color.Blue : TextBox43.ForeColor = Color.Blue TextBox48.ForeColor = Color.Blue : TextBox53.ForeColor = Color.Blue : TextBox58.ForeColor = Color.Blue ElseIf TextBox109.Text = "" Then TextBox63.ForeColor = Color.Black : TextBox3.ForeColor = Color.Black : TextBox7.ForeColor = Color.Black : TextBox11.ForeColor = Color.Black : TextBox15.ForeColor = Color.Black TextBox19.ForeColor = Color.Black : TextBox23.ForeColor = Color.Black : TextBox33.ForeColor = Color.Black : TextBox38.ForeColor = Color.Black : TextBox43.ForeColor = Color.Black TextBox48.ForeColor = Color.Black : TextBox53.ForeColor = Color.Black : TextBox58.ForeColor = Color.Black End If If TextBox108.Text = "貸" Then TextBox77.Text = Val(TextBox77.Text) * -1 : TextBox76.Text = Val(TextBox76.Text) * -1 : TextBox75.Text = Val(TextBox75.Text) * -1 : TextBox74.Text = Val(TextBox74.Text) * -1 TextBox73.Text = Val(TextBox73.Text) * -1 : TextBox72.Text = Val(TextBox72.Text) * -1 : TextBox71.Text = Val(TextBox71.Text) * -1 : TextBox70.Text = Val(TextBox70.Text) * -1 TextBox69.Text = Val(TextBox69.Text) * -1 : TextBox68.Text = Val(TextBox68.Text) * -1 : TextBox67.Text = Val(TextBox67.Text) * -1 : TextBox66.Text = Val(TextBox66.Text) * -1 TextBox65.Text = Val(TextBox65.Text) * -1 TextBox77.ForeColor = Color.Red : TextBox76.ForeColor = Color.Red : TextBox75.ForeColor = Color.Red : TextBox74.ForeColor = Color.Red : TextBox73.ForeColor = Color.Red TextBox72.ForeColor = Color.Red : TextBox71.ForeColor = Color.Red : TextBox70.ForeColor = Color.Red : TextBox69.ForeColor = Color.Red : TextBox68.ForeColor = Color.Red TextBox67.ForeColor = Color.Red : TextBox66.ForeColor = Color.Red : TextBox65.ForeColor = Color.Red ElseIf TextBox108.Text = "借" Then TextBox77.ForeColor = Color.Blue : TextBox76.ForeColor = Color.Blue : TextBox75.ForeColor = Color.Blue : TextBox74.ForeColor = Color.Blue : TextBox73.ForeColor = Color.Blue TextBox72.ForeColor = Color.Blue : TextBox71.ForeColor = Color.Blue : TextBox70.ForeColor = Color.Blue : TextBox69.ForeColor = Color.Blue : TextBox68.ForeColor = Color.Blue TextBox67.ForeColor = Color.Blue : TextBox66.ForeColor = Color.Blue : TextBox65.ForeColor = Color.Blue ElseIf TextBox108.Text = "" Then TextBox77.ForeColor = Color.Black : TextBox76.ForeColor = Color.Black : TextBox75.ForeColor = Color.Black : TextBox74.ForeColor = Color.Black : TextBox73.ForeColor = Color.Black TextBox72.ForeColor = Color.Black : TextBox71.ForeColor = Color.Black : TextBox70.ForeColor = Color.Black : TextBox69.ForeColor = Color.Black : TextBox68.ForeColor = Color.Black TextBox67.ForeColor = Color.Black : TextBox66.ForeColor = Color.Black : TextBox65.ForeColor = Color.Black End If If TextBox107.Text = "貸" Then TextBox78.Text = Val(TextBox78.Text) * -1 : TextBox90.Text = Val(TextBox90.Text) * -1 : TextBox89.Text = Val(TextBox89.Text) * -1 : TextBox88.Text = Val(TextBox88.Text) * -1 TextBox87.Text = Val(TextBox87.Text) * -1 : TextBox86.Text = Val(TextBox86.Text) * -1 : TextBox85.Text = Val(TextBox85.Text) * -1 : TextBox84.Text = Val(TextBox84.Text) * -1 TextBox83.Text = Val(TextBox83.Text) * -1 : TextBox82.Text = Val(TextBox82.Text) * -1 : TextBox81.Text = Val(TextBox81.Text) * -1 : TextBox80.Text = Val(TextBox80.Text) * -1 TextBox79.Text = Val(TextBox79.Text) * -1 TextBox78.ForeColor = Color.Red : TextBox90.ForeColor = Color.Red : TextBox89.ForeColor = Color.Red : TextBox88.ForeColor = Color.Red : TextBox87.ForeColor = Color.Red TextBox86.ForeColor = Color.Red : TextBox85.ForeColor = Color.Red : TextBox84.ForeColor = Color.Red : TextBox83.ForeColor = Color.Red : TextBox82.ForeColor = Color.Red TextBox81.ForeColor = Color.Red : TextBox80.ForeColor = Color.Red : TextBox79.ForeColor = Color.Red ElseIf TextBox107.Text = "借" Then TextBox78.ForeColor = Color.Blue : TextBox90.ForeColor = Color.Blue : TextBox89.ForeColor = Color.Blue : TextBox88.ForeColor = Color.Blue : TextBox87.ForeColor = Color.Blue TextBox86.ForeColor = Color.Blue : TextBox85.ForeColor = Color.Blue : TextBox84.ForeColor = Color.Blue : TextBox83.ForeColor = Color.Blue : TextBox82.ForeColor = Color.Blue TextBox81.ForeColor = Color.Blue : TextBox80.ForeColor = Color.Blue : TextBox79.ForeColor = Color.Blue ElseIf TextBox107.Text = "" Then TextBox78.ForeColor = Color.Black : TextBox90.ForeColor = Color.Black : TextBox89.ForeColor = Color.Black : TextBox88.ForeColor = Color.Black : TextBox87.ForeColor = Color.Black TextBox86.ForeColor = Color.Black : TextBox85.ForeColor = Color.Black : TextBox84.ForeColor = Color.Black : TextBox83.ForeColor = Color.Black : TextBox82.ForeColor = Color.Black TextBox81.ForeColor = Color.Black : TextBox80.ForeColor = Color.Black : TextBox79.ForeColor = Color.Black End If If TextBox106.Text = "貸" Then TextBox91.Text = Val(TextBox91.Text) * -1 : TextBox103.Text = Val(TextBox103.Text) * -1 : TextBox102.Text = Val(TextBox102.Text) * -1 : TextBox101.Text = Val(TextBox101.Text) * -1 TextBox100.Text = Val(TextBox100.Text) * -1 : TextBox99.Text = Val(TextBox99.Text) * -1 : TextBox98.Text = Val(TextBox98.Text) * -1 : TextBox97.Text = Val(TextBox97.Text) * -1 TextBox96.Text = Val(TextBox96.Text) * -1 : TextBox95.Text = Val(TextBox95.Text) * -1 : TextBox94.Text = Val(TextBox94.Text) * -1 : TextBox93.Text = Val(TextBox93.Text) * -1 TextBox92.Text = Val(TextBox92.Text) * -1 TextBox91.ForeColor = Color.Red : TextBox103.ForeColor = Color.Red : TextBox102.ForeColor = Color.Red : TextBox101.ForeColor = Color.Red : TextBox100.ForeColor = Color.Red TextBox99.ForeColor = Color.Red : TextBox98.ForeColor = Color.Red : TextBox97.ForeColor = Color.Red : TextBox96.ForeColor = Color.Red : TextBox95.ForeColor = Color.Red TextBox94.ForeColor = Color.Red : TextBox93.ForeColor = Color.Red : TextBox92.ForeColor = Color.Red ElseIf TextBox106.Text = "借" Then TextBox91.ForeColor = Color.Blue : TextBox103.ForeColor = Color.Blue : TextBox102.ForeColor = Color.Blue : TextBox101.ForeColor = Color.Blue : TextBox100.ForeColor = Color.Blue TextBox99.ForeColor = Color.Blue : TextBox98.ForeColor = Color.Blue : TextBox97.ForeColor = Color.Blue : TextBox96.ForeColor = Color.Blue : TextBox95.ForeColor = Color.Blue TextBox94.ForeColor = Color.Blue : TextBox93.ForeColor = Color.Blue : TextBox92.ForeColor = Color.Blue ElseIf TextBox106.Text = "" Then TextBox91.ForeColor = Color.Black : TextBox103.ForeColor = Color.Black : TextBox102.ForeColor = Color.Black : TextBox101.ForeColor = Color.Black : TextBox100.ForeColor = Color.Black TextBox99.ForeColor = Color.Black : TextBox98.ForeColor = Color.Black : TextBox97.ForeColor = Color.Black : TextBox96.ForeColor = Color.Black : TextBox95.ForeColor = Color.Black TextBox94.ForeColor = Color.Black : TextBox93.ForeColor = Color.Black : TextBox92.ForeColor = Color.Black End If If TextBox105.Text = "貸" Then TextBox104.Text = Val(TextBox104.Text) * -1 : TextBox30.Text = Val(TextBox30.Text) * -1 : TextBox29.Text = Val(TextBox29.Text) * -1 : TextBox28.Text = Val(TextBox28.Text) * -1 TextBox27.Text = Val(TextBox27.Text) * -1 : TextBox26.Text = Val(TextBox26.Text) * -1 : TextBox25.Text = Val(TextBox25.Text) * -1 : TextBox31.Text = Val(TextBox31.Text) * -1 TextBox36.Text = Val(TextBox36.Text) * -1 : TextBox41.Text = Val(TextBox41.Text) * -1 : TextBox46.Text = Val(TextBox46.Text) * -1 : TextBox51.Text = Val(TextBox51.Text) * -1 TextBox56.Text = Val(TextBox56.Text) * -1 TextBox104.ForeColor = Color.Red : TextBox30.ForeColor = Color.Red : TextBox29.ForeColor = Color.Red : TextBox28.ForeColor = Color.Red : TextBox27.ForeColor = Color.Red TextBox26.ForeColor = Color.Red : TextBox25.ForeColor = Color.Red : TextBox31.ForeColor = Color.Red : TextBox36.ForeColor = Color.Red : TextBox41.ForeColor = Color.Red TextBox46.ForeColor = Color.Red : TextBox51.ForeColor = Color.Red : TextBox56.ForeColor = Color.Red ElseIf TextBox105.Text = "借" Then TextBox104.ForeColor = Color.Blue : TextBox30.ForeColor = Color.Blue : TextBox29.ForeColor = Color.Blue : TextBox28.ForeColor = Color.Blue : TextBox27.ForeColor = Color.Blue TextBox26.ForeColor = Color.Blue : TextBox25.ForeColor = Color.Blue : TextBox31.ForeColor = Color.Blue : TextBox36.ForeColor = Color.Blue : TextBox41.ForeColor = Color.Blue TextBox46.ForeColor = Color.Blue : TextBox51.ForeColor = Color.Blue : TextBox56.ForeColor = Color.Blue ElseIf TextBox105.Text = "" Then TextBox104.ForeColor = Color.Black : TextBox30.ForeColor = Color.Black : TextBox29.ForeColor = Color.Black : TextBox28.ForeColor = Color.Black : TextBox27.ForeColor = Color.Black TextBox26.ForeColor = Color.Black : TextBox25.ForeColor = Color.Black : TextBox31.ForeColor = Color.Black : TextBox36.ForeColor = Color.Black : TextBox41.ForeColor = Color.Black TextBox46.ForeColor = Color.Black : TextBox51.ForeColor = Color.Black : TextBox56.ForeColor = Color.Black End If If Val(TextBox64.Text) < 0 Then : TextBox64.ForeColor = Color.Red : Else : TextBox64.ForeColor = Color.Blue : End If If Val(TextBox4.Text) < 0 Then : TextBox4.ForeColor = Color.Red : Else : TextBox4.ForeColor = Color.Blue : End If If Val(TextBox8.Text) < 0 Then : TextBox8.ForeColor = Color.Red : Else : TextBox8.ForeColor = Color.Blue : End If If Val(TextBox12.Text) < 0 Then : TextBox12.ForeColor = Color.Red : Else : TextBox12.ForeColor = Color.Blue : End If If Val(TextBox16.Text) < 0 Then : TextBox16.ForeColor = Color.Red : Else : TextBox16.ForeColor = Color.Blue : End If If Val(TextBox20.Text) < 0 Then : TextBox20.ForeColor = Color.Red : Else : TextBox20.ForeColor = Color.Blue : End If If Val(TextBox24.Text) < 0 Then : TextBox24.ForeColor = Color.Red : Else : TextBox24.ForeColor = Color.Blue : End If If Val(TextBox32.Text) < 0 Then : TextBox32.ForeColor = Color.Red : Else : TextBox32.ForeColor = Color.Blue : End If If Val(TextBox37.Text) < 0 Then : TextBox37.ForeColor = Color.Red : Else : TextBox37.ForeColor = Color.Blue : End If If Val(TextBox42.Text) < 0 Then : TextBox42.ForeColor = Color.Red : Else : TextBox42.ForeColor = Color.Blue : End If If Val(TextBox47.Text) < 0 Then : TextBox47.ForeColor = Color.Red : Else : TextBox47.ForeColor = Color.Blue : End If If Val(TextBox52.Text) < 0 Then : TextBox52.ForeColor = Color.Red : Else : TextBox52.ForeColor = Color.Blue : End If If Val(TextBox57.Text) < 0 Then : TextBox57.ForeColor = Color.Red : Else : TextBox57.ForeColor = Color.Blue : End If For no As Integer = 1 To 104 Dim TextBoxOO As TextBox = CType(Me.Controls.Find("TextBox" + no.ToString(), True)(0), TextBox) TextBoxOO.Text = Format(Val(TextBoxOO.Text), "#,##0 ") Next End Sub Private Sub 合計預設值() Set_清單13() For i As Integer = 0 To DataGridView14.Rows.Count - 1 Dim ComboBoxOO As ComboBox = CType(Me.Controls.Find("ComboBox" + (i + 2).ToString(), True)(0), ComboBox) : ComboBoxOO.Text = DataGridView14.Rows(i).Cells("名稱").Value Dim CheckBoxOO As CheckBox = CType(Me.Controls.Find("CheckBox" + (i + 1).ToString(), True)(0), CheckBox) : CheckBoxOO.Checked = DataGridView14.Rows(i).Cells("年度合計").Value Next End Sub Private Sub 營運報表_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.MdiParent = MAOJI_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True DataGridView14.Visible = False : ComboBox2下拉表單資料載入() : 合計預設值() : ComboBox1下拉表單資料載入() : ComboBox1.Text = Year(Today) End Sub Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click ComboBox2下拉表單資料載入() End Sub Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged Set_清單() : Set_清單1() : Set_清單2() : Set_清單3() : Set_清單4() : Set_清單5() : Set_清單6() : Set_清單7() : Set_清單8() : Set_清單9() : Set_清單10() : Set_清單11() : Set_清單12() 格式設定() End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Set_清單() : Set_清單1() : Set_清單2() : Set_清單3() : Set_清單4() : Set_清單5() : Set_清單6() : Set_清單7() : Set_清單8() : Set_清單9() : Set_清單10() : Set_清單11() : Set_清單12() 格式設定() End Sub Private Sub DataGridView2_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView2.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) If e.RowIndex = DataGridView2.Rows.Count - 1 Then : Exit Sub : Else If DataGridView2(1, e.RowIndex).Value.ToString <> DataGridView2(1, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView2.RowHeadersVisible, DataGridView2.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView2.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If If DataGridView2(2, e.RowIndex).Value.ToString <> DataGridView2(2, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView2.RowHeadersVisible, DataGridView2.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView2.HorizontalScrollingOffset e.Graphics.DrawLine(linePen1, startX, startY, endX, startY) : Exit Sub End If For i As Integer = 0 To DataGridView2.Rows.Count - 1 If DataGridView2("層級", i).Value = 1 Then : DataGridView2.Rows(i).DefaultCellStyle.BackColor = Color.LightPink ElseIf DataGridView2("層級", i).Value = 2 Then : DataGridView2.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If If DataGridView2("抵銷", i).Value = True Then : DataGridView2.Rows(i).DefaultCellStyle.ForeColor = Color.Red ElseIf DataGridView2("抵銷", i).Value = False Then : DataGridView2.Rows(i).DefaultCellStyle.ForeColor = Color.Blue : End If Next End If End Sub Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) If e.RowIndex = DataGridView1.Rows.Count - 1 Then : Exit Sub : Else If DataGridView1(1, e.RowIndex).Value.ToString <> DataGridView1(1, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If If DataGridView1(2, e.RowIndex).Value.ToString <> DataGridView1(2, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset e.Graphics.DrawLine(linePen1, startX, startY, endX, startY) : Exit Sub End If For i As Integer = 0 To DataGridView1.Rows.Count - 1 If DataGridView1("層級", i).Value = 1 Then : DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightPink ElseIf DataGridView1("層級", i).Value = 2 Then : DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If If DataGridView1("抵銷", i).Value = True Then : DataGridView1.Rows(i).DefaultCellStyle.ForeColor = Color.Red ElseIf DataGridView1("抵銷", i).Value = False Then : DataGridView1.Rows(i).DefaultCellStyle.ForeColor = Color.Blue : End If Next End If End Sub Private Sub DataGridView3_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView3.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) If e.RowIndex = DataGridView3.Rows.Count - 1 Then : Exit Sub : Else If DataGridView3(1, e.RowIndex).Value.ToString <> DataGridView3(1, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView3.RowHeadersVisible, DataGridView3.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView3.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView3.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If If DataGridView3(2, e.RowIndex).Value.ToString <> DataGridView3(2, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView3.RowHeadersVisible, DataGridView3.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView3.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView3.HorizontalScrollingOffset e.Graphics.DrawLine(linePen1, startX, startY, endX, startY) : Exit Sub End If For i As Integer = 0 To DataGridView3.Rows.Count - 1 If DataGridView3("層級", i).Value = 1 Then : DataGridView3.Rows(i).DefaultCellStyle.BackColor = Color.LightPink ElseIf DataGridView3("層級", i).Value = 2 Then : DataGridView3.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If If DataGridView3("抵銷", i).Value = True Then : DataGridView3.Rows(i).DefaultCellStyle.ForeColor = Color.Red ElseIf DataGridView3("抵銷", i).Value = False Then : DataGridView3.Rows(i).DefaultCellStyle.ForeColor = Color.Blue : End If Next End If End Sub Private Sub DataGridView4_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView4.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) If e.RowIndex = DataGridView4.Rows.Count - 1 Then : Exit Sub : Else If DataGridView4(1, e.RowIndex).Value.ToString <> DataGridView4(1, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView4.RowHeadersVisible, DataGridView4.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView4.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView4.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If If DataGridView4(2, e.RowIndex).Value.ToString <> DataGridView4(2, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView4.RowHeadersVisible, DataGridView4.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView4.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView4.HorizontalScrollingOffset e.Graphics.DrawLine(linePen1, startX, startY, endX, startY) : Exit Sub End If For i As Integer = 0 To DataGridView4.Rows.Count - 1 If DataGridView4("層級", i).Value = 1 Then : DataGridView4.Rows(i).DefaultCellStyle.BackColor = Color.LightPink ElseIf DataGridView4("層級", i).Value = 2 Then : DataGridView4.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If If DataGridView4("抵銷", i).Value = True Then : DataGridView4.Rows(i).DefaultCellStyle.ForeColor = Color.Red ElseIf DataGridView4("抵銷", i).Value = False Then : DataGridView4.Rows(i).DefaultCellStyle.ForeColor = Color.Blue : End If Next End If End Sub Private Sub DataGridView5_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView5.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) If e.RowIndex = DataGridView5.Rows.Count - 1 Then : Exit Sub : Else If DataGridView5(1, e.RowIndex).Value.ToString <> DataGridView5(1, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView5.RowHeadersVisible, DataGridView5.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView5.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView5.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If If DataGridView5(2, e.RowIndex).Value.ToString <> DataGridView5(2, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView5.RowHeadersVisible, DataGridView5.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView5.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView5.HorizontalScrollingOffset e.Graphics.DrawLine(linePen1, startX, startY, endX, startY) : Exit Sub End If For i As Integer = 0 To DataGridView5.Rows.Count - 1 If DataGridView5("層級", i).Value = 1 Then : DataGridView5.Rows(i).DefaultCellStyle.BackColor = Color.LightPink ElseIf DataGridView5("層級", i).Value = 2 Then : DataGridView5.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If If DataGridView5("抵銷", i).Value = True Then : DataGridView5.Rows(i).DefaultCellStyle.ForeColor = Color.Red ElseIf DataGridView5("抵銷", i).Value = False Then : DataGridView5.Rows(i).DefaultCellStyle.ForeColor = Color.Blue : End If Next End If End Sub Private Sub DataGridView6_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView6.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) If e.RowIndex = DataGridView6.Rows.Count - 1 Then : Exit Sub : Else If DataGridView6(1, e.RowIndex).Value.ToString <> DataGridView6(1, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView6.RowHeadersVisible, DataGridView6.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView6.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView6.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If If DataGridView6(2, e.RowIndex).Value.ToString <> DataGridView6(2, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView6.RowHeadersVisible, DataGridView6.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView6.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView6.HorizontalScrollingOffset e.Graphics.DrawLine(linePen1, startX, startY, endX, startY) : Exit Sub End If For i As Integer = 0 To DataGridView6.Rows.Count - 1 If DataGridView6("層級", i).Value = 1 Then : DataGridView6.Rows(i).DefaultCellStyle.BackColor = Color.LightPink ElseIf DataGridView6("層級", i).Value = 2 Then : DataGridView6.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If If DataGridView6("抵銷", i).Value = True Then : DataGridView6.Rows(i).DefaultCellStyle.ForeColor = Color.Red ElseIf DataGridView6("抵銷", i).Value = False Then : DataGridView6.Rows(i).DefaultCellStyle.ForeColor = Color.Blue : End If Next End If End Sub Private Sub DataGridView7_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView7.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) If e.RowIndex = DataGridView7.Rows.Count - 1 Then : Exit Sub : Else If DataGridView7(1, e.RowIndex).Value.ToString <> DataGridView7(1, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView7.RowHeadersVisible, DataGridView7.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView7.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView7.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If If DataGridView7(2, e.RowIndex).Value.ToString <> DataGridView7(2, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView7.RowHeadersVisible, DataGridView7.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView7.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView7.HorizontalScrollingOffset e.Graphics.DrawLine(linePen1, startX, startY, endX, startY) : Exit Sub End If For i As Integer = 0 To DataGridView7.Rows.Count - 1 If DataGridView7("層級", i).Value = 1 Then : DataGridView7.Rows(i).DefaultCellStyle.BackColor = Color.LightPink ElseIf DataGridView7("層級", i).Value = 2 Then : DataGridView7.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If If DataGridView7("抵銷", i).Value = True Then : DataGridView7.Rows(i).DefaultCellStyle.ForeColor = Color.Red ElseIf DataGridView7("抵銷", i).Value = False Then : DataGridView7.Rows(i).DefaultCellStyle.ForeColor = Color.Blue : End If Next End If End Sub Private Sub DataGridView8_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView8.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) If e.RowIndex = DataGridView8.Rows.Count - 1 Then : Exit Sub : Else If DataGridView8(1, e.RowIndex).Value.ToString <> DataGridView8(1, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView8.RowHeadersVisible, DataGridView8.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView8.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView8.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If If DataGridView8(2, e.RowIndex).Value.ToString <> DataGridView8(2, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView8.RowHeadersVisible, DataGridView8.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView8.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView8.HorizontalScrollingOffset e.Graphics.DrawLine(linePen1, startX, startY, endX, startY) : Exit Sub End If For i As Integer = 0 To DataGridView8.Rows.Count - 1 If DataGridView8("層級", i).Value = 1 Then : DataGridView8.Rows(i).DefaultCellStyle.BackColor = Color.LightPink ElseIf DataGridView8("層級", i).Value = 2 Then : DataGridView8.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If If DataGridView8("抵銷", i).Value = True Then : DataGridView8.Rows(i).DefaultCellStyle.ForeColor = Color.Red ElseIf DataGridView8("抵銷", i).Value = False Then : DataGridView8.Rows(i).DefaultCellStyle.ForeColor = Color.Blue : End If Next End If End Sub Private Sub DataGridView9_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView9.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) If e.RowIndex = DataGridView9.Rows.Count - 1 Then : Exit Sub : Else If DataGridView9(1, e.RowIndex).Value.ToString <> DataGridView9(1, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView9.RowHeadersVisible, DataGridView9.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView9.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView9.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If If DataGridView9(2, e.RowIndex).Value.ToString <> DataGridView9(2, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView9.RowHeadersVisible, DataGridView9.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView9.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView9.HorizontalScrollingOffset e.Graphics.DrawLine(linePen1, startX, startY, endX, startY) : Exit Sub End If For i As Integer = 0 To DataGridView9.Rows.Count - 1 If DataGridView9("層級", i).Value = 1 Then : DataGridView9.Rows(i).DefaultCellStyle.BackColor = Color.LightPink ElseIf DataGridView9("層級", i).Value = 2 Then : DataGridView9.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If If DataGridView9("抵銷", i).Value = True Then : DataGridView9.Rows(i).DefaultCellStyle.ForeColor = Color.Red ElseIf DataGridView9("抵銷", i).Value = False Then : DataGridView9.Rows(i).DefaultCellStyle.ForeColor = Color.Blue : End If Next End If End Sub Private Sub DataGridView10_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView10.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) If e.RowIndex = DataGridView10.Rows.Count - 1 Then : Exit Sub : Else If DataGridView10(1, e.RowIndex).Value.ToString <> DataGridView10(1, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView10.RowHeadersVisible, DataGridView10.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView10.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView10.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If If DataGridView10(2, e.RowIndex).Value.ToString <> DataGridView10(2, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView10.RowHeadersVisible, DataGridView10.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView10.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView10.HorizontalScrollingOffset e.Graphics.DrawLine(linePen1, startX, startY, endX, startY) : Exit Sub End If For i As Integer = 0 To DataGridView10.Rows.Count - 1 If DataGridView10("層級", i).Value = 1 Then : DataGridView10.Rows(i).DefaultCellStyle.BackColor = Color.LightPink ElseIf DataGridView10("層級", i).Value = 2 Then : DataGridView10.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If If DataGridView10("抵銷", i).Value = True Then : DataGridView10.Rows(i).DefaultCellStyle.ForeColor = Color.Red ElseIf DataGridView10("抵銷", i).Value = False Then : DataGridView10.Rows(i).DefaultCellStyle.ForeColor = Color.Blue : End If Next End If End Sub Private Sub DataGridView11_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView11.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) If e.RowIndex = DataGridView11.Rows.Count - 1 Then : Exit Sub : Else If DataGridView11(1, e.RowIndex).Value.ToString <> DataGridView11(1, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView11.RowHeadersVisible, DataGridView11.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView11.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView11.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If If DataGridView11(2, e.RowIndex).Value.ToString <> DataGridView11(2, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView11.RowHeadersVisible, DataGridView11.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView11.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView11.HorizontalScrollingOffset e.Graphics.DrawLine(linePen1, startX, startY, endX, startY) : Exit Sub End If For i As Integer = 0 To DataGridView11.Rows.Count - 1 If DataGridView11("層級", i).Value = 1 Then : DataGridView11.Rows(i).DefaultCellStyle.BackColor = Color.LightPink ElseIf DataGridView11("層級", i).Value = 2 Then : DataGridView11.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If If DataGridView11("抵銷", i).Value = True Then : DataGridView11.Rows(i).DefaultCellStyle.ForeColor = Color.Red ElseIf DataGridView11("抵銷", i).Value = False Then : DataGridView11.Rows(i).DefaultCellStyle.ForeColor = Color.Blue : End If Next End If End Sub Private Sub DataGridView12_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView12.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) If e.RowIndex = DataGridView12.Rows.Count - 1 Then : Exit Sub : Else If DataGridView12(1, e.RowIndex).Value.ToString <> DataGridView12(1, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView12.RowHeadersVisible, DataGridView12.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView12.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView12.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If If DataGridView12(2, e.RowIndex).Value.ToString <> DataGridView12(2, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView12.RowHeadersVisible, DataGridView12.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView12.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView12.HorizontalScrollingOffset e.Graphics.DrawLine(linePen1, startX, startY, endX, startY) : Exit Sub End If For i As Integer = 0 To DataGridView12.Rows.Count - 1 If DataGridView12("層級", i).Value = 1 Then : DataGridView12.Rows(i).DefaultCellStyle.BackColor = Color.LightPink ElseIf DataGridView12("層級", i).Value = 2 Then : DataGridView12.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If If DataGridView12("抵銷", i).Value = True Then : DataGridView12.Rows(i).DefaultCellStyle.ForeColor = Color.Red ElseIf DataGridView12("抵銷", i).Value = False Then : DataGridView12.Rows(i).DefaultCellStyle.ForeColor = Color.Blue : End If Next End If End Sub Private Sub DataGridView13_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView13.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) If e.RowIndex = DataGridView13.Rows.Count - 1 Then : Exit Sub : Else If DataGridView13(1, e.RowIndex).Value.ToString <> DataGridView13(1, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView13.RowHeadersVisible, DataGridView13.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView13.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView13.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If If DataGridView13(2, e.RowIndex).Value.ToString <> DataGridView13(2, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(DataGridView13.RowHeadersVisible, DataGridView13.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + DataGridView13.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView13.HorizontalScrollingOffset e.Graphics.DrawLine(linePen1, startX, startY, endX, startY) : Exit Sub End If For i As Integer = 0 To DataGridView13.Rows.Count - 1 If DataGridView13("層級", i).Value = 1 Then : DataGridView13.Rows(i).DefaultCellStyle.BackColor = Color.LightPink ElseIf DataGridView13("層級", i).Value = 2 Then : DataGridView13.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If If DataGridView13("抵銷", i).Value = True Then : DataGridView13.Rows(i).DefaultCellStyle.ForeColor = Color.Red ElseIf DataGridView13("抵銷", i).Value = False Then : DataGridView13.Rows(i).DefaultCellStyle.ForeColor = Color.Blue : End If Next End If End Sub Private Sub DataGridView2_Scroll(ByVal sender As Object, ByVal e As ScrollEventArgs) Handles DataGridView2.Scroll DataGridView1.FirstDisplayedScrollingRowIndex = DataGridView2.FirstDisplayedScrollingRowIndex : DataGridView3.FirstDisplayedScrollingRowIndex = DataGridView2.FirstDisplayedScrollingRowIndex DataGridView4.FirstDisplayedScrollingRowIndex = DataGridView2.FirstDisplayedScrollingRowIndex : DataGridView5.FirstDisplayedScrollingRowIndex = DataGridView2.FirstDisplayedScrollingRowIndex DataGridView6.FirstDisplayedScrollingRowIndex = DataGridView2.FirstDisplayedScrollingRowIndex : DataGridView7.FirstDisplayedScrollingRowIndex = DataGridView2.FirstDisplayedScrollingRowIndex DataGridView8.FirstDisplayedScrollingRowIndex = DataGridView2.FirstDisplayedScrollingRowIndex : DataGridView9.FirstDisplayedScrollingRowIndex = DataGridView2.FirstDisplayedScrollingRowIndex DataGridView10.FirstDisplayedScrollingRowIndex = DataGridView2.FirstDisplayedScrollingRowIndex : DataGridView11.FirstDisplayedScrollingRowIndex = DataGridView2.FirstDisplayedScrollingRowIndex DataGridView12.FirstDisplayedScrollingRowIndex = DataGridView2.FirstDisplayedScrollingRowIndex : DataGridView13.FirstDisplayedScrollingRowIndex = DataGridView2.FirstDisplayedScrollingRowIndex End Sub Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged PA1 = ComboBox2.Text : SQL_營運成本收支_決算表_彙總借貸() If dr.Read() Then : If dr("抵銷科目") = True Then : TextBox111.Text = "貸" : ElseIf dr("抵銷科目") = False Then : TextBox111.Text = "借" : End If : Else : TextBox111.Text = "" : End If End Sub Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged PA1 = ComboBox3.Text : SQL_營運成本收支_決算表_彙總借貸() If dr.Read() Then : If dr("抵銷科目") = True Then : TextBox110.Text = "貸" : ElseIf dr("抵銷科目") = False Then : TextBox110.Text = "借" : End If : Else : TextBox110.Text = "" : End If End Sub Private Sub ComboBox4_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox4.SelectedIndexChanged PA1 = ComboBox4.Text : SQL_營運成本收支_決算表_彙總借貸() If dr.Read() Then : If dr("抵銷科目") = True Then : TextBox109.Text = "貸" : ElseIf dr("抵銷科目") = False Then : TextBox109.Text = "借" : End If : Else : TextBox109.Text = "" : End If End Sub Private Sub ComboBox5_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox5.SelectedIndexChanged PA1 = ComboBox5.Text : SQL_營運成本收支_決算表_彙總借貸() If dr.Read() Then : If dr("抵銷科目") = True Then : TextBox108.Text = "貸" : ElseIf dr("抵銷科目") = False Then : TextBox108.Text = "借" : End If : Else : TextBox108.Text = "" : End If End Sub Private Sub ComboBox6_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox6.SelectedIndexChanged PA1 = ComboBox6.Text : SQL_營運成本收支_決算表_彙總借貸() If dr.Read() Then : If dr("抵銷科目") = True Then : TextBox107.Text = "貸" : ElseIf dr("抵銷科目") = False Then : TextBox107.Text = "借" : End If : Else : TextBox107.Text = "" : End If End Sub Private Sub ComboBox7_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox7.SelectedIndexChanged PA1 = ComboBox7.Text : SQL_營運成本收支_決算表_彙總借貸() If dr.Read() Then : If dr("抵銷科目") = True Then : TextBox106.Text = "貸" : ElseIf dr("抵銷科目") = False Then : TextBox106.Text = "借" : End If : Else : TextBox106.Text = "" : End If End Sub Private Sub ComboBox8_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox8.SelectedIndexChanged PA1 = ComboBox8.Text : SQL_營運成本收支_決算表_彙總借貸() If dr.Read() Then : If dr("抵銷科目") = True Then : TextBox105.Text = "貸" : ElseIf dr("抵銷科目") = False Then : TextBox105.Text = "借" : End If : Else : TextBox105.Text = "" : End If End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click For i As Integer = 0 To DataGridView14.Rows.Count - 1 Dim ComboBoxOO As ComboBox = CType(Me.Controls.Find("ComboBox" + (i + 2).ToString(), True)(0), ComboBox) Dim CheckBoxOO As CheckBox = CType(Me.Controls.Find("CheckBox" + (i + 1).ToString(), True)(0), CheckBox) PA1 = ComboBoxOO.Text : 布林1 = CheckBoxOO.Checked : PA2 = (i + 1) : SQL_財務決算表合計預設修改() : conn.Close() Next : MsgBox("存檔完畢。") : Me.重新整理ToolStripMenuItem.PerformClick() End Sub '-----------------------------滑鼠右鍵------------------------------------------------------------------------------------------------------------------------------------------ Private Sub 重新整理ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新整理ToolStripMenuItem.Click 合計預設值() : Set_清單() : Set_清單1() : Set_清單2() : Set_清單3() : Set_清單4() : Set_清單5() : Set_清單6() : Set_清單7() Set_清單8() : Set_清單9() : Set_清單10() : Set_清單11() : Set_清單12() : 格式設定() End Sub End Class