Option Strict Off
Imports System.IO
Public Class 採購單驗收
    Dim KKKJJ2 As String : Dim NUM1 As Integer : Dim EDR As Integer = 0 : Dim ESTR As String
    Dim TTYY As Boolean : Dim 新項次 As String : Dim KKK2 As String
    Public 變色 As Boolean : Dim 物料規格 As String
    Private Sub Set_核准採購清單()
        Dim ds3 As New DataSet : 已核准_dgv.DataSource = Nothing : ds3.Clear()
        已核准_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        已核准_dgv.ColumnHeadersHeight = 25
        已核准_dgv.AllowUserToAddRows = False
        SQL_建築物料來料驗收與指定入庫_已核准()
        da.Fill(ds3) : 已核准_dgv.DataSource = ds3.Tables(0) : conn.Close()
        For i As Integer = 0 To 20 : 已核准_dgv.Columns(i).Visible = False : Next
    End Sub
    Private Sub Set_核准採購明細()
        Dim ds4 As New DataSet : 明細_dgv.DataSource = Nothing : ds4.Clear()
        明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        明細_dgv.ColumnHeadersHeight = 25
        明細_dgv.AllowUserToAddRows = False
        If 小間距_ch.Checked = False And 中間距_ch.Checked = False And 大間距_ch.Checked = True Then : 明細_dgv.RowTemplate.Height = 65
        ElseIf 小間距_ch.Checked = False And 中間距_ch.Checked = True And 大間距_ch.Checked = False Then : 明細_dgv.RowTemplate.Height = 45
        ElseIf 小間距_ch.Checked = True And 中間距_ch.Checked = False And 大間距_ch.Checked = False Then : 明細_dgv.RowTemplate.Height = 25 : End If

        SQL_建築物料來料驗收與指定入庫_採購明細()
        da.Fill(ds4) : 明細_dgv.DataSource = ds4.Tables(0) : conn.Close()

        明細_dgv.Columns(0).Visible = False : 明細_dgv.Columns(1).FillWeight = 80 : 明細_dgv.Columns(3).FillWeight = 250 : 明細_dgv.Columns(4).FillWeight = 250 : 明細_dgv.Columns(2).FillWeight = 80
        明細_dgv.Columns(5).FillWeight = 150 : 明細_dgv.Columns(6).FillWeight = 90 : 明細_dgv.Columns(7).FillWeight = 90 : 明細_dgv.Columns(8).Visible = False
        明細_dgv.Columns(9).Visible = False : 明細_dgv.Columns(10).FillWeight = 80 : 明細_dgv.Columns(11).Visible = False : 明細_dgv.Columns(12).Visible = False
        明細_dgv.Columns(13).Visible = False : 明細_dgv.Columns(14).Visible = False : 明細_dgv.Columns(15).Visible = False : 明細_dgv.Columns("A2").Visible = False
        明細_dgv.Columns("A3").Visible = False : 明細_dgv.Columns("A4").Visible = False : 明細_dgv.Columns("A5").Visible = False : 明細_dgv.Columns("A6").Visible = False
        明細_dgv.Columns("A7").Visible = False : 明細_dgv.Columns("A8").Visible = False : 明細_dgv.Columns("規格庫編號").Visible = False : 明細_dgv.Columns("規格庫抬頭指定").Visible = False

        For Each columnIndex As Integer In {6, 8, 9}
            With 明細_dgv.Columns(columnIndex) : .DefaultCellStyle.Format = "#,##0"
                .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                .HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
            End With
        Next

        明細_dgv.Columns(1).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(10).ReadOnly = True

        If 低網速模式 = False Then
            明細_dgv.Columns(25).FillWeight = 80 : 明細_dgv.Columns(25).Visible = True
            Dim mycol As DataGridViewImageColumn = 明細_dgv.Columns("圖檔")
            mycol.ImageLayout = DataGridViewImageCellLayout.Zoom
        Else
            If 明細_dgv.Columns.Count = 26 Then
                明細_dgv.Columns(25).Visible = False
            End If
        End If
        新項次 = "00"
        For i As Integer = 0 To 明細_dgv.Rows.Count - 1
            NUM1 = Double.Parse(新項次) + 1
            If NUM1 < 10 Then : 新項次 = "0" & NUM1
            ElseIf NUM1 > 9 And NUM1 < 100 Then : 新項次 = NUM1
            End If
            明細_dgv.Rows(i).Cells("項次").Value = 新項次
            '-------------------------規格合併呈現----------------------------------------------------------------------------------------------------------------------------------------
            If i = 0 Then
                AAA1 = "" : AAA2 = "" : AAA3 = "" : AAA4 = "" : AAA5 = "" : AAA6 = "" : AAA7 = "" : AAA8 = ""
                PA3 = 明細_dgv.Rows(i).Cells("規格庫抬頭指定").Value
                SQL_規格庫抬頭讀取()
                If dr.Read() Then
                    AAA1 = dr("A1") : AAA2 = dr("A2") : AAA3 = dr("A3") : AAA4 = dr("A4") : AAA5 = dr("A5") : AAA6 = dr("A6") : AAA7 = dr("A7") : AAA8 = dr("A8")
                End If
                conn.Close()
            Else
                If 明細_dgv.Rows(i).Cells("規格庫抬頭指定").Value.ToString <> 明細_dgv.Rows(i - 1).Cells("規格庫抬頭指定").Value.ToString Then
                    AAA1 = "" : AAA2 = "" : AAA3 = "" : AAA4 = "" : AAA5 = "" : AAA6 = "" : AAA7 = "" : AAA8 = ""
                    PA3 = 明細_dgv.Rows(i).Cells("規格庫抬頭指定").Value
                    SQL_規格庫抬頭讀取()
                    If dr.Read() Then
                        AAA1 = dr("A1") : AAA2 = dr("A2") : AAA3 = dr("A3") : AAA4 = dr("A4") : AAA5 = dr("A5") : AAA6 = dr("A6") : AAA7 = dr("A7") : AAA8 = dr("A8")
                    End If
                    conn.Close()
                End If
            End If
            Dim ZA1, ZA2, ZA3, ZA4, ZA5, ZA6, ZA7, ZA8 As String : 物料規格 = ""
            If 詳細資料2_ch.Checked = True Then
                If 明細_dgv.Rows(i).Cells("規格").Value.ToString <> "" Then
                    ZA1 = AAA1 & "=" & 明細_dgv.Rows(i).Cells("規格").Value.ToString : 物料規格 = ZA1 : End If
                If 明細_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then : ZA2 = AAA2 & "=" & 明細_dgv.Rows(i).Cells("A2").Value
                    If 物料規格 = "" Then : 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If
                If 明細_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then : ZA3 = AAA3 & "=" & 明細_dgv.Rows(i).Cells("A3").Value
                    If 物料規格 = "" Then : 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If
                If 明細_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then : ZA4 = AAA4 & "=" & 明細_dgv.Rows(i).Cells("A4").Value
                    If 物料規格 = "" Then : 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If
                If 明細_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then : ZA5 = AAA5 & "=" & 明細_dgv.Rows(i).Cells("A5").Value
                    If 物料規格 = "" Then : 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If
                If 明細_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then : ZA6 = AAA6 & "=" & 明細_dgv.Rows(i).Cells("A6").Value
                    If 物料規格 = "" Then : 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If
                If 明細_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then : ZA7 = AAA7 & "=" & 明細_dgv.Rows(i).Cells("A7").Value
                    If 物料規格 = "" Then : 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If
                If 明細_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then : ZA8 = AAA8 & "=" & 明細_dgv.Rows(i).Cells("A8").Value
                    If 物料規格 = "" Then : 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If
            Else
                If 明細_dgv.Rows(i).Cells("規格").Value.ToString <> "" Then : ZA1 = 明細_dgv.Rows(i).Cells("規格").Value.ToString : 物料規格 = ZA1 : End If
                If 明細_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then
                    ZA2 = 明細_dgv.Rows(i).Cells("A2").Value : If 物料規格 = "" Then : 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If
                If 明細_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then
                    ZA3 = 明細_dgv.Rows(i).Cells("A3").Value : If 物料規格 = "" Then : 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If
                If 明細_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then
                    ZA4 = 明細_dgv.Rows(i).Cells("A4").Value : If 物料規格 = "" Then : 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If
                If 明細_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then
                    ZA5 = 明細_dgv.Rows(i).Cells("A5").Value : If 物料規格 = "" Then : 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If
                If 明細_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then
                    ZA6 = 明細_dgv.Rows(i).Cells("A6").Value : If 物料規格 = "" Then : 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If
                If 明細_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then
                    ZA7 = 明細_dgv.Rows(i).Cells("A7").Value : If 物料規格 = "" Then : 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If
                If 明細_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then
                    ZA8 = 明細_dgv.Rows(i).Cells("A8").Value : If 物料規格 = "" Then : 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If
            End If
            明細_dgv.Rows(i).Cells("規格").Value = 物料規格
        Next i
    End Sub
    Private Sub Set_準備指定入庫清單()
        Dim ds As New DataSet : 未入庫_dgv.DataSource = Nothing : ds.Clear()
        未入庫_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        未入庫_dgv.ColumnHeadersHeight = 25
        未入庫_dgv.AllowUserToAddRows = False
        If 小間距_ch.Checked = False And 中間距_ch.Checked = False And 大間距_ch.Checked = True Then : 未入庫_dgv.RowTemplate.Height = 65
        ElseIf 小間距_ch.Checked = False And 中間距_ch.Checked = True And 大間距_ch.Checked = False Then : 未入庫_dgv.RowTemplate.Height = 45
        ElseIf 小間距_ch.Checked = True And 中間距_ch.Checked = False And 大間距_ch.Checked = False Then : 未入庫_dgv.RowTemplate.Height = 25 : End If

        PA14 = KKKJJ2 : SQL_建築物料來料驗收與指定入庫_未入庫()
        da.Fill(ds) : 未入庫_dgv.DataSource = ds.Tables(0) : conn.Close()

        未入庫_dgv.Columns(0).FillWeight = 50 : 未入庫_dgv.Columns(1).FillWeight = 170 : 未入庫_dgv.Columns(3).FillWeight = 250 : 未入庫_dgv.Columns(4).FillWeight = 250
        未入庫_dgv.Columns(5).FillWeight = 250 : 未入庫_dgv.Columns(6).FillWeight = 90 : 未入庫_dgv.Columns(7).FillWeight = 90 : 未入庫_dgv.Columns(8).Visible = False
        未入庫_dgv.Columns(9).Visible = False : 未入庫_dgv.Columns(10).Visible = False : 未入庫_dgv.Columns(11).Visible = False : 未入庫_dgv.Columns(12).Visible = False
        未入庫_dgv.Columns(13).FillWeight = 80 : 未入庫_dgv.Columns(14).Visible = False : 未入庫_dgv.Columns(15).Visible = False : 未入庫_dgv.Columns("A2").Visible = False
        未入庫_dgv.Columns("A3").Visible = False : 未入庫_dgv.Columns("A4").Visible = False : 未入庫_dgv.Columns("A5").Visible = False : 未入庫_dgv.Columns("A6").Visible = False
        未入庫_dgv.Columns("A7").Visible = False : 未入庫_dgv.Columns("A8").Visible = False : 未入庫_dgv.Columns("規格庫編號").Visible = False : 未入庫_dgv.Columns("單價").Visible = False
        未入庫_dgv.Columns("規格庫抬頭指定").Visible = False : 未入庫_dgv.Columns(2).FillWeight = 100
        未入庫_dgv.Columns("乙方").Visible = False : 未入庫_dgv.Columns("甲方").Visible = False
        未入庫_dgv.Columns("立約日").Visible = False : 未入庫_dgv.Columns("序號").Visible = False

        未入庫_dgv.Columns(1).ReadOnly = True : 未入庫_dgv.Columns(3).ReadOnly = True : 未入庫_dgv.Columns(4).ReadOnly = True : 未入庫_dgv.Columns(5).ReadOnly = False
        未入庫_dgv.Columns(6).ReadOnly = True : 未入庫_dgv.Columns(7).ReadOnly = True : 未入庫_dgv.Columns(0).ReadOnly = False : 未入庫_dgv.Columns(12).ReadOnly = True
        未入庫_dgv.Columns(13).ReadOnly = True

        未入庫_dgv.Columns(6).DefaultCellStyle.Format = "#,##0"
        未入庫_dgv.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        未入庫_dgv.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        For i As Integer = 0 To 未入庫_dgv.Rows.Count - 1 : 未入庫_dgv.Rows(i).Cells("選擇").Value = False : Next i
        If 低網速模式 = False Then
            未入庫_dgv.Columns(29).FillWeight = 80 : 未入庫_dgv.Columns(29).Visible = True
            Dim mycol As DataGridViewImageColumn = 未入庫_dgv.Columns("圖檔")
            mycol.ImageLayout = DataGridViewImageCellLayout.Zoom
        Else
            If 未入庫_dgv.Columns.Count = 28 Then
                未入庫_dgv.Columns(29).Visible = False
            End If
        End If
        For i As Integer = 0 To 未入庫_dgv.Rows.Count - 1
            '-------------------------規格合併呈現----------------------------------------------------------------------------------------------------------------------------------------
            If i = 0 Then
                AAA1 = "" : AAA2 = "" : AAA3 = "" : AAA4 = "" : AAA5 = "" : AAA6 = "" : AAA7 = "" : AAA8 = ""
                PA3 = 未入庫_dgv.Rows(i).Cells("規格庫抬頭指定").Value
                SQL_規格庫抬頭讀取()
                If dr.Read() Then
                    AAA1 = dr("A1") : AAA2 = dr("A2") : AAA3 = dr("A3") : AAA4 = dr("A4") : AAA5 = dr("A5") : AAA6 = dr("A6") : AAA7 = dr("A7") : AAA8 = dr("A8")
                End If
                conn.Close()
            Else
                If 未入庫_dgv.Rows(i).Cells("規格庫抬頭指定").Value.ToString <> 未入庫_dgv.Rows(i - 1).Cells("規格庫抬頭指定").Value.ToString Then
                    AAA1 = "" : AAA2 = "" : AAA3 = "" : AAA4 = "" : AAA5 = "" : AAA6 = "" : AAA7 = "" : AAA8 = ""
                    PA3 = 未入庫_dgv.Rows(i).Cells("規格庫抬頭指定").Value
                    SQL_規格庫抬頭讀取()
                    If dr.Read() Then
                        AAA1 = dr("A1") : AAA2 = dr("A2") : AAA3 = dr("A3") : AAA4 = dr("A4") : AAA5 = dr("A5") : AAA6 = dr("A6") : AAA7 = dr("A7") : AAA8 = dr("A8")
                    End If
                    conn.Close()
                End If
            End If
            Dim ZA1, ZA2, ZA3, ZA4, ZA5, ZA6, ZA7, ZA8 As String : 物料規格 = ""
            If 詳細資料2_ch.Checked = True Then
                If 未入庫_dgv.Rows(i).Cells("規格").Value.ToString <> "" Then
                    ZA1 = AAA1 & "=" & 未入庫_dgv.Rows(i).Cells("規格").Value.ToString : 物料規格 = ZA1 : End If
                If 未入庫_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then : ZA2 = AAA2 & "=" & 未入庫_dgv.Rows(i).Cells("A2").Value
                    If 物料規格 = "" Then : 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If
                If 未入庫_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then : ZA3 = AAA3 & "=" & 未入庫_dgv.Rows(i).Cells("A3").Value
                    If 物料規格 = "" Then : 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If
                If 未入庫_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then : ZA4 = AAA4 & "=" & 未入庫_dgv.Rows(i).Cells("A4").Value
                    If 物料規格 = "" Then : 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If
                If 未入庫_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then : ZA5 = AAA5 & "=" & 未入庫_dgv.Rows(i).Cells("A5").Value
                    If 物料規格 = "" Then : 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If
                If 未入庫_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then : ZA6 = AAA6 & "=" & 未入庫_dgv.Rows(i).Cells("A6").Value
                    If 物料規格 = "" Then : 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If
                If 未入庫_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then : ZA7 = AAA7 & "=" & 未入庫_dgv.Rows(i).Cells("A7").Value
                    If 物料規格 = "" Then : 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If
                If 未入庫_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then : ZA8 = AAA8 & "=" & 未入庫_dgv.Rows(i).Cells("A8").Value
                    If 物料規格 = "" Then : 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If
            Else
                If 未入庫_dgv.Rows(i).Cells("規格").Value.ToString <> "" Then : ZA1 = 未入庫_dgv.Rows(i).Cells("規格").Value.ToString : 物料規格 = ZA1 : End If
                If 未入庫_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then
                    ZA2 = 未入庫_dgv.Rows(i).Cells("A2").Value : If 物料規格 = "" Then : 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If
                If 未入庫_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then
                    ZA3 = 未入庫_dgv.Rows(i).Cells("A3").Value : If 物料規格 = "" Then : 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If
                If 未入庫_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then
                    ZA4 = 未入庫_dgv.Rows(i).Cells("A4").Value : If 物料規格 = "" Then : 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If
                If 未入庫_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then
                    ZA5 = 未入庫_dgv.Rows(i).Cells("A5").Value : If 物料規格 = "" Then : 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If
                If 未入庫_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then
                    ZA6 = 未入庫_dgv.Rows(i).Cells("A6").Value : If 物料規格 = "" Then : 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If
                If 未入庫_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then
                    ZA7 = 未入庫_dgv.Rows(i).Cells("A7").Value : If 物料規格 = "" Then : 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If
                If 未入庫_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then
                    ZA8 = 未入庫_dgv.Rows(i).Cells("A8").Value : If 物料規格 = "" Then : 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If
            End If
            未入庫_dgv.Rows(i).Cells("規格").Value = 物料規格
        Next i
    End Sub
    Private Sub Set_清單()
        Dim ds1 As New DataSet : 入庫明細_dgv.DataSource = Nothing : ds1.Clear()
        入庫明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        入庫明細_dgv.ColumnHeadersHeight = 25
        入庫明細_dgv.AllowUserToAddRows = False
        If 小間距_ch.Checked = False And 中間距_ch.Checked = False And 大間距_ch.Checked = True Then : 入庫明細_dgv.RowTemplate.Height = 65
        ElseIf 小間距_ch.Checked = False And 中間距_ch.Checked = True And 大間距_ch.Checked = False Then : 入庫明細_dgv.RowTemplate.Height = 45
        ElseIf 小間距_ch.Checked = True And 中間距_ch.Checked = False And 大間距_ch.Checked = False Then : 入庫明細_dgv.RowTemplate.Height = 25 : End If

        PA20 = 指定入庫單號1_tb.Text
        SQL_建築物料來料驗收與指定入庫_入庫明細()
        da.Fill(ds1) : 入庫明細_dgv.DataSource = ds1.Tables(0) : conn.Close()

        入庫明細_dgv.Columns(0).Visible = False : 入庫明細_dgv.Columns(2).FillWeight = 250 : 入庫明細_dgv.Columns(3).FillWeight = 250 : 入庫明細_dgv.Columns(4).FillWeight = 100
        入庫明細_dgv.Columns(5).FillWeight = 100 : 入庫明細_dgv.Columns(6).FillWeight = 90 : 入庫明細_dgv.Columns(7).FillWeight = 150 : 入庫明細_dgv.Columns(8).Visible = False
        入庫明細_dgv.Columns(9).Visible = False : 入庫明細_dgv.Columns(10).Visible = False : 入庫明細_dgv.Columns("A2").Visible = False
        入庫明細_dgv.Columns("A3").Visible = False : 入庫明細_dgv.Columns("A4").Visible = False : 入庫明細_dgv.Columns("A5").Visible = False : 入庫明細_dgv.Columns("A6").Visible = False
        入庫明細_dgv.Columns("A7").Visible = False : 入庫明細_dgv.Columns("A8").Visible = False : 入庫明細_dgv.Columns("規格庫編號").Visible = False
        入庫明細_dgv.Columns("規格庫抬頭指定").Visible = False : 入庫明細_dgv.Columns("群組碼1").Visible = False : 入庫明細_dgv.Columns("群組碼1").Visible = False

        入庫明細_dgv.Columns(4).DefaultCellStyle.Format = "#,##0" : 入庫明細_dgv.Columns(5).DefaultCellStyle.Format = "#,##0"
        入庫明細_dgv.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 入庫明細_dgv.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        入庫明細_dgv.Columns(2).ReadOnly = True : 入庫明細_dgv.Columns(3).ReadOnly = True : 入庫明細_dgv.Columns(4).ReadOnly = True : 入庫明細_dgv.Columns(5).ReadOnly = True


        入庫明細_dgv.EditMode = DataGridViewEditMode.EditOnEnter
        If 低網速模式 = False Then
            入庫明細_dgv.Columns(21).FillWeight = 80 : 入庫明細_dgv.Columns(21).Visible = True
            Dim mycol As DataGridViewImageColumn = 入庫明細_dgv.Columns("圖檔")
            mycol.ImageLayout = DataGridViewImageCellLayout.Zoom
        Else
            If 入庫明細_dgv.Columns.Count = 22 Then
                入庫明細_dgv.Columns(21).Visible = False
            End If
        End If
        For i As Integer = 0 To 入庫明細_dgv.Rows.Count - 1
            '-------------------------規格合併呈現----------------------------------------------------------------------------------------------------------------------------------------

            If i = 0 Then
                AAA1 = "" : AAA2 = "" : AAA3 = "" : AAA4 = "" : AAA5 = "" : AAA6 = "" : AAA7 = "" : AAA8 = ""
                PA3 = 入庫明細_dgv.Rows(i).Cells("規格庫抬頭指定").Value
                SQL_規格庫抬頭讀取()
                If dr.Read() Then
                    AAA1 = dr("A1") : AAA2 = dr("A2") : AAA3 = dr("A3") : AAA4 = dr("A4") : AAA5 = dr("A5") : AAA6 = dr("A6") : AAA7 = dr("A7") : AAA8 = dr("A8")
                End If
                conn.Close()
            Else
                If 入庫明細_dgv.Rows(i).Cells("規格庫抬頭指定").Value.ToString <> 入庫明細_dgv.Rows(i - 1).Cells("規格庫抬頭指定").Value.ToString Then
                    AAA1 = "" : AAA2 = "" : AAA3 = "" : AAA4 = "" : AAA5 = "" : AAA6 = "" : AAA7 = "" : AAA8 = ""
                    PA3 = 入庫明細_dgv.Rows(i).Cells("規格庫抬頭指定").Value
                    SQL_規格庫抬頭讀取()
                    If dr.Read() Then
                        AAA1 = dr("A1") : AAA2 = dr("A2") : AAA3 = dr("A3") : AAA4 = dr("A4") : AAA5 = dr("A5") : AAA6 = dr("A6") : AAA7 = dr("A7") : AAA8 = dr("A8")
                    End If
                    conn.Close()
                End If
            End If
            Dim ZA1, ZA2, ZA3, ZA4, ZA5, ZA6, ZA7, ZA8 As String : 物料規格 = ""
            If 詳細資料2_ch.Checked = True Then
                If 入庫明細_dgv.Rows(i).Cells("規格").Value.ToString <> "" Then
                    ZA1 = AAA1 & "=" & 入庫明細_dgv.Rows(i).Cells("規格").Value.ToString : 物料規格 = ZA1 : End If
                If 入庫明細_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then : ZA2 = AAA2 & "=" & 入庫明細_dgv.Rows(i).Cells("A2").Value
                    If 物料規格 = "" Then : 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If
                If 入庫明細_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then : ZA3 = AAA3 & "=" & 入庫明細_dgv.Rows(i).Cells("A3").Value
                    If 物料規格 = "" Then : 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If
                If 入庫明細_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then : ZA4 = AAA4 & "=" & 入庫明細_dgv.Rows(i).Cells("A4").Value
                    If 物料規格 = "" Then : 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If
                If 入庫明細_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then : ZA5 = AAA5 & "=" & 入庫明細_dgv.Rows(i).Cells("A5").Value
                    If 物料規格 = "" Then : 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If
                If 入庫明細_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then : ZA6 = AAA6 & "=" & 入庫明細_dgv.Rows(i).Cells("A6").Value
                    If 物料規格 = "" Then : 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If
                If 入庫明細_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then : ZA7 = AAA7 & "=" & 入庫明細_dgv.Rows(i).Cells("A7").Value
                    If 物料規格 = "" Then : 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If
                If 入庫明細_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then : ZA8 = AAA8 & "=" & 入庫明細_dgv.Rows(i).Cells("A8").Value
                    If 物料規格 = "" Then : 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If
            Else
                If 入庫明細_dgv.Rows(i).Cells("規格").Value.ToString <> "" Then : ZA1 = 入庫明細_dgv.Rows(i).Cells("規格").Value.ToString : 物料規格 = ZA1 : End If
                If 入庫明細_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then
                    ZA2 = 入庫明細_dgv.Rows(i).Cells("A2").Value : If 物料規格 = "" Then : 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If
                If 入庫明細_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then
                    ZA3 = 入庫明細_dgv.Rows(i).Cells("A3").Value : If 物料規格 = "" Then : 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If
                If 入庫明細_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then
                    ZA4 = 入庫明細_dgv.Rows(i).Cells("A4").Value : If 物料規格 = "" Then : 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If
                If 入庫明細_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then
                    ZA5 = 入庫明細_dgv.Rows(i).Cells("A5").Value : If 物料規格 = "" Then : 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If
                If 入庫明細_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then
                    ZA6 = 入庫明細_dgv.Rows(i).Cells("A6").Value : If 物料規格 = "" Then : 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If
                If 入庫明細_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then
                    ZA7 = 入庫明細_dgv.Rows(i).Cells("A7").Value : If 物料規格 = "" Then : 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If
                If 入庫明細_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then
                    ZA8 = 入庫明細_dgv.Rows(i).Cells("A8").Value : If 物料規格 = "" Then : 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If
            End If
            入庫明細_dgv.Rows(i).Cells("規格").Value = 物料規格
        Next i
    End Sub
    Private Sub Set_清單1()
        Dim ds2 As New DataSet : 入庫申請_dgv.DataSource = Nothing : ds2.Clear()
        入庫申請_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        入庫申請_dgv.ColumnHeadersHeight = 25 : 入庫申請_dgv.AllowUserToAddRows = False : 入庫申請_dgv.RowTemplate.Height = 25

        SQL_建築物料來料驗收與指定入庫_入庫申請()
        da.Fill(ds2) : 入庫申請_dgv.DataSource = ds2.Tables(0) : conn.Close()

        入庫申請_dgv.Columns(0).FillWeight = 200 : 入庫申請_dgv.Columns(1).FillWeight = 107
    End Sub
    Private Sub Set_清單4()
        Dim ds2 As New DataSet : 無料明細_dgv.DataSource = Nothing : ds2.Clear()
        無料明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        無料明細_dgv.ColumnHeadersHeight = 25 : 無料明細_dgv.AllowUserToAddRows = False : 無料明細_dgv.RowTemplate.Height = 25

        SQL_入庫申請無料號()
        da.Fill(ds2) : 無料明細_dgv.DataSource = ds2.Tables(0) : conn.Close()
        無料明細_dgv.Columns(1).Visible = False : 無料明細_dgv.Columns(2).Visible = False : 無料明細_dgv.Columns(3).Visible = False : 無料明細_dgv.Columns(4).Visible = False
        無料明細_dgv.Columns(5).Visible = False : 無料明細_dgv.Columns(6).Visible = False : 無料明細_dgv.Columns(9).Visible = False
        無料明細_dgv.Columns(0).FillWeight = 50
    End Sub
    Private Sub Set_清單5()
        PA1 = 群組編碼_cb.Text
        Dim ds4 As New DataSet : 物料清單_dgv.DataSource = Nothing : ds4.Clear()
        物料清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        物料清單_dgv.ColumnHeadersHeight = 25 : 物料清單_dgv.AllowUserToAddRows = False

        ConnOpen() : SQL_物料清單一() : CmdSet_For_DGV()
        da.Fill(ds4) : 物料清單_dgv.DataSource = ds4.Tables(0) : conn.Close()
        物料清單_dgv.Columns(0).Visible = False : 物料清單_dgv.Columns(1).FillWeight = 80 : 物料清單_dgv.Columns(2).FillWeight = 175 : 物料清單_dgv.Columns(3).Visible = False
        物料清單_dgv.Columns(4).Visible = False : 物料清單_dgv.Columns(5).FillWeight = 45
        物料清單_dgv.Columns(0).ReadOnly = True : 物料清單_dgv.Columns(1).ReadOnly = True : 物料清單_dgv.Columns(2).ReadOnly = True
        For i As Integer = 0 To 物料清單_dgv.Rows.Count - 1 : 物料清單_dgv(0, i).Value = i + 1 : Next
    End Sub
    Private Sub 倉名_cb_下拉表單資料載入()
        SQL_倉名_下拉清單() : 倉名_cb.Items.Clear()
        While (dr.Read()) : 倉名_cb.Items.Add(dr("倉名")) : End While : conn.Close()
    End Sub
    Private Sub Sub廠商_cb_下拉表單資料載入()
        SQL_供應商資料表_公司名_下拉用() : 廠商_cb.Items.Clear() : While (dr.Read()) : 廠商_cb.Items.Add(dr("公司名")) : End While : conn.Close()
    End Sub
    Private Sub 群組編碼_cb_下拉表單資料載入()
        SQL_群組碼_下拉清單() : 群組編碼_cb.Items.Clear()
        While (dr.Read()) : 群組編碼_cb.Items.Add(dr("群組碼")) : End While : conn.Close()
    End Sub
    Private Sub 存檔備註()
        Set_日期格式轉換()
        PA5 = 採購單號_tb.Text
        For i As Integer = 0 To 未入庫_dgv.Rows.Count - 1
            資料數 = 未入庫_dgv.Rows.Count : MyMod.進度條()
            PA6 = 未入庫_dgv.Rows(i).Cells("備註").Value : PA5 = 未入庫_dgv.Rows(i).Cells("採購單號").Value
            PA4 = 未入庫_dgv.Rows(i).Cells("請購單號").Value : PA10 = 未入庫_dgv.Rows(i).Cells("項次").Value
            SQL_採購單明細表_修改備註() : conn.Close()
        Next
        Set_清單() : FH_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
    End Sub
    '-----------------------------觸碰說明--------------------------------------------------------------------------------------------------------------------------------------
    Private Sub 確定收貨_bt_MouseEnter(sender As Object, e As EventArgs) Handles 確定收貨_bt.MouseEnter
        ToolTip1.SetToolTip(Me.確定收貨_bt, "確定收貨-物料入倉 (入庫)")
    End Sub
    Private Sub 直送工地_bt_MouseEnter(sender As Object, e As EventArgs) Handles 直送工地_bt.MouseEnter
        ToolTip1.SetToolTip(Me.確定收貨_bt, "確定收貨-直接使用 (無入庫)")
    End Sub
    Private Sub 開立指定入庫單_bt_MouseEnter(sender As Object, e As EventArgs) Handles 開立指定入庫單_bt.MouseEnter
        ToolTip1.SetToolTip(Me.開立指定入庫單_bt, "開立指定入庫單")
    End Sub
    Private Sub 選定內容加入指定入庫申請單_bt_MouseEnter(sender As Object, e As EventArgs) Handles 選定內容加入指定入庫申請單_bt.MouseEnter
        ToolTip1.SetToolTip(Me.選定內容加入指定入庫申請單_bt, "選定內容加入指定入庫申請單")
    End Sub
    Private Sub 指定入庫申請單建立完成_bt_MouseEnter(sender As Object, e As EventArgs) Handles 指定入庫申請單建立完成_bt.MouseEnter
        ToolTip1.SetToolTip(Me.指定入庫申請單建立完成_bt, "指定入庫申請單建立完成")
    End Sub
    Private Sub 全部選擇_bt_MouseEnter(sender As Object, e As EventArgs) Handles 全部選擇_bt.MouseEnter
        ToolTip1.SetToolTip(Me.全部選擇_bt, "全部選擇")
    End Sub
    Private Sub 全部取消_bt_MouseEnter(sender As Object, e As EventArgs) Handles 全部取消_bt.MouseEnter
        ToolTip1.SetToolTip(Me.全部取消_bt, "全部取消")
    End Sub
    Private Sub 採購單驗收_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = FH_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
        倉級_tb.Enabled = False : 倉名編號_tb.Enabled = False : 指定入庫單號1_tb.Enabled = False : ToolTip1.ToolTipTitle = "功能說明"
        驗證碼_tb.Enabled = False : 圖片編碼_tb.Enabled = False : 供應商編碼_tb.Visible = False
        核對員_tb.Visible = False : 核對日期_tb.Visible = False : 詢價員_tb.Visible = False : 尋價日期_tb.Visible = False : 驗證碼1_tb.Visible = False
        指定入庫申請單建立完成_bt.Enabled = False : 指定入庫申請單建立完成_tsm.Enabled = False : SYS_DEBUG_tp.Enabled = False
        選定內容加入指定入庫申請單_bt.Enabled = False : 選定內容加入指定入庫申請單_tsm.Enabled = False : Panel1.SendToBack()
        小間距_ch.Checked = False : 中間距_ch.Checked = True : 大間距_ch.Checked = False

        群組編碼_cb_下拉表單資料載入() : SQL_建築物料來料驗收與指定入庫_已申請入庫NULL修改() : SQL_建築物料來料驗收與指定入庫_已收貨NULL修改() : conn.Close()
        倉名_cb_下拉表單資料載入() : Sub廠商_cb_下拉表單資料載入() : 變色 = True : Set_核准採購清單() : Set_準備指定入庫清單() : Set_清單1() : 變色 = False
        Set_清單4() : 採購單驗收_Size()
    End Sub
    Private Sub 採購單驗收_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
        採購單驗收_Size()
    End Sub
    Private Sub 採購單驗收_Size()
        已核准_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 7.6) : 明細_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 7.6)
        未入庫_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 7.6) : 入庫申請_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 7.6)
        入庫明細_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 7.6)
    End Sub
    Private Sub 語轉扭_bt_Click(sender As Object, e As EventArgs) Handles 語轉扭_bt.Click
        Set_核准採購清單() : Set_核准採購明細() : Set_準備指定入庫清單() : Set_清單() : Set_清單1()
    End Sub
    Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
        timeNow = 0 : FH_ERP_SYS.Timer1.Enabled = False : FH_ERP_SYS.Timer1.Enabled = True
    End Sub
    Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
        timeNow = 0 : FH_ERP_SYS.Timer1.Enabled = False : FH_ERP_SYS.Timer1.Enabled = True
    End Sub
    Private Sub 已核准_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 已核准_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            採購單號_tb.Text = 已核准_dgv(0, e.RowIndex).Value.ToString : 核對員_tb.Text = 已核准_dgv(4, e.RowIndex).Value.ToString
            核對日期_tb.Text = 已核准_dgv(5, e.RowIndex).Value.ToString : 詢價員_tb.Text = 已核准_dgv(6, e.RowIndex).Value.ToString
            尋價日期_tb.Text = 已核准_dgv(7, e.RowIndex).Value.ToString : 驗證碼1_tb.Text = 已核准_dgv(11, 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
            尾_tb.Text = 已核准_dgv("序號", e.RowIndex).Value.ToString

            供應商編碼_tb.Text = 已核准_dgv(1, e.RowIndex).Value.ToString : conn.Close()
            PA1 = 供應商編碼_tb.Text : SQL_建築物料採購單生成_供應商資料一()
            If dr.Read() Then : 廠商_cb.Text = dr("公司名") : conn.Close() : End If : conn.Close()
            驗證碼_tb.Text = 已核准_dgv(11, e.RowIndex).Value.ToString : 圖片編碼_tb.Text = 已核准_dgv(10, e.RowIndex).Value.ToString
            使用地點_tb.Text = 已核准_dgv(3, e.RowIndex).Value.ToString : 需求日期_dtp.Value = 已核准_dgv(2, e.RowIndex).Value
            '倉名_cb.Text = 已核准_dgv(3, e.RowIndex).Value.ToString
            Set_核准採購明細()
        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
            指定入庫單號1_tb.Text = 入庫申請_dgv.Rows(e.RowIndex).Cells("執行單號").Value
            指定入庫單號_tb.Text = 指定入庫單號1_tb.Text : Set_清單()
        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
            PA1 = 明細_dgv.Rows(e.RowIndex).Cells("群組碼").Value : PA2 = 明細_dgv.Rows(e.RowIndex).Cells("料號原則").Value
            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
        End If
        If 明細_dgv("已收貨", e.RowIndex).Value = True Then
            明細_dgv("已收貨", e.RowIndex).Value = False
        Else
            明細_dgv("已收貨", e.RowIndex).Value = True
        End If
        If 明細_dgv("已收貨", e.RowIndex).Value = True Then
            明細_dgv.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.LightPink
        Else
            明細_dgv.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.White
        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
            '倉名_cb.Text = 未入庫_dgv.Rows(e.RowIndex).Cells(表頭(136)).Value.ToString
            採購單號1_tb.Text = 未入庫_dgv.Rows(e.RowIndex).Cells("採購單號").Value.ToString
            PA1 = 未入庫_dgv.Rows(e.RowIndex).Cells("群組碼").Value : PA2 = 未入庫_dgv.Rows(e.RowIndex).Cells("料號原則").Value
            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)
                物料圖檔1_pb.Image = Bitmap.FromStream(oStream)
            End While
            conn.Close() : 物料圖檔1_pb.SizeMode = 4
            If 未入庫_dgv("選擇", e.RowIndex).Value = True Then
                未入庫_dgv("選擇", e.RowIndex).Value = False
            Else
                未入庫_dgv("選擇", e.RowIndex).Value = True
            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
            PA1 = 入庫明細_dgv.Rows(e.RowIndex).Cells("群組碼").Value : PA2 = 入庫明細_dgv.Rows(e.RowIndex).Cells("料號原則").Value
            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)
                物料圖檔1_pb.Image = Bitmap.FromStream(oStream)
            End While
            conn.Close() : 物料圖檔1_pb.SizeMode = 4
        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(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 無料明細_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 無料明細_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            群組編碼_cb.Text = 無料明細_dgv.Rows(e.RowIndex).Cells(7).Value
        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
            PA = 物料清單_dgv(1, e.RowIndex).Value.ToString
            PA1 = 物料清單_dgv.Rows(e.RowIndex).Cells("群組碼").Value : PA2 = 物料清單_dgv.Rows(e.RowIndex).Cells("料號原則").Value
            '------------------------------------------------------------------------------------------------------------------------------------------
            SQL_建築物料請購單申請_物料規格讀取()
            If dr.Read() Then : KKK2 = dr("規格庫編號") : PA3 = dr("規格庫抬頭指定") : PA4 = dr("群組碼") : End If : conn.Close()
            '------------------------------------------------------------------------------------------------------------------------------------------
            SQL_規格庫抬頭讀取()
            If dr.Read() Then : AAA1 = dr("A1") : AAA2 = dr("A2") : AAA3 = dr("A3") : AAA4 = dr("A4") : AAA5 = dr("A5") : AAA6 = dr("A6") : AAA7 = dr("A7") : AAA8 = dr("A8") : End If
            conn.Close()
            '------------------------------------------------------------------------------------------------------------------------------------------
            Dim ds3 As New DataSet
            物料規格_dgv.DataSource = Nothing : ds3.Clear()
            物料規格_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
            物料規格_dgv.ColumnHeadersHeight = 25 : 物料規格_dgv.AllowUserToAddRows = False : 物料規格_dgv.RowTemplate.Height = 20
            If KKK2 = "SQLB03" Then : SQL_物料規格_SQLB03()
            ElseIf KKK2 = "SQLB04" Then : SQL_物料規格_SQLB04()
            ElseIf KKK2 = "SQLB05" Then : SQL_物料規格_SQLB05()
            ElseIf KKK2 = "SQLB06" Then : SQL_物料規格_SQLB06()
            ElseIf KKK2 = "SQLB07" Then : SQL_物料規格_SQLB07()
            ElseIf KKK2 = "SQLB08" Then : SQL_物料規格_SQLB08() : End If
            da.Fill(ds3) : 物料規格_dgv.DataSource = ds3.Tables(0) : conn.Close() : 料號_tb.Text = ""

            物料規格_dgv.Columns(0).Visible = False : 物料規格_dgv.Columns(1).Visible = False : 物料規格_dgv.Columns(3).Visible = False
            物料規格_dgv.Columns(2).Width = 17 : 物料規格_dgv.Columns(12).Visible = False : 物料規格_dgv.Columns(13).Visible = False : 物料規格_dgv.Columns(14).Visible = False
            物料規格_dgv.Columns(15).Visible = False
            If KKK2 = "SQLB03" Then
                物料規格_dgv.Columns(7).Visible = False : 物料規格_dgv.Columns(8).Visible = False : 物料規格_dgv.Columns(9).Visible = False : 物料規格_dgv.Columns(10).Visible = False
                物料規格_dgv.Columns(11).Visible = False
                物料規格_dgv.Columns(4).FillWeight = 213 : 物料規格_dgv.Columns(5).FillWeight = 213 : 物料規格_dgv.Columns(6).FillWeight = 214
            ElseIf KKK2 = "SQLB04" Then
                物料規格_dgv.Columns(7).Visible = True : 物料規格_dgv.Columns(8).Visible = False : 物料規格_dgv.Columns(9).Visible = False : 物料規格_dgv.Columns(10).Visible = False
                物料規格_dgv.Columns(11).Visible = False
                物料規格_dgv.Columns(4).FillWeight = 160 : 物料規格_dgv.Columns(5).FillWeight = 160 : 物料規格_dgv.Columns(6).FillWeight = 160 : 物料規格_dgv.Columns(7).FillWeight = 160
            ElseIf KKK2 = "SQLB05" Then
                物料規格_dgv.Columns(7).Visible = True : 物料規格_dgv.Columns(8).Visible = True : 物料規格_dgv.Columns(9).Visible = False : 物料規格_dgv.Columns(10).Visible = False
                物料規格_dgv.Columns(11).Visible = False
                物料規格_dgv.Columns(4).FillWeight = 128 : 物料規格_dgv.Columns(5).FillWeight = 128 : 物料規格_dgv.Columns(6).FillWeight = 128 : 物料規格_dgv.Columns(7).FillWeight = 128
                物料規格_dgv.Columns(8).FillWeight = 128
            ElseIf KKK2 = "SQLB06" Then
                物料規格_dgv.Columns(7).Visible = True : 物料規格_dgv.Columns(8).Visible = True : 物料規格_dgv.Columns(9).Visible = True : 物料規格_dgv.Columns(10).Visible = False
                物料規格_dgv.Columns(11).Visible = False
                物料規格_dgv.Columns(4).FillWeight = 106 : 物料規格_dgv.Columns(5).FillWeight = 107 : 物料規格_dgv.Columns(6).FillWeight = 106 : 物料規格_dgv.Columns(7).FillWeight = 107
                物料規格_dgv.Columns(8).FillWeight = 106 : 物料規格_dgv.Columns(9).FillWeight = 108
            ElseIf KKK2 = "SQLB07" Then
                物料規格_dgv.Columns(7).Visible = True : 物料規格_dgv.Columns(8).Visible = True : 物料規格_dgv.Columns(9).Visible = True : 物料規格_dgv.Columns(10).Visible = True
                物料規格_dgv.Columns(11).Visible = False
                物料規格_dgv.Columns(4).FillWeight = 91 : 物料規格_dgv.Columns(5).FillWeight = 92 : 物料規格_dgv.Columns(6).FillWeight = 91 : 物料規格_dgv.Columns(7).FillWeight = 92
                物料規格_dgv.Columns(8).FillWeight = 91 : 物料規格_dgv.Columns(9).FillWeight = 92 : 物料規格_dgv.Columns(10).FillWeight = 91
            ElseIf KKK2 = "SQLB08" Then
                物料規格_dgv.Columns(7).Visible = True : 物料規格_dgv.Columns(8).Visible = True : 物料規格_dgv.Columns(9).Visible = True : 物料規格_dgv.Columns(10).Visible = True
                物料規格_dgv.Columns(11).Visible = True
                物料規格_dgv.Columns(4).FillWeight = 80 : 物料規格_dgv.Columns(5).FillWeight = 80 : 物料規格_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 = 80
            End If
            物料規格_dgv.EditMode = DataGridViewEditMode.EditOnEnter
            For Each column As DataGridViewColumn In 物料規格_dgv.Columns : column.ReadOnly = True : Next

            For i As Integer = 0 To 物料規格_dgv.Rows.Count - 1
                物料規格_dgv.Rows(i).Cells("項次").Value = i + 1
                物料規格_dgv.Rows(i).Cells("申請數 Terapkan").Value = 0
                If Not IsNumeric(物料規格_dgv.Rows(i).Cells("申請數 Terapkan").Value) Then : MsgBox("欄位輸入必須為數值!!")
                ElseIf Val(物料規格_dgv.Rows(i).Cells("申請數 Terapkan").Value) > 0 Then
                    物料規格_dgv.Rows(i).Cells("Pilih").Value = True
                ElseIf Val(物料規格_dgv.Rows(i).Cells("申請數 Terapkan").Value) <= 0 Then
                    物料規格_dgv.Rows(i).Cells("申請數 Terapkan").Value = "0"
                    物料規格_dgv.Rows(i).Cells("Pilih").Value = False
                End If
            Next i
        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.Rows(e.RowIndex).Cells("項次mor_Bagian").Value.ToString : End If
    End Sub
    Private Sub 倉名_cb_Click(sender As Object, e As EventArgs) Handles 倉名_cb.Click
        CB選擇清單(倉名_cb, 倉名_cb.Text)
    End Sub
    Private Sub 廠商_cb_Click(sender As Object, e As EventArgs) Handles 廠商_cb.Click
        CB選擇清單(廠商_cb, 廠商_cb.Text)
    End Sub
    Private Sub 選擇公司_cb_Click(sender As Object, e As EventArgs) Handles 選擇公司_cb.Click
        CB選擇清單(選擇公司_cb, 選擇公司_cb.Text)
    End Sub
    Private Sub 群組編碼_cb_Click(sender As Object, e As EventArgs) Handles 群組編碼_cb.Click
        CB選擇清單(群組編碼_cb, 群組編碼_cb.Text)
    End Sub
    Private Sub 倉名_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 倉名_cb.SelectedIndexChanged
        PA6 = 倉名_cb.Text : SQL_指定倉儲_資料讀取() : If dr.Read() Then : 倉級_tb.Text = dr("倉級") : 倉名編號_tb.Text = dr("倉名編號") : End If : conn.Close()
    End Sub
    Private Sub 廠商_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 廠商_cb.SelectedIndexChanged
        PA1 = 廠商_cb.Text : SQL_建築物料採購單生成_供應商資料二()
        If dr.Read() Then
            供應商編碼_tb.Text = dr("供應商編碼") : 地址_tb.Text = dr("公司地址") : 電話_tb.Text = dr("公司電話1") : 郵件_tb.Text = dr("聯繫人1郵箱") : 傳真_tb.Text = dr("公司傳真1") : End If
        conn.Close()
    End Sub
    Private Sub 圖片編碼_tb_TextChanged(sender As Object, e As EventArgs) Handles 圖片編碼_tb.TextChanged
        PA1 = 圖片編碼_tb.Text
        SQL_主管簽名檔管理_圖片流水號()
        簽名檔_pb.Image = Nothing
        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
    End Sub
    Private Sub Set_日期格式轉換()
        DTP = Format(Today(), "yyyy/MM/dd") : DTP1 = Format(Today(), "yyyyMMdd")
    End Sub
    Private Sub 開立指定入庫單()
        If 倉名_cb.Text = "" Then : MsgBox("沒有指定倉庫") : Else
            Set_日期格式轉換()
            For i As Integer = 1 To 999
                NUM1 = 0 + i
                If NUM1 < 10 Then : 指定入庫單號1_tb.Text = "WH-" & DTP1 & "-00" & NUM1
                ElseIf NUM1 > 9 And NUM1 < 100 Then : 指定入庫單號1_tb.Text = "WH-" & DTP1 & "-0" & NUM1
                ElseIf NUM1 > 99 Then : 指定入庫單號1_tb.Text = "WH-" & DTP1 & "-" & NUM1
                End If
                指定入庫單號_tb.Text = 指定入庫單號1_tb.Text : PA1 = 指定入庫單號1_tb.Text
                SQL_倉儲明細執行單號_執行單號驗證()
                If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close()
            Next
            SQL_倉儲明細執行單號_新增() : conn.Close()
            倉名_cb.Enabled = False : 入庫申請_dgv.Enabled = False
            指定入庫申請單建立完成_bt.Enabled = True : 指定入庫申請單建立完成_tsm.Enabled = True
            選定內容加入指定入庫申請單_bt.Enabled = True : 選定內容加入指定入庫申請單_tsm.Enabled = True
            開立指定入庫單_bt.Enabled = False : 開立指定入庫單_tsm.Enabled = False
        End If
    End Sub
    Private Sub 開立指定入庫單_bt_Click(sender As Object, e As EventArgs) Handles 開立指定入庫單_bt.Click
        開立指定入庫單()
    End Sub
    Private Sub 指定入庫申請單建立完成()
        倉名_cb_下拉表單資料載入() : 倉名_cb.Enabled = True : 入庫申請_dgv.Enabled = True
        指定入庫申請單建立完成_bt.Enabled = False : 指定入庫申請單建立完成_tsm.Enabled = False
        選定內容加入指定入庫申請單_bt.Enabled = False : 選定內容加入指定入庫申請單_tsm.Enabled = False
        開立指定入庫單_bt.Enabled = True : 開立指定入庫單_tsm.Enabled = True
        For i As Integer = 0 To 入庫明細_dgv.Rows.Count - 1
            資料數 = 入庫明細_dgv.Rows.Count : MyMod.進度條()
            PA10 = 入庫明細_dgv.Rows(i).Cells("備註").Value : PA11 = 入庫明細_dgv.Rows(i).Cells("No").Value
            SQL_倉儲明細表_備註修改() : conn.Close()
        Next
        MsgBox("入庫申請完成。") : FH_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
        Set_清單1() : 入庫明細_dgv.DataSource = Nothing
    End Sub
    Private Sub 指定入庫申請單建立完成_bt_Click(sender As Object, e As EventArgs) Handles 指定入庫申請單建立完成_bt.Click
        指定入庫申請單建立完成()
    End Sub
    Private Sub 選定內容加入指定入庫申請單()
        存檔備註() : Set_日期格式轉換()
        For i As Integer = 0 To 未入庫_dgv.Rows.Count - 1
            資料數 = 未入庫_dgv.Rows.Count : MyMod.進度條()
            If 未入庫_dgv.Rows(i).Cells("選擇").Value = True Then
                PA1 = 指定入庫單號1_tb.Text : PA2 = 未入庫_dgv.Rows(i).Cells("料號").Value
                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

                PA3 = ESTR : PA4 = 指定入庫單號1_tb.Text : PA5 = 倉級_tb.Text : PA6 = 倉名編號_tb.Text
                PA7 = 未入庫_dgv.Rows(i).Cells("數量").Value : PA8 = 未入庫_dgv.Rows(i).Cells("採購單號").Value
                PA9 = 未入庫_dgv.Rows(i).Cells("備註").Value : PA15 = 未入庫_dgv.Rows(i).Cells("單價").Value
                PA10 = 合約號_tb.Text : PA11 = 乙_tb.Text : PA12 = 甲_tb.Text : PA13 = 序_tb.Text : PA14 = 尾_tb.Text
                If 切換1_ts.Checked = True Then
                    SQL_建築物料來料驗收與指定入庫_倉儲明細表_新增1() : conn.Close()
                    SQL_採購單明細表_已申請入庫修改() : conn.Close()
                Else
                    SQL_建築物料來料驗收與指定入庫_倉儲明細表_新增() : conn.Close()
                    SQL_採購單明細表_已申請入庫修改() : conn.Close()
                End If
            End If
        Next
        Set_清單() : Set_準備指定入庫清單() : FH_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
    End Sub
    Private Sub 選定內容加入指定入庫申請單_bt_Click(sender As Object, e As EventArgs) Handles 選定內容加入指定入庫申請單_bt.Click
        選定內容加入指定入庫申請單()
    End Sub
    Private Sub 確定收貨_bt_Click(sender As Object, e As EventArgs) Handles 確定收貨_bt.Click
        If 倉名_cb.Text = "" Then : MsgBox("沒有選擇倉庫!!") : Else
            Dim S As Boolean
            For i As Integer = 0 To 明細_dgv.Rows.Count - 1
                If 明細_dgv.Rows(i).Cells("" & "已收貨" & "").Value = True Then
                    S = True : Exit For
                End If
            Next i
            If S = True Then : 資料數 = 明細_dgv.Rows.Count
                For i As Integer = 0 To 明細_dgv.Rows.Count - 1 : MyMod.進度條()
                    BL1 = 明細_dgv.Rows(i).Cells("" & "已收貨" & "").Value : PA1 = 明細_dgv.Rows(i).Cells("請購單號").Value : PA2 = 明細_dgv.Rows(i).Cells("項次1").Value
                    SQL_採購單明細表_已收貨修改() : conn.Close()
                    If 明細_dgv.Rows(i).Cells("" & "已收貨" & "").Value = True And 明細_dgv("" & "已收貨" & "", i).Value = True Then : TTYY = True : End If
                Next i
                FH_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
                BL2 = TTYY : PA3 = 採購單號_tb.Text
                SQL_請購單控制表_已收貨修改() : conn.Close() : Set_核准採購清單() : Set_準備指定入庫清單()
                If 切換_ts.Checked = False Then : MsgBox("驗收完成。") : End If : Sub廠商_cb_下拉表單資料載入() : Set_核准採購明細() : Set_核准採購清單()
                If 明細_dgv.Rows.Count = 0 Then
                    地址_tb.Text = "" : 電話_tb.Text = "" : 郵件_tb.Text = "" : 採購單號_tb.Text = "" : 使用地點_tb.Text = "" : 傳真_tb.Text = "" : 明細_dgv.DataSource = Nothing
                End If
                If 切換_ts.Created = True Then
                    If 未入庫_dgv.Rows.Count > 0 Then
                        採購單號1_tb.Text = 未入庫_dgv.Rows(0).Cells("採購單號").Value.ToString
                        PA1 = 未入庫_dgv.Rows(0).Cells("群組碼").Value : PA2 = 未入庫_dgv.Rows(0).Cells("料號原則").Value
                        全部選擇() : 開立指定入庫單() : 選定內容加入指定入庫申請單() : 指定入庫申請單建立完成()
                    End If
                End If
            Else : MsgBox("請勾選，已收貨欄位!!") : End If
        End If
    End Sub
    Private Sub 直送工地_bt_Click(sender As Object, e As EventArgs) Handles 直送工地_bt.Click
        Dim S As Boolean
        For i As Integer = 0 To 明細_dgv.Rows.Count - 1
            If 明細_dgv.Rows(i).Cells("" & "已收貨" & "").Value = True Then
                S = True : Exit For
            End If
        Next i
        If S = True Then : 資料數 = 明細_dgv.Rows.Count
            For i As Integer = 0 To 明細_dgv.Rows.Count - 1 : MyMod.進度條()
                BL1 = 明細_dgv.Rows(i).Cells("" & "已收貨" & "").Value : PA1 = 明細_dgv.Rows(i).Cells("請購單號").Value : PA2 = 明細_dgv.Rows(i).Cells("項次1").Value
                SQL_採購單明細表_已收貨修改() : conn.Close()
                If 明細_dgv.Rows(i).Cells("" & "已收貨" & "").Value = True And 明細_dgv("" & "已收貨" & "", i).Value = True Then : TTYY = True : End If
            Next i
            FH_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
            BL2 = TTYY : PA3 = 採購單號_tb.Text
            SQL_請購單控制表_已收貨修改() : conn.Close() : Set_核准採購清單() : Set_準備指定入庫清單()
            If 切換_ts.Checked = False Then : MsgBox("驗收完成。") : End If : Sub廠商_cb_下拉表單資料載入() : Set_核准採購明細() : Set_核准採購清單()
            If 明細_dgv.Rows.Count = 0 Then
                地址_tb.Text = "" : 電話_tb.Text = "" : 郵件_tb.Text = "" : 採購單號_tb.Text = "" : 使用地點_tb.Text = "" : 傳真_tb.Text = "" : 明細_dgv.DataSource = Nothing
            End If
            For i As Integer = 0 To 未入庫_dgv.Rows.Count - 1
                資料數 = 未入庫_dgv.Rows.Count : MyMod.進度條()
                PA2 = 未入庫_dgv.Rows(i).Cells("料號").Value : PA8 = 未入庫_dgv.Rows(i).Cells("採購單號").Value
                SQL_採購單明細表_已申請入庫修改()
            Next
            Set_清單() : Set_準備指定入庫清單() : FH_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
        Else : MsgBox("請勾選，已收貨欄位!!") : End If
    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_核准採購明細() : Set_準備指定入庫清單() : Set_清單()
    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_核准採購明細() : Set_準備指定入庫清單() : Set_清單()
    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_核准採購明細() : Set_準備指定入庫清單() : Set_清單()
    End Sub
    Private Sub 群組編碼_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 群組編碼_cb.SelectedIndexChanged
        Set_清單5()
    End Sub
    Private Sub 物料圖檔_pb_Click(sender As Object, e As EventArgs) Handles 物料圖檔_pb.Click
        If IsNothing(物料圖檔_pb.Image) = False Then : 圖片傳遞 = 物料圖檔_pb.Image : 圖片放大視窗.ShowDialog() : End If
    End Sub
    Private Sub 物料圖檔1_pb_Click(sender As Object, e As EventArgs) Handles 物料圖檔1_pb.Click
        If IsNothing(物料圖檔1_pb.Image) = False Then : 圖片傳遞 = 物料圖檔1_pb.Image : 圖片放大視窗.ShowDialog() : End If
    End Sub
    Private Sub 全部選擇()
        For i As Integer = 0 To 未入庫_dgv.Rows.Count - 1 : 未入庫_dgv.Rows(i).Cells("選擇").Value = True : Next i
    End Sub
    Private Sub 全部選擇_bt_Click(sender As Object, e As EventArgs) Handles 全部選擇_bt.Click
        全部選擇()
    End Sub
    Private Sub 全部取消_bt_Click(sender As Object, e As EventArgs) Handles 全部取消_bt.Click
        For i As Integer = 0 To 未入庫_dgv.Rows.Count - 1 : 未入庫_dgv.Rows(i).Cells("選擇").Value = False : Next i
    End Sub
    Private Sub 詳細資料2_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 詳細資料2_ch.Click
        If 詳細資料2_ch.Checked = True Then : 詳細資料2_ch.Checked = True : Else : 詳細資料2_ch.Checked = False : End If : Set_核准採購明細() : Set_準備指定入庫清單() : Set_清單()
    End Sub
    '-----------------------------滑鼠右鍵--------------------------------------------------------------------------------------------------------------------------------------
    Private Sub AAAToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 料來料驗收_tsm.Click
        Me.TabControl1.SelectedTab = Me.建築物料來料驗收單_tp
    End Sub
    Private Sub AAAToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles 料來料驗收1_tsm.Click
        Me.TabControl1.SelectedTab = Me.建築物料來料驗收單_tp
    End Sub
    Private Sub BBBToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 指定入庫申請_tsm.Click
        Me.TabControl1.SelectedTab = Me.物料驗收後指定入庫申請_tp
    End Sub
    Private Sub BBBToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles 指定入庫申請1_tsm.Click
        Me.TabControl1.SelectedTab = Me.物料驗收後指定入庫申請_tp
    End Sub
    Private Sub DDDSegarkanToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新整理_tsm.Click
        Set_核准採購清單() : Set_準備指定入庫清單()
    End Sub
    Private Sub DDDToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles 重新整理1_tsm.Click
        Set_核准採購清單() : Set_準備指定入庫清單()
    End Sub
    Private Sub 全部選擇PilihSemuaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 全部選擇_tsm.Click
        For i As Integer = 0 To 明細_dgv.Rows.Count - 1 : 明細_dgv.Rows(i).Cells("" & "已收貨" & "").Value = True : Next i
    End Sub
    Private Sub 全部取消BatalkanSemuaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 全部取消_tsm.Click
        For i As Integer = 0 To 明細_dgv.Rows.Count - 1 : 明細_dgv.Rows(i).Cells("" & "已收貨" & "").Value = False : Next i
    End Sub
    Private Sub 確定收貨BertekadUntukMenerimaBarangToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 確定收貨_tsm.Click
        Me.確定收貨_bt.PerformClick()
    End Sub
    Private Sub GGGToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 全部取消1_tsm.Click
        For i As Integer = 0 To 未入庫_dgv.Rows.Count - 1 : 未入庫_dgv.Rows(i).Cells("選擇").Value = False : Next i
    End Sub
    Private Sub FFFToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 依單號全部選擇_tsm.Click
        For i As Integer = 0 To 未入庫_dgv.Rows.Count - 1
            If 採購單號1_tb.Text = 未入庫_dgv.Rows(i).Cells("採購單號").Value.ToString Then
                未入庫_dgv.Rows(i).Cells("選擇").Value = True
            End If
        Next i
    End Sub
    Private Sub EEEToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 採購單號查詢_tsm.Click
        PA = InputBox("請輸入要查詢的採購單號。")
        KKKJJ2 = " And (採購單明細表.採購單號 Like N'%" & PA & "%') " : Set_準備指定入庫清單()
        KKKJJ2 = "" : PA = ""
    End Sub
    Private Sub 開立指定入庫單ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 開立指定入庫單_tsm.Click
        Me.開立指定入庫單_bt.PerformClick()
    End Sub
    Private Sub 選定內容加入指定入庫申請單ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 選定內容加入指定入庫申請單_tsm.Click
        Me.選定內容加入指定入庫申請單_bt.PerformClick()
    End Sub
    Private Sub 指定入庫申請單建立完成ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 指定入庫申請單建立完成_tsm.Click
        Me.指定入庫申請單建立完成_bt.PerformClick()
    End Sub
End Class