Няма описание
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.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. Option Strict Off
  2. Public Class 部件清單控制表
  3. Private ReadOnly ds, ds1, ds2, ds4, ds5 As New DataSet
  4. Private Sub Set_清單()
  5. 清單_dgv.DataSource = Nothing : ds.Clear()
  6. 清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  7. 清單_dgv.ColumnHeadersHeight = 25
  8. 清單_dgv.AllowUserToAddRows = False
  9. SQL_部件清單() : da.Fill(ds) : 清單_dgv.DataSource = ds.Tables(0) : conn.Close()
  10. 清單_dgv.Columns(0).Width = 200 : 清單_dgv.Columns(1).Width = 100 : 清單_dgv.Columns(2).Width = 100
  11. For i As Integer = 0 To 清單_dgv.Rows.Count - 1
  12. If 清單_dgv.Rows(i).Cells("樣品單用選擇").Value Is DBNull.Value Then
  13. 清單_dgv.Rows(i).Cells("樣品單用選擇").Value = False
  14. End If
  15. Next i
  16. End Sub
  17. Private Sub ComboBox1下拉表單資料載入()
  18. SQL_下拉部件類別1()
  19. 部件大項分類_cb.Items.Clear() : While (dr.Read()) : 部件大項分類_cb.Items.Add(dr("部件類別")) : End While : conn.Close()
  20. End Sub
  21. Private Sub ComboBox2下拉表單資料載入()
  22. SQL_下拉部件類別2()
  23. 貼標對應名稱_cb.Items.Clear() : While (dr.Read()) : 貼標對應名稱_cb.Items.Add(dr("貼標對應名稱")) : End While : conn.Close()
  24. End Sub
  25. Private Sub 部件清單控制表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  26. FormBorderStyle = FormBorderStyle.SizableToolWindow : ControlBox = True
  27. 部件_cb.Enabled = False : 確認新增_bt.Enabled = False
  28. ComboBox2下拉表單資料載入() : ComboBox1下拉表單資料載入()
  29. Set_清單()
  30. End Sub
  31. Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 部件大項分類_cb.SelectedIndexChanged
  32. 部件_cb.Text = Strings.Left(部件大項分類_cb.Text, 2)
  33. End Sub
  34. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 清單_dgv.CellClick
  35. If e.RowIndex = -1 Then : Else
  36. 部件_cb.Text = Strings.Left(清單_dgv.Rows(e.RowIndex).Cells("部件").Value, 2)
  37. SQL_讀取部件大項分類()
  38. If dr.Read() Then
  39. 部件大項分類_cb.Text = dr("部件類別")
  40. End If
  41. 部件1_cb.Text = Strings.Mid(清單_dgv.Rows(e.RowIndex).Cells("部件").Value, 3, 100)
  42. ComboBox2下拉表單資料載入()
  43. 貼標對應名稱_cb.Text = 清單_dgv.Rows(e.RowIndex).Cells("貼標對應名稱").Value
  44. End If
  45. End Sub
  46. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles 清空_bt.Click
  47. ComboBox2下拉表單資料載入()
  48. End Sub
  49. Private Sub Button29_Click(sender As Object, e As EventArgs) Handles 新增_bt.Click
  50. ComboBox2下拉表單資料載入() : ComboBox1下拉表單資料載入()
  51. 部件_cb.Text = "" : 部件1_cb.Text = ""
  52. 新增_bt.Enabled = False : 確認新增_bt.Enabled = True
  53. End Sub
  54. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles 確認新增_bt.Click
  55. If 部件_cb.Text = "" Or 部件1_cb.Text = "" Then
  56. MsgBox("部件大項資料沒有選擇或是部件名稱空白")
  57. Else
  58. SQL_查閱部件清單()
  59. If dr.Read() Then
  60. MsgBox("資料重複,請從新輸入或檢查") : conn.Close() : dr.Close()
  61. Else
  62. conn.Close() : dr.Close()
  63. SQL_新增部件清單()
  64. MsgBox("新增完成") : Set_清單()
  65. conn.Close() : dr.Close()
  66. 新增_bt.Enabled = True : 確認新增_bt.Enabled = False
  67. End If
  68. End If
  69. End Sub
  70. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles 刪除_bt.Click
  71. Dim aa As MsgBoxResult
  72. aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  73. If aa = MsgBoxResult.Ok Then : SQL_刪除部件清單() : MsgBox("刪除完成") : Set_清單() : End If
  74. conn.Close()
  75. End Sub
  76. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles 儲存修改_bt.Click
  77. For i As Integer = 0 To 清單_dgv.Rows.Count - 1
  78. 資料數 = 清單_dgv.Rows.Count : MyModule1.進度條()
  79. PA5 = 清單_dgv.Rows(i).Cells("樣品單用選擇").Value : PA6 = 清單_dgv.Rows(i).Cells("部件").Value
  80. SQL_更改部件清單() : conn.Close()
  81. Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  82. MsgBox("存檔完成")
  83. End Sub
  84. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles 全部選擇_bt.Click
  85. For i As Integer = 0 To 清單_dgv.Rows.Count - 1 : 清單_dgv.Rows(i).Cells("樣品單用選擇").Value = True : Next i
  86. End Sub
  87. Private Sub Button10_Click(sender As Object, e As EventArgs) Handles 全部取消選_bt.Click
  88. For i As Integer = 0 To 清單_dgv.Rows.Count - 1 : 清單_dgv.Rows(i).Cells("樣品單用選擇").Value = False : Next i
  89. End Sub
  90. End Class