% @ Language=VBScript %>
<% Response.Buffer = True %>
<%
If Validated() Then
SaveComittee()
Set dbNVS = Nothing
Response.Clear
Response.Redirect "committee_add.asp?confirm=yes"
Response.End
End If
%>
<%
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
'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
'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
Validated = True
End Function
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function SaveComittee()
On Error Resume Next
SaveComittee = False
Set cmdComm = Server.CreateObject("ADODB.Command")
Dim strSQL
strSQL = "Insert Into [COMM1] ("
strSQL = strSQL + "[COMNAME], [COMDESC], [MEMDESC], [URL], [STARTNOM], [ENDNOM], [STARTVOTE], "
strSQL = strSQL + "[ENDVOTE], [COM_SIZE], [TERM_LENGTH], [ELECTION_TYPE], [APPROVE_STATUS]"
strSQL = strSQL + ") Values ("
strSQL = strSQL + "'" + SQLFixTicks(Trim(Request.Form("txtComName"))) + "'," 'COMNAME
strSQL = strSQL + "'" + SQLFixTicks(Trim(Request.Form("txtComDesc"))) + "'," 'COMDESC
strSQL = strSQL + "'" + SQLFixTicks(Trim(Request.Form("txtMemDesc"))) + "'," 'MEMDESC
strSQL = strSQL + "'" + SQLFixTicks(Trim(Request.Form("txtComURL"))) + "'," 'URL
strSQL = strSQL + "#" + Cstr(DateAdd("d", -1, Date())) + "#," 'STARTNOM
strSQL = strSQL + "#" + Cstr(DateAdd("d", -1, Date())) + "#," 'ENDNOM
strSQL = strSQL + "#" + Cstr(DateAdd("d", -1, Date())) + "#," 'STARTVOTE
strSQL = strSQL + "#" + Cstr(DateAdd("d", -1, Date())) + "#," 'ENDVOTE
strSQL = strSQL + Cstr(Trim(Request.Form("txtComSize"))) + "," 'COM_SIZE
strSQL = strSQL + Cstr(Trim(Request.Form("txtComTerm"))) + "," 'TERM_LENGTH
strSQL = strSQL + Cstr(CInt(True)) + "," 'ELECTION_TYPE
strSQL = strSQL + Cstr(CInt(False)) + ")" 'APPROVE_STATUS
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 SaveComittee." + _
"
Please click the back button."
Response.End
SaveComittee = False
End if
dbNVS.CommitTrans
dbNVS.Close
Set cmdComm = Nothing
SaveComittee = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>