Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function SwipeBadge(cn As SQLiteConnection, RFID As String) As TimeSession
- Using cmd As New SQLiteCommand("Select count(*) from Sessions where RFID=@RFID and TimeOut IS NULL", cn)
- cmd.Parameters.AddWithValue("@RFID", RFID)
- Dim cnt As Integer = cmd.ExecuteScalar
- If cnt = 1
- cmd.CommandText = "Update Sessions set TimeOut=@TimeOut where RFID=@RFID and TimeOut IS NULL"
- cmd.Parameters.AddWithValue("@TimeOut", DateTime.Now.ToString("o"))
- Dim affected As Integer = cmd.ExecuteNonQuery
- Console.WriteLine($"User {RFID} clocked out. Updated row count: {affected}")
- Else
- cmd.CommandText = "Insert into Sessions (RFID,TimeIn) VALUES(@RFID, @TimeIn)"
- cmd.Parameters.AddWithValue("@TimeIn", DateTime.Now.ToString("o"))
- Dim affected As Integer = cmd.ExecuteNonQuery
- Console.WriteLine($"User {RFID} clocked In. Updated row count: {affected}")
- End If
- End Using
- Dim sessions=GetTimeSessions(cn).Dump($"Current db status {DateTime.Now}")
- Dim session = sessions.Where(Function(s) s.RFID = rfid).OrderByDescending(Function(s) s.TimeIn).First
- Return session
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement