Option Strict Off
Imports System.Data.SqlClient
Imports System.IO
Public Class 量產生產進度表
    ReadOnly conn As New SqlConnection
    ReadOnly da As New SqlDataAdapter
    ReadOnly cmd As New SqlCommand
    ReadOnly ds As New DataSet
    Dim dr As SqlDataReader
    Dim xlApp As Microsoft.Office.Interop.Excel.Application
    Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
    Dim file_name As String = ""
    ReadOnly BB(3) As Boolean
    Private Sub Set_DGV1載入前設定()
        DataGridView1.DataSource = Nothing : ds.Clear()
        DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView1.ColumnHeadersHeight = 40
        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_訂單清單()
        Set_DGV1載入前設定()
        If PA = "" Then
            SQL1 = "SELECT  訂單明細表抬頭.下單日 AS 接單日, 訂單控制表.訂單流水號, 訂單控制表.客戶訂單號, 
                            訂單控制表.GOODBOX AS 型體名稱, 訂單控制表.型體號碼, 訂單控制表.年份季度, 訂單控制表.TVW AS 楦型, 
                            訂單控制表.APMA確認 AS 顏色, 訂單控制表.訂單數量, 訂單控制表.工廠回復交期 AS 最後交期, 訂單控制表.BUYER, 
                            訂單控制表.材質, 訂單控制表.東莞業務備註, 訂單控制表.LEATHER AS 手剪全套, 訂單控制表.LEA_Note AS 斬刀全套, 
                            訂單控制表.面料, 訂單控制表.副料, 訂單控制表.中底, 訂單控制表.鞋墊, 訂單控制表.大底, 訂單控制表.跟, 
                            訂單控制表.包裝確認時間 AS 包裝, 訂單控制表.裁斷時間 AS 裁斷, 訂單控制表.針車時間 AS 針車, 
                            訂單控制表.成型時間 AS 成形, 訂單控制表.驗貨時間 AS 驗貨, 訂單控制表.工廠進度表備註1 AS 驗貨結果, 
                            訂單控制表.工廠進度表備註2 AS 工廠備註, 訂單控制表.驗貨報告圖片
                    FROM    訂單控制表 LEFT OUTER JOIN
                            訂單明細表抬頭 ON 訂單控制表.客戶訂單號 = 訂單明細表抬頭.客戶訂單號 AND 
                            訂單控制表.訂單流水號 = 訂單明細表抬頭.訂單流水號
                    WHERE  (訂單控制表.CXL = 0 OR
                            訂單控制表.CXL IS NULL) AND (訂單控制表.訂單數量 - 訂單控制表.出貨數量 <> 0)
                    ORDER BY   訂單控制表.訂單流水號 DESC, 訂單控制表.客戶交期1, 訂單控制表.型體號碼, 顏色, 楦型"
        Else
            SQL1 = "SELECT  訂單明細表抬頭.下單日 AS 接單日, 訂單控制表.訂單流水號, 訂單控制表.客戶訂單號, 
                            訂單控制表.GOODBOX AS 型體名稱, 訂單控制表.型體號碼, 訂單控制表.年份季度, 訂單控制表.TVW AS 楦型, 
                            訂單控制表.APMA確認 AS 顏色, 訂單控制表.訂單數量, 訂單控制表.工廠回復交期 AS 最後交期, 訂單控制表.BUYER, 
                            訂單控制表.材質, 訂單控制表.東莞業務備註, 訂單控制表.LEATHER AS 手剪全套, 訂單控制表.LEA_Note AS 斬刀全套, 
                            訂單控制表.面料, 訂單控制表.副料, 訂單控制表.中底, 訂單控制表.鞋墊, 訂單控制表.大底, 訂單控制表.跟, 
                            訂單控制表.包裝確認時間 AS 包裝, 訂單控制表.裁斷時間 AS 裁斷, 訂單控制表.針車時間 AS 針車, 
                            訂單控制表.成型時間 AS 成形, 訂單控制表.驗貨時間 AS 驗貨, 訂單控制表.工廠進度表備註1 AS 驗貨結果, 
                            訂單控制表.工廠進度表備註2 AS 工廠備註, 訂單控制表.驗貨報告圖片
                    FROM    訂單控制表 LEFT OUTER JOIN
                            訂單明細表抬頭 ON 訂單控制表.客戶訂單號 = 訂單明細表抬頭.客戶訂單號 AND 
                            訂單控制表.訂單流水號 = 訂單明細表抬頭.訂單流水號
                    WHERE ((訂單控制表.CXL = 0 OR 訂單控制表.CXL IS NULL) AND (訂單控制表.訂單數量 - 訂單控制表.出貨數量 <> 0)) AND ((訂單控制表.訂單流水號 LIKE '%" & PA & "%') OR 
                           (訂單控制表.年份季度 LIKE '%" & PA & "%') OR (訂單控制表.客戶訂單號 LIKE '%" & PA & "%') OR (訂單控制表.型體號碼 LIKE '%" & PA & "%') OR 
                           (訂單控制表.APMA確認 LIKE '%" & PA & "%') OR (訂單控制表.TVW LIKE '%" & PA & "%') OR (訂單控制表.生產工廠 LIKE '%" & PA & "%') OR (訂單控制表.訂單種類 LIKE '%" & PA & "%'))
                    ORDER BY   訂單控制表.訂單流水號 DESC, 訂單控制表.客戶交期1, 訂單控制表.型體號碼, 顏色, 楦型"
        End If
        Set_DGV1載入後設定()
    End Sub
    Private Sub Set_grid()
        DataGridView1.Columns(0).Width = 80 : DataGridView1.Columns(1).Width = 120 : DataGridView1.Columns(2).Width = 85 : DataGridView1.Columns(3).Width = 105
        DataGridView1.Columns(4).Width = 100 : DataGridView1.Columns(5).Width = 90 : DataGridView1.Columns(6).Width = 50 : DataGridView1.Columns(7).Width = 80
        DataGridView1.Columns(8).Width = 70 : DataGridView1.Columns(9).Width = 80 : DataGridView1.Columns(10).Width = 120 : DataGridView1.Columns(11).Width = 60
        DataGridView1.Columns(12).Width = 626 : DataGridView1.Columns(13).Width = 100 : DataGridView1.Columns(14).Width = 100 : DataGridView1.Columns(15).Width = 127
        DataGridView1.Columns(16).Width = 127 : DataGridView1.Columns(17).Width = 127 : DataGridView1.Columns(18).Width = 127 : DataGridView1.Columns(19).Width = 126
        DataGridView1.Columns(20).Width = 126 : DataGridView1.Columns(21).Width = 126 : DataGridView1.Columns(22).Width = 120 : DataGridView1.Columns(23).Width = 120
        DataGridView1.Columns(24).Width = 120 : DataGridView1.Columns(25).Width = 120 : DataGridView1.Columns(26).Width = 120 : DataGridView1.Columns(27).Width = 286
        DataGridView1.Columns(28).Visible = False
        DataGridView1.Columns(8).DefaultCellStyle.Format = "#,##0"
        DataGridView1.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        DataGridView1.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
        '886
        If BB(0) = True And BB(1) = True And BB(2) = True And BB(3) = True Then
            DataGridView1.Columns(11).Visible = True : DataGridView1.Columns(12).Visible = True : DataGridView1.Columns(13).Visible = True : DataGridView1.Columns(14).Visible = True

            DataGridView1.Columns(15).Visible = False : DataGridView1.Columns(16).Visible = False : DataGridView1.Columns(17).Visible = False : DataGridView1.Columns(18).Visible = False
            DataGridView1.Columns(19).Visible = False : DataGridView1.Columns(20).Visible = False : DataGridView1.Columns(21).Visible = False : DataGridView1.Columns(22).Visible = False
            DataGridView1.Columns(23).Visible = False : DataGridView1.Columns(24).Visible = False : DataGridView1.Columns(25).Visible = False : DataGridView1.Columns(26).Visible = False
            DataGridView1.Columns(27).Visible = False
        ElseIf BB(0) = False And BB(1) = True And BB(2) = True And BB(3) = True Then
            DataGridView1.Columns(11).Visible = False : DataGridView1.Columns(12).Visible = False : DataGridView1.Columns(13).Visible = False : DataGridView1.Columns(14).Visible = False

            DataGridView1.Columns(15).Visible = True : DataGridView1.Columns(16).Visible = True : DataGridView1.Columns(17).Visible = True : DataGridView1.Columns(18).Visible = True
            DataGridView1.Columns(19).Visible = True : DataGridView1.Columns(20).Visible = True : DataGridView1.Columns(21).Visible = True

            DataGridView1.Columns(22).Visible = False : DataGridView1.Columns(23).Visible = False : DataGridView1.Columns(24).Visible = False : DataGridView1.Columns(25).Visible = False
            DataGridView1.Columns(26).Visible = False : DataGridView1.Columns(27).Visible = False
        ElseIf BB(0) = True And BB(1) = False And BB(2) = True And BB(3) = True Then
            DataGridView1.Columns(11).Visible = False : DataGridView1.Columns(12).Visible = False : DataGridView1.Columns(13).Visible = False : DataGridView1.Columns(14).Visible = False
            DataGridView1.Columns(15).Visible = False : DataGridView1.Columns(16).Visible = False : DataGridView1.Columns(17).Visible = False : DataGridView1.Columns(18).Visible = False
            DataGridView1.Columns(19).Visible = False : DataGridView1.Columns(20).Visible = False : DataGridView1.Columns(21).Visible = False

            DataGridView1.Columns(22).Visible = True : DataGridView1.Columns(23).Visible = True : DataGridView1.Columns(24).Visible = True : DataGridView1.Columns(25).Visible = True
            DataGridView1.Columns(26).Visible = True : DataGridView1.Columns(27).Visible = True
        End If
    End Sub
    Private Sub 量產生產進度表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
        BB(0) = True : BB(1) = True : BB(2) = True : BB(3) = True
        Button2.Enabled = False
        Set_訂單清單() : Set_grid()
    End Sub
    Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        If e.RowIndex = -1 Then : Else
            PictureBox1.Image = Nothing : conn.Close()
            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 WHERE 形體號 LIKE N'" & DataGridView1.Rows(e.RowIndex).Cells("型體號碼").Value & "'  AND 類別 LIKE N'設計圖'"
            cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then
                PictureBox1.Image = Nothing : conn.Close()
                If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
                SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 WHERE 形體號 LIKE N'" & DataGridView1.Rows(e.RowIndex).Cells("型體號碼").Value & "'  AND 類別 LIKE N'設計圖'"
                cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
                While dr.Read() = True
                    Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
                    Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
                End While
                conn.Close()
            Else
                PictureBox1.Image = Nothing : conn.Close()
                If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
                SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 WHERE 形體號 LIKE N'" & DataGridView1.Rows(e.RowIndex).Cells("型體號碼").Value & "'"
                cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
                If dr.Read() Then
                    PictureBox1.Image = Nothing : conn.Close()
                    If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
                    SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 WHERE 形體號 LIKE N'" & DataGridView1.Rows(e.RowIndex).Cells("型體號碼").Value & "'"
                    cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
                    While dr.Read() = True
                        Dim unused1 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
                        Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
                    End While
                    conn.Close()
                Else
                    PictureBox1.Image = Nothing : conn.Close()
                    If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
                    SQL1 = "SELECT 圖片 FROM 鞋樣素描圖控制表 WHERE 型體編號 LIKE N'" & DataGridView1.Rows(e.RowIndex).Cells("型體號碼").Value & "'"
                    cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
                    If dr.Read() Then
                        PictureBox1.Image = Nothing : conn.Close()
                        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
                        SQL1 = "SELECT 圖片 FROM 鞋樣素描圖控制表 WHERE 型體編號 LIKE N'" & DataGridView1.Rows(e.RowIndex).Cells("型體號碼").Value & "'"
                        cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
                        While dr.Read() = True
                            Dim unused2 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
                            Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
                        End While
                        conn.Close()
                    Else
                        conn.Close()
                    End If
                End If
            End If : PictureBox1.SizeMode = 4

            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "SELECT TOP(1) 驗貨報告 FROM 驗貨報告圖庫 WHERE 驗貨報告編號 LIKE '" & DataGridView1.Rows(e.RowIndex).Cells("驗貨報告圖片").Value & "'"
            cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            PictureBox2.Image = Nothing
            While dr.Read() = True
                Dim unused3 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("驗貨報告"), Byte())
                Dim oStream As New MemoryStream(bytes) : PictureBox2.Image = Bitmap.FromStream(oStream)
            End While
            conn.Close() : PictureBox2.SizeMode = 4
            驗貨報告 = DataGridView1.Rows(e.RowIndex).Cells("驗貨報告圖片").Value
        End If
    End Sub
    Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
        Dim linePen As New Pen(Color.Blue, 2)
        If e.RowIndex = DataGridView1.Rows.Count - 1 Then
            Exit Sub
        Else
            If DataGridView1(2, e.RowIndex).Value.ToString <> DataGridView1(2, e.RowIndex + 1).Value.ToString Then
                Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
                Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset
                e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
                Exit Sub
            End If
        End If
    End Sub
    Private Sub Button28_Click(sender As Object, e As EventArgs) Handles Button28.Click
        列印_生產進度表.Show()
    End Sub
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            file_name = OpenFileDialog1.FileName
        End If
        xlApp = CreateObject("Excel.Application")
        xlApp.DisplayAlerts = True
        xlApp.Visible = True
        xlApp.Workbooks.Open(file_name)
        xlSheet = xlApp.Worksheets(1) : xlSheet.Activate()

        For i As Integer = 4 To 99999
            TextBox1.Text = xlSheet.Cells(i, 4).value
            TextBox2.Text = xlSheet.Cells(i, 1).value : If TextBox2.Text = "" Then : Else : TextBox2.Text = Format(xlSheet.Cells(i, 1).value, "yyyy/MM/dd") : End If
            TextBox3.Text = xlSheet.Cells(i, 10).value : If TextBox3.Text = "" Then : Else : TextBox3.Text = Format(xlSheet.Cells(i, 10).value, "yyyy/MM/dd") : End If
            If TextBox1.Text <> "" Then
                If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
                SQL1 = "UPDATE 訂單控制表 Set LEATHER = N'" & xlSheet.Cells(i, 14).value & "', " &
                                            "LEA_Note = N'" & xlSheet.Cells(i, 15).value & "', " &
                                                "面料 = N'" & xlSheet.Cells(i, 16).value & "', " &
                                                "副料 = N'" & xlSheet.Cells(i, 17).value & "', " &
                                                "中底 = N'" & xlSheet.Cells(i, 18).value & "', " &
                                                "鞋墊 = N'" & xlSheet.Cells(i, 19).value & "', " &
                                                "大底 = N'" & xlSheet.Cells(i, 20).value & "', " &
                                                  "跟 = N'" & xlSheet.Cells(i, 21).value & "', " &
                                        "包裝確認時間 = N'" & xlSheet.Cells(i, 22).value & "', " &
                                            "裁斷時間 = N'" & xlSheet.Cells(i, 23).value & "', " &
                                            "針車時間 = N'" & xlSheet.Cells(i, 24).value & "', " &
                                            "成型時間 = N'" & xlSheet.Cells(i, 25).value & "', " &
                                            "驗貨時間 = N'" & xlSheet.Cells(i, 26).value & "', " &
                                     "工廠進度表備註1 = N'" & xlSheet.Cells(i, 27).value & "', " &
                                     "工廠進度表備註2 = N'" & xlSheet.Cells(i, 28).value & "' " &
                       "WHERE (客戶訂單號 LIKE N'" & xlSheet.Cells(i, 3).value & "') AND (GOODBOX LIKE N'" & xlSheet.Cells(i, 4).value & "') AND (APMA確認 LIKE N'" & xlSheet.Cells(i, 8).value & "') " &
                       "AND (TVW LIKE N'" & xlSheet.Cells(i, 7).value & "') AND (訂單數量 = " & xlSheet.Cells(i, 9).value & ")  AND (型體號碼 LIKE N'" & xlSheet.Cells(i, 5).value & "')"
                cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
            Else
                i = 99999
            End If
            TextBox6.Text = i
        Next

        xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing
        TextBox6.Text = ""
        MsgBox("資料導入完成")
        Set_訂單清單() : Set_grid()
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            file_name = OpenFileDialog1.FileName
        End If
        xlApp = CreateObject("Excel.Application")
        xlApp.DisplayAlerts = True
        xlApp.Visible = True
        xlApp.Workbooks.Open(file_name)
        xlSheet = xlApp.Worksheets(1) : xlSheet.Activate()

        For i As Integer = 4 To 99999
            TextBox1.Text = xlSheet.Cells(i, 4).value
            TextBox2.Text = xlSheet.Cells(i, 1).value : If TextBox2.Text = "" Then : Else : TextBox2.Text = Format(xlSheet.Cells(i, 1).value, "yyyy/MM/dd") : End If
            TextBox3.Text = xlSheet.Cells(i, 10).value : If TextBox3.Text = "" Then : Else : TextBox3.Text = Format(xlSheet.Cells(i, 10).value, "yyyy/MM/dd") : End If
            If TextBox1.Text <> "" Then
                If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
                SQL1 = "UPDATE 訂單控制表 Set 材質 = N'" & xlSheet.Cells(i, 12).value & "', " &
                                     "東莞業務備註 = N'" & xlSheet.Cells(i, 13).value & "',
                        WHERE (客戶訂單號 LIKE N'" & xlSheet.Cells(i, 3).value & "') AND (GOODBOX LIKE N'" & xlSheet.Cells(i, 4).value & "') AND (APMA確認 LIKE N'" & xlSheet.Cells(i, 8).value & "') AND 
                              (TVW LIKE N'" & xlSheet.Cells(i, 7).value & "') AND (訂單數量 = " & xlSheet.Cells(i, 9).value & ")  AND (型體號碼 LIKE N'" & xlSheet.Cells(i, 5).value & "')"
                cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
            Else
                i = 99999
            End If
            TextBox6.Text = i
        Next

        xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing
        TextBox6.Text = ""
        MsgBox("資料導入完成")
        Set_訂單清單() : Set_grid()
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Button2.Enabled = False : Button34.Enabled = True : Button35.Enabled = True
        BB(0) = True : BB(1) = True : BB(2) = True : BB(3) = True
        Set_grid()
    End Sub
    Private Sub Button34_Click(sender As Object, e As EventArgs) Handles Button34.Click
        Button2.Enabled = True : Button34.Enabled = False : Button35.Enabled = True
        BB(0) = False : BB(1) = True : BB(2) = True : BB(3) = True
        Set_grid()
    End Sub
    Private Sub Button35_Click(sender As Object, e As EventArgs) Handles Button35.Click
        Button2.Enabled = True : Button34.Enabled = True : Button35.Enabled = False
        BB(0) = True : BB(1) = False : BB(2) = True : BB(3) = True
        Set_grid()
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        PA = InputBox("請輸入要查詢的資料")
        Set_訂單清單() : Set_grid()
    End Sub
    Private Sub Button20_Click(sender As Object, e As EventArgs) Handles Button20.Click
        驗貨報告大圖.ShowDialog()
    End Sub
    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        PictureBox2.Image.RotateFlip(RotateFlipType.Rotate90FlipNone) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4
    End Sub
    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        PictureBox2.Image.RotateFlip(RotateFlipType.Rotate270FlipNone) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4
    End Sub
    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        PictureBox2.Image.RotateFlip(RotateFlipType.Rotate180FlipY) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4
    End Sub
    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        PictureBox2.Image.RotateFlip(RotateFlipType.Rotate180FlipX) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4
    End Sub
End Class