Public Class 業務單號修改功能
    ReadOnly ds, ds1, ds2, ds3, ds4, ds5, ds6, ds7 As New DataSet
    Private Sub Set_清單1()
        銷售單據_dgv.DataSource = Nothing : ds1.Clear()
        銷售單據_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        銷售單據_dgv.ColumnHeadersHeight = 25
        銷售單據_dgv.AllowUserToAddRows = False
        銷售單據_dgv.RowTemplate.Height = 25

        PA19 = 業務_cb.Text
        SQL_銷售控制表1()
        da.Fill(ds1) : 銷售單據_dgv.DataSource = ds1.Tables(0) : conn.Close()
        銷售單據_dgv.Columns(0).Visible = False : 銷售單據_dgv.Columns(1).FillWeight = 100 : 銷售單據_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(7).Visible = False
        銷售單據_dgv.Columns(8).Visible = False : 銷售單據_dgv.Columns(9).Visible = False : 銷售單據_dgv.Columns(10).Visible = False : 銷售單據_dgv.Columns(11).Visible = False
    End Sub
    Private Sub 業務_cb_下拉表單資料載入()
        SQL_業務編號_下拉清單()
        業務_cb.Items.Clear() : 業務_cb.Items.Clear()
        While (dr.Read()) : 業務_cb.Items.Add(dr("業務號")) : End While : conn.Close()
    End Sub
    Private Sub 業務單號修改功能_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        業務_cb_下拉表單資料載入() : 業務_cb.Text = 業務號碼 : Set_清單1()
    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 = Strings.Left(銷售單據_dgv.Rows(e.RowIndex).Cells("單號").Value, 1)
            舊單號_tb.Text = 銷售單據_dgv.Rows(e.RowIndex).Cells("單號").Value
        End If
    End Sub
    Private Sub 業務_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 業務_cb.SelectedIndexChanged
        Set_清單1()
    End Sub
    Private Sub 存檔_bt_Click(sender As Object, e As EventArgs) Handles 存檔_bt.Click
        PA = 舊單號_tb.Text
        If 舊單號_tb.Text = "" Then
            MsgBox("修改單號資料不可空白!!")
        Else
            If IsNumeric(Strings.Mid(PA, 2, 6)) = True Then
                If PA.Length = 7 Or PA.Length = 9 Then
                    PA = 新單號_tb.Text
                    SQL_銷售控制表_單號是否重複()
                    If dr.Read Then
                        MsgBox("輸入的銷售單號重複。")
                    Else
                        SQL_銷售單號修改() : Set_清單1() : MsgBox("修改完成。")
                    End If
                Else
                    MsgBox("輸入的單號需要完整七位數或是九位數。")
                End If
            Else
                MsgBox("單號除了開頭第一位其他都必須是數字。")
            End If
        End If
    End Sub
End Class