How to trap when student is already log in or log out of the event, using Vb.net 2008 -
this code button
private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click user = 1 if textbox1.text <> "" dim namemo string = "" executequery("select * tbl_student id='" & textbox1.text & "'") if reader.hasrows try while reader.read namemo = reader.item("lname") & ", " & reader.item("fname") & " " & reader.item("mi") & "." end while catch ex exception end try call disconnectdb() 'for logging in if logstatus = 1 executequery("select * tbl_log studid='" & textbox1.text & "' , eventid=" & realid) if reader.hasrows call disconnectdb() executequery("update tbl_log set timein='" & now.hour & ":" & now.minute & "' studid='" & textbox1.text & "' , eventid='" & realid & "'") call disconnectdb() else call disconnectdb() executequery("insert tbl_log set studid='" & textbox1.text & "',eventid='" & realid & "', timein='" & now.hour & ":" & now.minute & "'") call disconnectdb() end if msgbox("hi " & strconv(namemo, vbstrconv.uppercase) & " login", msgboxstyle.information, "information") call disconnectdb() 'for logging out elseif logstatus = 2 executequery("select * tbl_log studid='" & textbox1.text & "' , eventid=" & realid) if reader.hasrows call disconnectdb() executequery("update tbl_log set timeout='" & now.hour & ":" & now.minute & "' studid='" & textbox1.text & "' , eventid='" & realid & "'") call disconnectdb() else call disconnectdb() executequery("insert tbl_log set studid='" & textbox1.text & "',eventid='" & realid & "', timeout='" & now.hour & ":" & now.minute & "'") call disconnectdb() end if msgbox("hi " & strconv(namemo, vbstrconv.uppercase) & " logged out.", msgboxstyle.information, "information") end if textbox1.clear() else msgbox("sorry " & textbox1.text & " id number not valid!", msgboxstyle.exclamation, "error") end if call disconnectdb() ' textbox1.clear() textbox1.focus() end if user = 0 end sub
Comments
Post a Comment