% @ Language=VBScript %>
<% Response.Buffer = True %>
<%
Dim message
If ValidNom() then
PostNominations()
Response.Clear
Response.Redirect "nominate.asp?init=0&ComId=" + Cstr(Request.Form("hdCOM_ID"))
Response.End
End If
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function PostNominations()
On Error Resume Next
set fso = Server.CreateObject("scripting.FileSystemObject")
set myFile = fso.OpenTextFile("C:\test.txt", 8, Create)
PostNominations = False
Dim strSQL
Dim message
For i = 1 to request.form("selFac").count
Set cmdPostNom = Server.CreateObject("ADODB.command")
If Cstr(Request.form("selFac")(i)) = Cstr(Session.Contents("USER_ID")) Then
strSQL="Insert Into [NOMINATED] ([USER_ID], [COMID], [NOM_ID],[STATUS])"
strSQL= strSQL +"Values ("
strSQL = strSQL + Cstr(Request.form("selFac")(i)) + ","
strSQL = strSQL + Cstr(Request.Form("hdCOM_ID")) + ","
strSQL = strSQL + Cstr(Session.Contents("USER_ID")) + ","
strSQL = strSQL + "'A')"
Else
strSQL="Insert Into [NOMINATED] ([USER_ID], [COMID], [NOM_ID],[STATUS])"
strSQL= strSQL +"Values ("
strSQL = strSQL + Cstr(Request.form("selFac")(i)) + ","
strSQL = strSQL + Cstr(Request.Form("hdCOM_ID")) + ","
strSQL = strSQL + Cstr(Session.Contents("USER_ID")) + ","
strSQL = strSQL + "'U')"
End If
response.write cstr(strSQL) + "
"
dbNVS.Open
cmdPostNom.ActiveConnection = dbNVS
cmdPostNom.CommandText = strSQL
dbNVS.BeginTrans
cmdPostNom.Execute
myFile.WriteLine(NOW() & " nom " & strSQL)
'~~~~~ERROR~~~~~~~~
'Error Handling in a small way...
If Err.Number > 0 then
dbNVS.Rollback
message = "A system error occured with the function PostNominations." + _
"
Please contact the Nominations and Election Committee to resolve this problem." + _
"
Please click the back button."
'something is wrong...
myFile.WriteLine(message)
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
PostNominations = False
End if
dbNVS.CommitTrans
dbNVS.Close
Set cmdPostNom = Nothing
Next
PostNominations = True
myfile.close
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function ValidNom()
ValidNom = False
Dim Count
Dim message
Count = 0
For i = 1 To Request.Form("selFac").Count
If Request.Form("selFac")(i) <> "0" then
Count = Count + 1
End If
Next
If Clng(Count) <= 0 then
message = "Please select a faculty member to nominate.
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
ValidNom = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<% Response.End %>