Option Strict Off
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
Public Class 倉儲控制表
    ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet : ReadOnly ds12 As New DataSet
    Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet
    Dim KKKK As String : Dim 比例 As Integer : Dim N1 As Integer
    Dim 首次開啟 As Boolean = False
    Dim N2 As Integer : Dim EDR As Integer = 0 : Dim ESTR As String
    Private Sub Set_清單()
        控制表_dgv.DataSource = Nothing : ds.Clear()
        控制表_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        控制表_dgv.ColumnHeadersHeight = 40
        控制表_dgv.AllowUserToAddRows = False
        控制表_dgv.RowTemplate.Height = 30
        If 登入人級別 = "00" Or 登入人級別 = "01" Or 登入人級別 = "02" Then : SQL5 = ", BB.成本" : Else : SQL5 = "" : End If

        SQL_倉儲控制表_控制表()
        da.Fill(ds) : 控制表_dgv.DataSource = ds.Tables(0) : conn.Close()

        控制表_dgv.Columns(0).FillWeight = 80 : 控制表_dgv.Columns(1).FillWeight = 140 : 控制表_dgv.Columns(2).FillWeight = 100 : 控制表_dgv.Columns(3).FillWeight = 350
        控制表_dgv.Columns(4).FillWeight = 200 : 控制表_dgv.Columns(5).FillWeight = 100 : 控制表_dgv.Columns(6).FillWeight = 80 : 控制表_dgv.Columns(7).FillWeight = 80
        控制表_dgv.Columns(8).FillWeight = 80 : 控制表_dgv.Columns(9).FillWeight = 80 : 控制表_dgv.Columns(10).FillWeight = 80 : 控制表_dgv.Columns(11).FillWeight = 100
        控制表_dgv.Columns(12).FillWeight = 50 : 控制表_dgv.Columns(13).Visible = False : 控制表_dgv.Columns(14).Visible = False : 控制表_dgv.Columns(15).Visible = False
        控制表_dgv.Columns(16).Visible = False

        If 登入人級別 = "00" Or 登入人級別 = "01" Or 登入人級別 = "02" Then
            控制表_dgv.Columns("成本").FillWeight = 70 : 控制表_dgv.Columns("成本").DefaultCellStyle.Format = "#,##0"
            控制表_dgv.Columns("成本").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
            控制表_dgv.Columns("成本").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        Else : End If

        控制表_dgv.Columns("庫存").DefaultCellStyle.Format = "#,##0" : 控制表_dgv.Columns("未入庫").DefaultCellStyle.Format = "#,##0"
        控制表_dgv.Columns("未出庫").DefaultCellStyle.Format = "#,##0" : 控制表_dgv.Columns("可領用").DefaultCellStyle.Format = "#,##0"
        控制表_dgv.Columns("最低庫存量").DefaultCellStyle.Format = "#,##0"
        控制表_dgv.Columns("庫存").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        控制表_dgv.Columns("未出庫").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        控制表_dgv.Columns("未入庫").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        控制表_dgv.Columns("可領用").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        控制表_dgv.Columns("最低庫存量").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        控制表_dgv.Columns("庫存").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        控制表_dgv.Columns("未出庫").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        控制表_dgv.Columns("未入庫").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        控制表_dgv.Columns("可領用").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        控制表_dgv.Columns("最低庫存量").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter

        資料筆數_tb.Text = 控制表_dgv.Rows.Count : 跑馬燈_tb.Text = ""

        For i As Integer = 0 To 控制表_dgv.Rows.Count - 1
            資料數 = 控制表_dgv.Rows.Count : MyModule1.進度條()
            If 控制表_dgv("倉名", i).Value.ToString = "" Then
                If 控制表_dgv("倉名1", i).Value.ToString <> "" Then
                    控制表_dgv("倉名", i).Value = 控制表_dgv("倉名1", i).Value.ToString
                ElseIf 控制表_dgv("倉名2", i).Value.ToString <> "" Then
                    控制表_dgv("倉名", i).Value = 控制表_dgv("倉名2", i).Value.ToString
                ElseIf 控制表_dgv("倉名3", i).Value.ToString <> "" Then
                    控制表_dgv("倉名", i).Value = 控制表_dgv("倉名3", i).Value.ToString
                End If
            End If

            If 控制表_dgv("庫存", i).Value.ToString = "" Then : 控制表_dgv("庫存", i).Value = 0 : End If
            If 控制表_dgv("未入庫", i).Value.ToString = "" Then : 控制表_dgv("未入庫", i).Value = 0 : End If
            If 控制表_dgv("未出庫", i).Value.ToString = "" Then : 控制表_dgv("未出庫", i).Value = 0 : End If
            If 控制表_dgv("可領用", i).Value.ToString = "" Then : 控制表_dgv("可領用", i).Value = 0 : End If

            If 控制表_dgv("倉名", i).Value.ToString <> "" And Val(控制表_dgv("庫存", i).Value) - Val(控制表_dgv("未出庫", i).Value) + Val(控制表_dgv("未入庫", i).Value) = 0 Then
                控制表_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow : End If
            控制表_dgv("可領用", i).Value = 控制表_dgv("庫存", i).Value + 控制表_dgv("未入庫", i).Value - 控制表_dgv("未出庫", i).Value
            If 控制表_dgv("可領用", i).Value.ToString = "0" Then : 控制表_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightPink : End If

            Dim myco2 As DataGridViewImageColumn = 控制表_dgv.Columns("庫存比例")
            myco2.ImageLayout = DataGridViewImageCellLayout.Zoom
            '-------------------------背景顏色----------------------------------------------------------------------------------------------------------------------------------------
            If Val(控制表_dgv("庫存", i).Value) + Val(控制表_dgv("未入庫", i).Value) - Val(控制表_dgv("未出庫", i).Value) = 0 Then
                控制表_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightPink
            ElseIf Val(控制表_dgv("庫存", i).Value) = 0 And (Val(控制表_dgv("未入庫", i).Value) <> 0 Or Val(控制表_dgv("未出庫", i).Value) <> 0) Then
                控制表_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow
            ElseIf Val(控制表_dgv("庫存", i).Value) + Val(控制表_dgv("未入庫", i).Value) - Val(控制表_dgv("未出庫", i).Value) <> 0 Then
                控制表_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White
            End If
            '-------------------------跑馬燈----------------------------------------------------------------------------------------------------------------------------------------
            If 控制表_dgv.Rows(i).Cells("物料狀態").Value = "0" Then
                跑馬燈_tb.Text = 跑馬燈_tb.Text & 控制表_dgv.Rows(i).Cells("料號").Value & "-" & 控制表_dgv.Rows(i).Cells("品名").Value &
                                     "-" & 控制表_dgv.Rows(i).Cells("訂製").Value & " - 數量為 : " & String.Format(Val(控制表_dgv.Rows(i).Cells("可領用").Value), "#,##0") &
                                     "_ 請注意重點銷售 --------"
            End If
            Timer1.Interval = 250 : Timer1.Enabled = True
            '-------------------------視覺百分比進度條----------------------------------------------------------------------------------------------------------------------------------------
            If 控制表_dgv.Rows(i).Cells("最低庫存量").Value = 0 Then
                If 控制表_dgv.Rows(i).Cells("可領用").Value = 0 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._000
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 1 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._001
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 2 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._002
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 3 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._003
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 4 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._004
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 5 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._005
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 6 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._006
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 7 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._007
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 8 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._008
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 9 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._009
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 10 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._010
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 11 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._011
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 12 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._012
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 13 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._013
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 14 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._014
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 15 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._015
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 16 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._016
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 17 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._017
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 18 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._018
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 19 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._019
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 20 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._020
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 21 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._021
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 22 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._022
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 23 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._023
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 24 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._024
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 25 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._025
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 26 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._026
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 27 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._027
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 28 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._028
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 29 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._029
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 30 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._030
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 31 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._031
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 32 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._032
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 33 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._033
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 34 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._034
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 35 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._035
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 36 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._036
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 37 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._037
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 38 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._038
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 39 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._039
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 40 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._040
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 41 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._041
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 42 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._042
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 43 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._043
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 44 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._044
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 45 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._045
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 46 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._046
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 47 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._047
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 48 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._048
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 49 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._049
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 50 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._050
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 51 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._051
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 52 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._052
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 53 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._053
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 54 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._054
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 55 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._055
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 56 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._056
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 57 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._057
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 58 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._058
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 59 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._059
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 60 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._060
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 61 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._061
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 62 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._062
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 63 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._063
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 64 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._064
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 65 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._065
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 66 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._066
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 67 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._067
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 68 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._068
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 69 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._069
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 70 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._070
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 71 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._071
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 72 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._072
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 73 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._073
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 74 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._074
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 75 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._075
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 76 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._076
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 77 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._077
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 78 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._078
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 79 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._079
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 80 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._080
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 81 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._081
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 82 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._082
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 83 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._083
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 84 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._084
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 85 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._085
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 86 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._086
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 87 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._087
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 88 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._088
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 89 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._089
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 90 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._090
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 91 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._091
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 92 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._092
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 93 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._093
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 94 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._094
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 95 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._095
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 96 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._096
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 97 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._097
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 98 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._098
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value = 99 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._099
                ElseIf 控制表_dgv.Rows(i).Cells("可領用").Value >= 100 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._100 : End If
            Else
                比例 = 控制表_dgv.Rows(i).Cells("可領用").Value / (控制表_dgv.Rows(i).Cells("最低庫存量").Value * 10) * 100
                If 比例 > 100 Then : 比例 = 100 : End If
                If 比例 = 0 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._000 : ElseIf 比例 = 1 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._001
                ElseIf 比例 = 2 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._002 : ElseIf 比例 = 3 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._003
                ElseIf 比例 = 4 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._004 : ElseIf 比例 = 5 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._005
                ElseIf 比例 = 6 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._006 : ElseIf 比例 = 7 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._007
                ElseIf 比例 = 8 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._008 : ElseIf 比例 = 9 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._009
                ElseIf 比例 = 10 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._010 : ElseIf 比例 = 11 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._011
                ElseIf 比例 = 12 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._012 : ElseIf 比例 = 13 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._013
                ElseIf 比例 = 14 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._014 : ElseIf 比例 = 15 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._015
                ElseIf 比例 = 16 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._016 : ElseIf 比例 = 17 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._017
                ElseIf 比例 = 18 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._018 : ElseIf 比例 = 19 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._019
                ElseIf 比例 = 20 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._020 : ElseIf 比例 = 21 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._021
                ElseIf 比例 = 22 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._022 : ElseIf 比例 = 23 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._023
                ElseIf 比例 = 24 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._024 : ElseIf 比例 = 25 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._025
                ElseIf 比例 = 26 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._026 : ElseIf 比例 = 27 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._027
                ElseIf 比例 = 28 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._028 : ElseIf 比例 = 29 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._029
                ElseIf 比例 = 30 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._030 : ElseIf 比例 = 31 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._031
                ElseIf 比例 = 32 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._032 : ElseIf 比例 = 33 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._033
                ElseIf 比例 = 34 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._034 : ElseIf 比例 = 35 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._035
                ElseIf 比例 = 36 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._036 : ElseIf 比例 = 37 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._037
                ElseIf 比例 = 38 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._038 : ElseIf 比例 = 39 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._039
                ElseIf 比例 = 40 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._040 : ElseIf 比例 = 41 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._041
                ElseIf 比例 = 42 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._042 : ElseIf 比例 = 43 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._043
                ElseIf 比例 = 44 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._044 : ElseIf 比例 = 45 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._045
                ElseIf 比例 = 46 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._046 : ElseIf 比例 = 47 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._047
                ElseIf 比例 = 48 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._048 : ElseIf 比例 = 49 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._049
                ElseIf 比例 = 50 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._050 : ElseIf 比例 = 51 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._051
                ElseIf 比例 = 52 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._052 : ElseIf 比例 = 53 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._053
                ElseIf 比例 = 54 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._054 : ElseIf 比例 = 55 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._055
                ElseIf 比例 = 56 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._056 : ElseIf 比例 = 57 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._057
                ElseIf 比例 = 58 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._058 : ElseIf 比例 = 59 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._059
                ElseIf 比例 = 60 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._060 : ElseIf 比例 = 61 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._061
                ElseIf 比例 = 62 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._062 : ElseIf 比例 = 63 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._063
                ElseIf 比例 = 64 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._064 : ElseIf 比例 = 65 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._065
                ElseIf 比例 = 66 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._066 : ElseIf 比例 = 67 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._067
                ElseIf 比例 = 68 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._068 : ElseIf 比例 = 69 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._069
                ElseIf 比例 = 70 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._070 : ElseIf 比例 = 71 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._071
                ElseIf 比例 = 72 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._072 : ElseIf 比例 = 73 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._073
                ElseIf 比例 = 74 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._074 : ElseIf 比例 = 75 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._075
                ElseIf 比例 = 76 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._076 : ElseIf 比例 = 77 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._077
                ElseIf 比例 = 78 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._078 : ElseIf 比例 = 79 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._079
                ElseIf 比例 = 80 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._080 : ElseIf 比例 = 81 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._081
                ElseIf 比例 = 82 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._082 : ElseIf 比例 = 83 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._083
                ElseIf 比例 = 84 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._084 : ElseIf 比例 = 85 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._085
                ElseIf 比例 = 86 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._086 : ElseIf 比例 = 87 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._087
                ElseIf 比例 = 88 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._088 : ElseIf 比例 = 89 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._089
                ElseIf 比例 = 90 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._090 : ElseIf 比例 = 91 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._091
                ElseIf 比例 = 92 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._092 : ElseIf 比例 = 93 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._093
                ElseIf 比例 = 94 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._094 : ElseIf 比例 = 95 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._095
                ElseIf 比例 = 96 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._096 : ElseIf 比例 = 97 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._097
                ElseIf 比例 = 98 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._098 : ElseIf 比例 = 99 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._099
                ElseIf 比例 >= 100 Then : 控制表_dgv.Rows(i).Cells("庫存比例").Value = My.Resources._100 : End If
            End If
        Next i : YD_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
    End Sub
    Private Sub Set_清單1()
        明細表_dgv.DataSource = Nothing : ds1.Clear()
        明細表_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        明細表_dgv.ColumnHeadersHeight = 40
        明細表_dgv.AllowUserToAddRows = False

        If 小間距_ch.Checked = False And 中間距_ch.Checked = False And 大間距_ch.Checked = True Then
            明細表_dgv.RowTemplate.Height = 95
        ElseIf 小間距_ch.Checked = False And 中間距_ch.Checked = True And 大間距_ch.Checked = False Then
            明細表_dgv.RowTemplate.Height = 60
        ElseIf 小間距_ch.Checked = True And 中間距_ch.Checked = False And 大間距_ch.Checked = False Then
            明細表_dgv.RowTemplate.Height = 25
        End If

        PA20 = 料號_tb.Text : PA19 = 訂製_tb.Text : PA18 = 狀態_tb.Text : PA17 = 倉庫_tb.Text
        SQL_倉儲控制表_明細()
        da.Fill(ds1) : 明細表_dgv.DataSource = ds1.Tables(0) : conn.Close()

        明細表_dgv.Columns(0).FillWeight = 150 : 明細表_dgv.Columns(1).FillWeight = 150 : 明細表_dgv.Columns(2).FillWeight = 100 : 明細表_dgv.Columns(3).FillWeight = 50
        明細表_dgv.Columns(4).FillWeight = 50 : 明細表_dgv.Columns(5).FillWeight = 200 : 明細表_dgv.Columns(6).FillWeight = 100 : 明細表_dgv.Columns(7).FillWeight = 100
        明細表_dgv.Columns(8).FillWeight = 100 : 明細表_dgv.Columns(9).FillWeight = 100 : 明細表_dgv.Columns(10).FillWeight = 100 : 明細表_dgv.Columns(11).FillWeight = 100
        明細表_dgv.Columns(12).Visible = False : 明細表_dgv.Columns(13).Visible = False : 明細表_dgv.Columns(14).Visible = False : 明細表_dgv.Columns(15).Visible = False
        明細表_dgv.Columns(16).Visible = False : 明細表_dgv.Columns(17).Visible = False : 明細表_dgv.Columns(18).FillWeight = 100

        明細表_dgv.Columns("入庫").DefaultCellStyle.Format = "#,##0" : 明細表_dgv.Columns("出庫").DefaultCellStyle.Format = "#,##0"
        明細表_dgv.Columns("入庫").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        明細表_dgv.Columns("入庫").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        明細表_dgv.Columns("出庫").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        明細表_dgv.Columns("出庫").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter

        明細表_dgv.Columns(0).ReadOnly = True : 明細表_dgv.Columns(1).ReadOnly = True : 明細表_dgv.Columns(2).ReadOnly = True : 明細表_dgv.Columns(3).ReadOnly = True
        明細表_dgv.Columns(4).ReadOnly = True : 明細表_dgv.Columns(5).ReadOnly = True : 明細表_dgv.Columns(6).ReadOnly = True : 明細表_dgv.Columns(7).ReadOnly = True
        明細表_dgv.Columns(8).ReadOnly = True

        資料筆數1_tb.Text = 明細表_dgv.Rows.Count
    End Sub
    Private Sub 指定倉庫_cb_下拉表單資料載入()
        SQL_倉名_下拉清單() : 指定倉庫_cb.Items.Clear()
        指定倉庫_cb.Items.Add("") : While (dr.Read()) : 指定倉庫_cb.Items.Add(dr("倉名")) : End While : conn.Close()
    End Sub
    Private Sub 倉儲狀態_cb_下拉表單資料載入()
        SQL_倉儲狀態_下拉清單() : 倉儲狀態_cb.Items.Clear()
        倉儲狀態_cb.Items.Add("") : While (dr.Read()) : 倉儲狀態_cb.Items.Add(dr("狀態")) : End While : conn.Close()
    End Sub
    Private Sub 狀態_cb_下拉表單資料載入()
        SQL_狀態_下拉清單() : 狀態_ch.Items.Clear()
        狀態_ch.Items.Add("") : While (dr.Read()) : 狀態_ch.Items.Add(dr("狀態")) : End While : conn.Close()
    End Sub
    Private Sub 倉儲控制表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = YD_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
        小間距_ch.Checked = True : 不顯示歸零_ch.Checked = True
        首次開啟 = False
        指定倉庫_cb_下拉表單資料載入() : 倉儲狀態_cb_下拉表單資料載入() : 狀態_cb_下拉表單資料載入() : Set_清單() : 首次開啟 = True '--------------------資料讀取
        If CC(52) = False Then
            刪除_bt.Enabled = False : 新增_bt.Enabled = False
        End If
        If YD_ERP_SYS.Size.Width > 1440 And YD_ERP_SYS.Size.Height > 900 Then
            字體_NUD.Value = 9
        ElseIf YD_ERP_SYS.Size.Width <= 1440 And YD_ERP_SYS.Size.Height <= 900 Then
            字體_NUD.Value = 7.6
        End If
    End Sub
    Private Sub 倉儲控制表_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
        If YD_ERP_SYS.Size.Width > 1440 And YD_ERP_SYS.Size.Height > 900 Then
            字體_NUD.Value = 9
        ElseIf YD_ERP_SYS.Size.Width <= 1440 And YD_ERP_SYS.Size.Height <= 900 Then
            字體_NUD.Value = 7.6
        End If
    End Sub
    Function 文字旋轉(ByVal s As String, ByVal v As Integer) As String
        '--- S=目標字串， V=捲動次數（ +v 右捲, -v 左捲）---
        文字旋轉 = Mid(s & s & s, Len(s) - (v Mod Len(s)) + 1, Len(s))
    End Function
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If 跑馬燈_tb.Text = "" Then
            Timer1.Enabled = False
        Else
            跑馬燈_tb.Text = 文字旋轉(跑馬燈_tb.Text, -1)
        End If
    End Sub
    Private Sub 控制表_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 控制表_dgv.CellEnter
        If 首次開啟 = True Then
            If e.RowIndex = -1 Then : Else
                料號_tb.Text = 控制表_dgv("料號", e.RowIndex).Value.ToString : 訂製_tb.Text = 控制表_dgv("訂製", e.RowIndex).Value.ToString
                品名_tb.Text = 控制表_dgv("品名", e.RowIndex).Value.ToString : 狀態_tb.Text = 控制表_dgv("狀態", e.RowIndex).Value.ToString
                倉庫_tb.Text = 控制表_dgv("倉名", e.RowIndex).Value.ToString

                Set_清單1()
                物料圖_pb.Image = Nothing : PA1 = 料號_tb.Text : SQL_物料檔案_是否有圖()
                If dr.Read() Then
                    If dr("是否有圖") = True Then
                        物料圖_pb.BackgroundImage = Nothing
                        PA = 料號_tb.Text : SQL_物料圖庫_圖片顯示() '--------------------圖片顯示
                        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)
                            物料圖_pb.Image = Bitmap.FromStream(oStream)
                        End While
                        conn.Close()
                        物料圖_pb.SizeMode = 4
                    Else
                        物料圖_pb.BackgroundImage = My.Resources.底圖1 : 物料圖_pb.BackgroundImageLayout = 3
                        物料圖_pb.Image = Nothing
                    End If
                End If : conn.Close()
            End If
        End If
    End Sub
    Private Sub 明細表_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 明細表_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            執行單號_tb.Text = 明細表_dgv("執行單號", e.RowIndex).Value.ToString
            採購流水_tb.Text = 明細表_dgv("採購流水", e.RowIndex).Value.ToString
            採購單_tb.Text = 明細表_dgv("採購單號", e.RowIndex).Value.ToString
            倉級_tb.Text = 明細表_dgv("倉級", e.RowIndex).Value.ToString
            倉名編號_tb.Text = 明細表_dgv("倉名編號", e.RowIndex).Value.ToString
            料號1_tb.Text = 明細表_dgv("料號", e.RowIndex).Value.ToString
            物料狀態_tb.Text = 明細表_dgv("物料狀態", e.RowIndex).Value.ToString
            訂製狀態_tb.Text = 明細表_dgv("訂製狀態", e.RowIndex).Value.ToString
            倉儲流水_tb.Text = 明細表_dgv("資料流水號", e.RowIndex).Value.ToString
            補單日_dtp.Value = 明細表_dgv("申請日期", e.RowIndex).Value
            備註_tb.Text = 明細表_dgv("備註", e.RowIndex).Value
        End If
    End Sub
    Private Sub 控制表_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 控制表_dgv.RowPostPaint
        Dim linePen As New Pen(Color.Blue, 2)
        If e.RowIndex = 控制表_dgv.Rows.Count - 1 Then : Exit Sub : Else
            If 控制表_dgv("供應商", e.RowIndex).Value.ToString <> 控制表_dgv("供應商", e.RowIndex + 1).Value.ToString Then
                Dim startX As Integer = IIf(控制表_dgv.RowHeadersVisible, 控制表_dgv.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                Dim endX As Integer = startX + 控制表_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 控制表_dgv.HorizontalScrollingOffset
                e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
            End If
        End If
        For i As Integer = 0 To 控制表_dgv.Rows.Count - 1
            If Val(控制表_dgv("庫存", i).Value) + Val(控制表_dgv("未入庫", i).Value) - Val(控制表_dgv("未出庫", i).Value) = 0 Then
                控制表_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightPink
            ElseIf Val(控制表_dgv("庫存", i).Value) = 0 And (Val(控制表_dgv("未入庫", i).Value) <> 0 Or Val(控制表_dgv("未出庫", i).Value) <> 0) Then
                控制表_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow
            ElseIf Val(控制表_dgv("庫存", i).Value) + Val(控制表_dgv("未入庫", i).Value) - Val(控制表_dgv("未出庫", i).Value) <> 0 Then
                控制表_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White
            End If
        Next
    End Sub
    Private Sub 明細表_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 明細表_dgv.RowPostPaint
        Dim linePen As New Pen(Color.Blue, 2)
        If e.RowIndex = 明細表_dgv.Rows.Count - 1 Then : Exit Sub : Else
            If 明細表_dgv(1, e.RowIndex).Value.ToString <> 明細表_dgv(1, e.RowIndex + 1).Value.ToString Then
                Dim startX As Integer = IIf(明細表_dgv.RowHeadersVisible, 明細表_dgv.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                Dim endX As Integer = startX + 明細表_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 明細表_dgv.HorizontalScrollingOffset
                e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
            End If
        End If
    End Sub
    Private Sub 指定倉庫_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 指定倉庫_cb.SelectedIndexChanged
        Set_清單()
    End Sub
    Private Sub 倉儲狀態_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 倉儲狀態_cb.SelectedIndexChanged
        Set_清單()
    End Sub
    Private Sub 料號2_tb_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles 料號2_tb.KeyPress
        If e.KeyChar = Chr(13) Then : 查詢_bt.PerformClick() : End If
    End Sub
    Private Sub 清空_bt_Click(sender As Object, e As EventArgs) Handles 清空_bt.Click
        指定倉庫_cb_下拉表單資料載入() : 倉儲狀態_cb_下拉表單資料載入() : Set_清單()
    End Sub
    Private Sub 重新整理_tsm_Click(sender As Object, e As EventArgs) Handles 重新整理_tsm.Click
        指定倉庫_cb_下拉表單資料載入() : 倉儲狀態_cb_下拉表單資料載入() : Set_清單()
    End Sub
    Private Sub 窄間距_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 小間距_ch.Click
        小間距_ch.Checked = True : 中間距_ch.Checked = False : 大間距_ch.Checked = False
        Set_清單1()
    End Sub
    Private Sub 中間距_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 中間距_ch.Click
        小間距_ch.Checked = False : 中間距_ch.Checked = True : 大間距_ch.Checked = False
        Set_清單1()
    End Sub
    Private Sub 大間距_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 大間距_ch.Click
        小間距_ch.Checked = False : 中間距_ch.Checked = False : 大間距_ch.Checked = True
        Set_清單1()
    End Sub
    Private Sub 顯示歸零_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 不顯示歸零_ch.Click
        Set_清單()
    End Sub

    Private Shared Function NewMethod(xlBook As Microsoft.Office.Interop.Excel.Workbook) As Microsoft.Office.Interop.Excel.Worksheet
        Return CType(xlBook.Worksheets.Add, Microsoft.Office.Interop.Excel.Worksheet)
    End Function
    Private Sub 列印Excel_bt_Click(sender As Object, e As EventArgs) Handles 列印Excel_bt.Click
        xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
        xlApp.Visible = True : xlApp.DisplayAlerts = True
        xlApp.Application.WindowState = xlMaximized
        xlBook = xlApp.Workbooks.Add
        xlSheet = NewMethod(xlBook)
        xlBook.Activate() : xlSheet.Activate()

        xlSheet.Cells(1, 1) = "雅邸家具有限公司-倉儲控制表 " : xlSheet.Cells(2, 1) = "倉名" : xlSheet.Cells(2, 2) = "料號" : xlSheet.Cells(2, 3) = "供應商"
        xlSheet.Cells(2, 4) = "品名" : xlSheet.Cells(2, 5) = "訂製" : xlSheet.Cells(2, 6) = "狀態" : xlSheet.Cells(2, 7) = "庫存" : xlSheet.Cells(2, 8) = "備註"
        If 登入人級別 = "00" Or 登入人級別 = "01" Or 登入人級別 = "02" Then
            xlSheet.Cells(2, 9) = "成本"
        Else : End If
        For i As Integer = 0 To 控制表_dgv.Rows.Count - 1
            xlSheet.Cells(i + 3, 1) = 控制表_dgv.Rows(i).Cells("倉名").Value : xlSheet.Cells(i + 3, 2) = 控制表_dgv.Rows(i).Cells("料號").Value
            xlSheet.Cells(i + 3, 3) = 控制表_dgv.Rows(i).Cells("供應商").Value : xlSheet.Cells(i + 3, 4) = 控制表_dgv.Rows(i).Cells("品名").Value
            xlSheet.Cells(i + 3, 5) = 控制表_dgv.Rows(i).Cells("訂製").Value : xlSheet.Cells(i + 3, 6) = 控制表_dgv.Rows(i).Cells("狀態").Value
            xlSheet.Cells(i + 3, 7) = 控制表_dgv.Rows(i).Cells("庫存").Value
            If 登入人級別 = "00" Or 登入人級別 = "01" Or 登入人級別 = "02" Then
                xlSheet.Cells(i + 3, 9) = 控制表_dgv.Rows(i).Cells("成本").Value
            Else : End If
            N2 = i + 3
        Next i

        BB(xlApp, xlSheet)
        xlSheet.PageSetup.PrintArea = ""
        xlApp.Cells.Select()
        xlApp.Application.WindowState = xlMinimized
        MsgBox("列印完成!!!")
    End Sub
    Private Sub BB(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
        xlSheet.Cells.Select()
        xlSheet.Range("J18").Activate()
        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.Range("A1:C1").Select()
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 22 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        myExcel.Selection.Font.Bold = True

        xlSheet.Rows("2:2").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("A3:G125").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 = 8
        xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 10
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0
            .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With

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

        xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 30
        xlSheet.Columns("E:E").Select : myExcel.Selection.ColumnWidth = 20
        xlSheet.Columns("F:F").Select : myExcel.Selection.ColumnWidth = 8
        xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 4
        xlSheet.Columns("H:H").Select : myExcel.Selection.ColumnWidth = 30

        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("A1:G2").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

        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : 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

        xlSheet.Range("A3:H" & N2).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

        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : 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

        xlSheet.Rows("3:3").Select : myExcel.ActiveWindow.DisplayGridlines = False : myExcel.ActiveWindow.FreezePanes = True

        xlSheet.Range("A1:G1").Select() : xlSheet.Range("A1:H2").Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
        myExcel.Selection.Borders(xlEdgeBottom).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        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

        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : 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

        xlSheet.Range("A1:H1").Select()
        With myExcel.Selection : .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
            .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.UnMerge
        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
    End Sub
    Private Sub 字體_NUD_ValueChanged(sender As Object, e As EventArgs) Handles 字體_NUD.ValueChanged
        控制表_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
        明細表_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
    End Sub
    Private Sub Set_日期格式轉換()
        DTP = Strings.Format(補單日_dtp.Value, "yyyy/MM/dd") : DTP1 = Strings.Format(補單日_dtp.Value, "yyyyMMdd")
    End Sub
    Private Sub 新增_bt_Click(sender As Object, e As EventArgs) Handles 新增_bt.Click
        If 狀態_ch.Text = "" Or 入庫_nup.Value + 出庫_nup.Value = 0 Then
            MsgBox("請注意資料完整性!!")
        Else
            SQL_倉儲明細表_最後一筆資料()
            If dr.Read() Then : EDR = Double.Parse(Strings.Right(dr("資料流水號").ToString, 9)) : Else : EDR = 0 : End If
            conn.Close() : EDR += 1
            If EDR < 10 Then : ESTR = "WH" & "00000000" & EDR
            ElseIf EDR > 9 And EDR < 100 Then : ESTR = "WH" & "0000000" & EDR
            ElseIf EDR > 99 And EDR < 1000 Then : ESTR = "WH" & "000000" & EDR
            ElseIf EDR > 999 And EDR < 10000 Then : ESTR = "WH" & "00000" & EDR
            ElseIf EDR > 9999 And EDR < 100000 Then : ESTR = "WH" & "0000" & EDR
            ElseIf EDR > 99999 And EDR < 100000 Then : ESTR = "WH" & "000" & EDR
            ElseIf EDR > 999999 And EDR < 1000000 Then : ESTR = "WH" & "00" & EDR
            ElseIf EDR > 9999999 And EDR < 10000000 Then : ESTR = "WH" & "0" & EDR
            ElseIf EDR > 99999999 Then : ESTR = "WH" & EDR : End If

            Set_日期格式轉換()
            PA3 = ESTR : PA4 = 執行單號_tb.Text : PA5 = 倉級_tb.Text : PA6 = 倉名編號_tb.Text : PA2 = 料號1_tb.Text : NU1 = 入庫_nup.Value : NU2 = 出庫_nup.Value
            PA1 = "" : PA10 = 狀態_ch.Text : PA = 採購單_tb.Text : PA7 = 物料狀態_tb.Text : PA9 = gUserName : PA8 = 訂製狀態_tb.Text
            SQL_倉儲調整()
            MsgBox("調整帳務完成!!") : Set_清單() : Set_清單1()
        End If
    End Sub
    Private Sub 資料存檔_bt_Click(sender As Object, e As EventArgs) Handles 資料存檔_bt.Click
        If 倉儲流水_tb.Text = "" Then : MsgBox("請先選擇資料!!") : Else
            PA20 = 倉儲流水_tb.Text : PA19 = 備註_tb.Text : SQL_倉儲控制表_備註存檔() : Set_清單1() : MsgBox("備註存檔成功!!")
        End If
    End Sub
    Private Sub 刪除_bt_Click(sender As Object, e As EventArgs) Handles 刪除_bt.Click
        Dim aa1 As MsgBoxResult = MsgBox("請確定是否刪除資料?", MsgBoxStyle.OkCancel)
        If aa1 = MsgBoxResult.Ok Then
            PA20 = 倉儲流水_tb.Text : SQL_倉儲控制表_刪除明細() : Set_清單() : Set_清單1() : MsgBox("刪除成功!!")
        End If
    End Sub
    Private Sub 清空1_bt_Click(sender As Object, e As EventArgs) Handles 清空1_bt.Click
        料號2_tb.Text = "" : Set_清單() : Set_清單1()
    End Sub
    Private Sub 查詢_bt_Click(sender As Object, e As EventArgs) Handles 查詢_bt.Click
        Set_清單() : Set_清單1()
    End Sub
End Class