Imports System.Windows.Forms.DataVisualization.Charting

Public Class 產品銷售分析表
    ReadOnly ds, ds1, ds3, ds4, ds5, ds6, ds7, ds8, ds9, ds10 As New DataSet
    Private Sub 讀取客戶資料表1()
        產品2_dgv.DataSource = Nothing : ds3.Clear()
        產品2_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        產品2_dgv.ColumnHeadersHeight = 30
        產品2_dgv.AllowUserToAddRows = False
        SQL_產品資料1()
        da.Fill(ds3) : 產品2_dgv.DataSource = ds3.Tables(0) : conn.Close()
        產品2_dgv.Columns(0).FillWeight = 65 : 產品2_dgv.Columns(1).FillWeight = 65 : 產品2_dgv.Columns(2).FillWeight = 65

        產品2_dgv.Columns(1).DefaultCellStyle.Format = "#,##0" : 產品2_dgv.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        產品2_dgv.Columns(2).DefaultCellStyle.Format = "#,##0" : 產品2_dgv.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
    End Sub
    Private Sub 讀取客戶資料表2()
        產品1_dgv.DataSource = Nothing : ds1.Clear()
        產品1_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        產品1_dgv.ColumnHeadersHeight = 30
        產品1_dgv.AllowUserToAddRows = False
        SQL_產品資料2()
        da.Fill(ds1) : 產品1_dgv.DataSource = ds1.Tables(0) : conn.Close()
        產品1_dgv.Columns(0).FillWeight = 50 : 產品1_dgv.Columns(1).FillWeight = 65 : 產品1_dgv.Columns(2).FillWeight = 65 : 產品1_dgv.Columns(3).FillWeight = 65

        產品1_dgv.Columns(3).DefaultCellStyle.Format = "#,##0" : 產品1_dgv.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        產品1_dgv.Columns(2).DefaultCellStyle.Format = "#,##0" : 產品1_dgv.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
    End Sub
    Private Sub 讀取客戶資料表3()
        產品3_dgv.DataSource = Nothing : ds.Clear()
        產品3_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        產品3_dgv.ColumnHeadersHeight = 30
        產品3_dgv.AllowUserToAddRows = False
        SQL_產品資料3()
        da.Fill(ds) : 產品3_dgv.DataSource = ds.Tables(0) : conn.Close()
        產品3_dgv.Columns(0).FillWeight = 50 : 產品3_dgv.Columns(1).Visible = False : 產品3_dgv.Columns(2).FillWeight = 40 : 產品3_dgv.Columns(3).FillWeight = 65

        產品3_dgv.Columns(3).DefaultCellStyle.Format = "#,##0" : 產品3_dgv.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        產品3_dgv.Columns(2).DefaultCellStyle.Format = "#,##0" : 產品3_dgv.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
    End Sub
    Private Sub 讀取客戶資料表4()
        產品4_dgv.DataSource = Nothing : ds4.Clear()
        產品4_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        產品4_dgv.ColumnHeadersHeight = 30
        產品4_dgv.AllowUserToAddRows = False
        SQL_產品資料4()
        da.Fill(ds4) : 產品4_dgv.DataSource = ds4.Tables(0) : conn.Close()
        產品4_dgv.Columns(0).FillWeight = 50 : 產品4_dgv.Columns(1).Visible = False : 產品4_dgv.Columns(2).FillWeight = 40 : 產品4_dgv.Columns(3).FillWeight = 65

        產品4_dgv.Columns(3).DefaultCellStyle.Format = "#,##0" : 產品4_dgv.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        產品4_dgv.Columns(2).DefaultCellStyle.Format = "#,##0" : 產品4_dgv.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
    End Sub
    Private Sub 讀取客戶資料表5()
        產品5_dgv.DataSource = Nothing : ds5.Clear()
        產品5_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        產品5_dgv.ColumnHeadersHeight = 30
        產品5_dgv.AllowUserToAddRows = False
        SQL_產品資料5()
        da.Fill(ds5) : 產品5_dgv.DataSource = ds5.Tables(0) : conn.Close()
        產品5_dgv.Columns(0).FillWeight = 50 : 產品5_dgv.Columns(1).Visible = False : 產品5_dgv.Columns(2).FillWeight = 40 : 產品5_dgv.Columns(3).FillWeight = 65

        產品5_dgv.Columns(3).DefaultCellStyle.Format = "#,##0" : 產品5_dgv.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        產品5_dgv.Columns(2).DefaultCellStyle.Format = "#,##0" : 產品5_dgv.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
    End Sub
    Private Sub 讀取客戶資料表6()
        產品6_dgv.DataSource = Nothing : ds6.Clear()
        產品6_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        產品6_dgv.ColumnHeadersHeight = 30
        產品6_dgv.AllowUserToAddRows = False
        SQL_產品資料6()
        da.Fill(ds6) : 產品6_dgv.DataSource = ds6.Tables(0) : conn.Close()
        產品6_dgv.Columns(0).FillWeight = 50 : 產品6_dgv.Columns(1).Visible = False : 產品6_dgv.Columns(2).FillWeight = 40 : 產品6_dgv.Columns(3).FillWeight = 65

        產品6_dgv.Columns(3).DefaultCellStyle.Format = "#,##0" : 產品6_dgv.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        產品6_dgv.Columns(2).DefaultCellStyle.Format = "#,##0" : 產品6_dgv.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
    End Sub
    Private Sub 讀取客戶資料表7()
        產品7_dgv.DataSource = Nothing : ds7.Clear()
        產品7_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        產品7_dgv.ColumnHeadersHeight = 30
        產品7_dgv.AllowUserToAddRows = False
        SQL_產品資料7()
        da.Fill(ds7) : 產品7_dgv.DataSource = ds7.Tables(0) : conn.Close()
        產品7_dgv.Columns(0).FillWeight = 50 : 產品7_dgv.Columns(1).Visible = False : 產品7_dgv.Columns(2).FillWeight = 40 : 產品7_dgv.Columns(3).FillWeight = 65

        產品7_dgv.Columns(3).DefaultCellStyle.Format = "#,##0" : 產品7_dgv.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        產品7_dgv.Columns(2).DefaultCellStyle.Format = "#,##0" : 產品7_dgv.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
    End Sub
    Private Sub 讀取客戶資料表8()
        產品8_dgv.DataSource = Nothing : ds8.Clear()
        產品8_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        產品8_dgv.ColumnHeadersHeight = 30
        產品8_dgv.AllowUserToAddRows = False
        SQL_產品資料8()
        da.Fill(ds8) : 產品8_dgv.DataSource = ds8.Tables(0) : conn.Close()
        產品8_dgv.Columns(0).FillWeight = 50 : 產品8_dgv.Columns(1).Visible = False : 產品8_dgv.Columns(2).FillWeight = 40 : 產品8_dgv.Columns(3).FillWeight = 65

        產品8_dgv.Columns(3).DefaultCellStyle.Format = "#,##0" : 產品8_dgv.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        產品8_dgv.Columns(2).DefaultCellStyle.Format = "#,##0" : 產品8_dgv.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
    End Sub
    Private Sub 讀取客戶資料表9()
        產品9_dgv.DataSource = Nothing : ds9.Clear()
        產品9_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        產品9_dgv.ColumnHeadersHeight = 30
        產品9_dgv.AllowUserToAddRows = False
        SQL_產品資料9()
        da.Fill(ds9) : 產品9_dgv.DataSource = ds9.Tables(0) : conn.Close()
        產品9_dgv.Columns(0).FillWeight = 50 : 產品9_dgv.Columns(1).Visible = False : 產品9_dgv.Columns(2).FillWeight = 40 : 產品9_dgv.Columns(3).FillWeight = 65

        產品9_dgv.Columns(3).DefaultCellStyle.Format = "#,##0" : 產品9_dgv.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        產品9_dgv.Columns(2).DefaultCellStyle.Format = "#,##0" : 產品9_dgv.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
    End Sub
    Private Sub 讀取客戶資料表10()
        產品10_dgv.DataSource = Nothing : ds10.Clear()
        產品10_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        產品10_dgv.ColumnHeadersHeight = 30
        產品10_dgv.AllowUserToAddRows = False
        SQL_產品資料10()
        da.Fill(ds10) : 產品10_dgv.DataSource = ds10.Tables(0) : conn.Close()
        產品10_dgv.Columns(0).FillWeight = 40 : 產品10_dgv.Columns(1).FillWeight = 180 : 產品10_dgv.Columns(2).FillWeight = 40 : 產品10_dgv.Columns(3).FillWeight = 65
        產品10_dgv.Columns(4).Visible = False : 產品10_dgv.Columns(5).FillWeight = 50

        產品10_dgv.Columns(3).DefaultCellStyle.Format = "#,##0" : 產品10_dgv.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        產品10_dgv.Columns(2).DefaultCellStyle.Format = "#,##0" : 產品10_dgv.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

        For i As Integer = 0 To 產品10_dgv.Rows.Count - 1
            產品10_dgv("項次", i).Value = i + 1
            產品10_dgv("比例", i).Value = Math.Round(產品10_dgv("金額", i).Value / Val(總金額_tb.Text) * 100)

            If 產品10_dgv.Rows(i).Cells("比例").Value = 0 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._000
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 1 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._001
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 2 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._002
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 3 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._003
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 4 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._004
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 5 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._005
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 6 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._006
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 7 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._007
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 8 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._008
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 9 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._009
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 10 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._010
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 11 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._011
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 12 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._012
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 13 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._013
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 14 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._014
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 15 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._015
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 16 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._016
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 17 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._017
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 18 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._018
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 19 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._019
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 20 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._020
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 21 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._021
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 22 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._022
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 23 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._023
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 24 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._024
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 25 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._025
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 26 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._026
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 27 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._027
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 28 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._028
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 29 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._029
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 30 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._030
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 31 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._031
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 32 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._032
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 33 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._033
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 34 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._034
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 35 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._035
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 36 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._036
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 37 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._037
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 38 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._038
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 39 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._039
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 40 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._040
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 41 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._041
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 42 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._042
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 43 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._043
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 44 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._044
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 45 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._045
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 46 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._046
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 47 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._047
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 48 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._048
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 49 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._049
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 50 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._050
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 51 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._051
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 52 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._052
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 53 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._053
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 54 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._054
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 55 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._055
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 56 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._056
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 57 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._057
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 58 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._058
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 59 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._059
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 60 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._060
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 61 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._061
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 62 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._062
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 63 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._063
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 64 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._064
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 65 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._065
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 66 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._066
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 67 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._067
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 68 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._068
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 69 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._069
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 70 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._070
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 71 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._071
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 72 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._072
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 73 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._073
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 74 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._074
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 75 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._075
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 76 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._076
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 77 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._077
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 78 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._078
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 79 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._079
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 80 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._080
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 81 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._081
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 82 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._082
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 83 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._083
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 84 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._084
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 85 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._085
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 86 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._086
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 87 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._087
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 88 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._088
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 89 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._089
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 90 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._090
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 91 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._091
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 92 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._092
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 93 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._093
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 94 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._094
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 95 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._095
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 96 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._096
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 97 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._097
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 98 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._098
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value = 99 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._099
            ElseIf 產品10_dgv.Rows(i).Cells("比例").Value >= 100 Then : 產品10_dgv.Rows(i).Cells("百分比").Value = My.Resources._100 : End If
        Next
        總金額_tb.Text = Strings.Format(Val(總金額_tb.Text), "#,##0") : 表格繪製2()
    End Sub
    Private Sub 產品銷售分析表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = GRAMS_SYS : Me.WindowState = 2 : Me.AutoScroll = True
        讀取客戶資料表1() : 讀取客戶資料表2() : 讀取客戶資料表3() : 讀取客戶資料表4() : 讀取客戶資料表5() : 讀取客戶資料表6() : 讀取客戶資料表7() : 讀取客戶資料表8()
        讀取客戶資料表9() : 讀取客戶資料表10() : 表格繪製()
        If 產品3_dgv.Rows.Count > 0 Then
            日期_tb.Text = 產品3_dgv("日期", 0).Value.ToString : 類別_tb.Text = "一般產品" : 總金額_tb.Text = Val(產品3_dgv("金額", 0).Value)
        Else
            日期_tb.Text = Strings.Format(Today(), "yyyy/MM/dd") : 類別_tb.Text = "一般產品" : 總金額_tb.Text = "0"
        End If
        讀取客戶資料表10()
    End Sub
    Private Sub 表格繪製()
        '-------線狀圖------------------------------------------------------
        Chart2.Series.Clear()
        Chart2.Series.Add("業務類別") : Chart2.Series("業務類別").ChartType = SeriesChartType.Pie
        Chart2.Series("業務類別").IsValueShownAsLabel = True
        Chart2.Series("業務類別").IsVisibleInLegend = True
        Chart2.Series("業務類別").IsXValueIndexed = True
        For i As Integer = 0 To 產品2_dgv.Rows.Count - 1
            Chart2.Series("業務類別").Points.AddXY(產品2_dgv.Rows(i).Cells("類別").Value.ToString, 產品2_dgv.Rows(i).Cells("金額").Value.ToString)
        Next

        '-------線狀圖------------------------------------------------------
        Chart1.Series.Clear() : Chart1.ChartAreas(0).AxisX.Minimum = 最小_NUD.Value : Chart1.ChartAreas(0).AxisX.Maximum = 最大_NUD.Value

        If CheckBox1.Checked = True Then
            Chart1.Series.Add("一般產品") : Chart1.Series("一般產品").ChartType = SeriesChartType.Line
            Dim NUDAA As Integer
            If 數列_NUD.Value >= 產品3_dgv.Rows.Count - 1 Or 數列_NUD.Value = 0 Then : NUDAA = 產品3_dgv.Rows.Count - 1
            ElseIf 數列_NUD.Value < 產品3_dgv.Rows.Count - 1 Then : NUDAA = 數列_NUD.Value : End If
            For i As Integer = 0 To NUDAA
                Chart1.Series("一般產品").Points.AddXY(產品3_dgv.Rows(NUDAA - i).Cells("日期").Value.ToString, 產品3_dgv.Rows(NUDAA - i).Cells("金額").Value.ToString)
            Next
        End If
        If CheckBox2.Checked = True Then
            Chart1.Series.Add("人工皮") : Chart1.Series("人工皮").ChartType = SeriesChartType.Line
            Dim NUDAA As Integer
            If 數列_NUD.Value >= 產品4_dgv.Rows.Count - 1 Or 數列_NUD.Value = 0 Then : NUDAA = 產品4_dgv.Rows.Count - 1
            ElseIf 數列_NUD.Value < 產品4_dgv.Rows.Count - 1 Then : NUDAA = 數列_NUD.Value : End If
            For i As Integer = 0 To NUDAA
                Chart1.Series("人工皮").Points.AddXY(產品4_dgv.Rows(NUDAA - i).Cells("日期").Value.ToString, 產品4_dgv.Rows(NUDAA - i).Cells("金額").Value.ToString)
            Next
        End If
        If CheckBox3.Checked = True Then
            Chart1.Series.Add("治療") : Chart1.Series("治療").ChartType = SeriesChartType.Line
            Dim NUDAA As Integer
            If 數列_NUD.Value >= 產品5_dgv.Rows.Count - 1 Or 數列_NUD.Value = 0 Then : NUDAA = 產品5_dgv.Rows.Count - 1
            ElseIf 數列_NUD.Value < 產品5_dgv.Rows.Count - 1 Then : NUDAA = 數列_NUD.Value : End If
            For i As Integer = 0 To NUDAA
                Chart1.Series("治療").Points.AddXY(產品5_dgv.Rows(NUDAA - i).Cells("日期").Value.ToString, 產品5_dgv.Rows(NUDAA - i).Cells("金額").Value.ToString)
            Next
        End If
        If CheckBox4.Checked = True Then
            Chart1.Series.Add("雷射") : Chart1.Series("雷射").ChartType = SeriesChartType.Line
            Dim NUDAA As Integer
            If 數列_NUD.Value >= 產品6_dgv.Rows.Count - 1 Or 數列_NUD.Value = 0 Then : NUDAA = 產品6_dgv.Rows.Count - 1
            ElseIf 數列_NUD.Value < 產品6_dgv.Rows.Count - 1 Then : NUDAA = 數列_NUD.Value : End If
            For i As Integer = 0 To NUDAA
                Chart1.Series("雷射").Points.AddXY(產品6_dgv.Rows(NUDAA - i).Cells("日期").Value.ToString, 產品6_dgv.Rows(NUDAA - i).Cells("金額").Value.ToString)
            Next
        End If
        If CheckBox5.Checked = True Then
            Chart1.Series.Add("手術") : Chart1.Series("手術").ChartType = SeriesChartType.Line
            Dim NUDAA As Integer
            If 數列_NUD.Value >= 產品7_dgv.Rows.Count - 1 Or 數列_NUD.Value = 0 Then : NUDAA = 產品7_dgv.Rows.Count - 1
            ElseIf 數列_NUD.Value < 產品7_dgv.Rows.Count - 1 Then : NUDAA = 數列_NUD.Value : End If
            For i As Integer = 0 To NUDAA
                Chart1.Series("手術").Points.AddXY(產品7_dgv.Rows(NUDAA - i).Cells("日期").Value.ToString, 產品7_dgv.Rows(NUDAA - i).Cells("金額").Value.ToString)
            Next
        End If
        If CheckBox6.Checked = True Then
            Chart1.Series.Add("美療") : Chart1.Series("美療").ChartType = SeriesChartType.Line
            Dim NUDAA As Integer
            If 數列_NUD.Value >= 產品8_dgv.Rows.Count - 1 Or 數列_NUD.Value = 0 Then : NUDAA = 產品8_dgv.Rows.Count - 1
            ElseIf 數列_NUD.Value < 產品8_dgv.Rows.Count - 1 Then : NUDAA = 數列_NUD.Value : End If
            For i As Integer = 0 To NUDAA
                Chart1.Series("美療").Points.AddXY(產品8_dgv.Rows(NUDAA - i).Cells("日期").Value.ToString, 產品8_dgv.Rows(NUDAA - i).Cells("金額").Value.ToString)
            Next
        End If
        If CheckBox7.Checked = True Then
            Chart1.Series.Add("植髮") : Chart1.Series("植髮").ChartType = SeriesChartType.Line
            Dim NUDAA As Integer
            If 數列_NUD.Value >= 產品9_dgv.Rows.Count - 1 Or 數列_NUD.Value = 0 Then : NUDAA = 產品9_dgv.Rows.Count - 1
            ElseIf 數列_NUD.Value < 產品9_dgv.Rows.Count - 1 Then : NUDAA = 數列_NUD.Value : End If
            For i As Integer = 0 To NUDAA
                Chart1.Series("植髮").Points.AddXY(產品9_dgv.Rows(NUDAA - i).Cells("日期").Value.ToString, 產品9_dgv.Rows(NUDAA - i).Cells("金額").Value.ToString)
            Next
        End If
    End Sub
    Private Sub 表格繪製1()
        '-------線狀圖------------------------------------------------------
        Chart2.Series.Clear()
        Chart2.Series.Add("業務類別") : Chart2.Series("業務類別").ChartType = SeriesChartType.Pie
        Chart2.Series("業務類別").IsValueShownAsLabel = True
        Chart2.Series("業務類別").IsVisibleInLegend = True
        Chart2.Series("業務類別").IsXValueIndexed = True
        For i As Integer = 0 To 產品1_dgv.Rows.Count - 1
            If 產品1_dgv.Rows(i).Cells("日期").Value.ToString = 日期_tb.Text Then
                Chart2.Series("業務類別").Points.AddXY(產品1_dgv.Rows(i).Cells("類別").Value, 產品1_dgv.Rows(i).Cells("金額").Value.ToString)
            End If
        Next
    End Sub
    Private Sub 表格繪製2()
        '-------線狀圖------------------------------------------------------
        Chart3.Series.Clear()
        Chart3.Series.Add("產品銷售") : Chart3.Series("產品銷售").ChartType = SeriesChartType.Column
        Chart3.Series("產品銷售").IsVisibleInLegend = False
        For i As Integer = 0 To 產品10_dgv.Rows.Count - 1
            Chart3.Series("產品銷售").Points.AddXY(產品10_dgv.Rows(i).Cells("項次").Value.ToString, 產品10_dgv.Rows(i).Cells("金額").Value.ToString)
        Next
    End Sub
    Private Sub 產品10_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 產品10_dgv.RowPostPaint
        表格繪製2()
    End Sub
    Private Sub 產品1_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 產品1_dgv.RowPostPaint
        Dim linePen As New Pen(Color.Blue, 2)
        If e.RowIndex = 產品1_dgv.Rows.Count - 1 Then
            Exit Sub
        Else
            If 產品1_dgv(0, e.RowIndex).Value.ToString <> 產品1_dgv(0, e.RowIndex + 1).Value.ToString Then
                Dim startX As Integer = IIf(產品1_dgv.RowHeadersVisible, 產品1_dgv.RowHeadersWidth, 0)
                Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                Dim endX As Integer = startX + 產品1_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 產品1_dgv.HorizontalScrollingOffset
                e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
                Exit Sub
            End If
        End If
    End Sub
    Private Sub 最大_NUD_ValueChanged(sender As Object, e As EventArgs) Handles 最大_NUD.ValueChanged
        表格繪製()
    End Sub
    Private Sub 最小_NUD_ValueChanged(sender As Object, e As EventArgs) Handles 最小_NUD.ValueChanged
        表格繪製()
    End Sub
    Private Sub CheckBox5_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox5.CheckedChanged
        表格繪製()
    End Sub
    Private Sub CheckBox4_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox4.CheckedChanged
        表格繪製()
    End Sub
    Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.CheckedChanged
        表格繪製()
    End Sub
    Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged
        表格繪製()
    End Sub
    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
        表格繪製()
    End Sub
    Private Sub CheckBox6_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox6.CheckedChanged
        表格繪製()
    End Sub
    Private Sub CheckBox7_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox7.CheckedChanged
        表格繪製()
    End Sub
    Private Sub 數列_NUD_ValueChanged(sender As Object, e As EventArgs) Handles 數列_NUD.ValueChanged
        最大_NUD.Value = 數列_NUD.Value + 1
    End Sub
    Private Sub 產品1_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 產品1_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            日期_tb.Text = 產品1_dgv("日期", e.RowIndex).Value.ToString : 類別_tb.Text = 產品1_dgv("類別", e.RowIndex).Value.ToString
            總金額_tb.Text = Val(產品1_dgv("金額", e.RowIndex).Value) : 讀取客戶資料表10() : 表格繪製1()
        End If
    End Sub
    Private Sub 產品3_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 產品3_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            日期_tb.Text = 產品3_dgv("日期", e.RowIndex).Value.ToString : 類別_tb.Text = "一般產品" : 總金額_tb.Text = Val(產品3_dgv("金額", e.RowIndex).Value) : 讀取客戶資料表10()
        End If
    End Sub
    Private Sub 產品4_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 產品4_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            日期_tb.Text = 產品4_dgv("日期", e.RowIndex).Value.ToString : 類別_tb.Text = "人工皮" : 總金額_tb.Text = Val(產品4_dgv("金額", e.RowIndex).Value) : 讀取客戶資料表10()
        End If
    End Sub
    Private Sub 產品5_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 產品5_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            日期_tb.Text = 產品5_dgv("日期", e.RowIndex).Value.ToString : 類別_tb.Text = "治療" : 總金額_tb.Text = Val(產品5_dgv("金額", e.RowIndex).Value) : 讀取客戶資料表10()
        End If
    End Sub
    Private Sub 產品6_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 產品6_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            日期_tb.Text = 產品6_dgv("日期", e.RowIndex).Value.ToString : 類別_tb.Text = "雷射" : 總金額_tb.Text = Val(產品6_dgv("金額", e.RowIndex).Value) : 讀取客戶資料表10()
        End If
    End Sub
    Private Sub 產品7_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 產品7_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            日期_tb.Text = 產品7_dgv("日期", e.RowIndex).Value.ToString : 類別_tb.Text = "手術" : 總金額_tb.Text = Val(產品7_dgv("金額", e.RowIndex).Value) : 讀取客戶資料表10()
        End If
    End Sub
    Private Sub 產品8_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 產品8_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            日期_tb.Text = 產品8_dgv("日期", e.RowIndex).Value.ToString : 類別_tb.Text = "美療" : 總金額_tb.Text = Val(產品8_dgv("金額", e.RowIndex).Value) : 讀取客戶資料表10()
        End If
    End Sub
    Private Sub 產品9_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 產品9_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            日期_tb.Text = 產品9_dgv("日期", e.RowIndex).Value.ToString : 類別_tb.Text = "植髮" : 總金額_tb.Text = Val(產品9_dgv("金額", e.RowIndex).Value) : 讀取客戶資料表10()
        End If
    End Sub
    Private Sub 產品10_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 產品10_dgv.MouseUp
        If 產品10_dgv.SelectedRows.Count > 0 Then
            Dim sb As New System.Text.StringBuilder()
            Dim x As Double = 0
            'Dim y As Double = 0
            For i As Integer = 0 To 產品10_dgv.SelectedRows.Count - 1
                x += Math.Round(產品10_dgv.Rows(產品10_dgv.SelectedRows.Item(i).Index).Cells(3).Value, 1)
            Next i
            選擇加總_tb.Text = Strings.Format(x, "#,##0")
        End If
    End Sub
End Class