Ensuring or validating that a student can only vote once using my voting system. -VB.Net -
i wanted have voting system registered student can vote once. have code used registered firstname , surname log-in access. can me guys on how possibly make student voted compromise his/her rights vote twice? thank you.
private sub metrobutton2_click(sender object, e eventargs) handles metrobutton2.click dim sql string if firstname2metrotextbox.text = "" msgbox("type in first name.") elseif surnamemetrotextbox.text = "" msgbox("type in surname.") else try if firstname2metrotextbox.text = "" , surnamemetrotextbox.text = "" msgbox("first name , surname doesn't match.") else sql = "select * student_registrants firstname = '" & firstname2metrotextbox.text & "' , surname = '" & surnamemetrotextbox.text & "'" cmd .connection = conn .commandtext = sql end timer1.start() da.dispose() end if catch ex exception msgbox(ex.message) end try conn.clone() end if end sub
and log-in voting form. after he/she picks his/her desired candidate, made code.
private sub tileitem26_itemclick(sender object, e devexpress.xtraeditors.tileitemeventargs) handles confirmtileitem.itemclick if presidentmetrolabel.text = "" msgbox("choose next president.") elseif vicepresidentmetrolabel.text = "" msgbox("choose next vice president.") elseif secretarymetrolabel.text = "" msgbox("choose next secretary.") elseif auditormetrolabel.text = "" msgbox("choose next auditor.") elseif senator1metrolabel.text = "" msgbox("choose next senator(s).") elseif senator2metrolabel.text = "" msgbox("choose next senator(s).") elseif senator3metrolabel.text = "" msgbox("choose next senator(s).") elseif senator4metrolabel.text = "" msgbox("choose next senator(s).") else try conn.connectionstring = ("server=localhost;user id=root;password=;database=university_election") conn.open() cmd .connection = conn .commandtext = "update `election_tally_presidents` set votes = votes + 1 president_id = '" & presidentint & "'; update `election_tally_vicepresidents` set votes = votes + 1 vicepresident_id = '" & vicepresidentint & "'; update `election_tally_secretary` set votes = votes + 1 secretary_id = '" & secretaryint & "'; update `election_tally_auditor` set votes = votes + 1 auditor_id = '" & auditorint & "'; update `election_tally_senators` set votes = votes + 1 senator_id = '" & senator1int & "'; update `election_tally_senators` set votes = votes + 1 senator_id = '" & senator2int & "'; update `election_tally_senators` set votes = votes + 1 senator_id = '" & senator3int & "'; update `election_tally_senators` set votes = votes + 1 senator_id = '" & senator4int & "';" result = cmd.executenonquery timer1.start() metroprogressbar1.show() metrolabel1.visible = true end catch ex exception msgbox("cannot register database: " & ex.message) conn.dispose() end try end if end sub
so what's code best fit system? thank you.
Comments
Post a Comment