<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.sql.Connection" %>
<%@page import="java.sql.*" %>
<%@page import="java.sql.DriverManager" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>学生管理</title>
<link rel="stylesheet" href="css/manage.css" type="text/css">
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="css/footer.css" type="text/css">
<script src="js/ie-emulation-modes-warning.js"></script>
</head>
  
  <body>
<div class="container">
  <h1 class="heading_title_text text-center">学生信息管理系统</h1>
  <div class="row">
    <div class="col-lg-2 col-md-2 hidden-xs">
      <ul class="nav nav-sidebar">
        <h3>学生管理</h3>
        <li class="active"><a href="add_student.php">添加学生<span class="sr-only">(current)</span></a></li>
        <li><a href="show_student.php">查看学生</a></li>
        <li><a href="change_student.php">修改学生</a></li>
      </ul>
      <ul class="nav nav-sidebar">
        <h3>班级管理</h3>
        <li><a href="add_dept.php">添加班级</a></li>
        <li><a href="show_dept.php">查看班级</a></li>
      </ul>
      <ul class="nav nav-sidebar">
        <h3>课程管理</h3>
        <li><a href="add_usergroup.php">添加课程</a></li>
        <li><a href="show_usergroup.php">查看课程</a></li>
      </ul>
      <ul class="nav nav-sidebar">
        <h3>成绩管理</h3>
        <li><a href="add_fun.php">添加成绩</a></li>
        <li><a href="show_fun.php">查看成绩</a></li>
      </ul>
    </div>
    <div class="col-lg-1 col-md-1 hidden-xs"></div>
    <div class="col-lg-9 col-md-9">
      <div class="panel panel-primary">
        <div class="panel-heading">
          <h3 class="panel-title text-center">学生管理</h3>
        </div>
        <div class="panel-body">
          <div class="table-responsive">
            <table class="table table-hover">
              <tr>
                <td>学号</td>
                <td>姓名</td>
                <td>性别</td>
                <td>出生日期</td>
                <td>省份</td>
                <td>民族</td>
                <td>班级</td>
    </tr>
    <%
    String driverClass="com.mysql.jdbc.Driver";
    String url="jdbc:mysql://localhost:3306/db_school";
    String user="root";
    String password="";
    Connection conn;
    try{
    Class.forName(driverClass);
    conn=DriverManager.getConnection(url,user,password);
    Statement stmt=conn.createStatement();
    String sql="select * from tb_student";
    ResultSet rs=stmt.executeQuery(sql);
    while(rs.next()){
    %>
    <tr>
    <td><%=rs.getString("studentNo") %></td>
    <td><%=rs.getString("studentName") %></td>
    <td><%=rs.getString("sex") %></td>
    <td><%=rs.getString("birthday") %></td>
    <td><%=rs.getString("native") %></td>
    <td><%=rs.getString("nation") %></td>
    <td><%=rs.getString("classNo") %></td>
    
    </tr>
    <% 
    }
    }
    catch(Exception ex){
    ex.printStackTrace();
    }
    %>
            </table>
          </div>
          <div class="student_btn pull-right"> <a href="add_student.php">
            <button type="button" class="btn btn-success">添加学生</button>
            </a> <a href="show_student.php">
            <button type="button" class="btn btn-primary">查看学生</button>
            </a></div>
        </div>
      </div>
      <div class="panel panel-primary">
        <div class="panel-heading">
          <h3 class="panel-title text-center">班级管理</h3>
        </div>
        <div class="panel-body">
          <table class="table table-hover">
            <tr>
              <td>课室号</td>
              <td>课室名</td>
              <td>学院</td>
              <td>年级</td>
              <td>人数</td>
            </tr>
            <%
    try{
    Class.forName(driverClass);
    conn=DriverManager.getConnection(url,user,password);
    Statement stmt=conn.createStatement();
    String sql="select * from tb_class";
    ResultSet rs=stmt.executeQuery(sql);
    while(rs.next()){
    %>
            <tr>
              <td>
              <%=rs.getString("classNo") %></td>
    <td><%=rs.getString("className") %></td>
    <td><%=rs.getString("department") %></td>
    <td><%=rs.getString("grade") %></td>
    <td><%=rs.getString("classNum") %></td>
            </tr>
            <% 
    }
    }
    catch(Exception ex){
    ex.printStackTrace();
    }
    %>
          </table>
        <div class="dept_btn pull-right"> <a href="add_dept.php">
          <button type="button" class="btn btn-success">添加班级</button>
          </a> <a href="show_dept.php">
          <button type="button" class="btn btn-primary">查看班级</button>
          </a></div>
          </div>
      </div>
      <div class="panel panel-primary">
        <div class="panel-heading">
          <h3 class="panel-title text-center">课程管理</h3>
        </div>
        <div class="panel-body">
          <table class="table table-hover">
            <tr>
              <td>课程编号</td>
              <td>课程名称</td>
              <td>学分</td>
              <td>课时</td>
              <td>学期</td>
              <td>先行课程</td>
            </tr>
            <%
    try{
    Class.forName(driverClass);
    conn=DriverManager.getConnection(url,user,password);
    Statement stmt=conn.createStatement();
    String sql="select * from tb_course";
    ResultSet rs=stmt.executeQuery(sql);
    while(rs.next()){
    %>
            <tr>
              <td><%=rs.getString("courseNo") %></td>
    <td><%=rs.getString("courseName") %></td>
    <td><%=rs.getString("credit") %></td>
    <td><%=rs.getString("courseHour") %></td>
    <td><%=rs.getString("term") %></td>
    <td><%=rs.getString("priorCourse") %></td>
            </tr>
            <% 
    }
    }
    catch(Exception ex){
    ex.printStackTrace();
    }
    %>
          </table>
        <div class="course_btn pull-right"> <a href="add_usergroup.php">
          <button type="button" class="btn btn-success">添加课程</button>
          </a> <a href="show_usergroup.php">
          <button type="button" class="btn btn-primary">查看课程</button>
          </a></div>
          </div>
      </div>
      <div class="panel panel-primary">
        <div class="panel-heading">
          <h3 class="panel-title text-center">成绩管理</h3>
        </div>
        <div class="panel-body">
          <table class="table table-hover">
            <tr>
              <td>姓名</td>
              <td>课程名称</td>
              <td>成绩</td>
            </tr>
            <%
    try{
    Class.forName(driverClass);
    conn=DriverManager.getConnection(url,user,password);
    Statement stmt=conn.createStatement();
    String sql="select * from tb_score AS g,tb_student AS s ,tb_course AS c where s.studentNo=g.studentNo AND g.courseNo=c.courseNo";
    ResultSet rs=stmt.executeQuery(sql);
    while(rs.next()){
    %>
            <tr>
               <td><%=rs.getString("studentName") %></td>
    <td><%=rs.getString("courseName") %></td>
    <td><%=rs.getString("score") %></td>
            </tr>
           <% 
    }
    }
    catch(Exception ex){
    ex.printStackTrace();
    }
    %>
          </table>
          <div class="score_btn pull-right"> <a href="add_fun.php">
            <button type="button" class="btn btn-success">添加成绩</button>
            </a> <a href="show_fun.php">
            <button type="button" class="btn btn-primary">查看成绩</button>
            </a></div>
        </div>
      </div>
    </div>
  </div>
  <!-- Footer -->
	<div class="footer">

		<!-- Copyright -->
		<div class="copyright">
			<p> &copy; 2016 学生信息管理系统. All Rights Reserved | Design by <a href="http://blog.sina.com.cn/u/2007780675">F嘉阳</a></p>
		</div>
		<!-- //Copyright -->

	</div>
	<!-- //Footer -->
</div>
</div>
<script src="js/jquery-1.11.2.min.js" type="text/javascript"></script> 
<script src="js/bootstrap.js" type="text/javascript"></script>
</body>
</html>
