Public Class 市構件分類
    Dim Str As String = Application.StartupPath
    Private Sub Set_群組清單1()
        Dim ds1 As New DataSet : 群組1_dgv.DataSource = Nothing : ds1.Clear()
        群組1_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        群組1_dgv.ColumnHeadersHeight = 25 : 群組1_dgv.AllowUserToAddRows = False : 群組1_dgv.RowTemplate.Height = 25
        SQL_物料群組_舊1()
        da.Fill(ds1) : 群組1_dgv.DataSource = ds1.Tables(0) : conn.Close()
        群組1_dgv.Columns(0).FillWeight = 30
    End Sub
    Private Sub Set_群組清單2()
        Dim ds1 As New DataSet : 群組2_dgv.DataSource = Nothing : ds1.Clear()
        群組2_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        群組2_dgv.ColumnHeadersHeight = 25 : 群組2_dgv.AllowUserToAddRows = False : 群組2_dgv.RowTemplate.Height = 25
        PA10 = B1_tb.Text : SQL_物料群組_舊2()
        da.Fill(ds1) : 群組2_dgv.DataSource = ds1.Tables(0) : conn.Close()
        群組2_dgv.Columns(0).FillWeight = 40
    End Sub
    Private Sub Set_群組清單3()
        Dim ds1 As New DataSet : 群組3_dgv.DataSource = Nothing : ds1.Clear()
        群組3_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        群組3_dgv.ColumnHeadersHeight = 25 : 群組3_dgv.AllowUserToAddRows = False : 群組3_dgv.RowTemplate.Height = 25
        PA10 = B2_tb.Text : SQL_物料群組_舊3()
        da.Fill(ds1) : 群組3_dgv.DataSource = ds1.Tables(0) : conn.Close()
        群組3_dgv.Columns(0).FillWeight = 50
    End Sub
    Private Sub Set_群組清單4()
        Dim ds1 As New DataSet : 群組4_dgv.DataSource = Nothing : ds1.Clear()
        群組4_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        群組4_dgv.ColumnHeadersHeight = 25 : 群組4_dgv.AllowUserToAddRows = False : 群組4_dgv.RowTemplate.Height = 25
        PA10 = B3_tb.Text : SQL_物料群組_舊4()
        da.Fill(ds1) : 群組4_dgv.DataSource = ds1.Tables(0) : conn.Close()
        群組4_dgv.Columns(0).FillWeight = 60
    End Sub
    Private Sub 市構件分類_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    End Sub
    Private Sub 市構件分類_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
        Set_群組清單1()
    End Sub
    Private Sub 群組1_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 群組1_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            A1_tb.Text = 群組1_dgv.Rows(e.RowIndex).Cells("項目").Value.ToString : B1_tb.Text = 群組1_dgv.Rows(e.RowIndex).Cells("編碼").Value.ToString
            C1_tb.Text = 群組1_dgv.Rows(e.RowIndex).Cells("項目").Value.ToString
            Set_群組清單2() : 群組3_dgv.DataSource = Nothing : 群組4_dgv.DataSource = Nothing
            A2_tb.Text = "" : A3_tb.Text = "" : A4_tb.Text = "" : B2_tb.Text = "" : B3_tb.Text = "" : B4_tb.Text = ""
            規則_tb.Text = B1_tb.Text : 規則1_tb.Text = A1_tb.Text
        End If
    End Sub
    Private Sub 群組2_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 群組2_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            A2_tb.Text = 群組2_dgv.Rows(e.RowIndex).Cells("項目").Value.ToString : B2_tb.Text = 群組2_dgv.Rows(e.RowIndex).Cells("編碼").Value.ToString
            C2_tb.Text = 群組2_dgv.Rows(e.RowIndex).Cells("項目").Value.ToString
            Set_群組清單3() : 群組4_dgv.DataSource = Nothing : A3_tb.Text = "" : A4_tb.Text = "" : B3_tb.Text = "" : B4_tb.Text = ""
            規則_tb.Text = B2_tb.Text : 規則1_tb.Text = A2_tb.Text
            If 舊群組開啟位置 = "物料採購統計表" Then : PA1 = 規則_tb.Text : 物料採購統計表.讀取_bt.PerformClick() : End If
        End If
    End Sub
    Private Sub 群組3_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 群組3_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            A3_tb.Text = 群組3_dgv.Rows(e.RowIndex).Cells("項目").Value.ToString : B3_tb.Text = 群組3_dgv.Rows(e.RowIndex).Cells("編碼").Value.ToString
            C3_tb.Text = 群組3_dgv.Rows(e.RowIndex).Cells("項目").Value.ToString
            Set_群組清單4() : A4_tb.Text = "" : B4_tb.Text = ""
            規則_tb.Text = B3_tb.Text : 規則1_tb.Text = A3_tb.Text
            If 舊群組開啟位置 = "物料資料庫" Then : PA1 = 規則_tb.Text : 精準 = True : 物料資料庫.關鍵字_bt.PerformClick() : End If
            If 舊群組開啟位置 = "專案項目BOM表" Then : PA1 = 規則_tb.Text : 精準 = True : 專案項目BOM表.關鍵字_bt.PerformClick() : End If
            If 舊群組開啟位置 = "請購單申請" Then : PA1 = 規則_tb.Text : 精準 = True : 請購單申請.關鍵字_bt.PerformClick() : End If
        End If
    End Sub
    Private Sub 群組4_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 群組4_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            A4_tb.Text = 群組4_dgv.Rows(e.RowIndex).Cells("項目").Value.ToString : B4_tb.Text = 群組4_dgv.Rows(e.RowIndex).Cells("編碼").Value.ToString
            C4_tb.Text = 群組4_dgv.Rows(e.RowIndex).Cells("項目").Value.ToString
            規則_tb.Text = B4_tb.Text : 規則1_tb.Text = A4_tb.Text
            If 舊群組開啟位置 = "物料資料庫" Then
                If 物料資料庫.改料號原則_ts.Checked = False Then : PA1 = 規則_tb.Text : 精準 = True : 物料資料庫.關鍵字_bt.PerformClick()
                Else : PA1 = 規則_tb.Text : 精準 = True : 物料資料庫.關鍵字_bt.PerformClick()
                    物料資料庫.群組碼1_tb.Text = B2_tb.Text & "-" & C2_tb.Text : 物料資料庫.品名1_tb.Text = "" : 物料資料庫.品名2_tb.Text = "" :: 物料資料庫.品名3_tb.Text = ""
                    物料資料庫.群組碼10_tb.Text = B2_tb.Text & "-" & C2_tb.Text : 物料資料庫.物料原則_tb.Text = 規則_tb.Text
                    物料資料庫.品名1_tb.Text = 規則1_tb.Text : 物料資料庫.品名2_tb.Text = 規則1_tb.Text : 物料資料庫.品名3_tb.Text = 規則1_tb.Text
                End If
            End If
            If 舊群組開啟位置 = "專案項目BOM表" Then : PA1 = 規則_tb.Text : 精準 = True : 專案項目BOM表.關鍵字_bt.PerformClick() : End If
            If 舊群組開啟位置 = "請購單申請" Then : PA1 = 規則_tb.Text : 精準 = True : 請購單申請.關鍵字_bt.PerformClick() : End If
        End If
    End Sub
    Private Sub ADD1_tb_Click(sender As Object, e As EventArgs) Handles ADD1_tb.Click
        SQL_查詢群組_舊1()
        If dr.Read Then
            If dr("編碼").ToString = "1" Then : 規則_tb.Text = "2" : ElseIf dr("編碼").ToString = "2" Then : 規則_tb.Text = "3"
            ElseIf dr("編碼").ToString = "3" Then : 規則_tb.Text = "4" : ElseIf dr("編碼").ToString = "4" Then : 規則_tb.Text = "5"
            ElseIf dr("編碼").ToString = "5" Then : 規則_tb.Text = "6" : ElseIf dr("編碼").ToString = "6" Then : 規則_tb.Text = "7"
            ElseIf dr("編碼").ToString = "7" Then : 規則_tb.Text = "8" : ElseIf dr("編碼").ToString = "8" Then : 規則_tb.Text = "9"
            ElseIf dr("編碼").ToString = "9" Then : 規則_tb.Text = "A" : ElseIf dr("編碼").ToString = "A" Then : 規則_tb.Text = "B"
            ElseIf dr("編碼").ToString = "B" Then : 規則_tb.Text = "C" : ElseIf dr("編碼").ToString = "C" Then : 規則_tb.Text = "D"
            ElseIf dr("編碼").ToString = "D" Then : 規則_tb.Text = "E" : ElseIf dr("編碼").ToString = "E" Then : 規則_tb.Text = "F"
            ElseIf dr("編碼").ToString = "F" Then : 規則_tb.Text = "G" : ElseIf dr("編碼").ToString = "G" Then : 規則_tb.Text = "H"
            ElseIf dr("編碼").ToString = "H" Then : 規則_tb.Text = "I" : ElseIf dr("編碼").ToString = "I" Then : 規則_tb.Text = "J"
            ElseIf dr("編碼").ToString = "J" Then : 規則_tb.Text = "K" : ElseIf dr("編碼").ToString = "K" Then : 規則_tb.Text = "L"
            ElseIf dr("編碼").ToString = "L" Then : 規則_tb.Text = "M" : ElseIf dr("編碼").ToString = "M" Then : 規則_tb.Text = "N"
            ElseIf dr("編碼").ToString = "N" Then : 規則_tb.Text = "O" : ElseIf dr("編碼").ToString = "O" Then : 規則_tb.Text = "P"
            ElseIf dr("編碼").ToString = "P" Then : 規則_tb.Text = "Q" : ElseIf dr("編碼").ToString = "Q" Then : 規則_tb.Text = "R"
            ElseIf dr("編碼").ToString = "R" Then : 規則_tb.Text = "S" : ElseIf dr("編碼").ToString = "S" Then : 規則_tb.Text = "T"
            ElseIf dr("編碼").ToString = "T" Then : 規則_tb.Text = "U" : ElseIf dr("編碼").ToString = "U" Then : 規則_tb.Text = "V"
            ElseIf dr("編碼").ToString = "V" Then : 規則_tb.Text = "W" : ElseIf dr("編碼").ToString = "W" Then : 規則_tb.Text = "X"
            ElseIf dr("編碼").ToString = "X" Then : 規則_tb.Text = "Y" : ElseIf dr("編碼").ToString = "Y" Then : 規則_tb.Text = "Z"
            ElseIf dr("編碼").ToString = "Z" Then : MsgBox("第一層編碼已滿無法再新增!!") : Exit Sub : End If
        Else : 規則_tb.Text = "1" : End If : PA11 = InputBox("請輸入要新增的項目名稱")
        If PA11 = "" Then : MsgBox("沒有輸入項目名稱無法新增!!") : 規則_tb.Text = "" : Else : PA12 = 規則_tb.Text : 規則1_tb.Text = PA11 : PA13 = "1" : SQL_舊群組_新增()
            Set_群組清單1() : 群組2_dgv.DataSource = Nothing : 群組3_dgv.DataSource = Nothing : 群組4_dgv.DataSource = Nothing
        End If
    End Sub
    Private Sub ADD2_tb_Click(sender As Object, e As EventArgs) Handles ADD2_tb.Click
        PA10 = B1_tb.Text : SQL_查詢群組_舊2()
        If dr.Read Then
            If Strings.Right(dr("編碼").ToString, 1) = "1" Then : 規則_tb.Text = B1_tb.Text & "2" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "2" Then : 規則_tb.Text = B1_tb.Text & "3"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "3" Then : 規則_tb.Text = B1_tb.Text & "4" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "4" Then : 規則_tb.Text = B1_tb.Text & "5"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "5" Then : 規則_tb.Text = B1_tb.Text & "6" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "6" Then : 規則_tb.Text = B1_tb.Text & "7"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "7" Then : 規則_tb.Text = B1_tb.Text & "8" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "8" Then : 規則_tb.Text = B1_tb.Text & "9"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "9" Then : 規則_tb.Text = B1_tb.Text & "A" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "A" Then : 規則_tb.Text = B1_tb.Text & "B"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "B" Then : 規則_tb.Text = B1_tb.Text & "C" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "C" Then : 規則_tb.Text = B1_tb.Text & "D"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "D" Then : 規則_tb.Text = B1_tb.Text & "E" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "E" Then : 規則_tb.Text = B1_tb.Text & "F"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "F" Then : 規則_tb.Text = B1_tb.Text & "G" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "G" Then : 規則_tb.Text = B1_tb.Text & "H"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "H" Then : 規則_tb.Text = B1_tb.Text & "I" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "I" Then : 規則_tb.Text = B1_tb.Text & "J"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "J" Then : 規則_tb.Text = B1_tb.Text & "K" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "K" Then : 規則_tb.Text = B1_tb.Text & "L"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "L" Then : 規則_tb.Text = B1_tb.Text & "M" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "M" Then : 規則_tb.Text = B1_tb.Text & "N"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "N" Then : 規則_tb.Text = B1_tb.Text & "O" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "O" Then : 規則_tb.Text = B1_tb.Text & "P"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "P" Then : 規則_tb.Text = B1_tb.Text & "Q" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "Q" Then : 規則_tb.Text = B1_tb.Text & "R"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "R" Then : 規則_tb.Text = B1_tb.Text & "S" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "S" Then : 規則_tb.Text = B1_tb.Text & "T"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "T" Then : 規則_tb.Text = B1_tb.Text & "U" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "U" Then : 規則_tb.Text = B1_tb.Text & "V"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "V" Then : 規則_tb.Text = B1_tb.Text & "W" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "W" Then : 規則_tb.Text = B1_tb.Text & "X"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "X" Then : 規則_tb.Text = B1_tb.Text & "Y" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "Y" Then : 規則_tb.Text = B1_tb.Text & "Z"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "Z" Then : MsgBox("第二層編碼已滿無法再新增!!") : Exit Sub : End If
        Else : 規則_tb.Text = B1_tb.Text & "1" : End If : PA11 = InputBox("請輸入要新增的項目名稱")
        If PA11 = "" Then : MsgBox("沒有輸入項目名稱無法新增!!") : 規則_tb.Text = "" : Else : PA12 = 規則_tb.Text : 規則1_tb.Text = PA11 : PA13 = "2" : SQL_舊群組_新增()
            Set_群組清單2() : 群組3_dgv.DataSource = Nothing : 群組4_dgv.DataSource = Nothing
            新群組建置()
        End If
    End Sub
    Private Sub ADD3_tb_Click(sender As Object, e As EventArgs) Handles ADD3_tb.Click
        PA10 = B2_tb.Text : SQL_查詢群組_舊3()
        If dr.Read Then
            If Strings.Right(dr("編碼").ToString, 1) = "1" Then : 規則_tb.Text = B2_tb.Text & "2" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "2" Then : 規則_tb.Text = B2_tb.Text & "3"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "3" Then : 規則_tb.Text = B2_tb.Text & "4" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "4" Then : 規則_tb.Text = B2_tb.Text & "5"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "5" Then : 規則_tb.Text = B2_tb.Text & "6" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "6" Then : 規則_tb.Text = B2_tb.Text & "7"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "7" Then : 規則_tb.Text = B2_tb.Text & "8" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "8" Then : 規則_tb.Text = B2_tb.Text & "9"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "9" Then : 規則_tb.Text = B2_tb.Text & "A" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "A" Then : 規則_tb.Text = B2_tb.Text & "B"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "B" Then : 規則_tb.Text = B2_tb.Text & "C" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "C" Then : 規則_tb.Text = B2_tb.Text & "D"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "D" Then : 規則_tb.Text = B2_tb.Text & "E" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "E" Then : 規則_tb.Text = B2_tb.Text & "F"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "F" Then : 規則_tb.Text = B2_tb.Text & "G" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "G" Then : 規則_tb.Text = B2_tb.Text & "H"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "H" Then : 規則_tb.Text = B2_tb.Text & "I" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "I" Then : 規則_tb.Text = B2_tb.Text & "J"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "J" Then : 規則_tb.Text = B2_tb.Text & "K" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "K" Then : 規則_tb.Text = B2_tb.Text & "L"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "L" Then : 規則_tb.Text = B2_tb.Text & "M" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "M" Then : 規則_tb.Text = B2_tb.Text & "N"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "N" Then : 規則_tb.Text = B2_tb.Text & "O" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "O" Then : 規則_tb.Text = B2_tb.Text & "P"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "P" Then : 規則_tb.Text = B2_tb.Text & "Q" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "Q" Then : 規則_tb.Text = B2_tb.Text & "R"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "R" Then : 規則_tb.Text = B2_tb.Text & "S" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "S" Then : 規則_tb.Text = B2_tb.Text & "T"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "T" Then : 規則_tb.Text = B2_tb.Text & "U" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "U" Then : 規則_tb.Text = B2_tb.Text & "V"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "V" Then : 規則_tb.Text = B2_tb.Text & "W" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "W" Then : 規則_tb.Text = B2_tb.Text & "X"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "X" Then : 規則_tb.Text = B2_tb.Text & "Y" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "Y" Then : 規則_tb.Text = B2_tb.Text & "Z"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "Z" Then : MsgBox("第三層編碼已滿無法再新增!!") : Exit Sub : End If
        Else : 規則_tb.Text = B2_tb.Text & "1" : End If : PA11 = InputBox("請輸入要新增的項目名稱")
        If PA11 = "" Then : MsgBox("沒有輸入項目名稱無法新增!!") : 規則_tb.Text = "" : Else : PA12 = 規則_tb.Text : 規則1_tb.Text = PA11 : PA13 = "3" : SQL_舊群組_新增()
            Set_群組清單3() : 群組4_dgv.DataSource = Nothing
        End If
    End Sub
    Private Sub ADD4_tb_Click(sender As Object, e As EventArgs) Handles ADD4_tb.Click
        PA10 = B3_tb.Text : SQL_查詢群組_舊4()
        If dr.Read Then
            If Strings.Right(dr("編碼").ToString, 1) = "1" Then : 規則_tb.Text = B3_tb.Text & "2" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "2" Then : 規則_tb.Text = B3_tb.Text & "3"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "3" Then : 規則_tb.Text = B3_tb.Text & "4" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "4" Then : 規則_tb.Text = B3_tb.Text & "5"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "5" Then : 規則_tb.Text = B3_tb.Text & "6" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "6" Then : 規則_tb.Text = B3_tb.Text & "7"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "7" Then : 規則_tb.Text = B3_tb.Text & "8" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "8" Then : 規則_tb.Text = B3_tb.Text & "9"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "9" Then : 規則_tb.Text = B3_tb.Text & "A" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "A" Then : 規則_tb.Text = B3_tb.Text & "B"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "B" Then : 規則_tb.Text = B3_tb.Text & "C" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "C" Then : 規則_tb.Text = B3_tb.Text & "D"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "D" Then : 規則_tb.Text = B3_tb.Text & "E" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "E" Then : 規則_tb.Text = B3_tb.Text & "F"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "F" Then : 規則_tb.Text = B3_tb.Text & "G" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "G" Then : 規則_tb.Text = B3_tb.Text & "H"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "H" Then : 規則_tb.Text = B3_tb.Text & "I" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "I" Then : 規則_tb.Text = B3_tb.Text & "J"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "J" Then : 規則_tb.Text = B3_tb.Text & "K" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "K" Then : 規則_tb.Text = B3_tb.Text & "L"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "L" Then : 規則_tb.Text = B3_tb.Text & "M" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "M" Then : 規則_tb.Text = B3_tb.Text & "N"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "N" Then : 規則_tb.Text = B3_tb.Text & "O" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "O" Then : 規則_tb.Text = B3_tb.Text & "P"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "P" Then : 規則_tb.Text = B3_tb.Text & "Q" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "Q" Then : 規則_tb.Text = B3_tb.Text & "R"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "R" Then : 規則_tb.Text = B3_tb.Text & "S" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "S" Then : 規則_tb.Text = B3_tb.Text & "T"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "T" Then : 規則_tb.Text = B3_tb.Text & "U" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "U" Then : 規則_tb.Text = B3_tb.Text & "V"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "V" Then : 規則_tb.Text = B3_tb.Text & "W" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "W" Then : 規則_tb.Text = B3_tb.Text & "X"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "X" Then : 規則_tb.Text = B3_tb.Text & "Y" : ElseIf Strings.Right(dr("編碼").ToString, 1) = "Y" Then : 規則_tb.Text = B3_tb.Text & "Z"
            ElseIf Strings.Right(dr("編碼").ToString, 1) = "Z" Then : MsgBox("第四層編碼已滿無法再新增!!") : Exit Sub : End If
        Else : 規則_tb.Text = B3_tb.Text & "1" : End If : PA11 = InputBox("請輸入要新增的項目名稱")
        If PA11 = "" Then : MsgBox("沒有輸入項目名稱無法新增!!") : 規則_tb.Text = "" : Else : PA12 = 規則_tb.Text : 規則1_tb.Text = PA11 : PA13 = "4" : SQL_舊群組_新增()
            Set_群組清單4()
        End If
    End Sub
    Private Sub 存檔1_bt_Click(sender As Object, e As EventArgs) Handles 存檔1_bt.Click
        Dim result As DialogResult = MessageBox.Show("請確定是否要修改項目名稱?", "請選擇", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If result = DialogResult.Yes Then : PA11 = A1_tb.Text : PA12 = B1_tb.Text : 規則_tb.Text = A1_tb.Text : SQL_舊群組_修改() : Set_群組清單1()
        End If
    End Sub
    Private Sub 共用()
        conn.Close() : dr.Close() : ConnOpen()
    End Sub
    Private Sub SET_新增按鈕程式共用3()
        cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close() : dr.Close()
    End Sub
    Private Sub 新群組建置()
        PA20 = 規則_tb.Text & "-" & 規則1_tb.Text : ConnOpen() : SQL_物料資料庫_群組碼重複查詢1() : CmdSet_For_dr()
        If dr.Read() Then : Else : ConnOpen() : SQL_物料資料庫_群組碼重複查詢_語轉1_1() : CmdSet_For_dr()
            If dr.Read() Then : Else : ConnOpen() : SQL_物料資料庫_群組碼重複查詢_語轉2_1() : CmdSet_For_dr()
                If dr.Read() Then : Else : ConnOpen() : SQL_物料資料庫_群組碼重複查詢_語轉3_1() : CmdSet_For_dr()
                    If dr.Read() Then : Else : PA49 = "D、市購件"
                        共用() : SQL_物料資料庫_新增群組碼1() : SET_新增按鈕程式共用3()
                        共用() : SQL_物料資料庫_新增群組碼_語轉11() : SET_新增按鈕程式共用3()
                        共用() : SQL_物料資料庫_新增群組碼_語轉21() : SET_新增按鈕程式共用3()
                        共用() : SQL_物料資料庫_新增群組碼_語轉31() : SET_新增按鈕程式共用3()

                        Dim FG As Integer : SQL_物料圖庫_群組圖片版本1()
                        If dr.Read Then
                            If dr("版本").ToString = "" Then : FG = 0 : Else : FG = Strings.Mid(dr("版本").ToString, 2, 2) + 1 : End If
                        End If
                        If FG < 10 Then : PA48 = "V0" & FG : Else : PA48 = "V" & FG : End If
                        PA49 = Str + "\LOGG.jpg" : SQL_物料圖庫_群組圖片修改1() : conn.Close() : PA49 = ""
                        If 舊群組開啟位置 = "物料資料庫" Then : 物料資料庫.市購新增_bt.PerformClick() : End If
                    End If
                End If
            End If
        End If
    End Sub
    Private Sub 新群組修改()
        PA20 = B2_tb.Text & "-" & A2_tb.Text
        共用() : SQL_物料資料庫_群組碼重複查詢_語轉反11() : CmdSet_For_dr()
        If dr.Read() Then : MsgBox("資料重複，請從新輸入或檢查?") : conn.Close() : dr.Close() : Else : 共用() : SQL_物料資料庫_群組碼重複查詢_語轉反21() : CmdSet_For_dr()
            If dr.Read() Then : MsgBox("資料重複，請從新輸入或檢查?") : conn.Close() : dr.Close() : Else : 共用() : SQL_物料資料庫_群組碼重複查詢_語轉反31() : CmdSet_For_dr()
                If dr.Read() Then : MsgBox("資料重複，請從新輸入或檢查?") : conn.Close() : dr.Close() : Else
                    PA = B2_tb.Text & "-" & A2_tb.Text : PA3 = B2_tb.Text & "-" & C2_tb.Text
                    If PA = "" Then : MsgBox("沒有輸入修改內容!!") : Else
                        PA49 = "D、市購件"
                        共用() : SQL_物料資料庫_群組碼修改0_11() : CmdSet_For_dr() : 共用() : SQL_物料資料庫_群組碼修改0_21() : CmdSet_For_dr()
                        共用() : SQL_物料資料庫_群組碼修改0_31() : CmdSet_For_dr() : 共用() : SQL_物料資料庫_群組碼修改1() : CmdSet_For_dr()
                        共用() : SQL_物料資料庫_群組碼修改2() : CmdSet_For_dr() : 共用() : SQL_物料資料庫_群組碼修改3() : CmdSet_For_dr()
                        共用() : SQL_物料資料庫_群組碼修改4() : CmdSet_For_dr() : 共用() : SQL_物料資料庫_群組碼修改5() : CmdSet_For_dr()
                        共用() : SQL_物料資料庫_群組碼修改6() : CmdSet_For_dr() : 共用() : SQL_物料資料庫_群組碼修改7() : CmdSet_For_dr()
                        共用() : SQL_物料資料庫_群組碼修改8() : CmdSet_For_dr()
                        conn.Close() : If 舊群組開啟位置 = "物料資料庫" Then : 物料資料庫.市購新增_bt.PerformClick() : End If
                    End If
                End If
            End If
        End If
    End Sub
    Private Sub 存檔2_bt_Click(sender As Object, e As EventArgs) Handles 存檔2_bt.Click
        If C2_tb.Text = "" Then : MsgBox("請重新使用滑鼠點選下方要修改的資料!!") : Else
            Dim result As DialogResult = MessageBox.Show("請確定是否要修改項目名稱?", "請選擇", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            If result = DialogResult.Yes Then
                PA11 = A2_tb.Text : PA12 = B2_tb.Text : 規則1_tb.Text = A2_tb.Text : SQL_舊群組_修改() : Set_群組清單2() : 新群組修改()
            End If
        End If
    End Sub
    Private Sub 存檔3_bt_Click(sender As Object, e As EventArgs) Handles 存檔3_bt.Click
        Dim result As DialogResult = MessageBox.Show("請確定是否要修改項目名稱?", "請選擇", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If result = DialogResult.Yes Then : PA11 = A3_tb.Text : PA12 = B3_tb.Text : 規則_tb.Text = A3_tb.Text : SQL_舊群組_修改() : Set_群組清單3()
        End If
    End Sub
    Private Sub 存檔4_bt_Click(sender As Object, e As EventArgs) Handles 存檔4_bt.Click
        Dim result As DialogResult = MessageBox.Show("請確定是否要修改項目名稱?", "請選擇", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If result = DialogResult.Yes Then : PA11 = A4_tb.Text : PA12 = B4_tb.Text : 規則_tb.Text = A4_tb.Text : SQL_舊群組_修改() : Set_群組清單4()
        End If
    End Sub
End Class