% @ Language=VBScript %>
<% Response.Buffer = True %>
<%
If Request.Form("btnSave") = "Save Changes" Then
'we're in edit mode, better save the changes...
Dim dtNomStart, dtNomEnd, dtVoteStart, dtVoteEnd
'get dates cleaned of bad characters...
dtNomStart = CleanDate(Request.Form("txtNomStart"))
dtNomEnd = CleanDate(Request.Form("txtNomEnd"))
dtVoteStart = CleanDate(Request.Form("txtVoteStart"))
dtVoteEnd = CleanDate(Request.Form("txtVoteEnd"))
If Validated() Then
UpdateCommittee()
Set dbNVS = Nothing
Response.Clear
Response.Redirect "committee_edit.asp?confirm=yes&init=0&mode=edit&comid=" + Cstr(Clng(Request.Form("hdComId")))
Response.End
Else
Response.Write "NOT VALIDATED"
Response.End
End If
Else
'we're in delete mode...the user has been prompted all ready, so lets delete the committee!!!
DeleteCommittee()
Set dbNVS = Nothing
Response.Clear
Response.Redirect "committee_edit.asp?confirmdelete=yes&init=1&mode=delete"
Response.End
End If
%>
<%
Function DeleteCommittee()
On Error Resume Next
DeleteCommittee = False
Dim cmdComm
Set cmdComm = Server.CreateObject("ADODB.Command")
Dim strSQL
'delete from the COMM1 table...
strSQL = "Delete From [COMM1] WHERE [COMID]= " + Cstr(Clng(Request.Form("hdComId")))
dbNVS.Open
cmdComm.ActiveConnection = dbNVS
cmdComm.CommandText = strSQL
dbNVS.BeginTrans
cmdComm.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...
Response.Clear
Response.Redirect "error.asp?mess=A system error occured with the function DeleteCommittee." + _
"
Please click the back button."
Response.End
DeleteCommittee = False
End if
dbNVS.CommitTrans
dbNVS.Close
Set cmdComm = Nothing
DeleteCommittee = True
End Function
%>
<%
Function Validated()%>
<%
On Error Resume Next
Validated = False
'validate the "NAME" field....
If Trim(Request.Form("txtComName")) = "" OR IsNull(Trim(Request.Form("txtComName"))) Then
Response.Clear
Response.Redirect "error.asp?mess=You must supply a Committee Name.
Please click the BACK button."
Response.End
End If
If Len(Trim(Request.Form("txtComName"))) > 50 Then
Response.Clear
Response.Redirect "error.asp?mess=The Committee Name can only be 50 characters long.
Please click the BACK button."
Response.End
End If
'validate the "SIZE" field...
If Trim(Request.Form("txtComSize")) = "" OR IsNull(Trim(Request.Form("txtComSize"))) Then
Response.Clear
Response.Redirect "error.asp?mess=You must supply a Committee Size.
Please click the BACK button."
Response.End
End If
If Len(Trim(Request.Form("txtComSize"))) > 3 Then
Response.Clear
Response.Redirect "error.asp?mess=The Committee Size can only be 3 characters long.
Please click the BACK button."
Response.End
End If
If Not IsNumeric(Trim(Request.Form("txtComSize"))) Then
Response.Clear
Response.Redirect "error.asp?mess=The Committee Size must be numeric.
Please click the BACK button."
Response.End
End If
'validate the "TERM" field...
If Trim(Request.Form("txtComTerm")) = "" OR IsNull(Trim(Request.Form("txtComTerm"))) Then
Response.Clear
Response.Redirect "error.asp?mess=You must supply a Committee Term Length.
Please click the BACK button."
Response.End
End If
If Len(Trim(Request.Form("txtComTerm"))) > 2 Then
Response.Clear
Response.Redirect "error.asp?mess=The Committee Term Length can only be 2 characters long.
Please click the BACK button."
Response.End
End If
If Not IsNumeric(Trim(Request.Form("txtComTerm"))) Then
Response.Clear
Response.Redirect "error.asp?mess=The Committee Term must be numeric.
Please click the BACK button."
Response.End
End If
'validate the "URL" field...
If Len(Trim(Request.Form("txtComUrl"))) > 50 Then
Response.Clear
Response.Redirect "error.asp?mess=The Committee URL can only be 50 characters long.
Please click the BACK button."
Response.End
End If
'validate the "Committee DESCRIPTION" field...
If Len(Trim(Request.Form("txtComDesc"))) > 4000 Then
Response.Clear
Response.Redirect "error.asp?mess=The Committee Description can only be 4000 characters long.
Please click the BACK button."
Response.End
End If
'validate the "Membership DESCRIPTION" field...
If Len(Trim(Request.Form("txtMemDesc"))) > 4000 Then
Response.Clear
Response.Redirect "error.asp?mess=The Membership Description can only be 4000 characters long.
Please click the BACK button."
Response.End
End If
'VALIDATE THE DATE FIELDS...
If Not DateOk(dtNomStart) Then
Response.Clear
Response.Redirect "error.asp?mess=The Nomination Start date is not valid.
Please click the BACK button."
Response.End
End If
If Not DateOk(dtNomEnd) Then
Response.Clear
Response.Redirect "error.asp?mess=The Nomination End date is not valid.
Please click the BACK button."
Response.End
End If
If Not DateOk(dtVoteStart) Then
Response.Clear
Response.Redirect "error.asp?mess=The Voting Start date is not valid.
Please click the BACK button."
Response.End
End If
If Not DateOk(dtVoteEnd) Then
Response.Clear
Response.Redirect "error.asp?mess=The Voting Start date is not valid.
Please click the BACK button."
Response.End
End If
If dtNomStart > dtNomEnd Then
Response.Clear
Response.Redirect "error.asp?mess=The Nominations Start date is greater than the Nominations End date.
Please click the BACK button."
Response.End
End If
If dtVoteStart > dtVoteEnd Then
Response.Clear
Response.Redirect "error.asp?mess=The Voting Start date is greater than the Voting End date.
Please click the BACK button."
Response.End
End If
If Cdate(dtNomStart) > CDate(dtVoteStart) OR CDate(dtNomStart) > CDate(dtVoteEnd) OR CDate(dtNomEnd) >= CDate(dtVoteStart) OR CDate(dtNomEnd) > CDate(dtVoteEnd) Then
Response.Clear
Response.Redirect "error.asp?mess=The Nominations period overlaps the Voting period.
Please click the BACK button."
Response.End
End If
Validated = True
Set rsCom = Nothing
End Function
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function UpdateCommittee()
On Error Resume Next
UpdateCommittee = False
Dim Election_Type, bEditNom, bEditVote
Dim rsCom
Dim cmdComm
Set rsCom = Server.CreateObject("ADODB.Recordset")
Set cmdComm = Server.CreateObject("ADODB.Command")
Dim strSQL
'assume we can edit, we'll validate below...
bEditNom = True
bEditVote = True
'get election type for storage...
If Request.Form("selVoteType") <> "Runoff" Then
Election_Type = True
Else
Election_Type = False
End If
strSQL = "Select * from [COMM1] where [COMID]= " + Cstr(Request.Form("hdComId"))
dbNVS.Open
rsCom.ActiveConnection = dbNVS
rsCom.Open strSQL, dbNVS, adOpenKeyset ', adLockOptimistic
rsCom.MoveFirst
If dtNomStart > rsCom.Fields("STARTNOM") AND dtNomStart < rsCom.Fields("ENDNOM") Then
'if committee is in a current nominations periods...don't allow an update...
bEditNom = False
End If
If dtNomEnd > rsCom.Fields("STARTNOM") AND dtNomEnd < rsCom.Fields("ENDNOM") Then
'if committee is in a current nominations periods...don't allow an update...
bEditNom = False
End If
If dtVoteStart > rsCom.Fields("STARTVOTE") AND dtVoteStart < rsCom.Fields("ENDVOTE") Then
'if committee is in a current nominations periods...don't allow an update...
bEditVote = False
End If
If dtVoteEnd > rsCom.Fields("STARTVOTE") AND dtVoteEnd < rsCom.Fields("ENDVOTE") Then
'if committee is in a current nominations periods...don't allow an update...
bEditVote = False
End If
dbNVS.Close
'update the COMM1 table...
strSQL = "Update [COMM1] Set"
strSQL = strSQL + " [COMNAME]= '" + SQLFixTicks(Trim(Request.Form("txtComName"))) + "'," 'COMNAME
strSQL = strSQL + " [COMDESC]= '" + SQLFixTicks(Trim(Request.Form("txtComDesc"))) + "'," 'COMDESC
strSQL = strSQL + " [MEMDESC]= '" + SQLFixTicks(Trim(Request.Form("txtMemDesc"))) + "'," 'MEMDESC
strSQL = strSQL + " [URL]= '" + SQLFixTicks(Trim(Request.Form("txtComURL"))) + "'," 'URL
'only edit these fields if committee is NOT in an nominations or election period...
If bEditNom Then
strSQL = strSQL + " [STARTNOM]= #" + Cstr(dtNomStart) + "#," 'STARTNOM
strSQL = strSQL + " [ENDNOM]= #" + Cstr(dtNomEnd) + "#," 'ENDNOM
End If
If bEditVote Then
strSQL = strSQL + " [STARTVOTE]= #" + Cstr(dtVoteStart) + "#," 'STARTVOTE
strSQL = strSQL + " [ENDVOTE]= #" + Cstr(dtVoteEnd) + "#," 'ENDVOTE
End If
strSQL = strSQL + " [COM_SIZE]= " + Cstr(Trim(Request.Form("txtComSize"))) + "," 'COM_SIZE
strSQL = strSQL + " [TERM_LENGTH]= " + Cstr(Trim(Request.Form("txtComTerm"))) + "," 'TERM_LENGTH
if Election_Type = True then
strSQL = strSQL + " [ELECTION_TYPE]= " + Cstr(1) + "," 'ELECTION_TYPE
else
strSQL = strSQL + " [ELECTION_TYPE]= " + Cstr(0) + "," 'ELECTION_TYPE
End If
'strSQL = strSQL + " [ELECTION_TYPE]= " + Cstr(CInt(Election_Type)) + "," 'ELECTION_TYPE
strSQL = strSQL + " [APPROVE_STATUS]= " + Cstr(CInt(False)) 'APPROVE_STATUS
strSQL = strSQL + " WHERE [COMID]= " + Cstr(Clng(Request.Form("hdComId")))
dbNVS.Open
cmdComm.ActiveConnection = dbNVS
cmdComm.CommandText = strSQL
dbNVS.BeginTrans
cmdComm.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...
Response.Clear
'Response.Redirect "error.asp?mess=A system error occured with the function UpdateCommittee." + _
' "
Please click the back button."
Response.redirect "error.asp?mess=" + Cstr(CInt(Election_Type))
Response.End
UpdateCommittee = False
End if
dbNVS.CommitTrans
dbNVS.Close
Set rsCom = Nothing
Set cmdComm = Nothing
UpdateCommittee = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>