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

新打卡系統.vb 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Public Class 新打卡系統
  4. Private Property MYSQL As String
  5. Dim conn As New SqlConnection
  6. Dim da As New SqlDataAdapter
  7. Dim cmd As New SqlCommand
  8. Dim ds As New DataSet : Dim ds1 As New DataSet
  9. Dim dr As SqlDataReader
  10. Dim DTP As String : Dim DTP1 As String
  11. Dim 有無資料判別 As String = ""
  12. Private Sub 新打卡系統_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  13. ConString = "Data Source=mssql-147629-0.cloudclusters.net,12711;Initial Catalog=GCM-AM-SYS;Persist Security Info=True;User ID=b70340;Password=Lee0911274990;Max pool size = 200;Connection Timeout=0"
  14. FormBorderStyle = FormBorderStyle.SizableToolWindow : ControlBox = False
  15. Label1.Text = Year(Today) : Label3.Text = Month(Today) : Label5.Text = Strings.Right(Format(Today(), "yyyy/MM/dd"), 2) : Label7.Text = Format(TimeOfDay(), "HH:mm:ss")
  16. Label16.Text = "" : Label19.Text = "" : Button1.Text = "打卡系統運行中" : Label20.Text = "" : Label21.Text = ""
  17. Label1.BackColor = Color.Transparent : Label2.BackColor = Color.Transparent : Label3.BackColor = Color.Transparent : Label4.BackColor = Color.Transparent : Label5.BackColor = Color.Transparent
  18. Label6.BackColor = Color.Transparent : Label7.BackColor = Color.Transparent : Label8.BackColor = Color.Transparent : Label15.BackColor = Color.Transparent : Label16.BackColor = Color.Transparent
  19. Label17.BackColor = Color.Transparent : Label19.BackColor = Color.Transparent
  20. Timer2.Enabled = True : TextBox2.Focus()
  21. End Sub
  22. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  23. Label16.Text = "" : Label19.Text = "" : Button1.Text = "打卡系統運行中" : Label20.Text = "" : Label21.Text = ""
  24. Timer1.Enabled = False
  25. End Sub
  26. Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
  27. Label1.Text = Year(Today) : Label3.Text = Month(Today) : Label5.Text = Strings.Right(Format(Today(), "yyyy/MM/dd"), 2) : Label7.Text = Format(TimeOfDay(), "HH:mm:ss")
  28. End Sub
  29. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  30. Me.Close()
  31. End Sub
  32. Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
  33. Label1.Text = Year(Today) : Label3.Text = Month(Today) : Label5.Text = Strings.Right(Format(Today(), "yyyy/MM/dd"), 2) : Label7.Text = Format(TimeOfDay(), "HH:mm:ss")
  34. If IsNumeric(TextBox2.Text) = True Then
  35. If TextBox2.Text.Length = 10 Then
  36. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  37. MYSQL = "SELECT 使用者權限管理表.DIN, ras_Users.UserName FROM 使用者權限管理表 INNER JOIN ras_Users ON 使用者權限管理表.DIN = ras_Users.DIN
  38. WHERE (使用者權限管理表.ID卡號 LIKE N'" & TextBox2.Text & "')"
  39. cmd.Connection = conn : cmd.CommandText = MYSQL : dr = cmd.ExecuteReader
  40. If dr.Read() Then
  41. Label16.Text = dr("UserName").ToString
  42. Label19.Text = dr("DIN").ToString
  43. conn.Close()
  44. Else
  45. TextBox2.Text = "" : TextBox2.Focus() : conn.Close()
  46. End If
  47. Timer1.Enabled = False
  48. Me.Button1.PerformClick()
  49. End If
  50. End If
  51. End Sub
  52. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  53. Timer1.Enabled = True : Label21.Text = "0"
  54. Label20.Text = "打卡時間 : " & Label1.Text & "-" & Label3.Text & "-" & Label5.Text & " " & Label7.Text
  55. 時間_dtp.Value = Now() : Label9.Text = Format(時間_dtp.Value, "yyyy-MM-dd HH:mm:ss")
  56. conn.Close() : If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  57. MYSQL = "SELECT ID FROM ras_AttRecord ORDER BY ID DESC"
  58. cmd.Connection = conn : cmd.CommandText = MYSQL : dr = cmd.ExecuteReader
  59. If dr.Read() Then
  60. Label21.Text = dr("ID") : Label21.Text = Val(Label21.Text) + 1
  61. End If : conn.Close()
  62. conn.Close() : If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  63. MYSQL = "SELECT ID FROM ras_AttRecord ORDER BY ID DESC"
  64. cmd.Connection = conn : cmd.CommandText = MYSQL : dr = cmd.ExecuteReader
  65. If dr.Read() Then
  66. Label21.Text = dr("ID")
  67. End If
  68. Label21.Text = Val(Label21.Text) + 1
  69. conn.Close() : If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  70. conn.Close() : If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  71. conn.Close() : If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  72. MYSQL = "INSERT INTO ras_AttRecord (DN, DIN, Clock, VerifyMode, Action, AttTypeId, CollectDate, JobCode, Antipassback, LastUpdatedUID, LastUpdatedDate, Remark)
  73. VALUES (N'1', N'" & Label19.Text & "', N'" & Label9.Text & "', N'0', N'1', N'H01',
  74. " & Today() & ", 0, 0, 0, " & Today() & ", N'')"
  75. cmd.Connection = conn : cmd.CommandText = MYSQL : dr = cmd.ExecuteReader : conn.Close()
  76. TextBox2.Text = "" : TextBox2.Focus()
  77. End Sub
  78. End Class