in this form the stuednt record the time when login so that when they take attendance know that time they come in
this the code :
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
lbltime.Text = "Time:" + TimeString
If String.IsNullOrWhiteSpace(txtadmno.Text) Or String.IsNullOrWhiteSpace(txtcard.Text) Then
'MessageBox.Show("Please complete the on the box.", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
Using conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb")
lbltime.Text = TimeOfDay.Hour & ":" & TimeOfDay.Minute & ":" & TimeOfDay.Second
If TimeOfDay.Second < 10 Then
Dim fitsecond As String
fitsecond = TimeOfDay.Second
lbltime.Text = TimeOfDay.Hour & ":" & TimeOfDay.Minute & ":" & "0" & fitsecond
End If
If TimeOfDay.Minute < 10 Then
Dim fitminute As String
fitminute = TimeOfDay.Minute
lbltime.Text = TimeOfDay.Hour & ":" & "0" & fitminute & ":" & TimeOfDay.Second
End If
If TimeOfDay.Hour < 10 Then
Dim fithour As String
fithour = TimeOfDay.Hour
lbltime.Text = "0" & fithour & ":" & TimeOfDay.Minute & ":" & TimeOfDay.Second
End If
Dim sql As String = "INSERT INTO tbl_studentadm (TimeIn, TimeOut) VALUES ([Stud Admin], [Admin Card]) = '" & txtadmno.Text & "' AND = '" & txtcard.Text & "'"
Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, Conn)
sqlCom.Connection = Conn
conn.Open()
Dim CMD As New System.Data.OleDb.OleDbCommand
CMD.CommandText = "Update(tbl_studentadm) SET(TimeIn = [Stud Admin], TimeOut = [Admin Card]) WHERE(TimeIn = [Stud Admin], TimeOut = [Admin Card])"
Dim result As Integer = sqlCom.ExecuteNonQuery()
sqlCom.Dispose()
Conn.Close()
If result > 0 Then
MessageBox.Show("Insert time in.")
Else
MessageBox.Show("Failure to time in.")
End If
End Using
'Catch ex As Exception
'MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
'End Try