Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. Imports System.Data.SqlClient
  2. Imports Npgsql
  3. Module SQL_Module
  4. Public 版本 As String = "2024102901"
  5. Public gUserName, 登入人部門, 版本號 As String
  6. Public SQL1, SQL2, SQL3, SQL4, SQL5, SQL6, SQL7, SQL8, SQL9, SQL10 As String
  7. Public CC(11), 重新計算, 首次進入 As Boolean
  8. Public lastFoundRowIndex, lastFoundColIndex, NU1 As Integer
  9. Public PA, PA1 As String
  10. Public 登入人IP As String = "59.125.246.164"
  11. Public ConString As String = "Host=" & 登入人IP & ";Port=4556;Database=""htp"";Username=odoo;Password=odootyughj;Pooling=true;Maximum Pool Size=200;Timeout=0"
  12. Public conn1 As New SqlConnection : Public cmd1 As New SqlCommand
  13. Public dr1 As SqlDataReader : Public da1 As New SqlDataAdapter
  14. Public conn As New NpgsqlConnection : Public cmd As New NpgsqlCommand
  15. Public dr As NpgsqlDataReader : Public da As New NpgsqlDataAdapter
  16. Friend Sub ConnOpen_SQL()
  17. 登入人IP = "59.125.246.164,4567"
  18. ConString = "Data Source=" & 登入人IP & ";Initial Catalog=HTODOO;Persist Security Info=True;User ID=b70340;Password=Lee0911274990;Max pool size = 200;Connection Timeout=0"
  19. conn1.Close() : If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  20. End Sub
  21. Friend Sub CmdSet_For_DGV_SQL()
  22. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : da1.SelectCommand = cmd1
  23. End Sub
  24. Friend Sub CmdSet_For_dr_SQL()
  25. cmd1.CommandText = SQL1 : cmd1.Connection = conn1 : dr1 = cmd1.ExecuteReader
  26. End Sub
  27. Friend Sub ConnOpen()
  28. 登入人IP = "59.125.246.164"
  29. ConString = "Host=" & 登入人IP & ";Port=4556;Database=""htp"";Username=odoo;Password=odootyughj;Pooling=true;Maximum Pool Size=200;Timeout=0"
  30. conn.Close() : If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  31. End Sub
  32. Friend Sub CmdSet_For_DGV()
  33. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd
  34. End Sub
  35. Friend Sub CmdSet_For_dr()
  36. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  37. End Sub
  38. Public Sub 查詢DGV中的關鍵字(ByVal dgv As DataGridView, ByVal txtKeyword As TextBox)
  39. Dim keyword As String = txtKeyword.Text
  40. Dim found As Boolean = False
  41. dgv.ClearSelection() ' 清除先前的选择
  42. Dim numColumns As Integer = dgv.Columns.Count ' 获取 DataGridView 的列数
  43. Dim startRowIndex As Integer = If(lastFoundRowIndex = -1, 0, lastFoundRowIndex + 1)
  44. For colIndex As Integer = If(lastFoundRowIndex = -1, 0, lastFoundColIndex) To numColumns - 1
  45. For rowIndex As Integer = startRowIndex To dgv.Rows.Count - 1
  46. Dim cellValue As String
  47. If IsNothing(dgv.Rows(rowIndex).Cells(colIndex).Value) Then
  48. cellValue = ""
  49. Else
  50. cellValue = dgv.Rows(rowIndex).Cells(colIndex).Value.ToString()
  51. End If
  52. If cellValue.Contains(keyword) Then
  53. dgv.Rows(rowIndex).Selected = True : dgv.FirstDisplayedScrollingRowIndex = rowIndex : NU1 = rowIndex : found = True
  54. lastFoundRowIndex = rowIndex : lastFoundColIndex = colIndex : Exit For
  55. End If
  56. Next : If found Then : Exit For : End If
  57. Next
  58. If Not found Then
  59. lastFoundRowIndex = -1 : lastFoundColIndex = -1 : dgv.FirstDisplayedScrollingRowIndex = 0 : 重新計算 = True : dgv.ClearSelection()
  60. Else : 重新計算 = False
  61. End If
  62. End Sub
  63. End Module