Back to the Source Listing 


<!--#include file="includes/FacConn.inc"-->

<%
'Developer: Angela Johnston
'Date: March 5, 2001
'
'addCourse.asp - This page takes information that the user entered on the editCourse.asp page and
' updates the database.
'
'***************************************************************************************************************
'Included pages
' FacConn.inc - Checks whether the user has application priviledges
' formStyle.css - The style sheet for the Faculty Application
' adovbs.inc - A page usually included with ASP to make openning tables and running queries easier.
' It assigns names to numbers, so that you don't have to remember what each number means.
' footer.asp - Contains the menu that should be located at the bottom of the page
'
'QueryStrings (name - value)
' None
'
'Recordsets (name - value)
' rsUser - (FacConn.inc) contains the current user logged on to the intranet (tblUser)
' rsFac - contains the current faculty member's information (tblFaculty)
' rsCourse - contains the information for all courses that the faculty member teaches (tblCourses)
' rsCoursesTaught - contains the courseID numbers corresponding to the currently faculty members ID (tblCoursesTaught)
'
'Variables
' strSQL - (FacConn.inc) use to store the sql string for a query
' bAdmin - (FacConn.inc) boolean value, "True" if user is an Administrator, "False" if the user is not
' lngUserID - (FacConn.inc) the ID number for the current user
' strUserLogon - (FacConn.inc) the Logon Name for the current user
' lngFacID - the ID number for the current faculty member
'
'Form Fields
' cboCourse - a combo box that allows the user to select a course to be added to the current page
' Number - (Required) the number for the new course to be added. It should have the text 'Agron' followed
' by three numbers. (example Agron 450).
' Name - (Required) the full name of the course.
' DescURL - The URL location of the description for the course. This location is on the Agronomy site.
' WebPageURL - The URL location for the course web site.
'***************************************************************************************************************
%>

 
<%
'On Error Resume Next
Dim rsFac, rsCourse, rsCoursesTaught
Dim lngCourseID, lngFacID
'Get current Faculty ID and open faculty record set
'**************************************************
If bAdmin = "True" Then
If Session("FacID") = "" Then
Response.Redirect "http://intranet.oznet.ksu.edu/agronomy/welcome.asp?error=NotFound"
Else
lngFacID = Session("FacID")
End If
 
'Open a recordset containing the current faculty member using the variable lngUserID
Set rsFac = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM tblFaculty WHERE fldFacID = " & lngFacID & ";"
rsFac.Open strSQL, fp_conn, adOpenDynamic, adLockOptimistic, adCmdText
Else
 
'Open a recordset containing the current faculty member using the variable lngUserID
Set rsFac = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM tblFaculty WHERE fldUserID = " & lngUserID & ";"
rsFac.Open strSQL, fp_conn, adOpenDynamic, adLockOptimistic, adCmdText
 
lngFacID = rsFac("fldFacID")
End If
'Update tblFaculty with the current date
'***************************************
rsFac("fldTimeStamp") = Now
 
rsFac.Update
rsFac.Close
'Chech whether the user has selected to remove the course from the current faculty page.
'This will not remove the course from the database.
'***************************************************************************************
If Request("Action") = "Remove" Then
 
'Delete Course and faculty from tblCoursesTaught
Set rsCoursesTaught = Server.CreateObject("ADODB.Recordset")
strSQL = "Select * FROM tblCoursesTaught WHERE fldCourseID = " & Request("ID") & " And fldFacID = " & lngFacID & ";"
rsCoursesTaught.Open strSQL, fp_conn, adOpenForwardOnly, adLockOptimistic, adCmdText
 
If Not rsCoursesTaught.EOF Then
rsCoursesTaught.Delete
End If
rsCoursesTaught.Close
 
'Delete Course information Not necessary here
'Set rsCourse = Server.CreateObject("ADODB.Recordset")
'rsCourse.Open "tblCourses", fp_conn, adOpenForwardOnly, adLockOptimistic
'rsCourse.Filter = "fldCourseID = " & Request("ID")
'If Not rsCourse.EOF Then
' rsCourse.Delete
'End If
'rsCourse.Close
 
Response.Redirect "editPage.asp"
Else
 
If Not Request.Form("cboCourse") = "" Then
'Get course ID
lngCourseID = Request.Form("cboCourse")
Else
'Open recordset containing all courses
Set rsCourse = Server.CreateObject("ADODB.Recordset")
rsCourse.Open "tblCourses", fp_conn, adOpenDynamic, adLockOptimistic, adCmdTable
 
If Request("CourseID") = "" Then
bNew = True
'Create new course
rsCourse.AddNew
Else
'Find the record for the selected course
rsCourse.Filter = "fldCourseID = " & Request("CourseID")
bNew = False
End If
 
'Update or create the course information
rsCourse("fldNumber") = Request.Form("Number")
rsCourse("fldName") = Request.Form("Name")
rsCourse("fldDescURL") = Request.Form("DescURL")
rsCourse("fldWebPageURL") = Request.Form("WebPageURL")
 
rsCourse.Update
rsCourse.Close
 
'Get the CourseID
Set rsCourse = Server.CreateObject("ADODB.Recordset")
rsCourse.Open "tblCourses", fp_conn
rsCourse.Filter = "fldNumber = '" & Request.Form("Number") & "'"
lngCourseID = rsCourse("fldCourseID")
rsCourse.Close
 
End If
 
'Add a record for the course and faculty in tblCoursesTaught if necessary
Set rsCoursesTaught = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM tblCoursesTaught WHERE fldCourseID = " & lngCourseID & " And fldFacID = " & lngFacID & ";"
rsCoursesTaught.Open strSQL, fp_conn, adOpenDynamic, adLockOptimistic, adCmdText
If rsCoursesTaught.EOF Then
rsCoursesTaught.AddNew
rsCoursesTaught("fldCourseID") = lngCourseID
rsCoursesTaught("fldFacID") = lngFacID
rsCoursesTaught.Update
rsCoursesTaught.Close
End If
End If
Response.Redirect "courseConfirmation.asp?ID=" & lngCourseID
%>