Option Strict Off
Public Class 系統編碼規則_1
    ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet : ReadOnly ds2 As New DataSet : ReadOnly ds3 As New DataSet : ReadOnly ds4 As New DataSet : ReadOnly ds5 As New DataSet
    ReadOnly ds6 As New DataSet : ReadOnly ds7 As New DataSet : ReadOnly ds8 As New DataSet : ReadOnly ds9 As New DataSet : ReadOnly ds10 As New DataSet : ReadOnly ds11 As New DataSet
    ReadOnly ds12 As New DataSet
    Dim EDR As Integer = 0 : Dim ESTR As String
    Private Sub Set_客戶清單()
        客戶_dgv.DataSource = Nothing : ds11.Clear()
        客戶_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        客戶_dgv.ColumnHeadersHeight = 25
        客戶_dgv.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 客戶簡稱 FROM 客戶控制表 ORDER BY 客戶簡稱"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds11) : 客戶_dgv.DataSource = ds11.Tables(0) : conn.Close()
        客戶_dgv.Columns(0).FillWeight = 100
    End Sub
    Private Sub Set_品牌清單()
        品牌_dgv.DataSource = Nothing : ds12.Clear()
        品牌_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        品牌_dgv.ColumnHeadersHeight = 25
        品牌_dgv.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT CUST FROM MTTOOCUST清單 ORDER BY CUST "
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds12) : 品牌_dgv.DataSource = ds12.Tables(0) : conn.Close()
        品牌_dgv.Columns(0).FillWeight = 100
    End Sub
    Private Sub Set_縮寫清單()
        縮寫_dgv.DataSource = Nothing : ds10.Clear()
        縮寫_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        縮寫_dgv.ColumnHeadersHeight = 25
        縮寫_dgv.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 縮寫 FROM 楦頭縮寫管理"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds10) : 縮寫_dgv.DataSource = ds10.Tables(0) : conn.Close()
        縮寫_dgv.Columns(0).FillWeight = 100
    End Sub
    Private Sub Set_帳本清單()
        帳本_dgv.DataSource = Nothing : ds9.Clear()
        帳本_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        帳本_dgv.ColumnHeadersHeight = 25
        帳本_dgv.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 編號, 帳本名稱 FROM 財務帳本編號 ORDER BY 編號"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds9) : 帳本_dgv.DataSource = ds9.Tables(0) : conn.Close()
        帳本_dgv.Columns(0).FillWeight = 100 : 帳本_dgv.Columns(1).FillWeight = 100
    End Sub
    Private Sub Set_部門清單()
        部門_dgv.DataSource = Nothing : ds.Clear()
        部門_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        部門_dgv.ColumnHeadersHeight = 25
        部門_dgv.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 部門 FROM METOO部門清單"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : 部門_dgv.DataSource = ds.Tables(0) : conn.Close()
        部門_dgv.Columns(0).FillWeight = 100
    End Sub
    Private Sub Set_清單2()
        貼標大項_dgv.DataSource = Nothing : ds1.Clear()
        貼標大項_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        貼標大項_dgv.ColumnHeadersHeight = 25
        貼標大項_dgv.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 貼標對應名稱 FROM 貼標對應名稱清單"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds1) : 貼標大項_dgv.DataSource = ds1.Tables(0) : conn.Close()
        貼標大項_dgv.Columns(0).FillWeight = 100
    End Sub
    Private Sub Set_清單1()
        部件大項_dgv.DataSource = Nothing : ds2.Clear()
        部件大項_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        部件大項_dgv.ColumnHeadersHeight = 25
        部件大項_dgv.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 部件類別 FROM 部件大項分類 ORDER BY   部件類別"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds2) : 部件大項_dgv.DataSource = ds2.Tables(0) : conn.Close()
        部件大項_dgv.Columns(0).FillWeight = 100
    End Sub
    Private Sub Set_職稱清單()
        職稱_dgv.DataSource = Nothing : ds3.Clear()
        職稱_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        職稱_dgv.ColumnHeadersHeight = 25
        職稱_dgv.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 職稱 FROM METOO職稱清單 ORDER BY 職稱"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds3) : 職稱_dgv.DataSource = ds3.Tables(0) : conn.Close()
        職稱_dgv.Columns(0).FillWeight = 100
    End Sub
    Private Sub Set_請假類別清單()
        請假類別_dgv.DataSource = Nothing : ds4.Clear()
        請假類別_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        請假類別_dgv.ColumnHeadersHeight = 25
        請假類別_dgv.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 請假類別 FROM METOO請假類別 ORDER BY 請假類別"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds4) : 請假類別_dgv.DataSource = ds4.Tables(0) : conn.Close()
        請假類別_dgv.Columns(0).FillWeight = 100
    End Sub
    Private Sub Set_廠商類別()
        DataGridView6.DataSource = Nothing : ds5.Clear()
        DataGridView6.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView6.ColumnHeadersHeight = 25
        DataGridView6.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 廠商類別 FROM 廠商類別 ORDER BY 廠商類別"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds5) : DataGridView6.DataSource = ds5.Tables(0) : conn.Close()
        DataGridView6.Columns(0).FillWeight = 100
    End Sub
    Private Sub Set_年度清單()
        DataGridView7.DataSource = Nothing : ds6.Clear()
        DataGridView7.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView7.ColumnHeadersHeight = 25
        DataGridView7.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT  年份 FROM 年份清單 ORDER BY 年份 DESC"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds6) : DataGridView7.DataSource = ds6.Tables(0) : conn.Close()
        DataGridView7.Columns(0).FillWeight = 100
    End Sub
    Private Sub Set_模具開發用結構清單()
        模具結構_dgv.DataSource = Nothing : ds7.Clear()
        模具結構_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        模具結構_dgv.ColumnHeadersHeight = 25
        模具結構_dgv.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT  結構 FROM 模具開發用結構清單 ORDER BY 結構"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds7) : 模具結構_dgv.DataSource = ds7.Tables(0) : conn.Close()
        模具結構_dgv.Columns(0).FillWeight = 100
    End Sub
    Private Sub Set_模具開發用材質清單()
        模具材料_dgv.DataSource = Nothing : ds8.Clear()
        模具材料_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        模具材料_dgv.ColumnHeadersHeight = 25
        模具材料_dgv.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT  材質 FROM 模具開發用材質清單 ORDER BY 材質"
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds8) : 模具材料_dgv.DataSource = ds8.Tables(0) : conn.Close()
        模具材料_dgv.Columns(0).FillWeight = 100
    End Sub
    Private Sub 系統編碼規則_1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
        Set_清單1() : Set_清單2() : Set_年度清單() : Set_部門清單() : Set_職稱清單() : Set_請假類別清單() : Set_廠商類別()
        Set_模具開發用結構清單() : Set_模具開發用材質清單() : Set_帳本清單() : Set_縮寫清單() : Set_客戶清單() : Set_品牌清單()
    End Sub
    Private Sub 客戶_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 客戶_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            TextBox11.Text = 客戶_dgv(0, e.RowIndex).Value.ToString
        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
            TextBox12.Text = 品牌_dgv(0, e.RowIndex).Value.ToString
        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
            TextBox10.Text = 縮寫_dgv(0, e.RowIndex).Value.ToString
        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
        End If
    End Sub
    Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 部門_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            TextBox1.Text = 部門_dgv(0, e.RowIndex).Value.ToString
        End If
    End Sub
    Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 貼標大項_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            TextBox3.Text = 貼標大項_dgv(0, e.RowIndex).Value.ToString
        End If
    End Sub
    Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 部件大項_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            TextBox4.Text = 部件大項_dgv(0, e.RowIndex).Value.ToString
        End If
    End Sub
    Private Sub DataGridView4_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 職稱_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            TextBox2.Text = 職稱_dgv(0, e.RowIndex).Value.ToString
        End If
    End Sub
    Private Sub DataGridView5_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 請假類別_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            TextBox5.Text = 請假類別_dgv(0, e.RowIndex).Value.ToString
        End If
    End Sub
    Private Sub DataGridView6_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView6.CellClick
        If e.RowIndex = -1 Then : Else
            TextBox6.Text = DataGridView6(0, e.RowIndex).Value.ToString
        End If
    End Sub
    Private Sub DataGridView7_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView7.CellClick
        If e.RowIndex = -1 Then : Else
            TextBox8.Text = DataGridView7(0, e.RowIndex).Value.ToString
        End If
    End Sub
    Private Sub DataGridView8_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 模具結構_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            TextBox7.Text = 模具結構_dgv(0, e.RowIndex).Value.ToString
        End If
    End Sub
    Private Sub DataGridView9_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 模具材料_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            TextBox9.Text = 模具材料_dgv(0, e.RowIndex).Value.ToString
        End If
    End Sub
    Private Sub SET_新增按鈕程式共用2()
        cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
        MsgBox("新增完成")
        conn.Close() : dr.Close()
    End Sub
    Private Sub SET_修改按鈕程式共用1()
        cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
        MsgBox("修改完成")
        conn.Close()
    End Sub
    Private Sub SET_刪除按鈕程式共用1()
        cmd.CommandText = SQL1 : cmd.Connection = conn
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        Dim aa As MsgBoxResult
        aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
        If aa = MsgBoxResult.Ok Then : cmd.ExecuteNonQuery() : cmd.ExecuteNonQuery() : MsgBox("刪除完成") : End If
        conn.Close()
        式共用1()
    End Sub
    Private Sub 式共用1()
        Set_清單1() : Set_清單2() : Set_年度清單() : Set_部門清單() : Set_職稱清單() : Set_請假類別清單() : Set_廠商類別()
        Set_帳本清單() : Set_模具開發用結構清單() : Set_模具開發用材質清單() : Set_縮寫清單() : Set_客戶清單() : Set_品牌清單() : PA = ""
    End Sub
    Private Sub 式共用2()
        conn.Close() : dr.Close()
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
    End Sub
    Private Sub 式共用3()
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        If TextBox4.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            式共用3()
            SQL1 = "SELECT 部件類別 FROM 部件大項分類 WHERE 部件類別 LIKE N'" & TextBox4.Text & "'"
            cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then
                MsgBox("資料重複，請從新輸入或檢查") : conn.Close() : dr.Close()
            Else
                式共用2()
                SQL1 = "INSERT INTO 部件大項分類 (部件類別) VALUES (N'" & TextBox4.Text & "')"
                SET_新增按鈕程式共用2()
            End If
        End If
        式共用1()
    End Sub
    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        If TextBox4.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            PA = InputBox("請輸入要修改的內容")
            If PA = "" Then
                MsgBox("沒有輸入修改內容")
            Else
                式共用3()
                SQL1 = "UPDATE 部件大項分類 SET 部件類別 = N'" & PA & "' WHERE 部件類別 LIKE N'" & TextBox4.Text & "'"
                SET_修改按鈕程式共用1()
            End If
        End If
        式共用1()
    End Sub
    Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
        SQL1 = "DELETE FROM 部件大項分類 WHERE (部件類別 = N'" & TextBox4.Text & "')"
        SET_刪除按鈕程式共用1()
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        If TextBox3.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            式共用3()
            SQL1 = "SELECT 貼標對應名稱 FROM 貼標對應名稱清單 WHERE 貼標對應名稱 LIKE N'" & TextBox3.Text & "'"
            cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then
                MsgBox("資料重複，請從新輸入或檢查") : conn.Close() : dr.Close()
            Else
                式共用2()
                SQL1 = "INSERT INTO 貼標對應名稱清單 (貼標對應名稱) VALUES (N'" & TextBox3.Text & "')"
                SET_新增按鈕程式共用2()
            End If
        End If
        式共用1()
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If TextBox3.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            PA = InputBox("請輸入要修改的內容")
            If PA = "" Then
                MsgBox("沒有輸入修改內容")
            Else
                式共用3()
                SQL1 = "UPDATE 貼標對應名稱清單 SET 貼標對應名稱 = N'" & PA & "' WHERE 貼標對應名稱 LIKE N'" & TextBox3.Text & "'"
                SET_修改按鈕程式共用1()
            End If
        End If
        式共用1()
    End Sub
    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        SQL1 = "DELETE FROM 貼標對應名稱清單 WHERE (貼標對應名稱 = N'" & TextBox3.Text & "')"
        SET_刪除按鈕程式共用1()
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Button20_Click(sender As Object, e As EventArgs) Handles Button20.Click
        If TextBox8.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            式共用3() : SQL1 = "SELECT 年份 FROM 年份清單 WHERE 年份 LIKE '" & TextBox8.Text & "'" : cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then
                MsgBox("資料重複，請從新輸入或檢查") : conn.Close() : dr.Close()
            Else
                式共用2() : SQL1 = "INSERT INTO 年份清單 (年份) VALUES (N'" & TextBox8.Text & "')" : SET_新增按鈕程式共用2()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button19_Click(sender As Object, e As EventArgs) Handles Button19.Click
        If TextBox8.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            PA = InputBox("請輸入要修改的內容")
            If PA = "" Then
                MsgBox("沒有輸入修改內容")
            Else
                式共用3() : SQL1 = "UPDATE 年份清單 SET 年份 = N'" & PA & "' WHERE 年份 LIKE N'" & TextBox8.Text & "'" : SET_修改按鈕程式共用1()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button21_Click(sender As Object, e As EventArgs) Handles Button21.Click
        SQL1 = "DELETE FROM 年份清單 WHERE (年份 = N'" & TextBox8.Text & "')" : SET_刪除按鈕程式共用1()
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        If TextBox1.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            式共用3() : SQL1 = "SELECT 部門 FROM METOO部門清單 WHERE 部門 LIKE '" & TextBox1.Text & "'" : cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then
                MsgBox("資料重複，請從新輸入或檢查") : conn.Close() : dr.Close()
            Else
                式共用2() : SQL1 = "INSERT INTO METOO部門清單 (部門) VALUES (N'" & TextBox1.Text & "')" : SET_新增按鈕程式共用2()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        If TextBox1.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            PA = InputBox("請輸入要修改的內容")
            If PA = "" Then
                MsgBox("沒有輸入修改內容")
            Else
                式共用3() : SQL1 = "UPDATE METOO部門清單 SET 部門 = N'" & PA & "' WHERE 部門 LIKE N'" & TextBox1.Text & "'" : SET_修改按鈕程式共用1()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        SQL1 = "DELETE FROM METOO部門清單 WHERE (部門 = N'" & TextBox1.Text & "')" : SET_刪除按鈕程式共用1()
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
        If TextBox2.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            式共用3() : SQL1 = "SELECT 職稱 FROM METOO職稱清單 WHERE 職稱 LIKE '" & TextBox2.Text & "'" : cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then
                MsgBox("資料重複，請從新輸入或檢查") : conn.Close() : dr.Close()
            Else
                式共用2() : SQL1 = "INSERT INTO METOO職稱清單 (職稱) VALUES (N'" & TextBox2.Text & "')" : SET_新增按鈕程式共用2()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        If TextBox2.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            PA = InputBox("請輸入要修改的內容")
            If PA = "" Then
                MsgBox("沒有輸入修改內容")
            Else
                式共用3() : SQL1 = "UPDATE METOO職稱清單 SET 職稱 = N'" & PA & "' WHERE 職稱 LIKE N'" & TextBox2.Text & "'" : SET_修改按鈕程式共用1()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
        SQL1 = "DELETE FROM METOO職稱清單 WHERE (職稱 = N'" & TextBox2.Text & "')" : SET_刪除按鈕程式共用1()
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
        If TextBox5.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            式共用3() : SQL1 = "SELECT 請假類別 FROM METOO請假類別 WHERE 請假類別 LIKE '" & TextBox5.Text & "'" : cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then
                MsgBox("資料重複，請從新輸入或檢查") : conn.Close() : dr.Close()
            Else
                式共用2() : SQL1 = "INSERT INTO METOO請假類別 (請假類別) VALUES (N'" & TextBox5.Text & "')" : SET_新增按鈕程式共用2()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
        If TextBox5.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            PA = InputBox("請輸入要修改的內容")
            If PA = "" Then
                MsgBox("沒有輸入修改內容")
            Else
                式共用3() : SQL1 = "UPDATE METOO請假類別 SET 請假類別 = N'" & PA & "' WHERE 請假類別 LIKE N'" & TextBox5.Text & "'" : SET_修改按鈕程式共用1()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
        SQL1 = "DELETE FROM METOO請假類別 WHERE (請假類別 = N'" & TextBox5.Text & "')" : SET_刪除按鈕程式共用1()
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click
        If TextBox6.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            式共用3() : SQL1 = "SELECT 廠商類別 FROM 廠商類別 WHERE 廠商類別 LIKE '" & TextBox6.Text & "'" : cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then
                MsgBox("資料重複，請從新輸入或檢查") : conn.Close() : dr.Close()
            Else
                式共用2() : SQL1 = "INSERT INTO 廠商類別 (廠商類別) VALUES (N'" & TextBox6.Text & "')" : SET_新增按鈕程式共用2()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click
        If TextBox6.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            PA = InputBox("請輸入要修改的內容")
            If PA = "" Then
                MsgBox("沒有輸入修改內容")
            Else
                式共用3() : SQL1 = "UPDATE 廠商類別 SET 廠商類別 = N'" & PA & "' WHERE 廠商類別 LIKE N'" & TextBox6.Text & "'" : SET_修改按鈕程式共用1()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
        SQL1 = "DELETE FROM 廠商類別 WHERE (廠商類別 = N'" & TextBox6.Text & "')" : SET_刪除按鈕程式共用1()
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Button23_Click(sender As Object, e As EventArgs) Handles Button23.Click
        If TextBox7.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            式共用3() : SQL1 = "SELECT 結構 FROM 模具開發用結構清單 WHERE 結構 LIKE '" & TextBox7.Text & "'" : cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then
                MsgBox("資料重複，請從新輸入或檢查") : conn.Close() : dr.Close()
            Else
                式共用2() : SQL1 = "INSERT INTO 模具開發用結構清單 (結構) VALUES (N'" & TextBox7.Text & "')" : SET_新增按鈕程式共用2()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button22_Click(sender As Object, e As EventArgs) Handles Button22.Click
        If TextBox7.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            PA = InputBox("請輸入要修改的內容")
            If PA = "" Then
                MsgBox("沒有輸入修改內容")
            Else
                式共用3() : SQL1 = "UPDATE 模具開發用結構清單 SET 結構 = N'" & PA & "' WHERE 結構 LIKE N'" & TextBox7.Text & "'" : SET_修改按鈕程式共用1()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button24_Click(sender As Object, e As EventArgs) Handles Button24.Click
        SQL1 = "DELETE FROM 模具開發用結構清單 WHERE (結構 = N'" & TextBox7.Text & "')" : SET_刪除按鈕程式共用1()
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Button26_Click(sender As Object, e As EventArgs) Handles Button26.Click
        If TextBox9.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            式共用3() : SQL1 = "SELECT 材質 FROM 模具開發用材質清單 WHERE 材質 LIKE '" & TextBox9.Text & "'" : cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then
                MsgBox("資料重複，請從新輸入或檢查") : conn.Close() : dr.Close()
            Else
                式共用2() : SQL1 = "INSERT INTO 模具開發用材質清單 (材質) VALUES (N'" & TextBox9.Text & "')" : SET_新增按鈕程式共用2()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button25_Click(sender As Object, e As EventArgs) Handles Button25.Click
        If TextBox9.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            PA = InputBox("請輸入要修改的內容")
            If PA = "" Then
                MsgBox("沒有輸入修改內容")
            Else
                式共用3() : SQL1 = "UPDATE 模具開發用材質清單 SET 材質 = N'" & PA & "' WHERE 材質 LIKE N'" & TextBox9.Text & "'" : SET_修改按鈕程式共用1()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button27_Click(sender As Object, e As EventArgs) Handles Button27.Click
        SQL1 = "DELETE FROM 模具開發用材質清單 WHERE (材質 = N'" & TextBox9.Text & "')" : SET_刪除按鈕程式共用1()
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------
    Private Sub 帳本_新增_bt_Click(sender As Object, e As EventArgs) Handles 帳本_新增_bt.Click, Button5.Click
        PA = InputBox("請輸入要新增的帳本") : SQL_帳本查詢()
        If dr.Read() Then : MsgBox("資料重複，請從新輸入或檢查") : conn.Close() : dr.Close()
        Else
            '----------------------自动生成流水号-------------------------------------------------------------------------
            SQL_帳本流水號最後一筆()
            If dr.Read() Then : EDR = Double.Parse(Strings.Right(dr("編號").ToString, 3)) : Else : EDR = 0 : End If : conn.Close() : EDR += 1
            If EDR < 10 Then : ESTR = "LN" & "00" & EDR
            ElseIf EDR > 9 And EDR < 100 Then : ESTR = "LN" & "0" & EDR
            ElseIf EDR > 99 Then : ESTR = "LN" & EDR : End If : PA1 = ESTR
            式共用2() : SQL_帳本新增() : SET_新增按鈕程式共用2()
        End If : 式共用1()
    End Sub
    Private Sub 帳本_修改_bt_Click(sender As Object, e As EventArgs) Handles 帳本_修改_bt.Click
        If 帳本編號_tb.Text = "" Or 帳本_tb.Text = "" Then : MsgBox("資料有缺或有誤，請重新檢查")
        Else
            PA = InputBox("請輸入要修改的職別")
            If PA = "" Then : MsgBox("沒有輸入修改內容")
            Else : 式共用3() : SQL_帳本修改() : SET_修改按鈕程式共用1() : End If
        End If : 式共用1()
    End Sub
    Private Sub 帳本_刪除_bt_Click(sender As Object, e As EventArgs) Handles 帳本_刪除_bt.Click
        SQL_帳本刪除() : SET_刪除按鈕程式共用1()
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Button29_Click(sender As Object, e As EventArgs) Handles Button29.Click
        If TextBox10.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            式共用3() : SQL1 = "SELECT 縮寫 FROM 楦頭縮寫管理 WHERE 縮寫 LIKE '" & TextBox10.Text & "'" : cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then
                MsgBox("資料重複，請從新輸入或檢查") : conn.Close() : dr.Close()
            Else
                式共用2() : SQL1 = "INSERT INTO 楦頭縮寫管理 (縮寫) VALUES (N'" & TextBox10.Text & "')" : SET_新增按鈕程式共用2()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button28_Click(sender As Object, e As EventArgs) Handles Button28.Click
        If TextBox10.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            PA = InputBox("請輸入要修改的內容")
            If PA = "" Then
                MsgBox("沒有輸入修改內容")
            Else
                式共用3() : SQL1 = "UPDATE 楦頭縮寫管理 SET 縮寫 = N'" & PA & "' WHERE 縮寫 LIKE N'" & TextBox10.Text & "'" : SET_修改按鈕程式共用1()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button30_Click(sender As Object, e As EventArgs) Handles Button30.Click
        SQL1 = "DELETE FROM 楦頭縮寫管理 WHERE (縮寫 = N'" & TextBox10.Text & "')" : SET_刪除按鈕程式共用1()
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Button32_Click(sender As Object, e As EventArgs) Handles Button32.Click
        If TextBox11.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            式共用3() : SQL1 = "SELECT 客戶簡稱 FROM 客戶控制表 WHERE 客戶簡稱 LIKE '" & TextBox11.Text & "'" : cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then
                MsgBox("資料重複，請從新輸入或檢查") : conn.Close() : dr.Close()
            Else
                式共用2() : SQL1 = "INSERT INTO 客戶控制表 (客戶簡稱) VALUES (N'" & TextBox11.Text & "')" : SET_新增按鈕程式共用2()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button31_Click(sender As Object, e As EventArgs) Handles Button31.Click
        If TextBox11.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            PA = InputBox("請輸入要修改的內容")
            If PA = "" Then
                MsgBox("沒有輸入修改內容")
            Else
                式共用3() : SQL1 = "UPDATE 客戶控制表 SET 客戶簡稱 = N'" & PA & "' WHERE 客戶簡稱 LIKE N'" & TextBox11.Text & "'" : SET_修改按鈕程式共用1()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button33_Click(sender As Object, e As EventArgs) Handles Button33.Click
        SQL1 = "DELETE FROM 客戶控制表 WHERE (客戶簡稱 = N'" & TextBox11.Text & "')" : SET_刪除按鈕程式共用1()
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Button35_Click(sender As Object, e As EventArgs) Handles Button35.Click
        If TextBox12.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            式共用3() : SQL1 = "SELECT CUST FROM MTTOOCUST清單 WHERE CUST LIKE '" & TextBox12.Text & "'" : cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            If dr.Read() Then
                MsgBox("資料重複，請從新輸入或檢查") : conn.Close() : dr.Close()
            Else
                式共用2() : SQL1 = "INSERT INTO MTTOOCUST清單 (CUST) VALUES (N'" & TextBox12.Text & "')" : SET_新增按鈕程式共用2()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button34_Click(sender As Object, e As EventArgs) Handles Button34.Click
        If TextBox12.Text = "" Then
            MsgBox("資料有缺或有誤，請重新檢查")
        Else
            PA = InputBox("請輸入要修改的內容")
            If PA = "" Then
                MsgBox("沒有輸入修改內容")
            Else
                式共用3() : SQL1 = "UPDATE MTTOOCUST清單 SET CUST = N'" & PA & "' WHERE CUST LIKE N'" & TextBox12.Text & "'" : SET_修改按鈕程式共用1()
            End If
        End If : 式共用1()
    End Sub
    Private Sub Button36_Click(sender As Object, e As EventArgs) Handles Button36.Click
        SQL1 = "DELETE FROM MTTOOCUST清單 WHERE (CUST = N'" & TextBox12.Text & "')" : SET_刪除按鈕程式共用1()
    End Sub
End Class