Option Strict Off
Public Class 倉儲出庫
    ReadOnly ds1, ds2, ds3, ds4, ds5, ds6 As New DataSet
    Dim 首次開啟 As Boolean = False : Dim 運費 As Integer : Dim NUM1 As Integer : Dim EDR As Integer = 0 : Dim ESTR As String
    Private Sub Set_清單1()
        銷售單據_dgv.DataSource = Nothing : ds1.Clear()
        銷售單據_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        銷售單據_dgv.ColumnHeadersHeight = 40
        銷售單據_dgv.AllowUserToAddRows = False
        銷售單據_dgv.RowTemplate.Height = 25

        PA19 = 業務_cb.Text : PA20 = 客戶1_tb.Text
        SQL_倉儲出庫_訂單控制表()
        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
        銷售單據_dgv.Columns(12).Visible = False : 銷售單據_dgv.Columns(13).FillWeight = 40 : 銷售單據_dgv.Columns(14).FillWeight = 40 : 銷售單據_dgv.Columns(15).FillWeight = 40

        Set_清單3()
        For i As Integer = 0 To 銷售單據_dgv.Rows.Count - 1
            銷售單據_dgv("入庫", i).Value = True
            For ii As Integer = 0 To 銷售單號_dgv.Rows.Count - 1
                If 銷售單據_dgv("單號", i).Value = 銷售單號_dgv("銷售單號", ii).Value Then : 銷售單據_dgv("入庫", i).Value = False : End If
            Next
            If IsDBNull(銷售單據_dgv("轉採", i).Value) = True Then : 銷售單據_dgv("轉採", i).Value = False : End If
            If IsDBNull(銷售單據_dgv("已採", i).Value) = True Then : 銷售單據_dgv("已採", i).Value = False : End If
            If 銷售單據_dgv("已採", i).Value = False And 銷售單據_dgv("轉採", i).Value = False Then
                銷售單據_dgv("入庫", i).Value = False
            ElseIf 銷售單據_dgv("已採", i).Value = False Then
                銷售單據_dgv("入庫", i).Value = False
            End If
        Next
    End Sub
    Private Sub Set_清單2()
        客戶資料_dgv.DataSource = Nothing : ds2.Clear()
        客戶資料_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        客戶資料_dgv.ColumnHeadersHeight = 25
        客戶資料_dgv.AllowUserToAddRows = False
        客戶資料_dgv.RowTemplate.Height = 25

        PA16 = 客戶_tb.Text
        SQL_銷售單申請_客戶資料驗證()
        da.Fill(ds2) : 客戶資料_dgv.DataSource = ds2.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_清單3()
        銷售單號_dgv.DataSource = Nothing : ds3.Clear()
        銷售單號_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        銷售單號_dgv.ColumnHeadersHeight = 40
        銷售單號_dgv.AllowUserToAddRows = False
        銷售單號_dgv.RowTemplate.Height = 25

        SQL_倉儲入庫_銷售單號()
        da.Fill(ds3) : 銷售單號_dgv.DataSource = ds3.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_清單4()
        銷售明細_dgv.DataSource = Nothing : ds4.Clear()
        銷售明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        銷售明細_dgv.ColumnHeadersHeight = 40
        銷售明細_dgv.AllowUserToAddRows = False

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

        PA2 = "" : PA2 = 單號_tb.Text
        SQL_倉儲出庫_銷售庫存比對表()
        da.Fill(ds4) : 銷售明細_dgv.DataSource = ds4.Tables(0) : conn.Close()

        銷售明細_dgv.Columns(0).Visible = False : 銷售明細_dgv.Columns(1).FillWeight = 40 : 銷售明細_dgv.Columns(2).FillWeight = 110 : 銷售明細_dgv.Columns(3).FillWeight = 200
        銷售明細_dgv.Columns(4).FillWeight = 120 : 銷售明細_dgv.Columns(5).FillWeight = 120 : 銷售明細_dgv.Columns(6).FillWeight = 120 : 銷售明細_dgv.Columns(7).FillWeight = 200
        銷售明細_dgv.Columns(8).FillWeight = 80 : 銷售明細_dgv.Columns(9).Visible = False : 銷售明細_dgv.Columns(10).Visible = False : 銷售明細_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(16).Visible = False : 銷售明細_dgv.Columns(17).Visible = False : 銷售明細_dgv.Columns(18).Visible = False : 銷售明細_dgv.Columns(19).Visible = False
        銷售明細_dgv.Columns(20).Visible = False : 銷售明細_dgv.Columns(21).FillWeight = 80 : 銷售明細_dgv.Columns(22).FillWeight = 50 : 銷售明細_dgv.Columns(23).Visible = False

        銷售明細_dgv.Columns(1).ReadOnly = True : 銷售明細_dgv.Columns(2).ReadOnly = True : 銷售明細_dgv.Columns(3).ReadOnly = True : 銷售明細_dgv.Columns(4).ReadOnly = True
        銷售明細_dgv.Columns(5).ReadOnly = True : 銷售明細_dgv.Columns(6).ReadOnly = True : 銷售明細_dgv.Columns(8).ReadOnly = True : 銷售明細_dgv.Columns(12).ReadOnly = True
        銷售明細_dgv.Columns(13).ReadOnly = True

        銷售明細_dgv.Columns("數量").DefaultCellStyle.Format = "#,##0" : 銷售明細_dgv.Columns("成本").DefaultCellStyle.Format = "#,##0"
        銷售明細_dgv.Columns("單價").DefaultCellStyle.Format = "#,##0.0" : 銷售明細_dgv.Columns("售價").DefaultCellStyle.Format = "#,##0"
        銷售明細_dgv.Columns("庫存").DefaultCellStyle.Format = "#,##0"
        銷售明細_dgv.Columns("庫存").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("庫存").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("數量").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("數量").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("成本").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("成本").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("單價").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("單價").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("售價").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("售價").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("項次").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("項次").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("倉儲情況").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("倉儲情況").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("料號").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售明細_dgv.Columns("料號").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter

        齊套_lb.Text = "產品已備齊"
        For i As Integer = 0 To 銷售明細_dgv.Rows.Count - 1
            If 銷售明細_dgv("含稅", i).Value = False Then
                銷售明細_dgv("售價", i).Value = 銷售明細_dgv("數量", i).Value * 銷售明細_dgv("單價", i).Value
            ElseIf 銷售明細_dgv("含稅", i).Value = True Then
                銷售明細_dgv("售價", i).Value = 銷售明細_dgv("數量", i).Value * 銷售明細_dgv("單價", i).Value * 1.05
            End If

            If 銷售明細_dgv("採購流水", i).Value.ToString <> "" Then
                銷售明細_dgv("庫存", i).Value = 銷售明細_dgv("有單庫存", i).Value
            ElseIf 銷售明細_dgv("採購流水", i).Value.ToString = "" And 銷售明細_dgv("無單庫存", i).Value.ToString <> "" Then
                銷售明細_dgv("庫存", i).Value = 銷售明細_dgv("無單庫存", i).Value
            ElseIf 銷售明細_dgv("採購流水", i).Value.ToString = "" And 銷售明細_dgv("無單庫存", i).Value.ToString = "" Then
                銷售明細_dgv("庫存", i).Value = 0
            End If

            If Val(銷售明細_dgv("庫存", i).Value.ToString) < Val(銷售明細_dgv("數量", i).Value.ToString) Then
                銷售明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightPink
                齊套_lb.Text = "產品未備齊"
            End If
            銷售明細_dgv("項次", i).Value = i + 1
            銷售明細_dgv("準備出貨", i).Value = False
        Next
    End Sub
    Private Sub Set_清單5()
        銷售備註_dgv.DataSource = Nothing : ds5.Clear()
        銷售備註_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        銷售備註_dgv.ColumnHeadersHeight = 25
        銷售備註_dgv.AllowUserToAddRows = False
        銷售備註_dgv.RowTemplate.Height = 25

        PA2 = "" : PA2 = 單號_tb.Text : SQL_銷售備註表()
        da.Fill(ds5) : 銷售備註_dgv.DataSource = ds5.Tables(0) : conn.Close()

        銷售備註_dgv.Columns(0).Visible = False : 銷售備註_dgv.Columns(1).FillWeight = 120 : 銷售備註_dgv.Columns(2).FillWeight = 910 : 銷售備註_dgv.Columns(3).FillWeight = 120
        銷售備註_dgv.Columns(4).FillWeight = 120
        銷售備註_dgv.Columns(0).ReadOnly = True : 銷售備註_dgv.Columns(1).ReadOnly = True

        銷售備註_dgv.Columns("收入").DefaultCellStyle.Format = "#,##0" : 銷售備註_dgv.Columns("支出").DefaultCellStyle.Format = "#,##0"
        銷售備註_dgv.Columns("收入").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售備註_dgv.Columns("收入").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售備註_dgv.Columns("支出").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售備註_dgv.Columns("支出").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售備註_dgv.Columns("項次").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        銷售備註_dgv.Columns("項次").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter

        For i As Integer = 0 To 銷售備註_dgv.Rows.Count - 1
            銷售備註_dgv("項次", i).Value = i + 1
        Next
        銷售備註_dgv.EditMode = DataGridViewEditMode.EditOnEnter
        Set_合記計算()
    End Sub
    Private Sub Set_清單6()
        收款事項_dgv.DataSource = Nothing : ds6.Clear()
        收款事項_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        收款事項_dgv.ColumnHeadersHeight = 25
        收款事項_dgv.AllowUserToAddRows = False
        收款事項_dgv.RowTemplate.Height = 25

        PA2 = "" : PA2 = 單號_tb.Text : SQL_銷售收款事項()
        da.Fill(ds6) : 收款事項_dgv.DataSource = ds6.Tables(0) : conn.Close()

        收款事項_dgv.Columns(0).Visible = False : 收款事項_dgv.Columns(1).Visible = False : 收款事項_dgv.Columns(2).Visible = False : 收款事項_dgv.Columns(3).FillWeight = 120
        收款事項_dgv.Columns(4).FillWeight = 960 : 收款事項_dgv.Columns(5).FillWeight = 180

        收款事項_dgv.Columns(2).ReadOnly = True

        收款事項_dgv.Columns("金額").DefaultCellStyle.Format = "#,##0"
        收款事項_dgv.Columns("金額").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        收款事項_dgv.Columns("金額").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        收款事項_dgv.Columns("項次").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        收款事項_dgv.Columns("項次").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter

        For i As Integer = 0 To 收款事項_dgv.Rows.Count - 1
            收款事項_dgv("項次", i).Value = i + 1
            If IsDBNull(收款事項_dgv("含稅", i).Value) = True Then
                收款事項_dgv("含稅", i).Value = False
            End If
        Next
        收款事項_dgv.EditMode = DataGridViewEditMode.EditOnEnter
        Set_合記計算()
    End Sub
    Private Sub 送貨地點_cb_下拉表單資料載入()
        SQL_送貨地點_下拉清單() : 送貨地點_cb.Items.Clear() : 最低運費_cb.Items.Clear() : 最低售價_cb.Items.Clear() : 司機運費_tb.Text = "0"
        While (dr.Read()) : 送貨地點_cb.Items.Add(dr("地區")) : 最低運費_cb.Items.Add(dr("起車")) : 最低售價_cb.Items.Add(dr("最低售額")) : End While : conn.Close()
    End Sub
    Private Sub Set_日期格式轉換()
        DTP = Format(開單日期_dtp.Value, "yyyy/MM/dd") : DTP1 = Format(Today(), "yyyyMMdd")
    End Sub
    Private Sub Set_合記計算()
        Dim 不含1類銷售小記 As Integer : Dim 金額1 As Integer = 0
        售價小計_tb.Text = "0" : 稅金_tb.Text = "0" : 銷售合計_tb.Text = "0" : 收入小計_tb.Text = "0" : 支出小計_tb.Text = "0" : 額外收支_tb.Text = "0" : 物料成本_tb.Text = "0"
        司機運費_tb.Text = "0" : 管銷費用_tb.Text = "0" : 其他成本_tb.Text = "0" : 刷卡總和_tb.Text = "0" : 刷卡稅金_tb.Text = "0" : 刷卡傭金_tb.Text = "0"
        '-------001-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        For i As Integer = 0 To 收款事項_dgv.Rows.Count - 1
            If 收款事項_dgv("真項次", i).Value.ToString = "0" And 收款事項_dgv("內容", i).Value.ToString <> "未收餘額" Then
                刷卡總和_tb.Text = Val(刷卡總和_tb.Text) + 收款事項_dgv("金額", i).Value
            End If
        Next
        刷卡稅金_tb.Text = CInt(Val(Val(刷卡總和_tb.Text) * 0.05)) : 刷卡傭金_tb.Text = CInt(Val(Val(刷卡總和_tb.Text) * 0.02))
        '-------002-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        For i As Integer = 0 To 銷售明細_dgv.Rows.Count - 1
            售價小計_tb.Text = Val(售價小計_tb.Text) + (銷售明細_dgv("數量", i).Value * 銷售明細_dgv("單價", i).Value)

            If Strings.Left(銷售明細_dgv("料號", i).Value.ToString, 4) <> "1001" Then
                物料成本_tb.Text = Val(物料成本_tb.Text) + (銷售明細_dgv("數量", i).Value * 銷售明細_dgv("成本", i).Value)
                不含1類銷售小記 = 不含1類銷售小記 + 銷售明細_dgv("售價", i).Value
            End If
            If Strings.Left(銷售明細_dgv("料號", i).Value.ToString, 4) = "1001" Then
                其他成本_tb.Text = Val(其他成本_tb.Text) + (銷售明細_dgv("數量", i).Value * 銷售明細_dgv("成本", i).Value)
            End If

            If 銷售明細_dgv("含稅", i).Value = True Then
                稅金_tb.Text = Val(稅金_tb.Text) + ((銷售明細_dgv("數量", i).Value * 銷售明細_dgv("單價", i).Value * 1.05) - (銷售明細_dgv("數量", i).Value * 銷售明細_dgv("單價", i).Value))
            End If
        Next
        管銷費用_tb.Text = Val(物料成本_tb.Text) * 1.06 - Val(物料成本_tb.Text)
        銷售合計_tb.Text = Val(售價小計_tb.Text) + Val(稅金_tb.Text)

        If Val(稅金_tb.Text) = 0 And Val(刷卡稅金_tb.Text) = 0 Then
            通知_lb.Text = "無稅金"
        ElseIf Val(稅金_tb.Text) = 0 And Val(刷卡稅金_tb.Text) <> 0 Then
            通知_lb.Text = "應刷卡稅金小，有刷卡帶入的稅金，所以拆售價以未稅顯示" : 稅金_tb.Text = 刷卡稅金_tb.Text : 售價小計_tb.Text = Val(銷售合計_tb.Text) - Val(稅金_tb.Text)
        ElseIf (Val(稅金_tb.Text) <> 0 Or Val(刷卡稅金_tb.Text) <> 0) And Val(稅金_tb.Text) > Val(刷卡稅金_tb.Text) Then
            通知_lb.Text = "應所拆售價稅金大於刷卡稅金，計算正常，利潤中扣除刷卡傭金"
        ElseIf (Val(稅金_tb.Text) <> 0 Or Val(刷卡稅金_tb.Text) <> 0) And Val(稅金_tb.Text) < Val(刷卡稅金_tb.Text) Then
            通知_lb.Text = "刷卡稅金大於自動計算後的稅金，邏輯有誤，請從新拆售價。"
        End If
        '-------003-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        For i As Integer = 0 To 銷售備註_dgv.Rows.Count - 1
            收入小計_tb.Text = Val(收入小計_tb.Text) + 銷售備註_dgv("收入", i).Value
            支出小計_tb.Text = Val(支出小計_tb.Text) + 銷售備註_dgv("支出", i).Value
        Next
        額外收支_tb.Text = Val(收入小計_tb.Text) - Val(支出小計_tb.Text)
        '-------004-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        Dim 金額 As Integer = 0
        For i As Integer = 0 To 收款事項_dgv.Rows.Count - 1
            If 收款事項_dgv("真項次", i).Value.ToString <> "0" And 收款事項_dgv("內容", i).Value.ToString <> "未收餘額" Then
                金額 = 金額 + 收款事項_dgv("金額", i).Value
            ElseIf 收款事項_dgv("真項次", i).Value.ToString = "0" And 收款事項_dgv("內容", i).Value.ToString <> "未收餘額" Then
                金額 = 金額 + 收款事項_dgv("金額", i).Value
            ElseIf 收款事項_dgv("真項次", i).Value.ToString = "0" And 收款事項_dgv("內容", i).Value.ToString = "未收餘額" Then
                收款事項_dgv("金額", i).Value = CInt(Val(銷售合計_tb.Text)) - 金額
            End If
        Next
        '-------005-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        If 送貨地點_cb.Text = "" Or 送貨地點_cb.Text = "自取" Or 最低運費_cb.Text = "" Or 最低售價_cb.Text = "" Then
            司機運費_tb.Text = "0"
        Else
            If 運費 = 0 Then
                If (不含1類銷售小記 - Val(其他成本_tb.Text)) <= Val(最低售價_cb.Text) Then
                    司機運費_tb.Text = 最低運費_cb.Text
                ElseIf (不含1類銷售小記 - Val(其他成本_tb.Text)) > Val(最低售價_cb.Text) Then
                    司機運費_tb.Text = (不含1類銷售小記 - Val(稅金_tb.Text) - Val(刷卡傭金_tb.Text) - Val(其他成本_tb.Text)) / 100 * 3
                End If
            Else
                司機運費_tb.Text = 運費
            End If
        End If
        '-------006-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        預估利潤_tb.Text = Val(售價小計_tb.Text) + Val(額外收支_tb.Text) - Val(其他成本_tb.Text) - Val(物料成本_tb.Text) - Val(司機運費_tb.Text) - Val(管銷費用_tb.Text) - Val(刷卡傭金_tb.Text)
        '-------007-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        售價小計_tb.Text = Format(Val(售價小計_tb.Text), "#,##0") : 稅金_tb.Text = Format(Val(稅金_tb.Text), "#,##0") : 銷售合計_tb.Text = Format(Val(銷售合計_tb.Text), "#,##0")
        收入小計_tb.Text = Format(Val(收入小計_tb.Text), "#,##0") : 支出小計_tb.Text = Format(Val(支出小計_tb.Text), "#,##0") : 額外收支_tb.Text = Format(Val(額外收支_tb.Text), "#,##0")
        司機運費_tb.Text = Format(Val(司機運費_tb.Text), "#,##0") : 管銷費用_tb.Text = Format(Val(管銷費用_tb.Text), "#,##0") : 預估利潤_tb.Text = Format(Val(預估利潤_tb.Text), "#,##0")
        物料成本_tb.Text = Format(Val(物料成本_tb.Text), "#,##0") : 其他成本_tb.Text = Format(Val(其他成本_tb.Text), "#,##0") : 刷卡總和_tb.Text = Format(Val(刷卡總和_tb.Text), "#,##0")
        刷卡稅金_tb.Text = Format(Val(刷卡稅金_tb.Text), "#,##0") : 刷卡傭金_tb.Text = Format(Val(刷卡傭金_tb.Text), "#,##0")
    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
        Me.MdiParent = YD_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
        中間距_ch.Checked = True : 確認出貨_bt.Enabled = False : 自動盤盈_cb.Enabled = CC(35)
        自動盤盈_cb.Checked = CC(36) : 無資料_bt.Enabled = False '--------------------控件隱藏、操作許可設定與其他基本顯示設定
        送貨地點_cb_下拉表單資料載入()
        首次開啟 = False : Set_清單1() : 首次開啟 = True '--------------------資料讀取
        SQL_銷售明細表_已出貨明細修正() : 業務_cb_下拉表單資料載入()
    End Sub
    Private Sub 銷售單申請_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
        If 單號_tb.Text = "" Then : Else
            Set_清單4() : Set_清單5() : Set_清單6()
        End If
    End Sub
    Private Sub 收款事項_dgv_CellEndEdit(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 收款事項_dgv.CellEndEdit
        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
            銷售收款流水號_tb.Text = 收款事項_dgv("資料流水號", e.RowIndex).Value.ToString : 項次2_tb.Text = 收款事項_dgv("項次", e.RowIndex).Value.ToString
            項次3_tb.Text = 收款事項_dgv("真項次", e.RowIndex).Value.ToString
        End If
    End Sub
    Private Sub 銷售備註_dgvCellEndEdit(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 銷售備註_dgv.CellEndEdit
        If (Val(銷售備註_dgv.Rows(e.RowIndex).Cells("收入").Value) <> 0 And Val(銷售備註_dgv.Rows(e.RowIndex).Cells("支出").Value) <> 0) Then
            MsgBox("支出與收入不能同時有金額")
            Set_清單5()
            Exit Sub
        End If
        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
            銷售備註流水號_tb.Text = 銷售備註_dgv("資料流水號", e.RowIndex).Value.ToString : 項次1_tb.Text = 銷售備註_dgv("項次", e.RowIndex).Value.ToString
        End If
    End Sub
    Private Sub 銷售明細_dgv_CellEndEdit(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 銷售明細_dgv.CellEndEdit
        Dim 計數判斷 As Integer = 0
        For i As Integer = 0 To 銷售明細_dgv.Rows.Count - 1
            If 銷售明細_dgv("含稅", i).Value = False Then
                銷售明細_dgv("售價", i).Value = 銷售明細_dgv("數量", i).Value * 銷售明細_dgv("單價", i).Value
            ElseIf 銷售明細_dgv("含稅", i).Value = True Then
                銷售明細_dgv("售價", i).Value = 銷售明細_dgv("數量", i).Value * 銷售明細_dgv("單價", i).Value * 1.05
            End If
            If 銷售明細_dgv("準備出貨", i).Value = True Then
                計數判斷 = 計數判斷 + 1
            End If
        Next
        Set_合記計算()
        If 計數判斷 = 0 Then
            出貨形式_lb.Text = "出貨形式 : 未選擇"
        ElseIf 計數判斷 = 銷售明細_dgv.Rows.Count Then
            出貨形式_lb.Text = "出貨形式 : 整單出貨"
        ElseIf 計數判斷 < 銷售明細_dgv.Rows.Count Then
            出貨形式_lb.Text = "出貨形式 : 拆單出貨"
        End If
    End Sub
    Private Sub 銷售明細_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 銷售明細_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            銷售資料流水號_tb.Text = 銷售明細_dgv("資料流水號", e.RowIndex).Value.ToString : 倉儲資料流水號_tb.Text = 銷售明細_dgv("倉儲流水號", e.RowIndex).Value.ToString
            項次_tb.Text = 銷售明細_dgv("項次", e.RowIndex).Value.ToString
            物料圖1_pb.Image = Nothing : PA1 = 銷售明細_dgv("料號", e.RowIndex).Value : SQL_物料檔案_是否有圖()
            If dr.Read() Then
                If dr("是否有圖") = True Then
                    物料圖1_pb.BackgroundImage = Nothing
                    PA = 銷售明細_dgv("料號", e.RowIndex).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
                Else
                    物料圖1_pb.BackgroundImage = My.Resources.底圖1 : 物料圖1_pb.BackgroundImageLayout = 3
                    物料圖1_pb.Image = Nothing
                End If
            End If : conn.Close()
        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("流水號").Value : 單號_tb.Text = 銷售單據_dgv.Rows(e.RowIndex).Cells("單號").Value
            開單日期_dtp.Value = 銷售單據_dgv.Rows(e.RowIndex).Cells("開單日期").Value : 客戶編號_tb.Text = 銷售單據_dgv.Rows(e.RowIndex).Cells("客戶編號").Value
            交貨日期_dtp.Value = 銷售單據_dgv.Rows(e.RowIndex).Cells("交貨日期").Value : 含稅_ch.Checked = 銷售單據_dgv.Rows(e.RowIndex).Cells("含稅").Value
            實際出貨日期_dtp.Value = 銷售單據_dgv.Rows(e.RowIndex).Cells("交貨日期").Value
            送貨地點_cb_下拉表單資料載入() : 送貨地點_cb.Text = 銷售單據_dgv.Rows(e.RowIndex).Cells("送貨地點").Value.ToString
            運費 = 銷售單據_dgv.Rows(e.RowIndex).Cells("運費").Value
            '業務_cb.Text = Strings.Left(銷售單據_dgv.Rows(e.RowIndex).Cells("單號").Value, 1)
            Set_清單4() : Set_清單5()
            Set_清單6()
            PA = 單號_tb.Text : SQL_銷售單號串聯倉儲表取得倉儲單號()
            If dr.Read() Then : 調庫單號_tb.Text = dr("執行單號") : Else : 調庫單號_tb.Text = "" : End If

            If 齊套_lb.Text = "產品已備齊" Then
                確認出貨_bt.Enabled = True
            Else
                If 自動盤盈_cb.Checked = True Then
                    確認出貨_bt.Enabled = True
                Else
                    確認出貨_bt.Enabled = False
                End If
            End If
            If 銷售明細_dgv.Rows.Count = 0 Then
                無資料_bt.Enabled = True
            Else
                無資料_bt.Enabled = False
            End If
        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_清單4()
    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_清單4()
    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_清單4()
    End Sub
    Private Sub 送貨地點_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 送貨地點_cb.SelectedIndexChanged
        最低運費_cb.SelectedIndex = 送貨地點_cb.SelectedIndex : 最低售價_cb.SelectedIndex = 送貨地點_cb.SelectedIndex : Set_合記計算()
    End Sub
    Private Sub 最低運費_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 最低運費_cb.SelectedIndexChanged
        送貨地點_cb.SelectedIndex = 最低運費_cb.SelectedIndex : 最低售價_cb.SelectedIndex = 最低運費_cb.SelectedIndex
    End Sub
    Private Sub 最低售價_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 最低售價_cb.SelectedIndexChanged
        送貨地點_cb.SelectedIndex = 最低售價_cb.SelectedIndex : 最低運費_cb.SelectedIndex = 最低售價_cb.SelectedIndex
    End Sub
    Private Sub 業務_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 業務_cb.SelectedIndexChanged
        Set_清單1()
    End Sub
    Private Sub 含稅_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 含稅_ch.CheckedChanged
        For i As Integer = 0 To 銷售明細_dgv.Rows.Count - 1
            If 含稅_ch.Checked = False Then : 銷售明細_dgv("含稅", i).Value = False
            ElseIf 含稅_ch.Checked = True Then : 銷售明細_dgv("含稅", i).Value = True
            End If
            If 銷售明細_dgv("含稅", i).Value = False Then
                銷售明細_dgv("售價", i).Value = 銷售明細_dgv("數量", i).Value * 銷售明細_dgv("單價", i).Value
            ElseIf 銷售明細_dgv("含稅", i).Value = True Then
                銷售明細_dgv("售價", i).Value = 銷售明細_dgv("數量", i).Value * 銷售明細_dgv("單價", i).Value * 1.05
            End If
        Next
        Set_合記計算()
    End Sub
    Private Sub 客戶編號_tb_TextChanged(sender As Object, e As EventArgs) Handles 客戶編號_tb.TextChanged
        PA15 = 客戶編號_tb.Text
        SQL_銷售單申請_客戶資料()
        If dr.Read() Then
            客戶_tb.Text = dr("名稱") : 公司_tb.Text = dr("公司名稱") : 統編_tb.Text = dr("統編") : 住址_tb.Text = dr("地址") : 電話1_tb.Text = dr("電話1") : 電話2_tb.Text = dr("電話2")
        Else
            客戶_tb.Text = "" : 公司_tb.Text = "" : 統編_tb.Text = "" : 住址_tb.Text = "" : 電話1_tb.Text = "" : 電話2_tb.Text = ""
        End If
    End Sub
    Private Sub 客戶1_tb_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles 客戶1_tb.KeyPress
        If e.KeyChar = Chr(13) Then
            Set_清單1()
        End If
    End Sub
    Private Sub 自動盤盈_cb_CheckedChanged(sender As Object, e As EventArgs) Handles 自動盤盈_cb.Click
        If 自動盤盈_cb.Checked = True Then
            確認出貨_bt.Enabled = True
        Else
            確認出貨_bt.Enabled = False
        End If
    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 = True : 出貨形式_lb.Text = "出貨形式 : 整單出貨" : Next i
    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 : 出貨形式_lb.Text = "出貨形式 : 未選擇" : Next i
    End Sub
    Private Sub Set_日期格式轉換1()
        DTP = Format(實際出貨日期_dtp.Value, "yyyy/MM/dd") : DTP1 = Format(實際出貨日期_dtp.Value, "yyyyMMdd")
    End Sub
    Private Sub Set_銷售出貨()
        Set_日期格式轉換1()
        For i As Integer = 1 To 999
            資料數 = 999 : MyModule1.進度條()
            NUM1 = 0 + i
            If NUM1 < 10 Then : 調庫單號_tb.Text = "WH-" & DTP1 & "-00" & NUM1
            ElseIf NUM1 > 9 And NUM1 < 100 Then : 調庫單號_tb.Text = "WH-" & DTP1 & "-0" & NUM1
            ElseIf NUM1 > 99 Then : 調庫單號_tb.Text = "WH-" & DTP1 & "-" & NUM1
            End If
            PA1 = 調庫單號_tb.Text
            SQL_倉儲明細執行單號_執行單號驗證()
            If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close()
        Next : YD_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
        SQL_倉儲明細執行單號_新增() : conn.Close()

        For i As Integer = 0 To 銷售明細_dgv.Rows.Count - 1
            資料數 = 銷售明細_dgv.Rows.Count : MyModule1.進度條()
            If 銷售明細_dgv.Rows(i).Cells("準備出貨").Value = True Then
                SQL_倉儲明細表_最後一筆資料()
                If dr.Read() Then : EDR = Double.Parse(Strings.Right(dr("資料流水號").ToString, 9)) : Else : EDR = 0 : End If
                conn.Close() : EDR += 1
                If EDR < 10 Then : ESTR = "WH" & "00000000" & EDR
                ElseIf EDR > 9 And EDR < 100 Then : ESTR = "WH" & "0000000" & EDR
                ElseIf EDR > 99 And EDR < 1000 Then : ESTR = "WH" & "000000" & EDR
                ElseIf EDR > 999 And EDR < 10000 Then : ESTR = "WH" & "00000" & EDR
                ElseIf EDR > 9999 And EDR < 100000 Then : ESTR = "WH" & "0000" & EDR
                ElseIf EDR > 99999 And EDR < 100000 Then : ESTR = "WH" & "000" & EDR
                ElseIf EDR > 999999 And EDR < 1000000 Then : ESTR = "WH" & "00" & EDR
                ElseIf EDR > 9999999 And EDR < 10000000 Then : ESTR = "WH" & "0" & EDR
                ElseIf EDR > 99999999 Then : ESTR = "WH" & EDR : End If

                Set_日期格式轉換1()
                PA3 = ESTR : PA4 = 調庫單號_tb.Text
                PA5 = 銷售明細_dgv.Rows(i).Cells("倉級").Value.ToString : PA6 = 銷售明細_dgv.Rows(i).Cells("倉儲狀態").Value.ToString
                PA2 = 銷售明細_dgv.Rows(i).Cells("料號").Value.ToString : NU1 = 0 : NU2 = 銷售明細_dgv.Rows(i).Cells("數量").Value
                PA1 = 銷售明細_dgv.Rows(i).Cells("備註").Value.ToString : PA = 單號_tb.Text
                PA7 = 銷售明細_dgv.Rows(i).Cells("物料狀態").Value.ToString : PA8 = 銷售明細_dgv.Rows(i).Cells("訂製狀態").Value.ToString
                PA9 = gUserName : PA10 = 銷售明細_dgv.Rows(i).Cells("採購流水").Value.ToString : PA11 = 銷售明細_dgv.Rows(i).Cells("資料流水號").Value.ToString
                SQL_倉儲明細表_倉儲出庫() : SQL_倉儲入庫_銷售明細表修改() : conn.Close()
            End If
        Next : YD_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
    End Sub
    Private Sub 確認出貨_bt_Click(sender As Object, e As EventArgs) Handles 確認出貨_bt.Click
        Dim 計數判斷 As Integer = 0
        For i As Integer = 0 To 銷售明細_dgv.Rows.Count - 1
            If 銷售明細_dgv("準備出貨", i).Value = True Then
                計數判斷 = 計數判斷 + 1
            End If
        Next

        If 計數判斷 = 0 Then
            出貨形式_lb.Text = "出貨形式 : 未選擇"
        ElseIf 計數判斷 = 銷售明細_dgv.Rows.Count Then
            出貨形式_lb.Text = "出貨形式 : 整單出貨"
        ElseIf 計數判斷 < 銷售明細_dgv.Rows.Count Then
            出貨形式_lb.Text = "出貨形式 : 拆單出貨"
        End If

        If 出貨形式_lb.Text = "出貨形式 : 未選擇" Then
            MsgBox("需要選擇出貨明細!!")
        Else
            Dim aa1 As MsgBoxResult = MsgBox("請確定選擇的入庫資料是否正確?", MsgBoxStyle.OkCancel)
            If aa1 = MsgBoxResult.Ok Then
                If 自動盤盈_cb.Checked = True Then
                    '----------無料盤盈--------------------------------------------------------------------------
                    Dim 判斷是否需要盤盈 As Boolean = False
                    For i As Integer = 0 To 銷售明細_dgv.Rows.Count - 1
                        If 銷售明細_dgv.Rows(i).Cells("準備出貨").Value = True Then
                            If Val(銷售明細_dgv.Rows(i).Cells("數量").Value) > Val(銷售明細_dgv.Rows(i).Cells("庫存").Value) Then
                                判斷是否需要盤盈 = True : Exit For
                            End If
                        End If
                    Next

                    If 判斷是否需要盤盈 = True Then
                        Set_日期格式轉換()
                        For i As Integer = 1 To 999
                            資料數 = 999 : MyModule1.進度條()
                            NUM1 = 0 + i
                            If NUM1 < 10 Then : 調庫單號_tb.Text = "WH-" & DTP1 & "-00" & NUM1
                            ElseIf NUM1 > 9 And NUM1 < 100 Then : 調庫單號_tb.Text = "WH-" & DTP1 & "-0" & NUM1
                            ElseIf NUM1 > 99 Then : 調庫單號_tb.Text = "WH-" & DTP1 & "-" & NUM1
                            End If
                            PA1 = 調庫單號_tb.Text
                            SQL_倉儲明細執行單號_執行單號驗證()
                            If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close()
                        Next : YD_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
                        SQL_倉儲明細執行單號_新增()

                        For i As Integer = 0 To 銷售明細_dgv.Rows.Count - 1
                            資料數 = 銷售明細_dgv.Rows.Count : MyModule1.進度條()
                            If 銷售明細_dgv.Rows(i).Cells("準備出貨").Value = True Then
                                If Val(銷售明細_dgv.Rows(i).Cells("數量").Value) > Val(銷售明細_dgv.Rows(i).Cells("庫存").Value) Then
                                    Dim 盤盈數量 As Integer = 0
                                    盤盈數量 = Val(銷售明細_dgv.Rows(i).Cells("數量").Value) - Val(銷售明細_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

                                    Set_日期格式轉換()
                                    PA3 = ESTR : PA4 = 調庫單號_tb.Text : NU1 = 盤盈數量 : NU2 = 0 : PA9 = gUserName : PA = 單號_tb.Text
                                    PA5 = 銷售明細_dgv.Rows(i).Cells("倉級").Value.ToString : PA6 = 銷售明細_dgv.Rows(i).Cells("倉儲狀態").Value.ToString
                                    PA7 = 銷售明細_dgv.Rows(i).Cells("物料狀態").Value.ToString : PA8 = 銷售明細_dgv.Rows(i).Cells("訂製狀態").Value.ToString
                                    PA1 = 銷售明細_dgv.Rows(i).Cells("備註").Value.ToString : PA2 = 銷售明細_dgv.Rows(i).Cells("料號").Value.ToString

                                    SQL_倉儲出庫_自動盤盈() : conn.Close()
                                End If
                            End If
                        Next : YD_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0

                        '----------銷售出庫--------------------------------------------------------------------------
                        Set_銷售出貨()
                        If 出貨形式_lb.Text = "出貨形式 : 整單出貨" Then
                            SQL_倉儲入庫_銷售控制表修改() : conn.Close()
                        End If
                        Set_清單1() : SQL_銷售明細表_已出貨明細修正()
                        MsgBox("出貨完成")
                        銷售明細_dgv.DataSource = Nothing : ds4.Clear()
                    Else
                        Set_銷售出貨()
                        If 出貨形式_lb.Text = "出貨形式 : 整單出貨" Then
                            SQL_倉儲入庫_銷售控制表修改() : conn.Close()
                        End If
                        Set_清單1() : SQL_銷售明細表_已出貨明細修正()
                        MsgBox("出貨完成")
                        銷售明細_dgv.DataSource = Nothing : ds4.Clear()
                    End If
                ElseIf 自動盤盈_cb.Checked = False Then
                    Set_銷售出貨()
                    If 出貨形式_lb.Text = "出貨形式 : 整單出貨" Then
                        SQL_倉儲入庫_銷售控制表修改() : conn.Close()
                    End If
                    Set_清單1() : SQL_銷售明細表_已出貨明細修正()
                    MsgBox("出貨完成")
                    銷售明細_dgv.DataSource = Nothing : ds4.Clear()
                End If
            End If
        End If
    End Sub
    Private Sub 重新整理_tsm_Click(sender As Object, e As EventArgs) Handles 重新整理_tsm.Click
        Set_清單1() : SQL_銷售明細表_已出貨明細修正()
    End Sub
    Private Sub 無資料_bt_Click(sender As Object, e As EventArgs) Handles 無資料_bt.Click
        PA = 單號_tb.Text : SQL_倉儲入庫_銷售控制表修改() : Set_清單1() : conn.Close()
    End Sub
    Private Sub 字體_NUD_ValueChanged(sender As Object, e As EventArgs) Handles 字體_NUD.ValueChanged
        銷售明細_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
        銷售備註_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
        收款事項_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
        銷售單據_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
    End Sub
End Class