'公用Sub updateTextBox()如何:时间在和超时状态上vb.net
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卡时,它应该是status = Time-In,当他/她第二次点击它时,状态应该是超时。每个学生每天有一次Time-In和一次Time-out限制。任何想法如何做到这一点?希望你们能得到我指出的内容。
您需要提供更多信息并希望获得一些代码。你有什么尝试?你使用的是数据库还是硬编码的“学生”?为每个学生记录一个计数器并不困难,所以这个问题相当广泛。 – TheValyreanGroup
这实际上只是一个非常宽泛的规范 - 它并不适用于堆栈溢出问答格式。另外 - 如果一个学生刻下他人的卡片并敲出来,每天限制1次,他们现在是否会陷入麻烦? –
@TheValyreanGroup是的,我正在使用数据库。我该怎么处理柜台?对不起,问我,刚刚对RFID和vb.net新希望你们明白。我将加上一些我使用的代码。这段代码的进展是它可以从数据库中检索数据。不介意DataGrid。我只是不知道该怎么做才能在状态中进行暂停和超时。 –