% @ Language=VBScript %>
<% Response.Buffer = True %>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim FacId
FacId = Cstr(Clng(Request.Form("hdFacId")))
If Request.Form("btnSave") = "Save Changes" Then
If Validated() Then
SaveFac()
Set dbNVS = Nothing
Set dbPWD = Nothing
Response.Clear
Response.Redirect "faculty_edit.asp?confirm=yes&init=0&mode=edit&facid=" + Cstr(Clng(Request.Form("hdFacId")))
Response.End
Else
Response.Write "NOT VALIDATED"
Response.End
End If
Else
DeleteFac()
Set dbNVS = Nothing
Set dbPWD = Nothing
Response.Clear
Response.Redirect "faculty_edit.asp?confirmdelete=yes&init=1&mode=delete"
Response.End
End If
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function DeleteFac()
On Error Resume Next
DeleteFac = False
Dim cmdFac, strSQL, message
Set cmdFac = Server.CreateObject("ADODB.Command")
dbNVS.Open
strSQL = "Delete From [FACULTY] WHERE [USER_ID]= " + Cstr(FacId)
cmdFac.ActiveConnection = dbNVS
cmdFac.CommandText = strSQL
dbNVS.BeginTrans
cmdFac.Execute
DelPWD()
If Err.Number <> 0 then
message = "A system error occured with the function DeleteFac in the dbNVS update." + _
"
Please click the back button."
dbNVS.RollBack
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
DeleteFac = False
End if
dbNVS.CommitTrans
dbNVS.Close
Set cmdFac = Nothing
DeleteFac = True
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function DelPWD()
%>
<%
On Error Resume Next
Dim strPWD, cmdPWD, message
Set cmdPWD = Server.CreateObject("ADODB.Command")
strPWD = "Delete From [Users] WHERE [ID]= " + Cstr(FacId)
dbConn.Open
cmdPWD.ActiveConnection = dbConn
cmdPWD.CommandText = strPWD
dbConn.BeginTrans
cmdPWD.Execute
If Err.Number <> 0 then
message ="A system error occured with the function DelPWD in the dbPWD update." + _
"
Please click the back button."
dbConn.RollBack
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
DelPWD= False
End if
dbConn.CommitTrans
Set cmdPWD = Nothing
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function Validated()%>
<%
On Error Resume Next
Validated = False
Dim strSQL, message
Dim rsFaculty
Set rsFaculty = Server.CreateObject("ADODB.Recordset")
GetFaculty rsFaculty
'USER ID************
If Trim(Request.Form("txtUserID")) = "" OR IsNull(Trim(Request.Form("txtUserID"))) Then
message = "You must supply an 6 character SNC Faculty ID #.
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
If Len(Trim(Request.Form("txtUserID"))) < 5 Then
message = "The SNC Faculty ID # is 5-6 characters long.
Please click the BACK button to correct the error."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
If Not IsNumeric(Trim(Request.Form("txtUserID"))) Then
message = "The SNC Faculty ID # must be numeric.
Please click the BACK button to correct the error."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
'LOGIN************
If Trim(Request.Form("txtLogin")) = "" OR IsNull(Trim(Request.Form("txtLogin"))) Then
message = "You must supply a SNC Network Login Name.
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
If Len(Trim(Request.Form("txtLogin"))) > 25 Then
message = "The SNC Network Login Name must be less than 25 characters long.
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
'since the PASSWORD and USER_ID are the same, initially, we only need to validate one of them...
If (Request.Form("txtUserID") <> Request.Form("hdUserID")) OR (Request.Form("txtLogin") <> Request.Form("hdLogin")) Then
'user has changed one or both of these fields...better validate them...
If Not rsFaculty.EOF Then
rsFaculty.MoveFirst
While Not rsFaculty.EOF
'if the user id changes, validate it...
If Request.Form("txtUserID") <> Request.Form("hdUserID") Then
If Trim(Request.Form("txtUserID")) = rsFaculty.Fields("USER_ID").Value then
message = "The SNC ID # you have entered all ready exists in the database.
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
End If
'if the login id changes, validate it...
If Request.Form("txtLogin") <> Request.Form("hdLogin") Then
If Trim(Request.Form("txtLogin")) = rsFaculty.Fields("LOGIN_ID").Value then
message = "The Network Login Id you have entered all ready exists in the database.
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
End If
rsFaculty.MoveNext
Wend
End If
End If
'FNAME************
If Trim(Request.Form("txtFName")) = "" OR IsNull(Trim(Request.Form("txtFName"))) Then
message = "You must supply a First Name.
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
If Len(Trim(Request.Form("txtFName"))) > 20 Then
message = "The First Name must be less than 20 characters long.
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
'LNAME************
If Trim(Request.Form("txtLName")) = "" OR IsNull(Trim(Request.Form("txtLName"))) Then
message = "You must supply a Last Name.
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
If Len(Trim(Request.Form("txtLName"))) > 30 Then
message = "The Last Name must be less than 30 characters long.
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
'EMAIL************ only length is checked b/c it is not a required field
If Len(Trim(Request.Form("txtEmail"))) > 50 Then
message = "The Email must be less than 50 characters long.
Please click the BACK button."
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
End If
Validated = True
dbNVS.Close
Set rsFaculty = Nothing
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function SaveFac()
On Error Resume Next
SaveFac = False
Set cmdFac = Server.CreateObject("ADODB.Command")
Dim strSQL, gen, tenure, admin, voter, message
If Request.Form("txtGender") <> "No" then 'F
gen = true 'M
else
gen = false
End If
If Request.Form("txtTenure") <> "No" then
tenure = true
else
tenure = false
End If
If Request.Form("txtAdmin") <> "No" then
admin = true
else
admin = false
End If
If Request.Form("txtAVoter") <> "No" then
voter = true
else
voter = false
End If
strSQL = "Update [FACULTY] SET"
strSQL = strSQL + " [USER_ID]=" + Cstr(Request.Form("txtUserID")) + ","
strSQL = strSQL + " [LOGIN_ID]='" + Cstr(SQLFixTicks(Trim(Request.Form("txtLogin")))) + "',"
strSQL = strSQL + " [F_NAME]='" + Cstr(SQLFixTicks(Trim(Request.Form("txtFName")))) + "',"
strSQL = strSQL + " [L_NAME]='" + Cstr(SQLFixTicks(Trim(Request.Form("txtLName")))) + "',"
strSQL = strSQL + " [SEX]=" + CStr(Cint(gen)) + ","
strSQL = strSQL + " [EMAIL]='" + CStr(SQLFixTicks(Trim(Request.Form("txtEmail")))) + "',"
strSQL = strSQL + " [DIV_ID]=" + CStr(Request.Form("selDiv")) + ","
strSQL = strSQL + " [TENURE]=" + Cstr(Cint(tenure)) + ","
strSQL = strSQL + " [ADMIN_ACCESS]=" + CStr(Cint(admin)) + ","
strSQL = strSQL + " [ACTIVE_VOTER]=" + Cstr(Cint(voter))
strSQL = strSQL + " WHERE [USER_ID]=" + Cstr(FacId)
dbNVS.Open
cmdFac.ActiveConnection = dbNVS
cmdFac.CommandText = strSQL
dbNVS.BeginTrans
cmdFac.Execute
If Err.Number <> 0 then
message = "A system error occured with the function SaveFac on the x_faculty_edit.asp page.
Please click the back button."
dbNVS.RollBack
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
SaveFac = False
End if
FacAddPWD()
dbNVS.CommitTrans
dbNVS.Close
Set cmdFac = Nothing
SaveFac True
End Function
%>
<%
Function FacAddPWD()%>
<%
On Error Resume Next
FacAddPWD = False
Dim strPWD, cmdF, message, admin
If Request.Form("txtAdmin") <> "No" then
admin = 1
else
admin = 0
End If
Set cmdF = Server.CreateObject("ADODB.Command")
strPWD = "UPDATE [USERS] SET"
strPWD = strPWD + " [ID]=" + CStr(Request.Form("txtUserID")) + ","
strPWD = strPWD + " [USERNAME]='" + Cstr(SQLFixTicks(Trim(Request.Form("txtLogin")))) + "',"
strPWD = strPWD + " [ADMIN]=" + Cstr(Cint(admin)) + ","
strPWD = strPWD + " [CHANGE_PWD]=" + Cstr(Cint(False))
strPWD = strPWD + " WHERE [ID]=" + Cstr(FacId)
dbConn.Open
cmdF.ActiveConnection = dbConn
cmdF.CommandText = strPWD
dbConn.BeginTrans
cmdF.Execute
If Err.Number <> 0 then
message ="A system error occured with the function FacAddPWD in the dbPWD update." + _
"
Please click the back button."
dbConn.RollBack
Response.Clear
Response.Redirect "error.asp?mess=" + Server.URLEncode(message)
Response.End
FacAddPWD= False
End if
dbConn.CommitTrans
dbConn.Close
Set cmdF = Nothing
FacAddPWD = True
End Function
%>