📄 core_save.jsp
字号:
<%@ page contentType="text/html;charset=GB2312" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<!------设置数据源------>
<sql:setDataSource dataSource="jdbc/sqlserver" var="sqlDS"/>
<html>
<body bgcolor="#DCDADA">
<!--查询出此班级的此门课程的所有成绩-->
<c:set var="selectRSSQL" value="select distinct student.student_id as student_id,
student.student_name as student_name,class.class_id as class_id
from student,class where student.class_id=class.class_id"/>
<c:if test="${not empty param.class_id}">
<c:set var="selectRSSQL" value="${selectRSSQL} and student.class_id=${param.class_id}
and class.class_id=${param.class_id}"/>
</c:if>
<sql:query sql="${selectRSSQL}"
var="classStudentRS" dataSource="${sqlDS}"/>
<c:if test="${classStudentRS.rowCount>=1}">
<c:forEach items="${classStudentRS.rowsByIndex}" var="cucN">
<c:set var="tempCore" value="stu${cucN[0]}"/>
<!--如果提交的成绩值为不空-->
<c:if test="${not empty param[tempCore]}">
<!--查询出成绩表中是否已有此成绩,如有则更新,如无则插入-->
<c:set var="selectSQL"
value="select core_id from core where student_id=${cucN[0]}
and lession_id=${param.lession_id}"/>
<sql:query sql="${selectSQL}" dataSource="${sqlDS}"
var="coreRS"/>
<!--如果已有此成绩,更新成绩-->
<c:if test="${coreRS.rowCount>=1}">
<c:set var="updateSQL" value="update core set
core=${param[tempCore]} where student_id=${cucN[0]}
and lession_id=${param.lession_id}"/>
<sql:update sql="${updateSQL}"
var="infec" dataSource="${sqlDS}"/>
<c:if test="${infec>=1}">
更新序号为${cucN[0]}的学生的成绩成功!<br>
</c:if>
</c:if>
<!--如果没有此成绩,插入成绩-->
<c:if test="${coreRS.rowCount<1}">
<c:set var="insertSQL"
value="insert into core(student_id,lession_id,core,close_status)
values(${cucN[0]},${param.lession_id},${param[tempCore]},0)"/>
<sql:update sql="${insertSQL}"
var="infec" dataSource="${sqlDS}"/>
<c:if test="${infec>=1}">
插入序号为${cucN[0]}的学生的成绩成功!<br>
</c:if>
</c:if>
</c:if>
</c:forEach>
</c:if>
<a href="core_add.jsp?lession_id=${param.lession_id}&class_id=${param.class_id}">返回</a>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -