Vous êtes sur la page 1sur 2

Private Sub studentPictureClickIn(ByVal sender As Object, ByVal e As EventArgs)

Dim clicedPic As PictureBox = DirectCast(sender, PictureBox)


Dim Ctime As DateTime = TimeOfDay
Dim Fname, Mname, Lname, sClass, Pass As String
Dim Sql As String
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim Chkdate As DateTime = My.Computer.Clock.LocalTime.Date.ToLongDateString
Sql = "SELECT * FROM students where where ID=" & clicedPic.Tag & ""
If con.State = ConnectionState.Open Then con.Close()
con.Open()
cmd = New OleDbCommand(Sql, con)
dr = cmd.ExecuteReader
'DataGridView1.Rows.Clear()

Fname = dr("Fname")
Mname = dr("Mname")
Lname = dr("Lname")
sClass = dr("Class")
Pass = dr("Passport")

Dim ins As String


Dim stud As New OleDbCommand(ins, con)
'Dim dr As OleDbDataReader = stud.ExecuteReader
'Try
' If dr.Read = True Then
ins = "UPDATE students SET students.Checkin='" & Ctime &
"',students.Status='" & "Yes" & "',students.Date='" & Chkdate & "'where ID=" &
clicedPic.Tag & ""
stud.CommandText = ins
stud.Connection = con
stud.ExecuteNonQuery()
stud.Dispose()
'Dim nme As String
'MsgBox(LoadP(nme))
'MsgBox("Welcome to School", vbInformation, "Saved")
If dr("Date") = Chkdate Then
MsgBox("Yes")
Dim spk As New SpeechSynthesizer
'Dim nme As String
Dim gt As String
spk.Rate = 0.0
spk.Volume = 100
'nme = lblPname.Text
gt = "Welcome to School. Do have a wonderful Day"
spk.Speak(gt)
spk.SetOutputToDefaultAudioDevice()
' Catch ex As Exception
'MsgBox("No")
' MsgBox(ex.Message)
' End Try

ElseIf dr("Date") <> Chkdate Then


MsgBox("No")
Dim Uno As String
Uno = getLastID()
Dim Stat, Chkout As String
Stat = "Yes"
Chkout = ""
Dim Allocat As New OleDbCommand("INSERT INTO students values (" &
Uno & ",'" & _
Fname & "','" & _
Mname & "','" & _
Lname & "','" & _
sClass & "','" & _
Pass & "','" & _
Ctime & "','" & _
Stat & "','" & _
Chkout & "','" & _
Chkdate & "')", con)

' MsgBox(Ctime)
' MsgBox(Chkdate)

End If

Me.Dispose()
frmNusry.Close()
con.Close()
'Exit Sub

'MsgBox(clicedPic.Tag)
End Sub

and please how can i search database between date and display result?

Vous aimerez peut-être aussi