Public Class 營運日報表
    ReadOnly ds, ds1 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 = 35

        PA = Strings.Format(開單日期_dtp.Value, "yyyy/MM/dd")
        SQL_當日簽單()
        da.Fill(ds1) : 今日開單_dgv.DataSource = ds1.Tables(0) : conn.Close()
        今日開單_dgv.Columns("簽單金額").DefaultCellStyle.Format = "#,##0" : 今日開單_dgv.Columns("目前已收").DefaultCellStyle.Format = "#,##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
        For i As Integer = 0 To 今日開單_dgv.Rows.Count - 1
            If 今日開單_dgv("簽單金額", i).Value.ToString = "" Then : 今日開單_dgv("簽單金額", i).Value = 0 : End If
            If 今日開單_dgv("目前已收", i).Value.ToString = "" Then : 今日開單_dgv("目前已收", i).Value = 0 : End If
            If 今日開單_dgv("其他應收", i).Value.ToString = "" Then : 今日開單_dgv("其他應收", i).Value = 0 : End If
            今日開單_dgv("未收餘額", i).Value =
                    CInt(今日開單_dgv("簽單金額", i).Value.ToString) + CInt(今日開單_dgv("其他應收", i).Value.ToString) - CInt(今日開單_dgv("目前已收", i).Value.ToString)
        Next
    End Sub
    Private Sub Set_清單2()
        今日送貨_dgv.DataSource = Nothing : ds.Clear()
        今日送貨_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        今日送貨_dgv.ColumnHeadersHeight = 25
        今日送貨_dgv.AllowUserToAddRows = False
        今日送貨_dgv.RowTemplate.Height = 35

        PA = Strings.Format(開單日期_dtp.Value, "yyyy/MM/dd")
        SQL_當日送貨()
        da.Fill(ds) : 今日送貨_dgv.DataSource = ds.Tables(0) : conn.Close()
        今日送貨_dgv.Columns("簽單金額").DefaultCellStyle.Format = "#,##0" : 今日送貨_dgv.Columns("目前已收").DefaultCellStyle.Format = "#,##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
        For i As Integer = 0 To 今日送貨_dgv.Rows.Count - 1
            If 今日送貨_dgv("簽單金額", i).Value.ToString = "" Then : 今日送貨_dgv("簽單金額", i).Value = 0 : End If
            If 今日送貨_dgv("目前已收", i).Value.ToString = "" Then : 今日送貨_dgv("目前已收", i).Value = 0 : End If
            If 今日送貨_dgv("其他應收", i).Value.ToString = "" Then : 今日送貨_dgv("其他應收", i).Value = 0 : End If
            今日送貨_dgv("未收餘額", i).Value =
                    CInt(今日送貨_dgv("簽單金額", i).Value.ToString) + CInt(今日送貨_dgv("其他應收", i).Value.ToString) - CInt(今日送貨_dgv("目前已收", i).Value.ToString)
        Next
    End Sub
    Private Sub 營運日報表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Set_清單1() : Set_清單2()
    End Sub
    Private Sub 上一天_bt_Click(sender As Object, e As EventArgs) Handles 上一天_bt.Click
        開單日期_dtp.Value = 開單日期_dtp.Value.AddDays(-1)
    End Sub
    Private Sub 下一天_bt_Click(sender As Object, e As EventArgs) Handles 下一天_bt.Click
        開單日期_dtp.Value = 開單日期_dtp.Value.AddDays(1)
    End Sub
    Private Sub 今天_bt_Click(sender As Object, e As EventArgs) Handles 今天_bt.Click
        開單日期_dtp.Value = Today()
    End Sub
    Private Sub 開單日期_dtp_ValueChanged(sender As Object, e As EventArgs) Handles 開單日期_dtp.ValueChanged
        Set_清單1() : Set_清單2()
    End Sub
End Class