<%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit %> <% If Session("ValidatedAdministrator") <> True Then Response.Redirect "error.asp?error=denied" End If %> Admin Edit Record Processing <% Dim objRS Dim objRSstudents Dim objRSTeacher Dim objStudent Dim sSQL Dim strTmp Dim strEmail Dim strName Dim bNewPassword Dim Mailer Dim i bNewPassword = False Select Case LCase(Trim(Request.Form("action"))) Case "save edits" If Trim(Request.Form("Last")) = "" Or Trim(Request.Form("First")) = "" Then Response.Write ("You must specify a First and Last name! Changes NOT saved.
") bNewPassword = 99 'Use this flag to skip the default message at the end Else strTmp = Request.QueryString("email") sSQL = "SELECT * FROM Students WHERE email = '" & strTmp & "';" Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open sSQL, objConn, adOpenDynamic, adLockOptimistic, adCmdText 'Don't try processing if record doesn't exist If Not (objRS.EOF And objRS.BOF) Then 'Special processing for a Teacher's account If objRS("security") = vbTeacher Then 'If a Teacher changes their email address, all the 'TeacherEmail' ' fields from their Student's accounts must be updated. If objRS("email") <> Trim(Request.Form("email")) Then objRS("email") = Trim(Request.Form("email")) sSQL = "SELECT * FROM Students WHERE Teacher = '" & objRS("name") & "';" Set objRSstudents = Server.CreateObject("ADODB.Recordset") objRSstudents.Open sSQL, objConn, adOpenDynamic, adLockOptimistic, adCmdText objRSstudents.MoveFirst 'If this Teacher has no students, don't do anything If Not (objRSstudents.EOF And objRSstudents.BOF) Then 'Update the TeacherEmail field of all the Teacher's students Do While Not objRSstudents.EOF objRSstudents("teacheremail") = Trim(Request.Form("email")) objRSstudents.MoveNext Loop objRSstudents.MoveFirst objRSstudents.Update objRSstudents.Close End If Set objRSstudents = Nothing End If strName = objRS("name") 'Process these fields for Student accounts only ' Don't let Teacher accounts change their names Else objRS("name") = Request.Form("Last") & ", " & Request.Form("First") strName = Request.Form("First") & " " & Request.Form("Last") End If objRS("email") = Trim(Request.Form("email")) 'If the password changes, email the student with the new password info If objRS("password") <> Request.Form("password") Then objRS("password") = Request.Form("password") strEmail = objRS("email") bNewPassword = True Set Mailer = Server.CreateObject("SoftArtisans.SMTPMail") Mailer.FromName = "Guy Campbell" Mailer.FromAddress = "campbell_guy@hotmail.com" Mailer.organization = "Visual Basic - Moorpark College" Mailer.Subject = "Moorpark College -- Visual Basic Account Modification" Mailer.smtplog = "C:\mysmtplog.txt" Mailer.live = True Mailer.RemoteHost = "sunny.moorpark.cc.ca.us" Mailer.Priority = 3 Mailer.addrecipient strName, objRS("email") Mailer.bodytext = "Your Visual Basic Account Password has been changed. " & vbCRLF _ & vbCRLF _ & "Name: " & objRS("name") & vbCRLF _ & "eMail: " & objRS("email") & vbCRLF _ & "New Password: " & objRS("password") & vbCRLF & vbCRLF _ & "Important: All information is case sensitive." & vbCRLF & vbCRLF _ & "http://cislab.moorpark.cc.ca.us/vbasic" & vbCRLF & vbCRLF _ & "Thank You, " & vbCRLF & vbCRLF & "Guy Campbell" & vbCRLF & "gcampbell@moorparkcollege.edu" Mailer.SendMail Mailer.ClearRecipients Else bNewPassword = False End If 'These fields for Students only If objRS("security") = vbStudent Then objRS("classtype") = Request.Form("cis40or41") objRS("meetday") = Request.Form("meetday") objRS("modified") = CStr(Date) 'If the Teacher changes be sure to update the TeacherEmail field If Request.Form("teacher") <> objRS("teacher") Then sSQL = "SELECT * FROM Students WHERE Name = '" & Request.Form("teacher") & "';" Set objRSTeacher = Server.CreateObject("ADODB.Recordset") objRSTeacher.Open sSQL, objConn, adOpenDynamic, adLockOptimistic, adCmdText objRSTeacher.MoveFirst 'If this Teacher doesn't exist, don't do anything If Not (objRSTeacher.EOF And objRSTeacher.BOF) Then 'Update the TeacherEmail field of the Teacher objRS("teacheremail") = objRSTeacher("email") objRS("teacher") = Request.Form("teacher") objRSTeacher.Close Set objRSTeacher = Nothing End If End If If IsNumeric(Trim(Request.Form("score1"))) Then objRS("score1") = CInt(Trim(Request.Form("score1"))) Else objRS("score1") = "0" End If If IsNumeric(Trim(Request.Form("score2"))) Then objRS("score2") = CInt(Trim(Request.Form("score2"))) Else objRS("score2") = "0" End If If IsNumeric(Trim(Request.Form("score3"))) Then objRS("score3") = CInt(Trim(Request.Form("score3"))) Else objRS("score3") = "0" End If If IsNumeric(Trim(Request.Form("score4"))) Then objRS("score4") = CInt(Trim(Request.Form("score4"))) Else objRS("score4") = "0" End If If IsNumeric(Trim(Request.Form("score5"))) Then objRS("score5") = CInt(Trim(Request.Form("score5"))) Else objRS("score5") = "0" End If If IsNumeric(Trim(Request.Form("score6"))) Then objRS("score6") = CInt(Trim(Request.Form("score6"))) Else objRS("score6") = "0" End If If IsNumeric(Trim(Request.Form("score7"))) Then objRS("score7") = CInt(Trim(Request.Form("score7"))) Else objRS("score7") = "0" End If If IsNumeric(Trim(Request.Form("score8"))) Then objRS("score8") = CInt(Trim(Request.Form("score8"))) Else objRS("score8") = "0" End If If IsNumeric(Trim(Request.Form("score9"))) Then objRS("score9") = CInt(Trim(Request.Form("score9"))) Else objRS("score9") = "0" End If If IsNumeric(Trim(Request.Form("score10"))) Then objRS("score10") = CInt(Trim(Request.Form("score10"))) Else objRS("score10") = "0" End If If IsNumeric(Trim(Request.Form("score11"))) Then objRS("score11") = CInt(Trim(Request.Form("score11"))) Else objRS("score11") = "0" End If If IsNumeric(Trim(Request.Form("score12"))) Then objRS("score12") = CInt(Trim(Request.Form("score12"))) Else objRS("score12") = "0" End If End If objRS.Update objRS.Close Set objRS = Nothing End If End If Case Else 'Cancel the edit Response.Redirect "admin.asp" End Select If bNewPassword = True Then Response.Write ("An email has been sent to " & strName & " at " & strEmail & "
informing them that their password has been changed.

") ElseIf bNewPassword = False Then Response.Write ("Edits to account " & strName & " saved.
") End If %>
<% %>