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

📄 managemycourse.asp

📁 一套完整的学生课程管理系统
💻 ASP
字号:
<!-- #include file="utility/checkTeacher.asp" -->

<%
	'****************************************
	'目的:			处理课程信息
	'开始时间:		2005-6-5 9:21
	'最后修改时间:	2005-6-5 9:21
	'编写人:		某某某
	'****************************************
	
	'定义相关变量
	dim actionType			'操作类型
	dim teacherID
	dim courseID
	dim sql				
	dim rs
	
	actionType = Request.QueryString("actionType")
	teacherID = Session("userID")
	
	'检查参数是否完整
	if(actionType = "") then
		Alert("参数丢失,拒绝操作!")
		GoBack()
		Response.end
	end if
	
	'判断操作类型并执行对应操作
	Select case (actionType)
		case "add": 	
				addCourse()			'添加课程信息
		case "deleteStuCourse":	
				deleteStuCourse()	'删除学生选课信息
		case "deleteCourse":
				deleteCourse()		'删除课程信息
		case "changeCourseState":
				changeCourseState()	'改变课程状态
	end Select	
	
	'添加课程子过程
	Sub addCourse()
		dim cName
		dim cCredit
		dim cStartTime
		dim cEndTime
		dim cTime
		dim cAddress
		
		cName = Trim(Request.Form("cName"))
		cCredit = Trim(Request.Form("cCredit"))
		cStartTime = Trim(Request.Form("cStartTime"))
		cEndTime = Trim(Request.Form("cEndTime"))
		cTime = Trim(Request.Form("cTime"))
		cAddress = Trim(Request.Form("cAddress"))
		
		'检查信息合法性
		if(cName = "" or cCredit = "" or cStartTime = "" or cEndTime = "" or cTime = "" or cAddress = "") then
			Alert("信息填充不完整,操作失败!")		
			GoBack()
			Response.end
		elseif((not IsDate(cStartTime)) or (not IsDate(cEndTime))) then
			Alert("日期格式错误,应该为yyyy-mm-dd,如:2005-3-25")
			GoBack()
			Response.end
		elseif(not IsNumeric(cCredit)) then
			Alert("学分应该为数字,请查实后再提交")
			GoBack()
			Response.end	
		end if	
		
		'添加课程信息到数据库
		sql = "insert into course (tID,cName,cStartTime,cEndTime,cTime,cAddress,cCredit) values ("
		sql = sql & teacherID & ",'" & cName & "','" & cStartTime & "','"
		sql = sql & cEndTime & "','" & cTime & "','" & cAddress & "'," & cCredit & ")"
		ExecuteNonQuery(sql)
		Alert("课程添加成功,请继续其他操作!")
		Go("listMyCourse.asp")
	end Sub
	
	'删除学生选课信息子过程
	Sub deleteStuCourse()
		dim stuCourseID
		stuCourseID = Request.QueryString("stuCourseID")
		
		dim studentID
		
		'判断是否有权限删除记录
		sql = "select stuCourse.stuID,stuCourse.courseID from stuCourse,course "
		sql = sql & "where stuCourse.courseID = course.ID "
		sql = sql & "and course.tID = " & teacherID
		set rs = ExecuteQuery(sql)
		if(rs.EOF) then
			Alert("无权删除这条记录,操作失败!")
			GoBack()
			rs.close()
			set rs = nothing
			Response.End
		end if
		studentID = rs(0)
		courseID = rs(1)
		rs.close()
		set rs = nothing
		
		
		'首先删除学生在这门课程中提交的作业信息
		sql = "delete from stuHomework where stuID = '" & studentID
		sql = sql & "' and homeworkID IN "
		sql = sql & "(select ID from courseHomework "
		sql = sql & "where courseID = " & courseID & ")"
		'Response.write(sql)
		'Response.end
		ExecuteNonQuery(sql)
		
		'现在删除学生选课的信息
		sql = "delete from stuCourse where ID = " & stuCourseID
		ExecuteNonQuery(sql)
		Alert("删除成功,请继续其他操作!")
		Go("listMyStudentCourse.asp")
	End Sub
	
	'删除课程信息子过程
	Sub deleteCourse()
		courseID = Request.QueryString("courseID")
		
		if(courseID = "") then
			Alert("参数丢失,操作失败!")
			GoBack()
			Response.end
		else
			sql = "delete from course where ID = " & courseID
			'这里保证不能删除其他教师的课程信息
			sql = sql & " and tID = " & teacherID
			ExecuteNonQuery(sql)
			Alert("课程信息删除成功,请继续其他操作!")
			Go("listMyCourse.asp")
		end if
	End Sub
	
	'改变课程状态
	Sub changeCourseState()
		courseID = Request.QueryString("courseID")
		
		if(courseID = "") then
			Alert("参数丢失,操作失败!")
			GoBack()
			Response.end
		else
			sql = "update course set canSelect = IIf(canSelect=1,0,1)"
			sql = sql & " where ID = " & courseID
			'这里保证不能删除其他教师的课程信息
			sql = sql & " and tID = " & teacherID
			ExecuteNonQuery(sql)
			Alert("课程状态修改成功,请继续其他操作!")
			Go("listMyCourse.asp")
		end if
	end Sub
%>

⌨️ 快捷键说明

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