Option Strict Off
Public Class 盤盈盤損控制表
    ReadOnly ds1 As New DataSet : ReadOnly ds2 As New DataSet
    Private Sub Set_清單2()
        調庫單據_dgv.DataSource = Nothing : ds2.Clear()
        調庫單據_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        調庫單據_dgv.ColumnHeadersHeight = 25
        調庫單據_dgv.AllowUserToAddRows = False
        調庫單據_dgv.RowTemplate.Height = 30
        調庫明細_dgv.RowTemplate.Height = 30

        SQL_盤盈盤損控制表_單據()
        da.Fill(ds2) : 調庫單據_dgv.DataSource = ds2.Tables(0) : conn.Close()
        資料筆數_tb.Text = 調庫單據_dgv.Rows.Count
        調庫單據_dgv.Columns(0).FillWeight = 150 : 調庫單據_dgv.Columns(1).FillWeight = 100 : 調庫單據_dgv.Columns(2).FillWeight = 100 : 調庫單據_dgv.Columns(2).FillWeight = 150
        調庫單據_dgv.Columns(2).FillWeight = 100 : 調庫單據_dgv.Columns(2).FillWeight = 100 : 調庫單據_dgv.Columns(2).FillWeight = 100
        調庫單據_dgv.Columns(0).ReadOnly = True : 調庫單據_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
    End Sub
    Private Sub Set_清單1()
        調庫明細_dgv.DataSource = Nothing : ds1.Clear()
        調庫明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        調庫明細_dgv.ColumnHeadersHeight = 40
        調庫明細_dgv.AllowUserToAddRows = False
        調庫明細_dgv.RowTemplate.Height = 35

        PA20 = 調庫單號_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).FillWeight = 100 : 調庫明細_dgv.Columns(3).FillWeight = 75
        調庫明細_dgv.Columns(4).FillWeight = 200 : 調庫明細_dgv.Columns(5).FillWeight = 100 : 調庫明細_dgv.Columns(6).FillWeight = 100 : 調庫明細_dgv.Columns(7).FillWeight = 50
        調庫明細_dgv.Columns(8).FillWeight = 50 : 調庫明細_dgv.Columns(9).FillWeight = 75 : 調庫明細_dgv.Columns(10).FillWeight = 100 : 調庫明細_dgv.Columns(11).FillWeight = 35
        調庫明細_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(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(9).ReadOnly = True : 調庫明細_dgv.Columns(11).ReadOnly = True
        調庫明細_dgv.EditMode = DataGridViewEditMode.EditOnEnter : 資料筆數1_tb.Text = 調庫明細_dgv.Rows.Count
    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
        Set_清單2()
        If YD_ERP_SYS.Size.Width > 1440 And YD_ERP_SYS.Size.Height > 900 Then
            字體_NUD.Value = 9
        ElseIf YD_ERP_SYS.Size.Width <= 1440 And YD_ERP_SYS.Size.Height <= 900 Then
            字體_NUD.Value = 7.6
        End If
    End Sub
    Private Sub 盤盈盤損控制表_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
        If YD_ERP_SYS.Size.Width > 1440 And YD_ERP_SYS.Size.Height > 900 Then
            字體_NUD.Value = 9
        ElseIf YD_ERP_SYS.Size.Width <= 1440 And YD_ERP_SYS.Size.Height <= 900 Then
            字體_NUD.Value = 8
        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
            Set_清單1()
        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
            物料圖1_pb.Image = Nothing : PA1 = 調庫明細_dgv.Rows(e.RowIndex).Cells("料號").Value : SQL_物料檔案_是否有圖()
            If dr.Read() Then
                If dr("是否有圖") = True Then
                    物料圖1_pb.BackgroundImage = Nothing
                    PA = 調庫明細_dgv.Rows(e.RowIndex).Cells("料號").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 字體_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)
    End Sub
End Class