Option Strict Off
Imports System.Data.SqlClient
Imports System.IO
Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
Imports Microsoft.Office.Interop.Excel.Constants
Imports Microsoft.Office.Interop.Excel.XlBordersIndex
Imports Microsoft.Office.Interop.Excel.XlLineStyle
Imports Microsoft.Office.Interop.Excel.XlBorderWeight
Imports Microsoft.Office.Interop.Excel.XlThemeFont
Imports Microsoft.Office.Interop.Excel.XlThemeColor
Imports Microsoft.Office.Interop.Excel.XlWindowState
Imports Microsoft.Office.Interop.Excel
Imports System.Threading
Public Class 樣品進度表
    Dim conn As New SqlConnection
    Dim da As New SqlDataAdapter
    Dim cmd As New SqlCommand
    Dim ds As New DataSet : Dim ds1 As New DataSet : Dim ds2 As New DataSet : Dim ds3 As New DataSet : Dim ds4 As New DataSet
    Dim ds5 As New DataSet : Dim ds6 As New DataSet : Dim ds7 As New DataSet : Dim ds8 As New DataSet
    Dim dr As SqlDataReader
    Dim N1 As Integer = 0 : Dim N2 As Integer = 0 : Dim N3 As Integer = 0 : Dim N4 As Integer = 0 : Dim N5 As Integer = 0 : Dim N6 As Integer = 0 : Dim FFGG As Integer
    Dim xlApp As Application
    Dim xlBook As Workbook
    Dim xlSheet As Worksheet
    Dim SSDD As String
    Private Sub Set_清單1()
        DataGridView2.DataSource = Nothing : ds1.Clear()
        DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView2.ColumnHeadersHeight = 25
        DataGridView2.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT SO, 版次 FROM 樣品訂單控制表 WHERE 季節 LIKE N'" & ComboBox7.Text & "' AND 客戶 LIKE N'" & ComboBox2.Text & "' AND 狀態 LIKE N'" & 樣品進度表分類1 & "' ORDER BY 型體號碼, SO, 版次 DESC"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close()
    End Sub
    '----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Set_讀取清單2()
        DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView3.ColumnHeadersHeight = 25
        DataGridView3.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 部件, 材料名稱, 材料說明, 備註, 廠商, 流水號
                FROM 樣品訂單部件表
                WHERE (SO LIKE '" & DataGridView2.Rows(N2).Cells("SO").Value & "') AND (版次 LIKE '" & DataGridView2.Rows(N2).Cells("版次").Value & "') AND (部件 LIKE N'A.%')
                ORDER BY   SO, 版次, 流水號, 部件"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds2) : DataGridView3.DataSource = ds2.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_清單2()
        DataGridView3.DataSource = Nothing : ds2.Clear()
        For i As Integer = 0 To DataGridView2.Rows.Count - 1
            If DataGridView2.Rows(i).Cells("版次").Value = "V01" Then
                N2 = i : Set_讀取清單2()
            ElseIf DataGridView2.Rows(i).Cells("版次").Value <> "V01" Then
                N2 = i : Set_讀取清單2()
                i = i + Val(Strings.Right(DataGridView2.Rows(i).Cells("版次").Value, 2)) - 1
            End If
        Next
    End Sub
    '----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Set_讀取清單3()
        DataGridView4.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView4.ColumnHeadersHeight = 25
        DataGridView4.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 部件, 材料名稱, 材料說明, 備註, 廠商, 流水號
                FROM 樣品訂單部件表
                WHERE (SO LIKE '" & DataGridView2.Rows(N2).Cells("SO").Value & "') AND (版次 LIKE '" & DataGridView2.Rows(N2).Cells("版次").Value & "') AND (部件 LIKE N'B.%')
                ORDER BY   SO, 版次, 流水號, 部件"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds3) : DataGridView4.DataSource = ds3.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_清單3()
        DataGridView4.DataSource = Nothing : ds3.Clear()
        For i As Integer = 0 To DataGridView2.Rows.Count - 1
            If DataGridView2.Rows(i).Cells("版次").Value = "V01" Then
                N2 = i : Set_讀取清單3()
            ElseIf DataGridView2.Rows(i).Cells("版次").Value <> "V01" Then
                N2 = i : Set_讀取清單3()
                i = i + Val(Strings.Right(DataGridView2.Rows(i).Cells("版次").Value, 2)) - 1
            End If
        Next
    End Sub
    '----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Set_讀取清單4()
        DataGridView5.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView5.ColumnHeadersHeight = 25
        DataGridView5.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 部件, 材料名稱, 材料說明, 備註, 廠商, 流水號
                FROM 樣品訂單部件表
                WHERE (SO LIKE '" & DataGridView2.Rows(N2).Cells("SO").Value & "') AND (版次 LIKE '" & DataGridView2.Rows(N2).Cells("版次").Value & "') AND (部件 LIKE N'C.%')
                ORDER BY   SO, 版次, 流水號, 部件"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds4) : DataGridView5.DataSource = ds4.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_清單4()
        DataGridView5.DataSource = Nothing : ds4.Clear()
        For i As Integer = 0 To DataGridView2.Rows.Count - 1
            If DataGridView2.Rows(i).Cells("版次").Value = "V01" Then
                N2 = i : Set_讀取清單4()
            ElseIf DataGridView2.Rows(i).Cells("版次").Value <> "V01" Then
                N2 = i : Set_讀取清單4()
                i = i + Val(Strings.Right(DataGridView2.Rows(i).Cells("版次").Value, 2)) - 1
            End If
        Next
    End Sub
    '----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Set_讀取清單5()
        DataGridView6.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView6.ColumnHeadersHeight = 25
        DataGridView6.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 部件, 材料名稱, 材料說明, 備註, 廠商, 流水號
                FROM 樣品訂單部件表
                WHERE (SO LIKE '" & DataGridView2.Rows(N2).Cells("SO").Value & "') AND (版次 LIKE '" & DataGridView2.Rows(N2).Cells("版次").Value & "') AND (部件 LIKE N'D.%')
                ORDER BY   SO, 版次, 流水號, 部件"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds5) : DataGridView6.DataSource = ds5.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_清單5()
        DataGridView6.DataSource = Nothing : ds5.Clear()
        For i As Integer = 0 To DataGridView2.Rows.Count - 1
            If DataGridView2.Rows(i).Cells("版次").Value = "V01" Then
                N2 = i : Set_讀取清單5()
            ElseIf DataGridView2.Rows(i).Cells("版次").Value <> "V01" Then
                N2 = i : Set_讀取清單5()
                i = i + Val(Strings.Right(DataGridView2.Rows(i).Cells("版次").Value, 2)) - 1
            End If
        Next
    End Sub
    '----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Set_讀取清單6()
        DataGridView7.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView7.ColumnHeadersHeight = 25
        DataGridView7.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 部件, 材料名稱, 材料說明, 備註, 廠商, 流水號
                FROM 樣品訂單部件表
                WHERE (SO LIKE '" & DataGridView2.Rows(N2).Cells("SO").Value & "') AND (版次 LIKE '" & DataGridView2.Rows(N2).Cells("版次").Value & "') AND (部件 LIKE N'E.%')
                ORDER BY   SO, 版次, 流水號, 部件"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds6) : DataGridView7.DataSource = ds6.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_清單6()
        DataGridView7.DataSource = Nothing : ds6.Clear()
        For i As Integer = 0 To DataGridView2.Rows.Count - 1
            If DataGridView2.Rows(i).Cells("版次").Value = "V01" Then
                N2 = i : Set_讀取清單6()
            ElseIf DataGridView2.Rows(i).Cells("版次").Value <> "V01" Then
                N2 = i : Set_讀取清單6()
                i = i + Val(Strings.Right(DataGridView2.Rows(i).Cells("版次").Value, 2)) - 1
            End If
        Next
    End Sub
    '----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Set_讀取清單7()
        DataGridView8.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView8.ColumnHeadersHeight = 25
        DataGridView8.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 部件, 材料名稱, 材料說明, 備註, 廠商, 流水號
                FROM 樣品訂單部件表
                WHERE (SO LIKE '" & DataGridView2.Rows(N2).Cells("SO").Value & "') AND (版次 LIKE '" & DataGridView2.Rows(N2).Cells("版次").Value & "') AND (部件 LIKE N'F.%')
                ORDER BY   SO, 版次, 流水號, 部件"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds7) : DataGridView8.DataSource = ds7.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_清單7()
        DataGridView8.DataSource = Nothing : ds7.Clear()
        For i As Integer = 0 To DataGridView2.Rows.Count - 1
            If DataGridView2.Rows(i).Cells("版次").Value = "V01" Then
                N2 = i : Set_讀取清單7()
            ElseIf DataGridView2.Rows(i).Cells("版次").Value <> "V01" Then
                N2 = i : Set_讀取清單7()
                i = i + Val(Strings.Right(DataGridView2.Rows(i).Cells("版次").Value, 2)) - 1
            End If
        Next
    End Sub
    '----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Set_讀取清單()
        DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView1.ColumnHeadersHeight = 25
        DataGridView1.AllowUserToAddRows = False
        DataGridView1.RowTemplate.Height = 140
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT      樣品訂單控制表.SO AS 序號, 鞋樣素描圖控制表.圖片, 樣品訂單控制表.SO, 樣品訂單控制表.版次, 
                            樣品訂單控制表.型體號碼, 樣品訂單控制表.型體名稱 AS STYLE, 樣品訂單控制表.工廠, 樣品訂單控制表.ISS_DATE, 
                            樣品訂單控制表.ETA, 樣品訂單清單.顏色, 樣品訂單清單.數量, 樣品訂單清單.SIZE, 樣品訂單清單.KEEP, 
                            樣品訂單清單.流水號, 樣品訂單清單.流水號 AS UPPER, 樣品訂單清單.流水號 AS LINING, 
                            樣品訂單清單.流水號 AS BUCKLE, 樣品訂單清單.流水號 AS [SOCK LINING], 樣品訂單清單.流水號 AS BOTTOM, 
                            樣品訂單清單.流水號 AS OTHER, METOO選擇按鈕.選擇
                FROM        樣品訂單控制表 LEFT OUTER JOIN
                            METOO選擇按鈕 ON 樣品訂單控制表.SO = METOO選擇按鈕.對應 LEFT OUTER JOIN
                            鞋樣素描圖控制表 ON 樣品訂單控制表.型體號碼 = 鞋樣素描圖控制表.型體編號 AND 
                            樣品訂單控制表.型體名稱 = 鞋樣素描圖控制表.型體名稱 FULL OUTER JOIN
                            樣品訂單清單 ON 樣品訂單控制表.SO = 樣品訂單清單.SO AND 樣品訂單控制表.版次 = 樣品訂單清單.版次
                 WHERE      (樣品訂單控制表.季節 LIKE N'" & ComboBox7.Text & "') AND (樣品訂單控制表.客戶 LIKE N'" & ComboBox2.Text & "') 
                            AND (樣品訂單控制表.狀態 LIKE N'" & 樣品進度表分類1 & "') AND 
                            (樣品訂單控制表.SO LIKE '" & DataGridView2.Rows(N2).Cells("SO").Value & "') AND 
                            (樣品訂單控制表.版次 LIKE '" & DataGridView2.Rows(N2).Cells("版次").Value & "')
                 ORDER BY   樣品訂單控制表.型體號碼, 序號, 樣品訂單控制表.版次 DESC"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() : Set_grid()
    End Sub
    Private Sub Set_清單()
        DataGridView1.DataSource = Nothing : ds.Clear()
        For i As Integer = 0 To DataGridView2.Rows.Count - 1
            If DataGridView2.Rows(i).Cells("版次").Value = "V01" Then
                N2 = i : Set_讀取清單()
            ElseIf DataGridView2.Rows(i).Cells("版次").Value <> "V01" Then
                N2 = i : Set_讀取清單()
                i = i + Val(Strings.Right(DataGridView2.Rows(i).Cells("版次").Value, 2)) - 1
            End If
        Next
    End Sub
    Private Sub Set_grid()
        DataGridView1.Columns(0).Width = 40 : DataGridView1.Columns(1).Width = 120 : DataGridView1.Columns(2).Visible = False : DataGridView1.Columns(3).Width = 40 : DataGridView1.Columns(4).Visible = False
        DataGridView1.Columns(5).Width = 95 : DataGridView1.Columns(6).Width = 80 : DataGridView1.Columns(7).Visible = False : DataGridView1.Columns(8).Width = 80
        DataGridView1.Columns(9).Width = 95 : DataGridView1.Columns(10).Width = 40 : DataGridView1.Columns(11).Width = 40 : DataGridView1.Columns(12).Visible = False
        DataGridView1.Columns(13).Visible = False : DataGridView1.Columns(14).Width = 230 : DataGridView1.Columns(15).Width = 230 : DataGridView1.Columns(16).Width = 190
        DataGridView1.Columns(17).Width = 200 : DataGridView1.Columns(18).Width = 200 : DataGridView1.Columns(19).Width = 130 : DataGridView1.Columns(20).Width = 60

        DataGridView1.Columns(10).DefaultCellStyle.Format = "#,##0.0" : DataGridView1.Columns(12).DefaultCellStyle.Format = "#,##0.0"
        DataGridView1.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(12).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        DataGridView1.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(12).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
        DataGridView1.EditMode = DataGridViewEditMode.EditOnEnter
        N1 = 1
        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            If i = DataGridView1.Rows.Count - 1 Then
                DataGridView1.Rows(i).Cells("序號").Value = N1.ToString : Exit For
            Else
                If DataGridView1(4, i).Value.ToString <> DataGridView1(4, i + 1).Value.ToString Then
                    DataGridView1.Rows(i).Cells("序號").Value = N1.ToString : N1 = N1 + 1
                Else
                    DataGridView1.Rows(i).Cells("序號").Value = N1.ToString
                End If
            End If
        Next
    End Sub
    Private Sub Set_grid0()
        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            DataGridView1.Rows(i).Cells("STYLE").Value = DataGridView1.Rows(i).Cells("型體號碼").Value & " 
" & DataGridView1.Rows(i).Cells("STYLE").Value & " 

" & DataGridView1.Rows(i).Cells("SO").Value
            DataGridView1.Rows(i).Cells("選擇").Value = False
        Next
        Dim mycol As DataGridViewImageColumn = DataGridView1.Columns("圖片")
        mycol.ImageLayout = DataGridViewImageCellLayout.Zoom
    End Sub
    Private Sub Set_清單8()
        DataGridView9.DataSource = Nothing : ds8.Clear()
        DataGridView9.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView9.ColumnHeadersHeight = 25
        DataGridView9.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 季節, 客戶 FROM 樣品訂單控制表 WHERE (狀態 LIKE '" & 樣品進度表分類1 & "') GROUP BY 季節, 客戶 ORDER BY 客戶, 季節"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds8) : DataGridView9.DataSource = ds8.Tables(0) : conn.Close() : Set_grid8()
    End Sub
    Private Sub Set_grid8()
        DataGridView9.Columns(0).Width = 120 : DataGridView9.Columns(1).Width = 240
    End Sub
    Private Sub 導入A類料()
        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
            DataGridView1.Rows(i).Cells("UPPER").Value = ""
            Dim aa As Integer = 1
            For ii As Integer = 0 To DataGridView3.Rows.Count - 1
                If DataGridView1.Rows(i).Cells("流水號").Value = DataGridView3.Rows(ii).Cells("流水號").Value Then
                    If aa = 1 Then
                        If DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value &
                                     "-" & DataGridView3.Rows(ii).Cells("材料說明").Value & "-" & DataGridView3.Rows(ii).Cells("備註").Value & "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView3.Rows(ii).Cells("材料說明").Value & "-" & DataGridView3.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView3.Rows(ii).Cells("材料說明").Value & "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView3.Rows(ii).Cells("備註").Value & "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料說明").Value &
                                       "-" & DataGridView3.Rows(ii).Cells("備註").Value & "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView3.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView3.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料說明").Value &
                                "-" & DataGridView3.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料說明").Value &
                                "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("備註").Value &
                                "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("廠商").Value
                        End If
                        aa += 1
                    Else
                        If DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value &
                            "-" & DataGridView3.Rows(ii).Cells("材料說明").Value & "-" & DataGridView3.Rows(ii).Cells("備註").Value & "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView3.Rows(ii).Cells("材料說明").Value &
 "-" & DataGridView3.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView3.Rows(ii).Cells("材料說明").Value &
 "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView3.Rows(ii).Cells("備註").Value &
 "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料說明").Value & "-" & DataGridView3.Rows(ii).Cells("備註").Value &
 "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView3.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView3.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料說明").Value & "-" & DataGridView3.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料說明").Value & "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("備註").Value & "-" & DataGridView3.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料名稱").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView3.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView3.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView3.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView3.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("UPPER").Value = DataGridView1.Rows(i).Cells("UPPER").Value & " 
 " & aa & "、" & DataGridView3.Rows(ii).Cells("部件").Value & " - " & DataGridView3.Rows(ii).Cells("廠商").Value
                        End If
                        aa += 1
                    End If
                End If
            Next
        Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
    End Sub
    Private Sub 導入B類料()
        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
            DataGridView1.Rows(i).Cells("LINING").Value = ""
            Dim aa As Integer = 1
            For ii As Integer = 0 To DataGridView4.Rows.Count - 1
                If DataGridView1.Rows(i).Cells("流水號").Value = DataGridView4.Rows(ii).Cells("流水號").Value Then
                    If aa = 1 Then
                        If DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value &
                                     "-" & DataGridView4.Rows(ii).Cells("材料說明").Value & "-" & DataGridView4.Rows(ii).Cells("備註").Value & "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView4.Rows(ii).Cells("材料說明").Value & "-" & DataGridView4.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView4.Rows(ii).Cells("材料說明").Value & "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView4.Rows(ii).Cells("備註").Value & "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料說明").Value &
                                       "-" & DataGridView4.Rows(ii).Cells("備註").Value & "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView4.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView4.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料說明").Value &
                                "-" & DataGridView4.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料說明").Value &
                                "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("備註").Value &
                                "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("廠商").Value
                        End If
                        aa += 1
                    Else
                        If DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value &
                            "-" & DataGridView4.Rows(ii).Cells("材料說明").Value & "-" & DataGridView4.Rows(ii).Cells("備註").Value & "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView4.Rows(ii).Cells("材料說明").Value &
 "-" & DataGridView4.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView4.Rows(ii).Cells("材料說明").Value &
 "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView4.Rows(ii).Cells("備註").Value &
 "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料說明").Value & "-" & DataGridView4.Rows(ii).Cells("備註").Value &
 "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView4.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView4.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料說明").Value & "-" & DataGridView4.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料說明").Value & "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("備註").Value & "-" & DataGridView4.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料名稱").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView4.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView4.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("LINING").Value = DataGridView1.Rows(i).Cells("LINING").Value & " 
 " & aa & "、" & DataGridView4.Rows(ii).Cells("部件").Value & " - " & DataGridView4.Rows(ii).Cells("廠商").Value
                        End If
                        aa += 1
                    End If
                End If
            Next
        Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
    End Sub
    Private Sub 導入C類料()
        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
            DataGridView1.Rows(i).Cells("BUCKLE").Value = ""
            Dim aa As Integer = 1
            For ii As Integer = 0 To DataGridView5.Rows.Count - 1
                If DataGridView1.Rows(i).Cells("流水號").Value = DataGridView5.Rows(ii).Cells("流水號").Value Then
                    If aa = 1 Then
                        If DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value &
                                     "-" & DataGridView5.Rows(ii).Cells("材料說明").Value & "-" & DataGridView5.Rows(ii).Cells("備註").Value & "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView5.Rows(ii).Cells("材料說明").Value & "-" & DataGridView5.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView5.Rows(ii).Cells("材料說明").Value & "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView5.Rows(ii).Cells("備註").Value & "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料說明").Value &
                                       "-" & DataGridView5.Rows(ii).Cells("備註").Value & "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView5.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView5.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料說明").Value &
                                "-" & DataGridView5.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料說明").Value &
                                "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("備註").Value &
                                "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("廠商").Value
                        End If
                        aa += 1
                    Else
                        If DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value &
                            "-" & DataGridView5.Rows(ii).Cells("材料說明").Value & "-" & DataGridView5.Rows(ii).Cells("備註").Value & "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView5.Rows(ii).Cells("材料說明").Value &
 "-" & DataGridView5.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView5.Rows(ii).Cells("材料說明").Value &
 "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView5.Rows(ii).Cells("備註").Value &
 "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料說明").Value & "-" & DataGridView5.Rows(ii).Cells("備註").Value &
 "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView5.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView5.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料說明").Value & "-" & DataGridView5.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料說明").Value & "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("備註").Value & "-" & DataGridView5.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料名稱").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView5.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView5.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView5.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView5.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BUCKLE").Value = DataGridView1.Rows(i).Cells("BUCKLE").Value & " 
 " & aa & "、" & DataGridView5.Rows(ii).Cells("部件").Value & " - " & DataGridView5.Rows(ii).Cells("廠商").Value
                        End If
                        aa += 1
                    End If
                End If
            Next
        Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
    End Sub
    Private Sub 導入D類料()
        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
            DataGridView1.Rows(i).Cells("SOCK LINING").Value = ""
            Dim aa As Integer = 1
            For ii As Integer = 0 To DataGridView6.Rows.Count - 1
                If DataGridView1.Rows(i).Cells("流水號").Value = DataGridView6.Rows(ii).Cells("流水號").Value Then
                    If aa = 1 Then
                        If DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value &
                                     "-" & DataGridView6.Rows(ii).Cells("材料說明").Value & "-" & DataGridView6.Rows(ii).Cells("備註").Value & "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView6.Rows(ii).Cells("材料說明").Value & "-" & DataGridView6.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView6.Rows(ii).Cells("材料說明").Value & "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView6.Rows(ii).Cells("備註").Value & "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料說明").Value &
                                       "-" & DataGridView6.Rows(ii).Cells("備註").Value & "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView6.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView6.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料說明").Value &
                                "-" & DataGridView6.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料說明").Value &
                                "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("備註").Value &
                                "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("廠商").Value
                        End If
                        aa += 1
                    Else
                        If DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value &
                            "-" & DataGridView6.Rows(ii).Cells("材料說明").Value & "-" & DataGridView6.Rows(ii).Cells("備註").Value & "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView6.Rows(ii).Cells("材料說明").Value &
 "-" & DataGridView6.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView6.Rows(ii).Cells("材料說明").Value &
 "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView6.Rows(ii).Cells("備註").Value &
 "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料說明").Value & "-" & DataGridView6.Rows(ii).Cells("備註").Value &
 "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView6.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView6.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料說明").Value & "-" & DataGridView6.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料說明").Value & "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("備註").Value & "-" & DataGridView6.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料名稱").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView6.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView6.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView6.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView6.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("SOCK LINING").Value = DataGridView1.Rows(i).Cells("SOCK LINING").Value & " 
 " & aa & "、" & DataGridView6.Rows(ii).Cells("部件").Value & " - " & DataGridView6.Rows(ii).Cells("廠商").Value
                        End If
                        aa += 1
                    End If
                End If
            Next
        Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
    End Sub
    Private Sub 導入E類料()
        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
            DataGridView1.Rows(i).Cells("BOTTOM").Value = ""
            Dim aa As Integer = 1
            For ii As Integer = 0 To DataGridView7.Rows.Count - 1
                If DataGridView1.Rows(i).Cells("流水號").Value = DataGridView7.Rows(ii).Cells("流水號").Value Then
                    If aa = 1 Then
                        If DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value &
                                     "-" & DataGridView7.Rows(ii).Cells("材料說明").Value & "-" & DataGridView7.Rows(ii).Cells("備註").Value & "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView7.Rows(ii).Cells("材料說明").Value & "-" & DataGridView7.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView7.Rows(ii).Cells("材料說明").Value & "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView7.Rows(ii).Cells("備註").Value & "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料說明").Value &
                                       "-" & DataGridView7.Rows(ii).Cells("備註").Value & "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value & " - ".ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & DataGridView7.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView7.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView7.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料說明").Value &
                                "-" & DataGridView7.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料說明").Value &
                                "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("備註").Value &
                                "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("廠商").Value
                        End If
                        aa += 1
                    Else
                        If DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value &
                            "-" & DataGridView7.Rows(ii).Cells("材料說明").Value & "-" & DataGridView7.Rows(ii).Cells("備註").Value & "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView7.Rows(ii).Cells("材料說明").Value &
 "-" & DataGridView7.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView7.Rows(ii).Cells("材料說明").Value &
 "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView7.Rows(ii).Cells("備註").Value &
 "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料說明").Value & "-" & DataGridView7.Rows(ii).Cells("備註").Value &
 "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView7.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView7.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料說明").Value & "-" & DataGridView7.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料說明").Value & "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("備註").Value & "-" & DataGridView7.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料名稱").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView7.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView7.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView7.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView7.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("BOTTOM").Value = DataGridView1.Rows(i).Cells("BOTTOM").Value & " 
 " & aa & "、" & DataGridView7.Rows(ii).Cells("部件").Value & " - " & DataGridView7.Rows(ii).Cells("廠商").Value
                        End If
                        aa += 1
                    End If
                End If
            Next
        Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
    End Sub
    Private Sub 導入F類料()
        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
            DataGridView1.Rows(i).Cells("OTHER").Value = ""
            Dim aa As Integer = 1
            For ii As Integer = 0 To DataGridView8.Rows.Count - 1
                If DataGridView1.Rows(i).Cells("流水號").Value = DataGridView8.Rows(ii).Cells("流水號").Value Then
                    If aa = 1 Then
                        If DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value &
                                     "-" & DataGridView8.Rows(ii).Cells("材料說明").Value & "-" & DataGridView8.Rows(ii).Cells("備註").Value & "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView8.Rows(ii).Cells("材料說明").Value & "-" & DataGridView8.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView8.Rows(ii).Cells("材料說明").Value & "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value &
                                       "-" & DataGridView8.Rows(ii).Cells("備註").Value & "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料說明").Value &
                                       "-" & DataGridView8.Rows(ii).Cells("備註").Value & "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView8.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView8.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料說明").Value &
                                "-" & DataGridView8.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value &
                                "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料說明").Value &
                                "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("備註").Value &
                                "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("廠商").Value
                        End If
                        aa += 1
                    Else
                        If DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value &
                            "-" & DataGridView8.Rows(ii).Cells("材料說明").Value & "-" & DataGridView8.Rows(ii).Cells("備註").Value & "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView8.Rows(ii).Cells("材料說明").Value &
 "-" & DataGridView8.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView8.Rows(ii).Cells("材料說明").Value &
 "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView8.Rows(ii).Cells("備註").Value &
 "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料說明").Value & "-" & DataGridView8.Rows(ii).Cells("備註").Value &
 "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView8.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView8.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料說明").Value & "-" & DataGridView8.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value & "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料說明").Value & "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("備註").Value & "-" & DataGridView8.Rows(ii).Cells("廠商").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料名稱").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString <> "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("材料說明").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString <> "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString = "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("備註").Value

                        ElseIf DataGridView8.Rows(ii).Cells("材料名稱").Value.ToString = "" And DataGridView8.Rows(ii).Cells("材料說明").Value.ToString = "" And
                            DataGridView8.Rows(ii).Cells("備註").Value.ToString = "" And DataGridView8.Rows(ii).Cells("廠商").Value.ToString <> "" Then
                            DataGridView1.Rows(i).Cells("OTHER").Value = DataGridView1.Rows(i).Cells("OTHER").Value & " 
 " & aa & "、" & DataGridView8.Rows(ii).Cells("部件").Value & " - " & DataGridView8.Rows(ii).Cells("廠商").Value
                        End If
                        aa += 1
                    End If
                End If
            Next
        Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
    End Sub
    Private Sub ComboBox7下拉表單資料載入()
        conn.Close()
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT SEASON FROM 季節清單 ORDER BY SEASON"
        cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
        ComboBox7.Items.Clear() : While (dr.Read()) : ComboBox7.Items.Add(dr("SEASON")) : End While : conn.Close()
    End Sub
    Private Sub ComboBox2下拉表單資料載入()
        conn.Close()
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 客戶簡稱 FROM 客戶控制表 ORDER BY 客戶簡稱"
        cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
        ComboBox2.Items.Clear() : While (dr.Read()) : ComboBox2.Items.Add(dr("客戶簡稱")) : End While : conn.Close()
    End Sub
    Private Sub 樣品進度表DEVELOPMENT_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
        ComboBox7下拉表單資料載入() : ComboBox2下拉表單資料載入()
        DataGridView2.Visible = False : DataGridView3.Visible = False : DataGridView4.Visible = False : DataGridView5.Visible = False : DataGridView6.Visible = False : DataGridView7.Visible = False
        DataGridView8.Visible = False : GroupBox1.Visible = False : ComboBox7.Enabled = False : ComboBox2.Enabled = False
    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)
        If e.RowIndex = DataGridView1.Rows.Count - 1 Then
            Exit Sub
        Else
            If DataGridView1(0, e.RowIndex).Value.ToString <> DataGridView1(0, 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
        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)
        If e.RowIndex = DataGridView8.Rows.Count - 1 Then
            Exit Sub
        Else
            If DataGridView8(0, e.RowIndex).Value.ToString <> DataGridView8(0, 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
        End If
    End Sub
    Private Sub DataGridView9_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView9.CellClick
        If e.RowIndex = -1 Then : Else
            ComboBox7下拉表單資料載入() : ComboBox2下拉表單資料載入()
            ComboBox7.Text = DataGridView9.Rows(e.RowIndex).Cells("季節").Value
            ComboBox2.Text = DataGridView9.Rows(e.RowIndex).Cells("客戶").Value
        End If
    End Sub
    Private Sub ComboBox7_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox7.SelectedIndexChanged
        If ComboBox7.Text = "" Or ComboBox2.Text = "" Then : Else : Set_清單1() : Set_清單2() : Set_清單3() : Set_清單4() : Set_清單5() : Set_清單6() : Set_清單7() : Set_清單()
            導入A類料() : 導入B類料() : 導入C類料() : 導入D類料() : 導入E類料() : 導入F類料() : Set_grid0() : ComboBox7.Enabled = False : ComboBox2.Enabled = False : End If
    End Sub
    Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
        If ComboBox7.Text = "" Or ComboBox2.Text = "" Then : Else : Set_清單1() : Set_清單2() : Set_清單3() : Set_清單4() : Set_清單5() : Set_清單6() : Set_清單7() : Set_清單()
            導入A類料() : 導入B類料() : 導入C類料() : 導入D類料() : 導入E類料() : 導入F類料() : Set_grid0() : ComboBox7.Enabled = False : ComboBox2.Enabled = False : End If
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ComboBox7.Enabled = True : ComboBox2.Enabled = True : ComboBox7下拉表單資料載入() : ComboBox2下拉表單資料載入()
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        GroupBox1.Visible = False
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Set_清單8() : GroupBox1.Visible = True
    End Sub
    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        For i As Integer = 0 To DataGridView1.Rows.Count - 1 : DataGridView1.Rows(i).Cells("選擇").Value = False : Next
        CheckBox1.Checked = False
    End Sub
    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        For i As Integer = 0 To DataGridView1.Rows.Count - 1 : DataGridView1.Rows(i).Cells("選擇").Value = True : Next
        CheckBox1.Checked = True
    End Sub
    Private Sub 圖片導入2()
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT TOP (1) 圖片 FROM 鞋樣素描圖控制表 WHERE  型體編號  LIKE N'" & SSDD & "'"
        cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
        PictureBox2.Image = Nothing
        While dr.Read() = True
            Dim bytes As Byte() = New Byte(-1) {}
            bytes = DirectCast(dr.Item("圖片"), Byte())
            Dim oStream As New MemoryStream(bytes)
            PictureBox2.Image = Bitmap.FromStream(oStream)
        End While
        conn.Close()
        PictureBox2.SizeMode = 4
    End Sub
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        xlApp = CType(CreateObject("Excel.Application"), Application)
        xlBook = xlApp.Workbooks.Add
        xlApp.DisplayAlerts = True
        xlBook.Activate()
        xlSheet = NewMethod(xlBook)
        xlSheet.Activate()
        xlApp.Visible = True
        xlApp.Application.WindowState = xlMaximized
        FFGG = DataGridView1.Rows.Count + 3
        AA(xlApp, xlSheet)
        xlSheet.Cells(1, 1) = ComboBox2.Text & " - " & ComboBox7.Text & " - " & 樣品進度表分類1 & " - " & "SAMPLE SCHEDULE"
        xlSheet.Cells(3, 1) = "No." : xlSheet.Cells(3, 2) = "工廠" : xlSheet.Cells(3, 3) = "圖片" : xlSheet.Cells(3, 4) = "STYLE" : xlSheet.Cells(3, 5) = "C_No" : xlSheet.Cells(3, 6) = "顏色"
        xlSheet.Cells(3, 7) = "SIZE" : xlSheet.Cells(3, 8) = "UPPER_____A." : xlSheet.Cells(3, 9) = "LINING_____B." : xlSheet.Cells(3, 10) = "STITCHING_____F."
        xlSheet.Cells(3, 11) = "ACCESSORIES_____C." : xlSheet.Cells(3, 12) = "SOCK LINING_____D." : xlSheet.Cells(3, 13) = "BOTTOM_____E." : xlSheet.Cells(3, 14) = "數量"
        xlSheet.Cells(3, 15) = "ETD" : xlSheet.Cells(3, 16) = "備註"
        Dim VVBB As String = "0" : Dim FF As Integer = 0
        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            SSDD = DataGridView1.Rows(i).Cells("型體號碼").Value
            If DataGridView1.Rows(i).Cells("選擇").Value = True Then
                N3 = FF + 4
                If VVBB <> SSDD Then
                    圖片導入2() : N6 = 1
                    For ii As Integer = 0 To 20
                        If PictureBox2.Image Is Nothing Then
                            Thread.Sleep(100) '延迟0.1秒
                        Else
                            BB(xlApp, xlSheet) : ii = 20
                        End If
                    Next ii
                End If
                VVBB = SSDD
                xlSheet.Cells(FF + 4, 1) = DataGridView1.Rows(i).Cells("序號").Value : xlSheet.Cells(FF + 4, 2) = DataGridView1.Rows(i).Cells("工廠").Value
                xlSheet.Cells(FF + 4, 4) = DataGridView1.Rows(i).Cells("STYLE").Value : xlSheet.Cells(FF + 4, 5) = N6
                xlSheet.Cells(FF + 4, 6) = DataGridView1.Rows(i).Cells("顏色").Value : xlSheet.Cells(FF + 4, 7) = DataGridView1.Rows(i).Cells("SIZE").Value
                xlSheet.Cells(FF + 4, 8) = DataGridView1.Rows(i).Cells("UPPER").Value : xlSheet.Cells(FF + 4, 9) = DataGridView1.Rows(i).Cells("LINING").Value
                xlSheet.Cells(FF + 4, 10) = DataGridView1.Rows(i).Cells("OTHER").Value : xlSheet.Cells(FF + 4, 11) = DataGridView1.Rows(i).Cells("BUCKLE").Value
                xlSheet.Cells(FF + 4, 12) = DataGridView1.Rows(i).Cells("SOCK LINING").Value : xlSheet.Cells(FF + 4, 13) = DataGridView1.Rows(i).Cells("BOTTOM").Value
                xlSheet.Cells(FF + 4, 14) = DataGridView1.Rows(i).Cells("數量").Value : xlSheet.Cells(FF + 4, 15) = DataGridView1.Rows(i).Cells("ETA").Value
                FF = FF + 1
            End If
            N6 = N6 + 1
        Next i
        CC(xlApp, xlSheet)
        xlSheet.PageSetup.PrintArea = ""
        xlApp.Cells.Select()
        xlSheet.Range("B1").Select()
        xlApp.Application.WindowState = xlMinimized
        MsgBox("列印完成")
    End Sub
    Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
        Return CType(xlBook.Worksheets.Add, Worksheet)
    End Function
    Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        xlSheet.Cells.Select()
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
            .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Rows("4:" & FFGG).Select
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 8 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
            .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        myExcel.Selection.RowHeight = 90
        With myExcel.Selection : .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With

        xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 3
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : End With
        xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 10
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : End With
        xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 16
        xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 9
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : End With
        xlSheet.Columns("E:E").Select : myExcel.Selection.ColumnWidth = 4
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : End With
        xlSheet.Columns("F:F").Select : myExcel.Selection.ColumnWidth = 12
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : End With

        xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 5
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : End With

        xlSheet.Columns("H:H").Select : myExcel.Selection.ColumnWidth = 27 : xlSheet.Columns("I:I").Select : myExcel.Selection.ColumnWidth = 27
        xlSheet.Columns("J:J").Select : myExcel.Selection.ColumnWidth = 20 : xlSheet.Columns("K:K").Select : myExcel.Selection.ColumnWidth = 27
        xlSheet.Columns("L:L").Select : myExcel.Selection.ColumnWidth = 27 : xlSheet.Columns("M:M").Select : myExcel.Selection.ColumnWidth = 27
        xlSheet.Columns("N:N").Select : myExcel.Selection.ColumnWidth = 3
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : End With
        xlSheet.Columns("O:O").Select : myExcel.Selection.ColumnWidth = 8
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : End With
        xlSheet.Columns("P:P").Select : myExcel.Selection.ColumnWidth = 16

        xlSheet.Columns("I:I").Select : myExcel.Selection.ColumnWidth = 27

        xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 5 : xlSheet.Rows("3:3").Select : myExcel.Selection.RowHeight = 35
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 8 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
            .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With

        xlSheet.Range("A1:P1").Select()
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
            .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
        myExcel.Selection.Merge
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 18 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
    End Sub
    Private Sub BB(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        Clipboard.SetDataObject(PictureBox2.Image)
        xlSheet.Cells(1, 1).Select
        Thread.Sleep(100) '延迟0.1秒
        xlSheet.Range("C" & N3).Select()
        myExcel.ActiveSheet.Paste
        If PictureBox2.Image.Height < PictureBox2.Image.Width Then
            myExcel.Selection.ShapeRange.Width = 90
        Else
            myExcel.Selection.ShapeRange.Height = 85
        End If
        myExcel.Selection.ShapeRange.IncrementLeft(2)
        myExcel.Selection.ShapeRange.IncrementTop(2)
    End Sub
    Private Sub CC(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        xlSheet.Range("A3:P3").Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlThin : End With
        myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        N4 = 0 : N5 = 0
        If CheckBox1.Checked = True Then
            Dim ZZXX As Boolean = False : Dim XXCC As Boolean = False
            For i As Integer = 0 To DataGridView1.Rows.Count - 1
                If i = DataGridView1.Rows.Count - 1 Then
                    xlSheet.Range("A" & N4 + 3 & ":P" & N5 + 4).Select()
                    myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
                    With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlMedium : End With
                    With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlMedium : End With
                    With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlMedium : End With
                    With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlMedium : End With
                    With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlHairline : End With
                    With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlHairline : End With
                    Exit For
                ElseIf (DataGridView1.Rows(i).Cells("序號").Value = DataGridView1.Rows(i + 1).Cells("序號").Value) And i < DataGridView1.Rows.Count Then
                    If ZZXX = False Then
                        N4 = i + 1 : ZZXX = True
                    End If
                    N5 = i + 1
                ElseIf (DataGridView1.Rows(i).Cells("序號").Value <> DataGridView1.Rows(i + 1).Cells("序號").Value) And i < DataGridView1.Rows.Count Then
                    If XXCC = False Then
                        xlSheet.Range("A" & N4 + 3 & ":P" & N5 + 4).Select() : XXCC = True
                    Else
                        xlSheet.Range("A" & N4 + 4 & ":P" & N5 + 4).Select()
                    End If
                    myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
                    With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlMedium : End With
                    With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlMedium : End With
                    With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlMedium : End With
                    With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlMedium : End With
                    With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlHairline : End With
                    With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = xlAutomatic : .TintAndShade = 0 : .Weight = xlHairline : End With

                    ZZXX = False
                    If ZZXX = False Then
                        N4 = i + 1 : ZZXX = True
                    End If
                    N5 = i + 1
                End If
            Next
            myExcel.ActiveWindow.Zoom = 90
            ZZXX = False : XXCC = False
        End If
        myExcel.Application.PrintCommunication = False
        With myExcel.ActiveSheet.PageSetup
            .PrintTitleRows = "$1:$3"
            .PrintTitleColumns = ""
        End With
        myExcel.Application.PrintCommunication = True
        myExcel.ActiveSheet.PageSetup.PrintArea = ""
        myExcel.Application.PrintCommunication = False
        With myExcel.ActiveSheet.PageSetup
            '.LeftHeader = ""
            '.CenterHeader = ""
            '.RightHeader = ""
            '.LeftFooter = ""
            '.CenterFooter = ""
            '.RightFooter = ""
            .LeftMargin = myExcel.Application.InchesToPoints(0.25)
            .RightMargin = myExcel.Application.InchesToPoints(0.25)
            .TopMargin = myExcel.Application.InchesToPoints(0.75)
            .BottomMargin = myExcel.Application.InchesToPoints(0.75)
            .HeaderMargin = myExcel.Application.InchesToPoints(0.3)
            .FooterMargin = myExcel.Application.InchesToPoints(0.3)
            ''.PrintHeadings = False
            ''.PrintGridlines = False
            '.PrintQuality = 600
            '.CenterHorizontally = False
            '.CenterVertically = False
            '.Draft = False
            .FirstPageNumber = xlAutomatic
            '.BlackAndWhite = False
            .Zoom = 38
            '.OddAndEvenPagesHeaderFooter = False
            '.DifferentFirstPageHeaderFooter = False
            '.ScaleWithDocHeaderFooter = True
            '.AlignMarginsHeaderFooter = True
            '.EvenPage.LeftHeader.Text = ""
            '.EvenPage.CenterHeader.Text = ""
            '.EvenPage.RightHeader.Text = ""
            '.EvenPage.LeftFooter.Text = ""
            '.EvenPage.CenterFooter.Text = ""
            '.EvenPage.RightFooter.Text = ""
            '.FirstPage.LeftHeader.Text = ""
            '.FirstPage.CenterHeader.Text = ""
            '.FirstPage.RightHeader.Text = ""
            '.FirstPage.LeftFooter.Text = ""
            '.FirstPage.CenterFooter.Text = ""
            '.FirstPage.RightFooter.Text = ""
        End With
        myExcel.Application.PrintCommunication = True
    End Sub
End Class