kecheng2.jsp~3~
资源名称:JSP02.rar [点击查看]
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:1k
源码类别:
Jsp/Servlet
开发平台:
VBScript
- <%@ page contentType="text/html; charset=GBK" %>
- <%@ page import="java.sql.*" %>
- <%@ page language="java" %>
- <%@ page import="java.util.*" %>
- <%@ page import="proj112.*" %>
- <jsp:useBean id="a" scope="page" class="proj112.dbconn"/>
- <html>
- <head>
- <title>
- kecheng3
- </title>
- </head>
- <body bgcolor="#ffffff">
- <%
- request.setCharacterEncoding("GBK");
- String kechenghao=request.getParameter("id2");
- String xuehao=(String)session.getAttribute("id");
- String sql="";
- String sql2="";
- String sql3="";
- int totalrecord = 0;
- sql3= "SELECT count(*) as recordcount FROM 选课关联 where stu_id='"+xuehao+"'";
- ResultSet rs = a.executeQuery(sql3);
- if (rs.next()) totalrecord = rs.getInt("recordcount");
- if(totalrecord<3)
- {
- sql="SELECT * FROM 选课关联 where stu_id='"+xuehao+"' and kch='"+kechenghao+"'";
- ResultSet rs1=a.executeQuery(sql);
- if(rs1.next())
- {%>
- <script language="javascript">
- alert("你已经选了这门课,请重新选择");
- </script>
- <%}
- else
- {
- sql2=" INSERT INTO 选课关联(stu_id,kch) values('"+xuehao+"','"+kechenghao+"')";
- a.executeUpdate(sql2);
- %>
- <script language="javascript">
- alert("选课成功,请继续选课");
- </script>
- <% }
- }
- else
- {%>
- <script language="javascript">
- alert("你只能选3门课程,请确认后在选");
- </script>
- <%}
- %>
- <script language="javascript">
- history.go(-1) ;
- </script>
- </body>
- </html>