% @ Language=VBScript %>
<% Response.Buffer = True %>
<%
If ValidDeNom() then
DeleteNominations()
Response.Clear
Response.Redirect "nominate.asp?init=0&ComId=" + Cstr(Request.Form("hdCOM_ID"))
Response.End
End If
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function DeleteNominations()
On Error Resume Next
DeleteNominations = False
Set cmdPostNom = Server.CreateObject("ADODB.command")
Dim strSQL, strUSERIDS
Dim message
set fso = Server.CreateObject("scripting.FileSystemObject")
set myFile = fso.OpenTextFile("C:\test.txt", 8)
strUSERIDS = ""
For i = 1 To Request.Form("selFacNom").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("selFacNom")(i) <> "0" then
If strUSERIDS = "" then
strUSERIDS = Request.Form("selFacNom")(i) + ", "
Else
'If this is the last user_id to vote for, do NOT put a comma after it...
If i = Request.Form("selFacNom").Count Then
strUSERIDS = strUSERIDS + Request.Form("selFacNom")
Else
strUSERIDS = strUSERIDS + Request.Form("selFacNom") + ", "
End IF
End If
End If
Next
strSQL = " Delete * FROM Nominated "
strSQL = strSQL + " Where [COMID] = " + Cstr(Request.Form("hdCOM_ID"))
strSQL = strSQL + " And [NOM_ID] = " + Cstr(Session.Contents("USER_ID"))
strSQL = strSQL + " And [USER_ID] IN (" + Cstr(strUSERIDS) + ")"
dbNVS.Open
cmdPostNom.ActiveConnection = dbNVS
cmdPostNom.CommandText = strSQL
dbNVS.BeginTrans
cmdPostNom.Execute
myfile.WriteLine(NOW() & " " & strSQL)
'Error Handling in a small way...
If Err.Number > 0 then
dbNVS.Rollback
message = "A system error occured with the function DeleteNominations." + _
"
Please contact the Nominations and Election Committee to resolve this problem." + _
"
Please click the back button."
'something is wrong...
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
myfile.WriteLine(NOW() & " " & message)
DeleteNominations = False
End if
dbNVS.CommitTrans
dbNVS.Close
Set cmdPostNom = Nothing
DeleteNominations = True
myfile.close
set fso = nothing
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function ValidDeNom()
ValidDeNom = False
Dim Count
Dim message
Count = 0
For i = 1 To Request.Form("selFacNom").Count
If Request.Form("selFacNom")(i) <> "0" then
Count = Count + 1
End If
Next
If Clng(Count) <= 0 then
message = "Please select a faculty member to denominate.
Please click the BACK button to return to the nominating screen."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
ValidDeNom = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<% Response.End %>