暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

出庫紀錄表.vb 6.1KB

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