MajorCourseList.jsp
上传用户:jhoneliu
上传日期:2022-07-31
资源大小:950k
文件大小:3k
- <%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage=""%>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
- </head>
- <body>
- <%
- if (session.getAttribute("userid") == null || session.getAttribute("userid").equals("")) {
- response.sendRedirect("index.jsp");
- }
- %>
- <jsp:include flush="true" page="head.jsp"/>
- <br/>
- <p align="center">
- <strong>
- <font size="4" color="#FF0000"">专业课程资料列表</font>
- </strong>
- </p>
- <table width="768" border="0" align="center" cellpadding="3" cellspacing="1">
- <tr>
- <td>
- <a href="MajorCourseAdd.jsp">新增</a>
- </td>
- </tr>
- </tr></table>
- <table width="768" border="1" align="center" cellpadding="3" cellspacing="1">
- <tr>
- <td>
- <div align="center">专业名称</div>
- </td>
- <td>
- <div align="center">课程名称</div>
- </td>
- <td>
- <div align="center">所属分院</div>
- </td>
- <td>
- <div align="center">修改资料</div>
- </td>
- <td>
- <div align="center">删除资料</div>
- </td>
- </tr>
- <%
- String driver = "sun.jdbc.odbc.JdbcOdbcDriver"; //驱动程序,见第十四章
- String url = "jdbc:odbc:stud"; //数据库连接语句,见第十四章
- String userID = "sa", pwd = "", sql = "";
- try {
- Class.forName(driver); //调入JDBC-ODBC桥的驱动程序
- Connection conn = DriverManager.getConnection(url, userID, pwd); //建立与数据的连接
- //request对象见第四章
- sql = "select m1.recid,m2.majorname,c.coursename,d.depname from majorcourse m1 left outer join major m2 on m1.majorid=m2.majorid ";
- sql = sql + " left outer join Course c on m1.courseid=c.courseid left outer join department d on m2.depid=d.depid";
- Statement stmt = conn.createStatement(); //建立Statement的实例,相当于创建一个查询分析器的运行环境
- ResultSet rs = stmt.executeQuery(sql); //把查询结果放入ResultSet对象
- String recid = "", majorname = "", coursename="",depname = "";
- while (rs.next()) {
- recid = rs.getString("recid");
- majorname = rs.getString("majorname");
- coursename = rs.getString("coursename");
- depname = rs.getString("depname");
- %>
- <tr>
- <td>
- <div align="center"><%=majorname%> </div>
- </td>
- <td>
- <div align="center"><%=coursename%> </div>
- </td>
- <td>
- <div align="center"><%=depname%> </div>
- </td>
- <td>
- <div align="center">
- <a href="majorCourseEdit.jsp?recId=<%=recid%>">修改资料</a>
- </div>
- </td>
- <td>
- <div align="center">
- <a href="majorCourseDel.jsp?recId=<%=recid%>" onclick="return check();">删除资料</a>
- </div>
- </td>
- </tr>
- <%
- }
- } catch (Exception e) {
- System.out.println(e.getMessage());
- }
- %>
- </table>
- <br/>
- <jsp:include flush="true" page="bottom.jsp"/>
- </body>
- </html>
- <script language="javascript">
- function check()
- {
- if(confirm("删除确认"))
- {
- return true;
- }
- return false;
- }
- </script>