问题/我想发生
1) 如果员工/用户超时,她必须等待3或5个小时才能超时
2) 如果她试图超时不到3或5小时,她将得到一个messagebox/标签,他/她已经超时
这是我的密码
getQuery = "SELECT dtr.time_in, dtr.date FROM dtr, employee WHERE employee.employee_id ='" & empid.Text & _
"'AND dtr.employee_id ='" & empid.Text & "' AND dtr.rfid ='" & txtRFID.Text & "' AND dtr.date ='" & Date.Now.ToString("yyyy-MM-dd") & "'"
getCommand = New MySqlCommand(getQuery, MySQLConnection)
getReader = getCommand.ExecuteReader
If getReader.Read = True Then
TimeIN = (getReader.Item("time_in").ToString)
getDate = (getReader.Item("date"))
End If
getReader.Close()
getQuery = "SELECT dtr.time_out, dtr.date FROM dtr, employee WHERE employee.employee_id ='" & empid.Text & "' AND dtr.employee_id ='" & _
empid.Text & "' AND dtr.rfid ='" & txtRFID.Text & "' AND dtr.date ='" & Date.Now.ToString("yyyy-MM-dd") & "'"
getCommand = New MySqlCommand(getQuery, MySQLConnection)
getReader = getCommand.ExecuteReader
If getReader.Read = True Then
TimeOUT = (getReader.Item("time_out").ToString)
getDate = (getReader.Item("date"))
End If
getReader.Close()
If TimeIN = "" Then
disableTimeOutColor()
TimeIN = Nothing
TimeOUT = Nothing
getDate = Nothing
ElseIf TimeIN <> "" And TimeOUT <> "" And getDate = Date.Today Then
TimeOUT = Nothing
TimeIN = Nothing
getDate = Nothing
ElseIf TimeIN <> "" Then
disableTimeINColor()
TimeIN = Nothing
TimeOUT = Nothing
getDate = Nothing
ElseIf TimeOUT = "" Then
disableTimeINColor()
TimeOUT = Nothing
TimeIN = Nothing
getDate = Nothing
ElseIf TimeOUT <> "" Then
disableTimeOutColor()
TimeOUT = Nothing
TimeIN = Nothing
getDate = Nothing
ElseIf TimeIN = "" And TimeOUT = "" And getDate = "" Then
disableTimeOutColor()
TimeOUT = Nothing
TimeIN = Nothing
getDate = Nothing
End If
1条答案
按热度按时间hwazgwia1#
在“编译”选项卡上的“项目属性”中启用“选项严格”。这将在您运行代码之前捕获许多潜在的错误。
首先,你的问题。您只从一个表中进行选择,因此似乎没有任何理由引用employee表。使用参数重写代码是非常重要的;否则,您很容易受到sql注入的攻击。
我猜测了数据类型。检查数据库中的正确类型。似乎您正在将数据值存储为字符串。日期实际上应该存储为日期。
using语句可确保即使出现错误,也能正确关闭和释放对象。
我真的不能再往前走了,不知道时间。