Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

出庫紀錄表.vb 5.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. Option Strict Off
  2. Public Class 出庫紀錄表
  3. ReadOnly ds1 As New DataSet
  4. Private Sub DGV2讀取前設定()
  5. DataGridView2.DataSource = Nothing : ds1.Clear()
  6. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  7. DataGridView2.ColumnHeadersHeight = 25
  8. DataGridView2.AllowUserToAddRows = False
  9. ConnOpen()
  10. End Sub
  11. Private Sub DGV2讀取後設定()
  12. CmdSet_For_DGV() : da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close()
  13. End Sub
  14. Private Sub 讀取出庫紀錄表()
  15. If PA = "" Then
  16. DGV2讀取前設定()
  17. SQL1 = "SELECT 零件出庫紀錄.零件編號, 零件出庫紀錄.結單日期, 零件出庫紀錄.出貨數量, 零件成本紀錄表.品名, 零件成本紀錄表.型號及備註, 零件出庫紀錄.進貨成本, " &
  18. "零件出庫紀錄.出貨金額, 零件出庫紀錄.利潤, 零件出庫紀錄.台幣利潤 FROM 零件出庫紀錄 INNER JOIN 零件成本紀錄表 ON 零件出庫紀錄.零件編號 = 零件成本紀錄表.流水碼 " &
  19. "ORDER BY 零件出庫紀錄.結單日期 DESC"
  20. 列印用SQL1 = SQL1 : DGV2讀取後設定() : Set_自動彙總1()
  21. Else
  22. DGV2讀取前設定()
  23. SQL1 = "SELECT 零件出庫紀錄.零件編號, 零件出庫紀錄.結單日期, 零件出庫紀錄.出貨數量, 零件成本紀錄表.品名, 零件成本紀錄表.型號及備註, 零件出庫紀錄.進貨成本, " &
  24. "零件出庫紀錄.出貨金額, 零件出庫紀錄.利潤, 零件出庫紀錄.台幣利潤 FROM 零件出庫紀錄 INNER JOIN 零件成本紀錄表 ON 零件出庫紀錄.零件編號 = 零件成本紀錄表.流水碼 " &
  25. "WHERE (零件出庫紀錄.零件編號 LIKE '%" & PA & "%') OR (零件出庫紀錄.結單日期 LIKE '%" & PA & "%') OR (零件出庫紀錄.出貨數量 LIKE '%" & PA & "%') OR " &
  26. "(零件成本紀錄表.品名 LIKE '%" & PA & "%') OR (零件成本紀錄表.型號及備註 LIKE '%" & PA & "%')ORDER BY 零件出庫紀錄.結單日期 DESC"
  27. 列印用SQL1 = SQL1 : DGV2讀取後設定() : Set_自動彙總1()
  28. End If
  29. End Sub
  30. Private Sub Set_自動彙總1()
  31. Dim 數量加總 As Double = 0 : Dim 金額加總1 As Double = 0 : Dim 金額加總2 As Double = 0 : Dim 金額加總3 As Double = 0 : Dim 金額加總4 As Double = 0
  32. For i As Integer = 0 To DataGridView2.Rows.Count - 1
  33. If DataGridView2.RowCount = 0 Then : TextBox13.Text = "0" : Else : 數量加總 += DataGridView2.Rows(i).Cells("出貨數量").Value : End If
  34. Next i
  35. For i As Integer = 0 To DataGridView2.Rows.Count - 1
  36. If DataGridView2.RowCount = 0 Then : TextBox16.Text = "0.00" : Else : 金額加總1 += DataGridView2.Rows(i).Cells("進貨成本").Value : End If
  37. Next i
  38. For i As Integer = 0 To DataGridView2.Rows.Count - 1
  39. If DataGridView2.RowCount = 0 Then : TextBox1.Text = "0.00" : Else : 金額加總2 += DataGridView2.Rows(i).Cells("出貨金額").Value : End If
  40. Next i
  41. For i As Integer = 0 To DataGridView2.Rows.Count - 1
  42. If DataGridView2.RowCount = 0 Then : TextBox17.Text = "0.00" : Else : 金額加總3 += DataGridView2.Rows(i).Cells("利潤").Value : End If
  43. Next i
  44. For i As Integer = 0 To DataGridView2.Rows.Count - 1
  45. If DataGridView2.RowCount = 0 Then : TextBox2.Text = "0.00" : Else : 金額加總4 += DataGridView2.Rows(i).Cells("台幣利潤").Value : End If
  46. Next i
  47. TextBox13.Text = Format(Val(數量加總), "#,##0")
  48. TextBox16.Text = Format(Val(金額加總1), "#,##0.00")
  49. TextBox1.Text = Format(Val(金額加總2), "#,##0.00")
  50. TextBox17.Text = Format(Val(金額加總3), "#,##0.00")
  51. TextBox2.Text = Format(Val(金額加總4), "#,##0.00")
  52. If 金額加總3 = 0 Then
  53. TextBox3.Text = "0.00%"
  54. Else
  55. TextBox3.Text = Format(Val(金額加總2 / 金額加總3), "#,##0.00") & "%"
  56. End If
  57. End Sub
  58. Private Sub Set_grid2()
  59. DataGridView2.Columns(0).Width = 70 : DataGridView2.Columns(1).Width = 70 : DataGridView2.Columns(2).Width = 70 : DataGridView2.Columns(3).Width = 150
  60. DataGridView2.Columns(4).Width = 150 : DataGridView2.Columns(5).Width = 70 : DataGridView2.Columns(6).Width = 70 : DataGridView2.Columns(7).Width = 70
  61. DataGridView2.Columns(8).Width = 70
  62. DataGridView2.Columns(2).DefaultCellStyle.Format = "#,##0" : DataGridView2.Columns(5).DefaultCellStyle.Format = "#,##0.00"
  63. DataGridView2.Columns(6).DefaultCellStyle.Format = "#,##0.00" : DataGridView2.Columns(7).DefaultCellStyle.Format = "#,##0.00"
  64. DataGridView2.Columns(8).DefaultCellStyle.Format = "#,##0.00"
  65. End Sub
  66. Private Sub 出庫紀錄表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  67. FormBorderStyle = FormBorderStyle.SizableToolWindow
  68. 讀取出庫紀錄表() : Set_grid2()
  69. End Sub
  70. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  71. timeNow = 0
  72. GCM_ERP_SYS.Timer1.Enabled = False
  73. GCM_ERP_SYS.Timer1.Enabled = True
  74. End Sub
  75. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  76. timeNow = 0
  77. GCM_ERP_SYS.Timer1.Enabled = False
  78. GCM_ERP_SYS.Timer1.Enabled = True
  79. End Sub
  80. Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
  81. PA = InputBox("請輸入要查詢零件的資料")
  82. 讀取出庫紀錄表() : Set_grid2()
  83. PA = ""
  84. End Sub
  85. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  86. 列印(1) = True
  87. 列印清單.Show()
  88. End Sub
  89. End Class