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 形體總表MINI_WALL
    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 dr As SqlDataReader
    Dim AASS As String : Dim SSDD As String
    Dim 楦頭最大數 As Integer : Dim 草圖計算數 As Integer : Dim 草圖最大數 As Integer : Dim N1 As Integer : Dim N2 As Integer : Dim 位置1 As String : Dim 位置2 As String : Dim 位置3 As String : Dim 位置4 As String
    Dim 位置5 As String : Dim 位置6 As String : Dim 位置7 As String : Dim 位置8 As String : Dim 位置9 As String : Dim 位置10 As String
    Dim xlApp As Application
    Dim xlBook As Workbook
    Dim xlSheet As Worksheet
    Private Sub Set_DGV1載入前設定()
        DataGridView1.DataSource = Nothing : ds.Clear()
        DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView1.ColumnHeadersHeight = 25
        DataGridView1.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
    End Sub
    Private Sub Set_DGV1載入後設定()
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
    End Sub
    Private Sub 草圖表清單()
        Set_DGV1載入前設定()
        SQL1 = "SELECT 鞋樣素描圖控制表.模具編號, 鞋樣素描圖控制表.型體編號, 鞋樣素描圖控制表.型體名稱, METOO選擇按鈕.選擇 , 鞋樣素描圖控制表.鞋樣素描圖編號
                FROM 鞋樣素描圖控制表 LEFT OUTER JOIN METOO選擇按鈕 ON 鞋樣素描圖控制表.楦頭編號 = METOO選擇按鈕.對應
                WHERE (鞋樣素描圖控制表.品牌 LIKE '" & ComboBox1.Text & "') AND (鞋樣素描圖控制表.楦頭編號 LIKE '" & AASS & "')"
        Set_DGV1載入後設定() : Set_grid()
    End Sub
    Private Sub Set_grid()
        DataGridView1.Columns(0).Width = 120 : DataGridView1.Columns(1).Width = 120 : DataGridView1.Columns(2).Width = 120 : DataGridView1.Columns(3).Width = 40 : DataGridView1.Columns(4).Visible = False
        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            DataGridView1.Rows(i).Cells("選擇").Value = False
        Next i
    End Sub
    Private Sub Set_DGV2載入前設定()
        DataGridView2.DataSource = Nothing : ds1.Clear()
        DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView2.ColumnHeadersHeight = 25
        DataGridView2.AllowUserToAddRows = False
        DataGridView2.RowTemplate.Height = 60
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
    End Sub
    Private Sub Set_DGV2載入後設定()
        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()
        Set_DGV2載入前設定()
        SQL1 = "SELECT 楦頭規格控制表.楦頭名, 楦頭圖片庫.楦頭圖片, 楦頭規格控制表.楦頭編號, MINI_WALL_明細表.製造, MINI_WALL_明細表.選擇
                FROM MINI_WALL_明細表 LEFT OUTER JOIN 楦頭規格控制表 ON MINI_WALL_明細表.楦頭編號 = 楦頭規格控制表.楦頭編號 LEFT OUTER JOIN 楦頭圖片庫 ON MINI_WALL_明細表.楦頭編號 = 楦頭圖片庫.楦頭編號
                WHERE (MINI_WALL_明細表.MW編號 LIKE N'" & TextBox1.Text & "')"
        Set_DGV2載入後設定() : Set_grid1()
    End Sub
    Private Sub Set_grid1()
        DataGridView2.Columns(0).Width = 100 : DataGridView2.Columns(1).Width = 70 : DataGridView2.Columns(2).Visible = False : DataGridView2.Columns(3).Width = 70 : DataGridView2.Columns(4).Width = 40
        DataGridView2.EditMode = DataGridViewEditMode.EditOnEnter
        Dim mycol As DataGridViewImageColumn = DataGridView2.Columns("楦頭圖片")
        mycol.ImageLayout = DataGridViewImageCellLayout.Zoom

        For i As Integer = 0 To DataGridView2.Rows.Count - 1
            If DataGridView2.Rows(i).Cells("選擇").Value Is DBNull.Value Then
                DataGridView2.Rows(i).Cells("選擇").Value = False
            End If
        Next i
    End Sub
    Private Sub Set_DGV3載入前設定()
        DataGridView3.DataSource = Nothing : ds2.Clear()
        DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView3.ColumnHeadersHeight = 25
        DataGridView3.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
    End Sub
    Private Sub Set_DGV3載入後設定()
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds2) : DataGridView3.DataSource = ds2.Tables(0) : conn.Close()
        For i As Integer = 0 To DataGridView3.Rows.Count - 1
            DataGridView3.Rows(i).Cells("選擇").Value = False
        Next i
    End Sub
    Private Sub Set_楦頭清單()
        Set_DGV3載入前設定()
        SQL1 = "SELECT 楦頭規格控制表.楦頭編號, METOO選擇按鈕.選擇
                FROM 鞋樣素描圖控制表 LEFT OUTER JOIN METOO選擇按鈕 ON 鞋樣素描圖控制表.楦頭編號 = METOO選擇按鈕.對應 LEFT OUTER JOIN 楦頭規格控制表 ON 鞋樣素描圖控制表.楦頭編號 = 楦頭規格控制表.楦頭編號
                WHERE (鞋樣素描圖控制表.品牌 LIKE '" & ComboBox1.Text & "') GROUP BY 楦頭規格控制表.楦頭編號, METOO選擇按鈕.選擇"
        Set_DGV3載入後設定() : Set_grid2()
    End Sub
    Private Sub Set_grid2()
        DataGridView3.Columns(0).Width = 120 : DataGridView3.Columns(1).Visible = False
    End Sub
    Private Sub Set_DGV4載入前設定()
        DataGridView4.DataSource = Nothing : ds3.Clear()
        DataGridView4.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView4.ColumnHeadersHeight = 25
        DataGridView4.AllowUserToAddRows = False
        DataGridView4.RowTemplate.Height = 60
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
    End Sub
    Private Sub Set_DGV4載入後設定()
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds3) : DataGridView4.DataSource = ds3.Tables(0) : conn.Close()
    End Sub
    Private Sub 清單3()
        Set_DGV4載入前設定()
        SQL1 = "SELECT 鞋樣素描圖控制表.楦頭編號, 鞋樣素描圖控制表.模具編號, 鞋樣素描圖控制表.型體編號, 鞋樣素描圖控制表.型體名稱, 
                       鞋樣素描圖控制表.圖片, MINI_WALL_草圖明細.選擇, MINI_WALL_草圖明細.鞋樣素描圖編號
                FROM MINI_WALL_草圖明細 LEFT OUTER JOIN 鞋樣素描圖控制表 ON MINI_WALL_草圖明細.鞋樣素描圖編號 = 鞋樣素描圖控制表.鞋樣素描圖編號
                WHERE (MINI_WALL_草圖明細.MW編號 LIKE N'" & TextBox1.Text & "') AND (MINI_WALL_草圖明細.楦頭編號 LIKE N'" & AASS & "')"
        Set_DGV4載入後設定() : Set_grid3()
    End Sub
    Private Sub Set_grid3()
        DataGridView4.Columns(0).Width = 120 : DataGridView4.Columns(1).Width = 120 : DataGridView4.Columns(2).Width = 120 : DataGridView4.Columns(3).Width = 120 : DataGridView4.Columns(4).Width = 120
        DataGridView4.Columns(5).Width = 40 : DataGridView4.Columns(6).Visible = False
        Dim mycol As DataGridViewImageColumn = DataGridView4.Columns("圖片")
        mycol.ImageLayout = DataGridViewImageCellLayout.Zoom

        For i As Integer = 0 To DataGridView4.Rows.Count - 1
            If DataGridView4.Rows(i).Cells("選擇").Value Is DBNull.Value Then
                DataGridView4.Rows(i).Cells("選擇").Value = False
            End If
        Next i
    End Sub
    Private Sub Set_DGV5載入前設定()
        DataGridView5.DataSource = Nothing : ds4.Clear()
        DataGridView5.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView5.ColumnHeadersHeight = 25
        DataGridView5.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
    End Sub
    Private Sub Set_DGV5載入後設定()
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds4) : DataGridView5.DataSource = ds4.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_清單1()
        Set_DGV5載入前設定()
        SQL1 = "SELECT MW編號, 季節, 品牌 FROM MINI_WALL_控制表 ORDER BY MW編號"
        Set_DGV5載入後設定() : Set_grid4()
    End Sub
    Private Sub Set_grid4()
        DataGridView5.Columns(0).Width = 100 : DataGridView5.Columns(1).Width = 60 : DataGridView5.Columns(2).Width = 140
    End Sub
    Private Sub ComboBox1下拉表單資料載入()
        conn.Close()
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 客戶簡稱 FROM 型體控制表 GROUP BY   客戶簡稱 ORDER BY   客戶簡稱"
        cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
        ComboBox1.Items.Clear() : While (dr.Read()) : ComboBox1.Items.Add(dr("客戶簡稱")) : End While : conn.Close()
    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 圖片導入1()
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 楦頭圖片 FROM 楦頭圖片庫 WHERE 楦頭編號 LIKE N'" & AASS & "'"
        cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
        PictureBox1.Image = Nothing
        While dr.Read() = True
            Dim bytes As Byte() = New Byte(-1) {}
            bytes = DirectCast(dr.Item("楦頭圖片"), Byte())
            Dim oStream As New MemoryStream(bytes)
            PictureBox1.Image = Bitmap.FromStream(oStream)
        End While
        conn.Close()
        PictureBox1.SizeMode = 4
    End Sub
    Private Sub 圖片導入2()
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 圖片 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 形體總表MINI_WALL_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
        ComboBox1下拉表單資料載入() : ComboBox7下拉表單資料載入() : Set_清單1()
        TextBox1.Enabled = False : TextBox2.Enabled = False : TextBox3.Enabled = False
    End Sub
    Private Sub DataGridView5_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView5.CellClick
        If e.RowIndex = -1 Then : Else
            TextBox1.Text = DataGridView5.Rows(e.RowIndex).Cells("MW編號").Value : ComboBox7.Text = DataGridView5.Rows(e.RowIndex).Cells("季節").Value
            ComboBox1.Text = DataGridView5.Rows(e.RowIndex).Cells("品牌").Value
            Set_清單2() : TextBox2.Text = "" : TextBox3.Text = ""
        End If
    End Sub
    Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView2.CellClick
        If e.RowIndex = -1 Then : Else
            AASS = DataGridView2.Rows(e.RowIndex).Cells("楦頭編號").Value
            TextBox2.Text = DataGridView2.Rows(e.RowIndex).Cells("楦頭編號").Value
            清單3() : TextBox3.Text = ""
        End If
    End Sub
    Private Sub DataGridView4_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView4.CellClick
        If e.RowIndex = -1 Then : Else
            TextBox3.Text = DataGridView4.Rows(e.RowIndex).Cells("鞋樣素描圖編號").Value
        End If
    End Sub
    Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView3.CellClick
        If e.RowIndex = -1 Then : Else
            AASS = DataGridView3.Rows(e.RowIndex).Cells("楦頭編號").Value
            草圖表清單() : 圖片導入1()
        End If
    End Sub
    Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        If e.RowIndex = -1 Then : Else
            SSDD = DataGridView1.Rows(e.RowIndex).Cells("鞋樣素描圖編號").Value
            圖片導入2()
        End If
    End Sub
    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        Set_楦頭清單()
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        清單修改.Close() : 季節清單修改 = True : 清單修改.ShowDialog() : ComboBox7下拉表單資料載入() : 季節清單修改 = False
    End Sub
    Private Sub Button29_Click(sender As Object, e As EventArgs) Handles Button29.Click
        If ComboBox7.Text = "" Or ComboBox1.Text = "" Then
            MsgBox("季節與品牌沒有選擇")
        Else
            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "SELECT TOP (1) MW編號 FROM MINI_WALL_控制表 GROUP BY MW編號 ORDER BY MW編號 DESC"
            cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then : TextBox1.Text = dr("MW編號").ToString : Else : TextBox1.Text = "MW00000000" : End If
            conn.Close()
            Dim NUM1 As Integer
            NUM1 = Double.Parse(Strings.Right(TextBox1.Text, 8)) + 1
            If NUM1 < 10 Then : TextBox1.Text = "MW" & "0000000" & NUM1
            ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox1.Text = "MW" & "000000" & NUM1
            ElseIf NUM1 > 99 And NUM1 < 1000 Then : TextBox1.Text = "MW" & "00000" & NUM1
            ElseIf NUM1 > 999 And NUM1 < 10000 Then : TextBox1.Text = "MW" & "0000" & NUM1
            ElseIf NUM1 > 9999 And NUM1 < 100000 Then : TextBox1.Text = "MW" & "000" & NUM1
            ElseIf NUM1 > 99999 And NUM1 < 100000 Then : TextBox1.Text = "MW" & "00" & NUM1
            ElseIf NUM1 > 999999 And NUM1 < 1000000 Then : TextBox1.Text = "MW" & "0" & NUM1
            ElseIf NUM1 > 9999999 Then : TextBox1.Text = "MW" & NUM1 + 1
            End If

            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "INSERT INTO  MINI_WALL_控制表 (MW編號, 季節, 品牌) VALUES (N'" & TextBox1.Text & "', N'" & ComboBox7.Text & "', N'" & ComboBox1.Text & "')"
            cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
            MsgBox("MINI WALL主體準備完畢") : Set_清單1()
        End If
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        For i As Integer = 0 To DataGridView1.Rows.Count - 1 : DataGridView1.Rows(i).Cells("選擇").Value = True : Next i
    End Sub
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        For i As Integer = 0 To DataGridView1.Rows.Count - 1 : DataGridView1.Rows(i).Cells("選擇").Value = False : Next i
    End Sub
    Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
        For i As Integer = 0 To DataGridView2.Rows.Count - 1 : DataGridView2.Rows(i).Cells("選擇").Value = True : Next i
    End Sub
    Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        For i As Integer = 0 To DataGridView2.Rows.Count - 1 : DataGridView2.Rows(i).Cells("選擇").Value = False : Next i
    End Sub
    Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
        For i As Integer = 0 To DataGridView4.Rows.Count - 1 : DataGridView4.Rows(i).Cells("選擇").Value = True : Next i
    End Sub
    Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
        For i As Integer = 0 To DataGridView4.Rows.Count - 1 : DataGridView4.Rows(i).Cells("選擇").Value = False : Next i
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If AASS = "" Then
            MsgBox("沒有選擇楦頭")
        Else
            Dim DDFF As Boolean
            For i As Integer = 0 To DataGridView1.Rows.Count - 1
                DDFF = DataGridView1.Rows(i).Cells("選擇").Value = True
                If DDFF = True Then
                    Exit For
                ElseIf i = DataGridView1.Rows.Count - 1 And DDFF = False Then
                    MsgBox("沒有選擇鞋樣素描") : Exit For
                End If
            Next i
            If DDFF = True Then
                If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
                SQL1 = "SELECT MW編號 FROM MINI_WALL_明細表 WHERE MW編號 LIKE N'" & TextBox1.Text & "' AND 楦頭編號 LIKE N'" & AASS & "'"
                cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
                If dr.Read() Then : Else
                    conn.Close()
                    If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
                    SQL1 = "INSERT INTO  MINI_WALL_明細表 (MW編號, 楦頭編號) VALUES (N'" & TextBox1.Text & "', N'" & AASS & "')"
                    cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
                End If
                conn.Close()

                For i As Integer = 0 To DataGridView1.Rows.Count - 1
                    資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
                    If DataGridView1.Rows(i).Cells("選擇").Value = True Then
                        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
                        SQL1 = "SELECT MW編號 FROM MINI_WALL_草圖明細 
                                WHERE MW編號 LIKE N'" & TextBox1.Text & "' AND 楦頭編號 LIKE N'" & AASS & "' AND 鞋樣素描圖編號 LIKE N'" & DataGridView1.Rows(i).Cells("鞋樣素描圖編號").Value & "'"
                        cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
                        If dr.Read() Then : Else
                            conn.Close()
                            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
                            SQL1 = "INSERT INTO  MINI_WALL_草圖明細 (MW編號, 楦頭編號, 鞋樣素描圖編號) 
                                    VALUES (N'" & TextBox1.Text & "', N'" & AASS & "', N'" & DataGridView1.Rows(i).Cells("鞋樣素描圖編號").Value & "')"
                            cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
                        End If
                        conn.Close()
                    Else : End If
                Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
                Set_清單2() : 清單3() : AASS = "" : DDFF = False
                MsgBox("新增完成")
            End If
        End If
    End Sub
    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        For i As Integer = 0 To DataGridView2.Rows.Count - 1
            資料數 = DataGridView2.Rows.Count : MyModule1.進度條()
            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "UPDATE MINI_WALL_明細表 SET  選擇 = N'" & DataGridView2.Rows(i).Cells("選擇").Value & "', 製造 = N'" & DataGridView2.Rows(i).Cells("製造").Value & "' 
                    WHERE (MW編號 LIKE N'" & TextBox1.Text & "' AND 楦頭編號 LIKE N'" & DataGridView2.Rows(i).Cells("楦頭編號").Value & "')"
            cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
        Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
        MsgBox("存檔完成")
    End Sub
    Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
        For i As Integer = 0 To DataGridView4.Rows.Count - 1
            資料數 = DataGridView4.Rows.Count : MyModule1.進度條()
            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "UPDATE  MINI_WALL_草圖明細 SET  選擇 = N'" & DataGridView4.Rows(i).Cells("選擇").Value & "' 
                    WHERE (MW編號 LIKE N'" & TextBox1.Text & "' AND 鞋樣素描圖編號 LIKE N'" & DataGridView4.Rows(i).Cells("鞋樣素描圖編號").Value & "')"
            cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
        Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
        MsgBox("存檔完成")
    End Sub
    Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
        Dim aa As MsgBoxResult
        aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
        If aa = MsgBoxResult.Ok Then
            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "DELETE FROM MINI_WALL_控制表 WHERE (MW編號 LIKE N'" & TextBox1.Text & "')"
            cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close()

            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "DELETE FROM MINI_WALL_明細表  WHERE (MW編號 LIKE N'" & TextBox1.Text & "')"
            cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close()

            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "DELETE FROM MINI_WALL_草圖明細 WHERE (MW編號 LIKE N'" & TextBox1.Text & "')"
            cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close()

            MsgBox("刪除完成") : Set_清單1() : Set_清單2() : 清單3()
        End If
    End Sub
    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Dim aa As MsgBoxResult
        aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
        If aa = MsgBoxResult.Ok Then
            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "DELETE FROM MINI_WALL_明細表  WHERE (MW編號 LIKE N'" & TextBox1.Text & "' AND 楦頭編號 LIKE N'" & TextBox2.Text & "')"
            cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close()

            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "DELETE FROM MINI_WALL_草圖明細 WHERE (MW編號 LIKE N'" & TextBox1.Text & "' AND 楦頭編號 LIKE N'" & TextBox2.Text & "')"
            cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close()

            MsgBox("刪除完成") : Set_清單2() : 清單3()
        End If
    End Sub
    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        Dim aa As MsgBoxResult
        aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
        If aa = MsgBoxResult.Ok Then
            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "DELETE FROM MINI_WALL_草圖明細 WHERE (MW編號 LIKE N'" & TextBox1.Text & "' AND 鞋樣素描圖編號 LIKE N'" & TextBox3.Text & "')"
            cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close()

            MsgBox("刪除完成") : Set_清單2() : 清單3()
        End If
    End Sub

    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        楦頭最大數 = 0 : 草圖最大數 = 0
        For i As Integer = 0 To DataGridView2.Rows.Count - 1
            If DataGridView2.Rows(i).Cells("選擇").Value = True Then
                楦頭最大數 += 1
                Set_DGV4載入前設定()
                SQL1 = "SELECT 鞋樣素描圖控制表.楦頭編號, 鞋樣素描圖控制表.模具編號, 鞋樣素描圖控制表.型體編號, 鞋樣素描圖控制表.型體名稱, 
                               鞋樣素描圖控制表.圖片, MINI_WALL_草圖明細.選擇, MINI_WALL_草圖明細.鞋樣素描圖編號
                        FROM MINI_WALL_草圖明細 LEFT OUTER JOIN 鞋樣素描圖控制表 ON MINI_WALL_草圖明細.鞋樣素描圖編號 = 鞋樣素描圖控制表.鞋樣素描圖編號
                        WHERE (MINI_WALL_草圖明細.MW編號 LIKE N'" & TextBox1.Text & "') AND (MINI_WALL_草圖明細.楦頭編號 LIKE N'" & DataGridView2.Rows(i).Cells("楦頭編號").Value & "')"
                Set_DGV4載入後設定() : Set_grid3()
                草圖計算數 = 0
                For ii As Integer = 0 To DataGridView4.Rows.Count - 1
                    If DataGridView4.Rows(ii).Cells("選擇").Value = True Then
                        草圖計算數 += 1
                    End If
                Next ii
                If 草圖計算數 > 草圖最大數 Then
                    草圖最大數 = 草圖計算數
                End If
            End If
        Next i
        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

        xlSheet.Cells(1, 1) = ComboBox1.Text & " - " & ComboBox7.Text & " - MINI WALL" : AA(xlApp, xlSheet) : N1 = 0
        For I As Integer = 0 To 草圖最大數 - 1
            xlSheet.Cells(10 + N1, 1) = "Sketch" : xlSheet.Cells(11 + N1, 1) = "STYLE #" : xlSheet.Cells(12 + N1, 1) = "STYLE NAME"
            xlSheet.Cells(13 + N1, 1) = "LAST #" : xlSheet.Cells(14 + N1, 1) = "OUTSOLE #"
            BB(xlApp, xlSheet) : JJ(xlApp, xlSheet)
            N1 += 5
        Next
        N2 = 0
        For i As Integer = 0 To DataGridView2.Rows.Count - 1
            If DataGridView2.Rows(i).Cells("選擇").Value = True Then
                DD(xlApp, xlSheet)
                AASS = DataGridView2.Rows(i).Cells("楦頭編號").Value : 圖片導入1()
                If CheckBox1.Checked = True Then
                    xlSheet.Cells(3, 2 + N2) = DataGridView2.Rows(i).Cells("製造").Value
                End If
                xlSheet.Cells(8, 2 + N2) = DataGridView2.Rows(i).Cells("楦頭名").Value
                FF(xlApp, xlSheet)
                For ii As Integer = 0 To 999999999
                    If PictureBox1.Image Is Nothing Then
                    Else
                        CC(xlApp, xlSheet)
                        ii = 999999999
                    End If
                Next

                Set_DGV4載入前設定()
                SQL1 = "SELECT 鞋樣素描圖控制表.楦頭編號, 鞋樣素描圖控制表.模具編號, 鞋樣素描圖控制表.型體編號, 鞋樣素描圖控制表.型體名稱, 
                               鞋樣素描圖控制表.圖片, MINI_WALL_草圖明細.選擇, MINI_WALL_草圖明細.鞋樣素描圖編號
                        FROM MINI_WALL_草圖明細 LEFT OUTER JOIN 鞋樣素描圖控制表 ON MINI_WALL_草圖明細.鞋樣素描圖編號 = 鞋樣素描圖控制表.鞋樣素描圖編號
                        WHERE (MINI_WALL_草圖明細.MW編號 LIKE N'" & TextBox1.Text & "') AND (MINI_WALL_草圖明細.楦頭編號 LIKE N'" & DataGridView2.Rows(i).Cells("楦頭編號").Value & "')"
                Set_DGV4載入後設定() : Set_grid3()
                N1 = 0
                For ii As Integer = 0 To DataGridView4.Rows.Count - 1
                    If DataGridView4.Rows(ii).Cells("選擇").Value = True Then
                        SSDD = DataGridView4.Rows(ii).Cells("鞋樣素描圖編號").Value
                        圖片導入2()
                        xlSheet.Cells(11 + N1, 2 + N2) = DataGridView4.Rows(ii).Cells("型體編號").Value : xlSheet.Cells(12 + N1, 2 + N2) = DataGridView4.Rows(ii).Cells("型體名稱").Value
                        xlSheet.Cells(13 + N1, 2 + N2) = DataGridView4.Rows(ii).Cells("楦頭編號").Value : xlSheet.Cells(14 + N1, 2 + N2) = DataGridView4.Rows(ii).Cells("模具編號").Value
                        GG(xlApp, xlSheet)
                        For iii As Integer = 0 To 999999999
                            If PictureBox2.Image Is Nothing Then
                            Else
                                EE(xlApp, xlSheet)
                                iii = 999999999
                            End If
                        Next

                        N1 += 5
                    End If
                Next
                N2 += 2
            End If
        Next
        HH(xlApp, xlSheet)
        xlSheet.PageSetup.PrintArea = ""
        xlApp.Cells.Select()
        xlSheet.Range("B1").Select()
        xlApp.Application.WindowState = xlMinimized
        MsgBox("列印完成")

        PictureBox1.Image = Nothing : PictureBox2.Image = Nothing : DataGridView2.DataSource = Nothing : ds1.Clear() : DataGridView4.DataSource = Nothing : ds3.Clear()
    End Sub
    Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
        Return CType(xlBook.Worksheets.Add, Worksheet)
    End Function
    Private Sub RTFGRTFG()
        If N2 = 0 Then : 位置1 = "B6" : 位置3 = "C"
        ElseIf N2 = 2 Then : 位置1 = "D6" : 位置3 = "E" : ElseIf N2 = 4 Then : 位置1 = "F6" : 位置3 = "G" : ElseIf N2 = 6 Then : 位置1 = "H6" : 位置3 = "I"
        ElseIf N2 = 8 Then : 位置1 = "J6" : 位置3 = "K" : ElseIf N2 = 10 Then : 位置1 = "L6" : 位置3 = "M" : ElseIf N2 = 12 Then : 位置1 = "N6" : 位置3 = "O"
        ElseIf N2 = 14 Then : 位置1 = "P6" : 位置3 = "Q" : ElseIf N2 = 16 Then : 位置1 = "R6" : 位置3 = "S" : ElseIf N2 = 18 Then : 位置1 = "T6" : 位置3 = "U"
        ElseIf N2 = 20 Then : 位置1 = "V6" : 位置3 = "W" : ElseIf N2 = 22 Then : 位置1 = "X6" : 位置3 = "Y" : ElseIf N2 = 24 Then : 位置1 = "Z6" : 位置3 = "AA"
        ElseIf N2 = 26 Then : 位置1 = "AB6" : 位置3 = "AC" : ElseIf N2 = 28 Then : 位置1 = "AD6" : 位置3 = "AE" : ElseIf N2 = 30 Then : 位置1 = "AF6" : 位置3 = "AG"
        ElseIf N2 = 32 Then : 位置1 = "AH6" : 位置3 = "AI" : ElseIf N2 = 34 Then : 位置1 = "AJ6" : 位置3 = "AK" : ElseIf N2 = 36 Then : 位置1 = "AL6" : 位置3 = "AM"
        ElseIf N2 = 38 Then : 位置1 = "AN6" : 位置3 = "AO" : ElseIf N2 = 40 Then : 位置1 = "AP6" : 位置3 = "AQ" : ElseIf N2 = 42 Then : 位置1 = "AR6" : 位置3 = "AS"
        ElseIf N2 = 44 Then : 位置1 = "AT6" : 位置3 = "AU" : ElseIf N2 = 46 Then : 位置1 = "AV6" : 位置3 = "AW" : ElseIf N2 = 48 Then : 位置1 = "AX6" : 位置3 = "AY"
        ElseIf N2 = 50 Then : 位置1 = "AZ6" : 位置3 = "BA" : ElseIf N2 = 52 Then : 位置1 = "BB6" : 位置3 = "BC" : ElseIf N2 = 54 Then : 位置1 = "BD6" : 位置3 = "BE"
        ElseIf N2 = 56 Then : 位置1 = "BF6" : 位置3 = "BG" : ElseIf N2 = 58 Then : 位置1 = "BH6" : 位置3 = "BI" : ElseIf N2 = 60 Then : 位置1 = "BJ6" : 位置3 = "BK"
        ElseIf N2 = 62 Then : 位置1 = "BL6" : 位置3 = "BM" : ElseIf N2 = 64 Then : 位置1 = "BN6" : 位置3 = "BO" : ElseIf N2 = 66 Then : 位置1 = "BP6" : 位置3 = "BQ"
        ElseIf N2 = 68 Then : 位置1 = "BR6" : 位置3 = "BS" : ElseIf N2 = 70 Then : 位置1 = "BT6" : 位置3 = "BU" : ElseIf N2 = 72 Then : 位置1 = "BV6" : 位置3 = "BW"
        ElseIf N2 = 74 Then : 位置1 = "BX6" : 位置3 = "BY" : ElseIf N2 = 76 Then : 位置1 = "BZ6" : 位置3 = "CA" : ElseIf N2 = 78 Then : 位置1 = "CB6" : 位置3 = "CC"
        ElseIf N2 = 80 Then : 位置1 = "DD6" : 位置3 = "CE" : End If
        If N2 > 24 Then
            位置2 = Strings.Left(位置1, 2) & ":" & Strings.Left(位置1, 2) : 位置3 = Strings.Left(位置3, 2) & ":" & Strings.Left(位置3, 2) : 位置4 = Strings.Left(位置1, 2) & 10 + N1
            位置5 = Strings.Left(位置1, 2) & "6:" & Strings.Left(位置1, 2) & "9" : 位置6 = Strings.Left(位置1, 2) & 10 + N1 & ":" & Strings.Left(位置1, 2) & 14 + N1
            位置7 = "A1:" & Strings.Left(位置3, 2) & 1 : 位置8 = "B3:" & Strings.Left(位置1, 2) & 3 : 位置9 = "A6:" & Strings.Left(位置3, 2) & 5 * 草圖最大數 + 9
        ElseIf N2 = 24 Then
            位置2 = Strings.Left(位置1, 1) & ":" & Strings.Left(位置1, 1) : 位置3 = Strings.Left(位置3, 2) & ":" & Strings.Left(位置3, 2) : 位置4 = Strings.Left(位置1, 1) & 10 + N1
            位置5 = Strings.Left(位置1, 1) & "6:" & Strings.Left(位置1, 1) & "9" : 位置6 = Strings.Left(位置1, 1) & 10 + N1 & ":" & Strings.Left(位置1, 1) & 14 + N1
            位置7 = "A1:" & Strings.Left(位置3, 2) & 1 : 位置8 = "B3:" & Strings.Left(位置1, 1) & 3 : 位置9 = "A6:" & Strings.Left(位置3, 2) & 5 * 草圖最大數 + 9
        ElseIf N2 < 24 Then
            位置2 = Strings.Left(位置1, 1) & ":" & Strings.Left(位置1, 1) : 位置3 = Strings.Left(位置3, 1) & ":" & Strings.Left(位置3, 1) : 位置4 = Strings.Left(位置1, 1) & 10 + N1
            位置5 = Strings.Left(位置1, 1) & "6:" & Strings.Left(位置1, 1) & "9" : 位置6 = Strings.Left(位置1, 1) & 10 + N1 & ":" & Strings.Left(位置1, 1) & 14 + N1
            位置7 = "A1:" & Strings.Left(位置3, 1) & 1 : 位置8 = "B3:" & Strings.Left(位置1, 1) & 3 : 位置9 = "A6:" & Strings.Left(位置3, 1) & 5 * 草圖最大數 + 9
        End If
    End Sub
    Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        xlSheet.Cells.Select()
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
            .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With

        xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 15
        xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 25 : xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 5
        xlSheet.Rows("3:3").Select : myExcel.Selection.RowHeight = 25 : xlSheet.Rows("4:5").Select : myExcel.Selection.RowHeight = 5
        xlSheet.Rows("6:6").Select : myExcel.Selection.RowHeight = 90 : xlSheet.Rows("7:7").Select : myExcel.Selection.RowHeight = 5
        xlSheet.Rows("9:9").Select : myExcel.Selection.RowHeight = 5
    End Sub
    Private Sub BB(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        xlSheet.Rows(10 + N1 & ":" & 10 + N1).Select : myExcel.Selection.RowHeight = 90
    End Sub
    Private Sub CC(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        RTFGRTFG()
        Clipboard.SetDataObject(PictureBox1.Image)
        Thread.Sleep(100) '延迟0.1秒
        xlSheet.Range(位置1).Select()
        myExcel.ActiveSheet.Paste
        If PictureBox1.Image.Height < PictureBox1.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 DD(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        RTFGRTFG()
        xlSheet.Columns(位置2).Select : myExcel.Selection.ColumnWidth = 15
        xlSheet.Columns(位置3).Select : myExcel.Selection.ColumnWidth = 1
    End Sub
    Private Sub EE(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        RTFGRTFG()
        Clipboard.SetDataObject(PictureBox2.Image)
        xlSheet.Cells(1, 1).Select
        Thread.Sleep(100) '延迟0.1秒
        xlSheet.Range(位置4).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 FF(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        RTFGRTFG()
        xlSheet.Range(位置5).Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
    End Sub
    Private Sub GG(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        RTFGRTFG()
        xlSheet.Range(位置6).Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
    End Sub
    Private Sub HH(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        N2 = 楦頭最大數 * 2 - 2
        RTFGRTFG()
        xlSheet.Cells.Select()
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
        xlSheet.Range(位置7).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
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        xlSheet.Range(位置8).Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        xlSheet.Range(位置9).Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        myExcel.ActiveWindow.DisplayGridlines = False
    End Sub
    Private Sub JJ(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        位置10 = "A" & 10 + N1 & ":A" & 14 + N1
        xlSheet.Range(位置10).Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
    End Sub
End Class