⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_class_change.asp

📁 A java project in e-bussiness module.
💻 ASP
字号:
<html>
<head>
<!-- Author: Brad Pierce -->
<title>Admiminstrator Class Management</title>
<link href="admin_basics.css" rel="stylesheet" type="text/css">
<% 
   If NOT Session("admin_authenticated") Then
      Response.Redirect("admin_login.asp")
   End If
%>
</head>

<table border='0'><tr><td><img src="../images/netest.png"></td><td width='5%'></td><td width='100%'><br><h2>Class Management</h2></td></tr>
<!-- #include file="../admin_navbar/admin_navbar_print.inc" -->

<TD valign='top'><br>
<body>
<%
   'CHECK FOR PAGE REFRESH OR RESUBMIT
   IF session("classes_changed") = TRUE THEN
      Response.Write "<p><div id=warning><img src='../images/warning.gif'>&nbspYou cannot resubmit the update.</div><br>"
	  Response.Write "<a href='admin_edit_classes.asp'>Click here to modify classes.</a><br>"
	  Response.Write "<a href='admin_home.asp'>Click here to return to the home page.</a></p>"
%>
      </td></tr></table>
      <br><br><table width='86%' align='right' border='0'><tr><td>
      <hr size='2' color='#000000'>
      <font size='1'>Powered by Netest</font>
      </td></tr></table>
<%
      Response.End
   END IF
   
   'PROCEED WITH PAGE
   const MAX_SECTIONS=10
   dim oConn   ' Connection Object
   dim oRS     ' Record Set Object
   Set oConn=Server.CreateObject("ADODB.connection")
   set oRS=Server.CreateObject("ADODB.recordset")
   oConn.Open "DSN=sd2db; UserID=Admin; pwd=netest"
   
   return_previous = FALSE
   
   '-----------
   'ADD A CLASS
   '-----------
   if request("submit_add_class") <> "" then
      
      'error check data entered
      if trim(request("new_class_code")) = "" then
         error_message = "New class code cannot be blank" 
         call DisplayError()
	  end if
	  
	  if trim(request("new_class_name")) = "" then
	     error_message = "New class new cannot be blank" 
         call DisplayError()
      end if
      
	  'check to see if class already exist
	  sqltext = "SELECT * FROM Course"
	  oRS.Open sqltext, oConn
	  
	  do while not oRS.EOF
	     if ucase(trim(request("new_class_code"))) = oRS("Course_Code") then
		    error_message = "Class Code already exists" 
            call DisplayError()
		 end if
	     oRS.MoveNext
	  loop
	  oRS.Close
	  
      'if no errors submit to database
      if return_previous = FALSE then
         sqltext = "SELECT * FROM Course"
         oRS.Open sqltext, oConn, 2, 2
   
         oRS.AddNew
         oRS.Fields("Course_Code") = ucase(request("new_class_code"))
         oRS.Fields("Course_Name") = request("new_class_name")
         oRS.Fields("Course_Max_Sections") = MAX_SECTIONS
         oRS.Update
         oRS.Close
		 
		 response.write "<h4>" & ucase(request("new_class_code")) & "&nbsp" & request("new_class_name") & " added successfully.</h4>"
		 
		 call DisplayFinish()
		 session("classes_changed") = TRUE
      else
	  	 Response.Write "<br><div id='warning'><u>Hit the back button on your browser to make corrections.</u></div>"
	  end if
   end if
   
   '-------------
   'ADD A SECTION
   '-------------
   if request("submit_add_section") <> "" then
      sqltext = "SELECT * FROM Section"
	  oRS.Open sqltext, oConn
	  
	  dim new_section_number
	  if request("new_section_number") = "0" then
	     new_section_number = ""
	  else
	     new_section_number = request("new_section_number")
	  end if
	  
	  do while not oRS.EOF
	     if request("new_class_section") = oRS("Course_Code") then
		    if new_section_number = trim(oRS("Section_Code")) then
		       error_message = "Section already exists" 
               call DisplayError()
		    end if
		 end if
		 oRS.MoveNext
	  loop
	  oRS.Close
	  
	  'if no errors submit to database
	  if return_previous = FALSE then
	     sqltext = "SELECT * FROM Section"
         oRS.Open sqltext, oConn, 2, 2
		 
         oRS.AddNew
         oRS.Fields("Course_Code") = ucase(request("new_class_section"))
         oRS.Fields("Section_Code") = new_section_number
         oRS.Fields("Inst_Code") = request("new_section_teacher")
         oRS.Update
         oRS.Close
		 
		 response.write "<h4>" & ucase(request("new_class_section"))
		 if new_section_number <> "" then
		    response.write "-" & new_section_number
	     end if
		 
		 sqltext = "SELECT Course_Name FROM Course WHERE Course_Code='" & request("new_class_section") & "'"
		 oRS.Open sqltext, oConn
		 response.write " " & oRS("Course_Name") & " added successfully.</h4>"
		 oRS.Close
			
		 sqltext = "SELECT * FROM Instructor WHERE Inst_Code='" & request("new_section_teacher") & "'"
		 oRS.Open sqltext, oConn
		 response.write "<h4>Teacher: " & oRS("Inst_FirstName") & " " & oRS("Inst_LastName") & "</h4>"
		 oRS.Close
		 
		 call DisplayFinish()
		 session("classes_changed") = TRUE
      else
	  	 Response.Write "<br><div id='warning'><u>Hit the back button on your browser to make corrections.</u></div>"
	  end if
   end if
   
   '--------------
   'DELETE A CLASS
   '--------------   
   if request("submit_delete_class") <> "" then
      response.write "<div id='warning'>Delete class not implemented at this time.<br>Please hit back button.</div>"
   end if
   
   '----------------
   'DELETE A SECTION
   '----------------
   if request("submit_delete_section") <> "" then
      response.write "<div id='warning'>Delete section not implemented at this time.<br>Please hit back button.</div>"
   end if
   
   '----------------
   'MODIFY A CLASS
   '----------------
   if request("submit_modify_class") <> "" then
      response.write "<div id='warning'>Modify class not implemented at this time.<br>Please hit back button.</div>"
   end if
   
   '----------------
   'MODIFY A SECTION
   '----------------
   if request("submit_modify_section") <> "" then
      response.write "<div id='warning'>Modify section not implemented at this time.<br>Please hit back button.</div>"
   end if
   
sub DisplayError()
   Response.Write "<div id=warning><img src='../images/warning.gif'>&nbsp" & error_message & "</div>"
   return_previous = TRUE
end sub

sub DisplayFinish()
%>
   <br><hr><br>
   <table border='0'><tr><td><img src="../images/question.gif"></td><td><font color='#003333'><b>Finished?</b></font></td><td><a href='inst_home.asp'>Return to teacher home page.</a></td></tr>
   <tr><td><img src="../images/question.gif"></td><td><font color='#003333'><b>Test contains errors?</b></font></td><td><a href="inst_choose_test_modifications.asp">Add, Edit, or Delete Questions</a></td></tr></table>
<%   
end sub
%>
</body>
</td></tr>

<tr><td></td><td colspan='2'><br><br><hr size='2' color='#000000'>
<font size='1'>Powered by Netest</font>
</td></tr></table>

</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -