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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. Option Strict Off
  2. Public Class 機構科目清單
  3. ReadOnly ds As New DataSet
  4. Private Sub 讀取科目類型表()
  5. ConnOpen()
  6. If ComboBox6.Text = "" Or ComboBox6.Text = "-請選擇-" Then
  7. ComboBox6.Text = "-請選擇-"
  8. DataGridView2.DataSource = Nothing : ds.Clear()
  9. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  10. DataGridView2.ColumnHeadersHeight = 25
  11. DataGridView2.AllowUserToAddRows = False
  12. SQL1 = "SELECT 流水碼, 科目, 類型 FROM 機構成本科目類型表"
  13. Else
  14. DataGridView2.DataSource = Nothing : ds.Clear()
  15. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  16. DataGridView2.ColumnHeadersHeight = 25
  17. DataGridView2.AllowUserToAddRows = False
  18. SQL1 = "SELECT 流水碼, 科目, 類型 FROM 機構成本科目類型表 WHERE (科目 ='" & ComboBox6.Text & "')"
  19. End If
  20. CmdSet_For_DGV() : da.Fill(ds) : DataGridView2.DataSource = ds.Tables(0) : conn.Close()
  21. End Sub
  22. Private Sub Set_grid2()
  23. DataGridView2.Columns(0).Visible = False : DataGridView2.Columns(1).Visible = False : DataGridView2.Columns(2).Width = 180
  24. End Sub
  25. Private Sub 機構科目清單_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  26. FormBorderStyle = FormBorderStyle.SizableToolWindow
  27. 讀取科目類型表() : Set_grid2()
  28. ComboBox6.Items.AddRange(科目清單)
  29. End Sub
  30. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  31. timeNow = 0
  32. GCM_ERP_SYS.Timer1.Enabled = False
  33. GCM_ERP_SYS.Timer1.Enabled = True
  34. End Sub
  35. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  36. timeNow = 0
  37. GCM_ERP_SYS.Timer1.Enabled = False
  38. GCM_ERP_SYS.Timer1.Enabled = True
  39. End Sub
  40. Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellClick
  41. If e.RowIndex = -1 Then : Else
  42. TextBox7.Text = DataGridView2(0, e.RowIndex).Value.ToString : ComboBox6.Text = DataGridView2(1, e.RowIndex).Value.ToString
  43. TextBox6.Text = DataGridView2(2, e.RowIndex).Value.ToString
  44. End If
  45. End Sub
  46. Private Sub ComboBox6_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox6.Click
  47. If ComboBox6.Text = "" Or ComboBox6.Text = "-請選擇-" Then
  48. DataGridView2.Enabled = False
  49. 讀取科目類型表() : Set_grid2()
  50. Else
  51. DataGridView2.Enabled = True
  52. 讀取科目類型表() : Set_grid2()
  53. End If
  54. TextBox7.Text = "" : TextBox6.Text = ""
  55. End Sub
  56. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  57. If ComboBox6.Text = "-請選擇-" Or TextBox6.Text = "" Then
  58. MsgBox("科目或類型欄位不可空白")
  59. Else
  60. Dim NUM1 As Integer
  61. For NUM1 = 0 To 9999
  62. If NUM1 < 10 Then
  63. TextBox8.Text = "A" & "00" & NUM1
  64. ElseIf NUM1 > 9 And NUM1 < 100 Then
  65. TextBox8.Text = "A" & "0" & NUM1
  66. ElseIf NUM1 > 99 Then
  67. TextBox8.Text = "A" & NUM1
  68. End If
  69. ConnOpen()
  70. SQL1 = "SELECT 流水碼 FROM 機構成本科目類型表 WHERE (流水碼 ='" & TextBox8.Text & "')"
  71. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  72. If dr.Read() Then : TextBox7.Text = dr("流水碼").ToString : Else : TextBox7.Text = "" : End If
  73. conn.Close()
  74. If TextBox7.Text = "" Then
  75. TextBox7.Text = TextBox8.Text : TextBox8.Text = "可用"
  76. NUM1 = 9999
  77. End If
  78. Next
  79. If TextBox8.Text = "可用" Then
  80. ConnOpen()
  81. SQL1 = "INSERT INTO 機構成本科目類型表 (流水碼, 科目, 類型) VALUES ('" & TextBox7.Text & "','" & ComboBox6.Text &
  82. "','" & TextBox6.Text & "')"
  83. CmdSet_For_dr()
  84. MsgBox("新增完成")
  85. conn.Close()
  86. End If
  87. End If
  88. 讀取科目類型表() : Set_grid2()
  89. End Sub
  90. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  91. ConnOpen()
  92. SQL1 = "UPDATE 機構成本科目類型表 SET 科目 = '" & ComboBox6.Text & "', 類型 = '" & TextBox6.Text &
  93. "' WHERE (流水碼 = '" & TextBox7.Text & "')"
  94. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  95. MsgBox("修改完成")
  96. conn.Close()
  97. 讀取科目類型表() : Set_grid2()
  98. End Sub
  99. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  100. SQL1 = "DELETE FROM 機構成本科目類型表 WHERE (流水碼 = '" & TextBox7.Text & "')"
  101. cmd.CommandText = SQL1 : cmd.Connection = conn
  102. ConnOpen()
  103. Dim aa As MsgBoxResult
  104. aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  105. If aa = MsgBoxResult.Ok Then : cmd.ExecuteNonQuery() : MsgBox("刪除完成") : End If
  106. conn.Close()
  107. ComboBox6.Text = "-請選擇-"
  108. 讀取科目類型表() : Set_grid2()
  109. End Sub
  110. End Class