<% @ Language=VBScript %> <% Response.Buffer = True %> <% If ValidCount() Then If Cstr(Request.Form("btnSave")) <> "Save Vote" Then Dim strComids LoadVotingBallot() Set dbNVS = Nothing Response.Clear Response.Redirect "vote.asp?init=0&comid=" + Cstr(Session.Contents("VOTE_COMID")) Response.End Else SaveVotes() Set dbNVS = Nothing Response.Clear Response.Redirect "mainmenu.asp" Response.End End If End If %> <% '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Function ValidCount() Dim message ValidCount = False Dim Count Count = 0 'Bennett Giesler Changed from "-->" If Cstr(Request.Form("btnVoteFor")) = "Move to Ballot -->" then 'user has tried to nominate someone... For i = 1 To Request.Form("selFac").Count 'This is in case the user selected some values that 'do not mean anything, like the empty space or the text "Nominees" If Request.Form("selFac")(i) <> "0" then Count = Count + 1 End If Next If Clng(Count) <= 0 then message = "You must select at lease one faculty member to add to your voting ballot.
Please click the BACK button to return to the voting screen." Response.Clear Response.Redirect "error.asp?mess=" + Server.URLEncode(message) Response.End End If 'Bennett Giesler Changed from "<--" ElseIf Cstr(Request.Form("btnVoteOff")) = "<-- Remove from Ballot" Then 'user has tried to take someone off of thier ballot... For i = 1 To Request.Form("selBallot").Count 'This is in case the user selected some values that 'do not mean anything, like the empty space or the text "Nominees" If Request.Form("selBallot")(i) <> "0" then Count = Count + 1 End If Next If Clng(Count) <= 0 then message = "You must select at lease one faculty member to remove from voting ballot.
Please click the BACK button to return to the voting screen." Response.Clear Response.Redirect "error.asp?mess=" + Server.URLEncode(message) Response.End End If ElseIf Cstr(Request.Form("btnSave")) = "Save Vote" Then If Session.Contents("VOTE_IDS") = "" OR IsNull(Session.Contents("VOTE_IDS")) Then message = "You must have at lease one faculty member on your voting ballot in order to save your vote.
Please click the BACK button to return to the voting screen." Response.Clear Response.Redirect "error.asp?mess=" + Server.URLEncode(message) Response.End End If If CLng(Session.Contents("BALLOT_COUNT")) > CLng(Request.Form("hdNumToVote")) Then message = "You may only vote for a maximum of " & Cstr(Clng(Request.Form("hdNumToVote"))) & " committee members.
Please click the BACK button to return to the voting screen." Response.Clear Response.Redirect "error.asp?mess=" + Server.URLEncode(message) Response.End End If Else message = "There has been a system error in the function ValidCount
Please contact the Nominating and Elections Committee to resolve this problem.
Please click the BACK button to return the the voting screen." Response.Clear Response.Redirect "error.asp?mess=" + Server.URLEncode(message) Response.End End If ValidCount = True End Function '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %> <% Function LoadVotingBallot()%> <% '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' FUNCTION LOADS THE VOTING BALLOT USER IDS INTO A ' SCRIPTING DICTIONARY OBJECT, WHICH IS USED TO DETERMINE WHO WILL ' NOT SHOW UP IN THE "NOMINEES" SELECTION BOX... ' ' THE FACULTY IDS IN THE DICTIONARY OBJECT WILL BE USED TO LOAD THE ' "VOTING BALLOT" SELECTION BOX... '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On Error Resume Next Dim i, int_count Dim message Dim sdBallot Set sdBallot = Server.CreateObject("Scripting.Dictionary") 'Bennett Giesler Changed from "-->" If Cstr(Request.Form("btnVoteFor")) = "Move to Ballot -->" then 'user has tried to nominate someone... 'add the faculty the user selected from the nominees list... For i = 1 To Request.Form("selFac").Count sdBallot.Add Cstr(i), Request.Form("selFac")(i) Next int_count = i 'add the faculty the user has all ready put on the ballot... For i = 1 to Request.Form("lngCOUNT") sdBallot.Add Cstr(int_count + i), Cstr(Request.Form("hdUSERS" + Cstr(i))) Next 'Bennett Giesler Changed from "<--" ElseIf Cstr(Request.Form("btnVoteOff")) = "<-- Remove from Ballot" Then 'user has tried to take someone off of thier ballot... 'add the faculty the user has all ready put on the ballot... For i = 1 to Request.Form("lngCOUNT") sdBallot.Add Cstr(Request.Form("hdUSERS" + Cstr(i))), Cstr(Request.Form("hdUSERS" + Cstr(i))) Next For intLoop = 1 To Request.Form("selBallot").Count If sdBallot.Exists(Request.Form("selBallot")(intLoop)) Then sdBallot.Remove(Request.Form("selBallot")(intLoop)) End If Next Else message = "There has been a system error in the function LoadVotingBallot
Please contact the Nominating and Elections Committee to resolve this problem.
Please click the BACK button to return the the voting screen." Response.Clear Response.Redirect "error.asp?mess=" + Server.URLEncode(message) Response.End End If 'set the sesssion variable to pass to the voting page so the ballot can be loaded correctly... Set Session.Contents("sdBallot") = sdBallot Set sdBallot = Nothing End Function %> <% '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Function IncrementVotes()%> <% On Error Resume Next set fso = Server.CreateObject("scripting.FileSystemObject") set myFile = fso.OpenTextFile("C:\test.txt", 8) IncrementVotes = False Set cmdAddVotes = Server.CreateObject("ADODB.Command") Dim strSQL Dim message strSQL = "Update [VOTING_RESULTS] Set" strSQL = strSQL + " [VOTES]= ([VOTES]+1)" strSQL = strSQL + " Where [COMID]= " + Cstr(Clng(Session.Contents("VOTE_COMID"))) strSQL = strSQL + " And [USER_ID] IN (" + Cstr(Session.Contents("VOTE_IDS")) + ")" dbNVS.Open cmdAddVotes.ActiveConnection = dbNVS cmdAddVotes.CommandText = strSQL dbNVS.BeginTrans cmdAddVotes.Execute myFile.WriteLine(NOW() & " vote " & strSQL) 'Error Handling in a small way... If Err.Number <> 0 then 'if something goes wrong, don't update the database... dbNVS.RollBack 'something is wrong... message = "A system error occured with the function IncrementVotes." + _ "
Please contact the Nominations and Election Committee to resolve this problem." + _ "
Please click the back button." Response.Clear Response.Redirect "error.asp?mess=" + Server.URLEncode(message) Response.End myFile.WriteLine(NOW() & message) IncrementVotes = False End if dbNVS.CommitTrans dbNVS.Close myfile.close Set cmdAddVotes = Nothing IncrementVotes = True End Function '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Function DecrementVotes()%> <% On Error Resume Next DecrementVotes = False Set cmdDecVotes = Server.CreateObject("ADODB.Command") Dim strSQL Dim message strSQL = "Update [VOTING_RESULTS] Set" strSQL = strSQL + " [VOTES]= ([VOTES]-1)" strSQL = strSQL + " Where [COMID]= " + Cstr(Clng(Session.Contents("VOTE_COMID"))) strSQL = strSQL + " And [USER_ID] IN (" + Cstr(Session.Contents("VOTE_IDS")) + ")" dbNVS.Open cmdDecVotes.ActiveConnection = dbNVS cmdDecVotes.CommandText = strSQL dbNVS.BeginTrans cmdDecVotes.Execute 'Error Handling in a small way... If Err.Number <> 0 then 'if something goes wrong, don't update the database... dbNVS.RollBack 'something is wrong... message = "A system error occured with the function DecrementVotes." + _ "
Please contact the Nominations and Election Committee to resolve this problem." + _ "
Please click the back button." Response.Clear Response.Redirect "error.asp?mess=" + Server.URLEncode(message) Response.End DecrementVotes = False End if dbNVS.CommitTrans dbNVS.Close Set cmdDecVotes = Nothing DecrementVotes = True End Function '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Function AddVoted()%> <% On Error Resume Next AddVoted = False Set cmdAddVoted = Server.CreateObject("ADODB.Command") Dim strSQL Dim message strSQL = "Insert Into [VOTED] (" strSQL = strSQL + "[USER_ID], [COMID], [DATE]" strSQL = strSQL + ") Values (" strSQL = strSQL + Cstr(Session.Contents("USER_ID")) + "," strSQL = strSQL + Cstr(Session.Contents("VOTE_COMID")) + "," strSQL = strSQL + "#" + Cstr(Date) + "#)" dbNVS.Open cmdAddVoted.ActiveConnection = dbNVS cmdAddVoted.CommandText = strSQL dbNVS.BeginTrans cmdAddVoted.Execute 'Error Handling in a small way... If Err.Number <> 0 then 'if something goes wrong, don't update the database... dbNVS.RollBack 'something is wrong... message = "A system error occured with the function AddVoted." + _ "
Please contact the Nominations and Election Committee to resolve this problem." + _ "
Please click the back button." Response.Clear Response.Redirect "error.asp?mess=" + Server.URLEncode(message) Response.End AddVoted = False End if dbNVS.CommitTrans dbNVS.Close Set cmdAddVoted = Nothing AddVoted = True End Function '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Function SaveVotes() Dim message If Not IncrementVotes Then message = "An error has occured while trying to record your votes.
Please contact the Facluty Voting and Nominating Committee to resolve this problem.
Please click the BACK button." Response.Clear Response.Redirect "error.asp?mess=" + Server.URLEncode(message) Response.End End If If Not AddVoted then 'If we can't record that someone has voted, 'then we need to erase the votes that were just cast by them DecrementVotes() message = "An error has occured while trying to record your votes.
Please contact the Facluty Voting and Nominating Committee to resolve this problem.
Please click the BACK button." Response.Clear Response.Redirect "error.asp?mess=" + Server.URLEncode(message) Response.End End If Set dbNVS = Nothing End Function '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %>