12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- Option Strict Off
- Public Class 出庫紀錄表
- ReadOnly ds1 As New DataSet
- Private Sub DGV2讀取前設定()
- DataGridView2.DataSource = Nothing : ds1.Clear()
- DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
- DataGridView2.ColumnHeadersHeight = 25
- DataGridView2.AllowUserToAddRows = False
- ConnOpen()
- End Sub
- Private Sub DGV2讀取後設定()
- CmdSet_For_DGV() : da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close()
- End Sub
- Private Sub 讀取出庫紀錄表()
- If PA = "" Then
- DGV2讀取前設定()
- SQL1 = "SELECT 零件出庫紀錄.零件編號, 零件出庫紀錄.結單日期, 零件出庫紀錄.出貨數量, 零件成本紀錄表.品名, 零件成本紀錄表.型號及備註, 零件出庫紀錄.進貨成本, " &
- "零件出庫紀錄.出貨金額, 零件出庫紀錄.利潤, 零件出庫紀錄.台幣利潤 FROM 零件出庫紀錄 INNER JOIN 零件成本紀錄表 ON 零件出庫紀錄.零件編號 = 零件成本紀錄表.流水碼 " &
- "ORDER BY 零件出庫紀錄.結單日期 DESC"
- 列印用SQL1 = SQL1 : DGV2讀取後設定() : Set_自動彙總1()
- Else
- DGV2讀取前設定()
- SQL1 = "SELECT 零件出庫紀錄.零件編號, 零件出庫紀錄.結單日期, 零件出庫紀錄.出貨數量, 零件成本紀錄表.品名, 零件成本紀錄表.型號及備註, 零件出庫紀錄.進貨成本, " &
- "零件出庫紀錄.出貨金額, 零件出庫紀錄.利潤, 零件出庫紀錄.台幣利潤 FROM 零件出庫紀錄 INNER JOIN 零件成本紀錄表 ON 零件出庫紀錄.零件編號 = 零件成本紀錄表.流水碼 " &
- "WHERE (零件出庫紀錄.零件編號 LIKE N'%" & PA & "%') OR (零件出庫紀錄.結單日期 LIKE N'%" & PA & "%') OR (零件出庫紀錄.出貨數量 LIKE N'%" & PA & "%') OR " &
- "(零件成本紀錄表.品名 LIKE N'%" & PA & "%') OR (零件成本紀錄表.型號及備註 LIKE N'%" & PA & "%')ORDER BY 零件出庫紀錄.結單日期 DESC"
- 列印用SQL1 = SQL1 : DGV2讀取後設定() : Set_自動彙總1()
- End If
- End Sub
- Private Sub Set_自動彙總1()
- Dim 數量加總 As Double = 0 : Dim 金額加總1 As Double = 0 : Dim 金額加總2 As Double = 0 : Dim 金額加總3 As Double = 0 : Dim 金額加總4 As Double = 0
- For i As Integer = 0 To DataGridView2.Rows.Count - 1
- If DataGridView2.RowCount = 0 Then : TextBox13.Text = "0" : Else : 數量加總 += DataGridView2.Rows(i).Cells("出貨數量").Value : End If
- Next i
- For i As Integer = 0 To DataGridView2.Rows.Count - 1
- If DataGridView2.RowCount = 0 Then : TextBox16.Text = "0.00" : Else : 金額加總1 += DataGridView2.Rows(i).Cells("進貨成本").Value : End If
- Next i
- For i As Integer = 0 To DataGridView2.Rows.Count - 1
- If DataGridView2.RowCount = 0 Then : TextBox1.Text = "0.00" : Else : 金額加總2 += DataGridView2.Rows(i).Cells("出貨金額").Value : End If
- Next i
- For i As Integer = 0 To DataGridView2.Rows.Count - 1
- If DataGridView2.RowCount = 0 Then : TextBox17.Text = "0.00" : Else : 金額加總3 += DataGridView2.Rows(i).Cells("利潤").Value : End If
- Next i
- For i As Integer = 0 To DataGridView2.Rows.Count - 1
- If DataGridView2.RowCount = 0 Then : TextBox2.Text = "0.00" : Else : 金額加總4 += DataGridView2.Rows(i).Cells("台幣利潤").Value : End If
- Next i
-
- TextBox13.Text = Format(Val(數量加總), "#,##0")
- TextBox16.Text = Format(Val(金額加總1), "#,##0.00")
- TextBox1.Text = Format(Val(金額加總2), "#,##0.00")
- TextBox17.Text = Format(Val(金額加總3), "#,##0.00")
- TextBox2.Text = Format(Val(金額加總4), "#,##0.00")
- If 金額加總3 = 0 Then
- TextBox3.Text = "0.00%"
- Else
- TextBox3.Text = Format(Val(金額加總2 / 金額加總3), "#,##0.00") & "%"
- End If
- End Sub
- Private Sub Set_grid2()
- DataGridView2.Columns(0).Width = 70 : DataGridView2.Columns(1).Width = 70 : DataGridView2.Columns(2).Width = 70 : DataGridView2.Columns(3).Width = 150
- DataGridView2.Columns(4).Width = 150 : DataGridView2.Columns(5).Width = 70 : DataGridView2.Columns(6).Width = 70 : DataGridView2.Columns(7).Width = 70
- DataGridView2.Columns(8).Width = 70
-
- DataGridView2.Columns(2).DefaultCellStyle.Format = "#,##0" : DataGridView2.Columns(5).DefaultCellStyle.Format = "#,##0.00"
- DataGridView2.Columns(6).DefaultCellStyle.Format = "#,##0.00" : DataGridView2.Columns(7).DefaultCellStyle.Format = "#,##0.00"
- DataGridView2.Columns(8).DefaultCellStyle.Format = "#,##0.00"
- End Sub
- Private Sub 出庫紀錄表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- FormBorderStyle = FormBorderStyle.SizableToolWindow
- 讀取出庫紀錄表() : Set_grid2()
- End Sub
- Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
- timeNow = 0
- GCM_ERP_SYS.Timer1.Enabled = False
- GCM_ERP_SYS.Timer1.Enabled = True
- End Sub
- Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
- timeNow = 0
- GCM_ERP_SYS.Timer1.Enabled = False
- GCM_ERP_SYS.Timer1.Enabled = True
- End Sub
- Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
- PA = InputBox("請輸入要查詢零件的資料")
- 讀取出庫紀錄表() : Set_grid2()
- PA = ""
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- 列印(1) = True
- 列印清單.Show()
- End Sub
- End Class
|