% @ Language=VBScript %>
<% Response.Buffer = True %>
<%
If Request.Form("btnSave") = "Save Changes" Then
'we're in edit mode, better save the changes...
If Validated() Then
UpdateDivision()
Set dbNVS = Nothing
Response.Clear
Response.Redirect "division_edit.asp?confirm=yes&init=0&mode=edit&divid=" + Cstr(Clng(Request.Form("hdDivId")))
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!!!
DeleteDivision()
Set dbNVS = Nothing
Response.Clear
Response.Redirect "division_edit.asp?confirmdelete=yes&init=1&mode=delete"
Response.End
End If
%>
<%
Function DeleteDivision()
On Error Resume Next
DeleteDivision = False
Dim cmdDiv
Set cmdDiv = Server.CreateObject("ADODB.Command")
Dim strSQL
'delete from the COMM1 table...
strSQL = "Delete From [DIVISION] WHERE [DIV_ID]= " + Cstr(Clng(Request.Form("hdDivId")))
dbNVS.Open
cmdDiv.ActiveConnection = dbNVS
cmdDiv.CommandText = strSQL
dbNVS.BeginTrans
cmdDiv.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 DeleteDivision." + _
"
Please click the back button."
Response.End
DeleteDivision = False
End if
dbNVS.CommitTrans
dbNVS.Close
Set cmdDiv = Nothing
DeleteDivision = True
End Function
%>
<%
Function Validated()%>
<%
On Error Resume Next
Validated = False
'validate the "NAME" field....
If Trim(Request.Form("txtDivName")) = "" OR IsNull(Trim(Request.Form("txtDivName"))) Then
Response.Clear
Response.Redirect "error.asp?mess=You must supply a Division Name.
Please click the BACK button."
Response.End
End If
If Len(Trim(Request.Form("txtDivName"))) > 50 Then
Response.Clear
Response.Redirect "error.asp?mess=The Division Name can only be 25 characters long.
Please click the BACK button."
Response.End
End If
Validated = True
End Function
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function UpdateDivision()
On Error Resume Next
UpdateDivision = False
Dim cmdDiv
Set cmdDiv = Server.CreateObject("ADODB.Command")
Dim strSQL
'update the COMM1 table...
strSQL = "Update [DIVISION] Set"
strSQL = strSQL + " [DIVISION]= '" + SQLFixTicks(Trim(Request.Form("txtDivName"))) + "'" 'DIVISION
strSQL = strSQL + " WHERE [DIV_ID]= " + Cstr(Clng(Request.Form("hdDivId")))
dbNVS.Open
cmdDiv.ActiveConnection = dbNVS
cmdDiv.CommandText = strSQL
dbNVS.BeginTrans
cmdDiv.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 UpdateDivision." + _
"
Please click the back button."
Response.End
UpdateDivision = False
End if
dbNVS.CommitTrans
dbNVS.Close
Set cmdDiv = Nothing
UpdateDivision = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>