%@ Language=VBScript %>
<% Response.Buffer = True %>
<%
Dim message, bExecuted, blnExists
Dim ComId
If Request.Form("btnAdd") = "Add ------>" Then
'we are in "ADDING" mode...
If ValidAddNominees() Then
ComId = Request.Form("hdCOM_ID")
For i = 1 to Request.Form("selFaculty").Count
If Request.Form("selFaculty")(i) <> "0" then
'check to see if the person has been nominated before...
Response.Write("HERE -- Err.Num: " + Cstr(Err.number) + "
")
blnExists = ExistsAsNominee(Request.Form("selFaculty")(i))
If Not blnExists Then
'if the person hasn't been nominated, add them and set status to 'A' to be on the candidate slate
AddNominee Request.Form("selFaculty")(i)
Else
'if user was previously nominated, set their status to 'A' to be on the candidate slate
UpdateNomineeStatus Request.Form("selFaculty")(i)
End If
End If
Next
Set dbNVS = Nothing
Response.Clear
Response.Redirect "nominations.asp?init=0&comid=" + Cstr(Request.Form("hdCOM_ID"))
Response.End
End If
ElseIf Request.Form("btnDelete") = "<---- Delete" Then
'we are in "DELETING" mode...
If ValidDeleteNominees() then
DeleteNominees()
Set dbNVS = Nothing
Response.Clear
Response.Redirect "nominations.asp?init=0&comid=" + Cstr(Request.Form("hdCOM_ID"))
Response.End
End If
ElseIf Request.Form("btnApprove") = "Approve Candidate Slate" Then
ComId = Request.Form("hdCOM_ID")
Dim dictSlate
Set dictSlate = Server.CreateObject("Scripting.Dictionary")
LoadNomineesForVoteBallotSave dictSlate, ComId
If ValidSlate(dictSlate) Then
Dim intLoop, arrKeys
DeleteVotingRecords ComId
arrKeys = dictSlate.Keys
'save each committee member approved for the ballot...
For intLoop = 0 to dictSlate.Count - 1
SaveNewVotingBallot rsSlate, ComId, arrKeys(intLoop)
Next
DeleteCandidateSlate ComId
Set dictSlate = Nothing
Response.Clear
Response.Redirect "nominations.asp?init=1&confirm=yes&comid=" + Cstr(Request.Form("hdCOM_ID"))
Response.End
End If
Set rsSlate = Nothing
Else
message = "System error trying to submit nominations form.
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function SaveNewVotingBallot(rsSlate, ComId, lngUSER_ID)%>
<%
On Error Resume Next
set fso = Server.CreateObject("scripting.FileSystemObject")
set myFile = fso.OpenTextFile("C:\test.txt", 8, Create)
SaveNewVotingBallot = False
Dim strSQL
Dim cmdADD
Set cmdADD = Server.CreateObject("ADODB.command")
dbNVS.Open
cmdADD.ActiveConnection = dbNVS
dbNVS.BeginTrans
strSQL = "INSERT INTO [VOTING_RESULTS] ("
strSQL = strSQL + " [USER_ID], [COMID], [VOTES]"
strSQL = strSQL + ") Values ("
strSQL = strSQL + Cstr(lngUSER_ID) + ","
strSQL = strSQL + Cstr(ComId) + ","
strSQL = strSQL + Cstr(Clng(0)) + ")"
cmdADD.CommandText = strSQL
cmdADD.Execute
myFile.WriteLine(NOW() & " admin-nom " & strSQL)
'Error Handling in a small way...
If Err.Number > 0 then
'something is wrong...don't allow update to database...
dbNVS.RollBack
dbNVS.Close
'delete the records all ready added and then show error...
DeleteVotingRecords ComId
message = "A system error occured with the function SaveNewVotingBallot." + _
"
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
SaveNewVotingBallot = False
End if
dbNVS.CommitTrans
dbNVS.Close
Set cmdADD = Nothing
SaveNewVotingBallot = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function DeleteCandidateSlate(ComId)%>
<%
On Error Resume Next
set fso = Server.CreateObject("scripting.FileSystemObject")
set myFile = fso.OpenTextFile("C:\test.txt", 8, Create)
DeleteCandidateSlate = False
Dim cmdDELETE
Set cmdDELETE = Server.CreateObject("ADODB.command")
strSQL = " DELETE FROM [NOMINATED]"
strSQL = strSQL + " WHERE [COMID] = " + Cstr(ComId)
dbNVS.Open
cmdDELETE.ActiveConnection = dbNVS
cmdDELETE.CommandText = strSQL
dbNVS.BeginTrans
cmdDELETE.Execute
myFile.WriteLine(NOW() & " admin-nom " & strSQL)
'Error Handling in a small way...
If Err.Number > 0 then
'something is wrong...don't allow update to database...
dbNVS.RollBack
'the voting ballot has been entered so if this errors, we need to clear the voting table...
DeleteVotingRecords ComId
message = "A system error occured with the function DeleteCandidateSlate." + _
"
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
DeleteCandidateSlate = False
End if
dbNVS.CommitTrans
dbNVS.Close
Set cmdDELETE = Nothing
Response.Write "FINISHED DELETING CANDIDATE SLATE
"
DeleteCandidateSlate = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function ExistsAsNominee(lngUSER_ID)%>
<%
On Error Resume Next
ExistsAsNominee = False
Dim strSQL, blnExists
Response.Write("Before adLockOptimistic -- Err.Num: " + Cstr(Err.number) + "
")
adLockOptimistic = 3
Response.Write("After adLockOptimistic -- Err.Num: " + Cstr(Err.number) + "
")
Dim rsExists
Set rsExists = Server.CreateObject("ADODB.Recordset")
strSQL = "Select * From [NOMINATED]"
strSQL = strSQL + " WHERE [USER_ID]=" + Cstr(lngUSER_ID)
strSQL = strSQL + " AND [COMID]=" + Cstr(Request.Form("hdCOM_ID"))
dbNVS.Open
Response.Write("HERE 2 -- Err.Num: " + Cstr(Err.number))
rsExists.ActiveConnection = dbNVS
rsExists.Open strSQL, dbNVS, adOpenKeyset, adLockOptimistic
Response.Write("HERE 3 -- Err.Num: " + Cstr(Err.number))
If Not rsExists.EOF then
Response.Write("HERE True -- Err.Num: " + Cstr(Err.number) + "
")
ExistsAsNominee = True
Response.Write("HERE True After -- Err.Num: " + Cstr(Err.number) + "
")
Else
Response.Write("HERE False -- Err.Num: " + Cstr(Err.number) + "
")
ExistsAsNominee = False
Response.Write("HERE False After -- Err.Num: " + Cstr(Err.number) + "
")
End If
Response.Write("HERE False After -- Err.Num: " + Cstr(Err.number) + "
")
'Error Handling in a small way...
If Err.Number > 0 then
message = "A system error occured with the function ExistsAsNominee." + _
"
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message + " -- " + Err.Description)
Response.End
End if
dbNVS.Close
Response.Write("HERE CLOSE")
Set rsExists = Nothing
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function UpdateNomineeStatus(lngUSER_ID)%>
<%
On Error Resume Next
UpdateNomineeStatus = False
Dim strSQL, blnExists
Dim cmdEDIT
Set cmdEDIT = Server.CreateObject("ADODB.command")
strSQL = "Update [NOMINATED] SET "
strSQL = strSQL + " [STATUS]='A'"
strSQL = strSQL + " WHERE [USER_ID]=" + Cstr(lngUSER_ID)
strSQL = strSQL + " AND [COMID]=" + Cstr(Request.Form("hdCOM_ID"))
dbNVS.Open
cmdEDIT.ActiveConnection = dbNVS
cmdEDIT.CommandText = strSQL
dbNVS.BeginTrans
cmdEDIT.Execute
'Error Handling in a small way...
If Err.Number > 0 then
'something is wrong...don't allow update to database...
dbNVS.RollBack
message = "A system error occured with the function UpdateNomineeStatus." + _
"
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
UpdateNomineeStatus = False
End if
dbNVS.CommitTrans
dbNVS.Close
Set cmdEDIT = Nothing
UpdateNomineeStatus = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function AddNominee(lngUSER_ID)%>
<%
On Error Resume Next
AddNominee = False
Dim strSQL, blnExists
Dim cmdADD
Set cmdADD = Server.CreateObject("ADODB.command")
dbNVS.Open
cmdADD.ActiveConnection = dbNVS
strSQL = "INSERT INTO [NOMINATED] ("
strSQL = strSQL + " [USER_ID], [COMID], [NOM_ID], [STATUS]"
strSQL = strSQL + ") Values ("
strSQL = strSQL + Cstr(lngUSER_ID) + ","
strSQL = strSQL + Cstr(Request.Form("hdCOM_ID")) + ","
strSQL = strSQL + Cstr(Clng(999999)) + "," 'HARDCODED FOR NOW....
strSQL = strSQL + "'" + Cstr("A") + "')" 'DEFAUT ID NUMER USED FOR ADMIN ADDITIONS
cmdADD.CommandText = strSQL
dbNVS.BeginTrans
cmdADD.Execute
'Error Handling in a small way...
If Err.Number > 0 then
'something is wrong...don't allow update to database...
dbNVS.RollBack
message = "A system error occured with the function AddNominee." + _
"
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
AddNominee = False
End if
dbNVS.CommitTrans
dbNVS.Close
Set cmdADD = Nothing
AddNominee = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function DeleteNominees()%>
<%
On Error Resume Next
DeleteNominees = False
Dim cmdDELETE
Set cmdDELETE = Server.CreateObject("ADODB.command")
Dim strSQL, strUSERIDS
strUSERIDS = ""
For i = 1 To Request.Form("selMembers").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("selMembers")(i) <> "0" then
If strUSERIDS = "" then
strUSERIDS = Request.Form("selMembers")(i) + ", "
Else
'If this is the last user_id to vote for, do NOT put a comma after it...
If i = Request.Form("selMembers").Count Then
strUSERIDS = strUSERIDS + Request.Form("selMembers")
Else
strUSERIDS = strUSERIDS + Request.Form("selMembers") + ", "
End IF
End If
End If
Next
strSQL = " Delete FROM [NOMINATED] "
strSQL = strSQL + " Where [COMID] = " + Cstr(Request.Form("hdCOM_ID"))
strSQL = strSQL + " And [USER_ID] IN (" + Cstr(strUSERIDS) + ")"
dbNVS.Open
cmdDELETE.ActiveConnection = dbNVS
cmdDELETE.CommandText = strSQL
dbNVS.BeginTrans
cmdDELETE.Execute
'Error Handling in a small way...
If Err.Number > 0 then
'something is wrong...don't allow update to database...
dbNVS.RollBack
message = "A system error occured with the function DeleteNominees." + _
"
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
DeleteNominees = False
End if
dbNVS.CommitTrans
dbNVS.Close
Set cmdDELETE = Nothing
DeleteNominees = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function ValidAddNominees()
ValidAddNominees = False
Dim Count
Count = 0
For i = 1 To Request.Form("selFaculty").Count
If Request.Form("selFaculty")(i) <> "0" then
Count = Count + 1
End If
Next
If Count <= 0 Then
message = "You must select at least one faculty member to add to the nominating slate."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
ValidAddNominees = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function ValidSlate(rsSlate)
ValidSlate = False
If dictSlate.Count <= Clng(0) Then
message = "There are currently no faculty members nominated to this committee."
message = message + "
At least one facluty member must be nominated to the"
message = message + " commitee in order for a vote to occur."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
ValidSlate = False
End If
ValidSlate = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function ValidDeleteNominees()
ValidDeleteNominees = False
Dim Count
Count = 0
For i = 1 To Request.Form("selMembers").Count
If Request.Form("selMembers")(i) <> "0" then
Count = Count + 1
End If
Next
If Count <= 0 Then
message = "You must select at least one faculty member to remove from the nominating slate."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
ValidDeleteNominees = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<% Response.End %>