`Public Sub updateTextBox()
s = s + SerialPort1.ReadExisting()
If Len(s) > 12 Then
Try
txtReceived.Text = Microsoft.VisualBasic.Mid(s, 1, 12)
strSql = "SELECT * FROM stud WHERE tag = '" & txtReceived.Text & "';"
command.CommandText = strSql
command.Connection = SQLConnection
datapter.SelectCommand = command
datardr = command.ExecuteReader
Dim img() As Byte
If datardr.HasRows Then
datardr.Read()
img = datardr("picture")
Dim ms As New MemoryStream(img)
txtFname.Text = datardr("fname").ToString
txtLname.Text = datardr("lname").ToString
PictureBox1.Image = Image.FromStream(ms)
SQLConnection.Close()
End If
SQLConnection.Open()
Catch ex As Exception
End Try
Try
Dim i As Integer
Dim newtag As Boolean = True
Dim stringfix As String
Dim string1 As String
Dim string2 As String
For i = 0 To (grid.Rows.Count - 1)
stringfix = grid.Rows.Item(i).Cells(0).Value
string1 = Microsoft.VisualBasic.Mid(stringfix, 1, 10)
string2 = Microsoft.VisualBasic.Mid(stringfix, 2, 10)
If string1 = string2 Then
newtag = False
Exit For
Else
newtag = True
End If
Next
If newtag = True Then
Dim dr As Integer
dr = grid.Rows.Add()
grid.Rows.Item(dr).Cells.Item(0).Value = Microsoft.VisualBasic.Mid(s, 1, 12)
grid.Rows.Item(dr).Cells(1).Value = txtFname.Text
grid.Rows.Item(dr).Cells(2).Value = txtLname.Text
grid.Rows.Item(dr).Cells.Item(3).Value = txtDate.Text + " " + txtTime.Text
grid.Rows.Item(dr).Cells.Item(4).Value = "TIME IN"
ElseIf newtag = False Then
grid.Rows.Item(i).Cells.Item(3).Value = txtDate.Text + " " + txtTime.Text
grid.Rows.Item(i).Selected = True
End If
Catch ex As Exception
End Try
Dim timeOut As DateTimeOffset = Now.AddMilliseconds(1500)
Do
Application.DoEvents()
Loop Until Now > timeOut
s = SerialPort1.ReadExisting()
SerialPort1.DiscardOutBuffer()
s = String.Empty
SerialPort1.DtrEnable = True
txtReceived.Text = ""
txtFname.Text = ""
txtLname.Text = ""
PictureBox1.Image = Nothing
End If
End Sub`
美好的一天!我一直致力于为我们的论文研究基于RFID的学校每日时间记录。我的问题是当他/她第一次点击RFID卡时,如何设置学生的“状态”状态= Time-In并且当他/她第二次点击它时状态应该是超时。每个学生每天都有一个时间限制和一个超时限制。有关如何做到这一点的任何想法?希望你们得到我指出的东西。
答案 0 :(得分:0)
有很多方法可以做到这几乎太宽泛了。一种简单的方法是在数据库中添加两列,并在扫描或扫描RFID时分别递增。然后,当您从数据库中选择SELECT时,您可以引用这些列,如果两者都是> 1,那么就是这样。
另一种方式是所有学生TAG的阵列。并且您可以在本地以本地方式跟踪计数器,而不是在数据库中。所以在扫描标签之后......
If inCounter(tag) > 1 or outCounter(tag) > 1 Then
msgbox("User has reached the quota.")
Else
inCounter(tag) += 1
outCounter(tag) += 1
End If
然后,您需要实现每天重置这些计数器的DateTime类。