1 2 3 4

11.19(周四)

昨天发了一下其他相关知识的一些代码,所以从今天开始更新那个选课系统的代码!

先从前端界面代码开始!

登录界面

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<div id="addSubjectForm" align="center">
<form action="SchoolServlet" method="post">               
                <tr>
                <h1>学校教务系统 </h1>
                </tr>
<table align="center"> 
<tr>
    <td>身份:
    
    <select name="profession"> 
     <option value="1">管理员</option> 
     <option value="2">教师</option>
     <option value="3" selected>学生</option> 
     </select> 
    </td>
</tr>

         <tr><td>
             用户名:<input pattern="[a-zA-Z0-9]{6,12}" name="username"></td></tr>
        
         <tr><td>
             密码:<input pattern="[a-zA-Z0-9]{6,12}" type="password" name="password"></td> </tr>
        </tr>
        
            <tr>
                      <td colspan="2"><div align="center">
                        <input type="submit" value="登录"></div></td> </tr>
</table>
</form>
</div>
                
</body>
</html>

管理员界面

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<div id="addSubjectForm" align="center">
                <form action="SubjectAddServlet" method="post">
                <tr>
                <h1>管理员系统</h1> 
                <ul>
                <li><a href="teacheradd.jsp">添加教师信息 </a></li>
                <li><a href="studentadd.jsp">添加学生信息 </a></li>
                <li><a href="school.jsp">退出登录 </a></li>
                </ul>
                </form>
</body>
</html>

添加教师信息界面

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div id="addSubjectForm" align="center">
<form action="SchoolAddServlet?method=teacher" method="post" onsubmit="return check()">
<tr>
<h2>请输入教师信息</h2>
</tr>

<table align="center"> 

    
    <tr>
    <td>教师工号:</td>
    <td> 
     <input pattern="[a-zA-Z0-9]{8,8}" name="teacherID" >(输入八位工号)  
     </td> 
    </tr>
     <tr>
    <td>教师登录密码:</td>
    <td> 
     <input pattern="[a-zA-Z0-9]{8,8}" name="teacherpassword" >(默认八位工号)  
     </td> 
    </tr>
<tr>
    <td>教师姓名:</td>
    <td>
    <input type="text" name="teachername">
    </td>
</tr>



<tr>
    <td>教师性别:</td>
    <td>
     <input type="radio" name="teachersex" value=""><input type="radio" name="teachersex" value="" checked></td>
</tr>

<tr>
    <td>教师所在学院:</td>
    <td>
    <input type="text" name="teachercollege">
    </td>
</tr>

<tr>
    <td>教师职称:</td>
    <td>
     <select name="teachercall"> 
     <option value="教授" selected>教授</option> 
     <option value="副教授">副教授</option> 
     <option value="助教">助教</option>
     <option value="讲师">讲师</option> 

      
     </select> 
    </td>
</tr>

<tr>
                      <td colspan="2"><div align="center">
                        <input type="submit" value="录入信息">    
                    </div>
                </td>
                  </tr>
                  </form>
                  </div>
                  
</body>
<script type="text/javascript">
function check()                        //封装一个<body>中做成点击事件的函数
{
    
    if($('input:radio[name="teachername"]:checked').val()==null) {
          alert('教师姓名不能为空!');
          document.getElementById('techername').focus();
          return false;
         }
    if($('input:radio[name="teacherID"]:checked').val()==null) {
          alert('教师工号不能为空!');
          document.getElementById('teacherID').focus();
          return false;
         }
    if($('input:radio[name="teachersex"]:checked').val()==null) {
          alert('性别不能为空!');
          document.getElementById('teachersex').focus();
          return false;
         }
    if(document.getElementById('teachercollege').value=='') {
          alert('教师所在学院不能为空!');
          document.getElementById('teachercollege').focus();
          isInterger(classplace);
          return false;
         }
    
    if(document.getElementById('teachercall').value=='') {
          alert('教师职称不能为空!');
          document.getElementById('teachercall').focus();
          return false;
         }
    
}
</script>
</html>

添加学生信息界面

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div id="addSubjectForm" align="center">
<form action="SchoolAddServlet?method=stu" method="post">
<tr>
<h2>请输入教师信息</h2>
</tr>

<table align="center"> 

    
    <tr>
    <td>学生学号:</td>
    <td> 
     <input pattern="[a-zA-Z0-9]{8,8}" name="stuID" >(输入八位学号)  
     </td> 
    </tr>
    <tr>
    <td>学生学号:</td>
    <td> 
     <input pattern="[a-zA-Z0-9]{6,8}" name="stupassword" >(默认八位学号)  
     </td> 
    </tr>
<tr>
    <td>学生姓名:</td>
    <td>
    <input type="text" name="stuname">
    </td>
</tr>



<tr>
    <td>学生性别:</td>
    <td>
     <input type="radio" name="stusex" value=""><input type="radio" name="stusex" value="" checked></td>
</tr>

<tr>
    <td>学生所在班级:</td>
    <td>
    <input type="text" name="stuclass">
    </td>
</tr>

<tr>
    <td>学生所在专业:</td>
    <td>
    <input type="text" name="stumajor">
    </td>
</tr>

<tr>
                      <td colspan="2"><div align="center">
                        <input type="submit" value="录入信息">    
                    </div>
                </td>
                  </tr>
                  </form>
                  </div>
                  
</body>
<script type="text/javascript">
function check()                        //封装一个<body>中做成点击事件的函数
{
    
    if($('input:radio[name="stuname"]:checked').val()==null) {
          alert('学生姓名不能为空!');
          document.getElementById('stuname').focus();
          return false;
         }
    if($('input:radio[name="stuID"]:checked').val()==null) {
          alert('学生学号不能为空!');
          document.getElementById('stuID').focus();
          return false;
         }
    if($('input:radio[name="stusex"]:checked').val()==null) {
          alert('性别不能为空!');
          document.getElementById('stusex').focus();
          return false;
         }
    if(document.getElementById('stuclass'').value=='') {
          alert('学生所在班级不能为空!');
          document.getElementById('stuclass').focus();
          isInterger(classplace);
          return false;
         }
    
    if(document.getElementById('stumajor').value=='') {
          alert('学生专业不能为空!');
          document.getElementById('stumajor').focus();
          return false;
         }
    
}
</script>
</html>

教师界面

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="dao.SchoolDaoImpl"  %>
    <%@page import= "java.util.*" %>
    <%@page import="entity.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%                    String teacherID=(String)request.getSession().getAttribute("ID");
                      //String teacherID=(String)request.getAttribute("ID");
                      session.setAttribute("teacherID", teacherID);
                    request.setAttribute("teacherID", teacherID);
                    System.out.println(teacherID);
                  %>

<div id="addSubjectForm" align="center">
                <form action="SubjectAddServlet" method="post">
                <tr>
                <h1>教师系统</h1> 
                <ul>
                <li><a href="Teacherservlet?method=showname">添加课程信息 </a></li>
                <li><a href="Teacherservlet?method=show" >修改个人信息 </a></li>
                <li><a href="Teacherservlet?method=showclass">浏览选课学生 </a></li>
                <li><a href="school.jsp">退出登录 </a></li>
                </ul>
                </form>
</body>
</html>

添加课程信息界面

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="dao.SchoolDaoImpl"  %>
    <%@page import= "java.util.*" %>
    <%@page import="entity.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div id="classadd" align="center">
<%
                      List<School> list=(List<School>)request.getAttribute("list");
                      
                      
                      %>
                          <table border="0" cellspacing="10" cellpadding="0">
                       
                       <%
                          for(School school:list){
                          String teacherID=school.getTeacherID();
                  %>
                  <tr align="center">
                          
                          <td><%=school.getTeachername()%>您好!!!</td>
                          <%String teachername=school.getTeachername(); 
                          session.setAttribute("teachername", teachername);
                           request.setAttribute("teachername", teachername);
                          %>
                  </tr>
                  <%}
                    
                       
                  %>
                  <tr align="center">
                  <font color="red" size="5"> <br> 如果不再修改 <br>

                请点击 <a href="teacher.jsp">这里回到主页面</a>!!! <br>

            </font>
                  </tr>
                  </table>
                  
                 

<form action="Teacherservlet?method=classadd" method="post" onsubmit="return check()">

<tr>
<h2>请输入您要添加的课程信息:</h2>
</tr>

<table align="center"> 

    
    <tr>
    <td>课程编号:</td>
    <td> 
     <input pattern="[a-zA-Z0-9]{6,6}" name="classID" >
     </td> 
    </tr>
<tr>
    <td>课程名称:</td>
    <td>
    <input type="text" name="classname">
    </td>
</tr>

<tr>
    <td>选课人数:</td>
    <td>
    <input type="text" name="classnum">
    </td>
</tr>



<tr>
                      <td colspan="2"><div align="center">
                        <input type="submit" value="添加课程">    
                    </div>
                </td>
                  </tr>
                  </form>
                  </div>
                  
</body>
<script type="text/javascript">
function check()                        //封装一个<body>中做成点击事件的函数
{
    
    if($('input:radio[name="classname"]:checked').val()==null) {
          alert('课程名称不能为空!');
          document.getElementById('classname').focus();
          return false;
         }
    if($('input:radio[name="classID"]:checked').val()==null) {
          alert('课程编号不能为空!');
          document.getElementById('classID').focus();
          return false;
         }
    if($('input:radio[name="classnum"]:checked').val()==null) {
          alert('课程人数不能为空!');
          document.getElementById('classnum').focus();
          return false;
         }
    
    
}
</script>
</html>

教师修改个人界面

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="dao.SchoolDaoImpl"  %>
    <%@page import= "java.util.*" %>
    <%@page import="entity.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<div id="teacherupdate" align="center"><!--显示试题-->

            
                      <%
                      List<School> list=(List<School>)request.getAttribute("list");
                      
                      
                      if(list==null||list.size()<1){
                          response.setHeader("refresh",

                                "5;URL=teacher.jsp");
                      %>
                      <font color="red" size="5"> 查询信息时出现错误,未能读出您的信息<br> 五秒后将跳转到主页面 <br>

                如果没有跳转,请点击 <a href="teacher.jsp">这里</a>!!! <br>

            </font>
                      <% }
                      else{%>
                          <table border="0" cellspacing="10" cellpadding="0">
                        <tr>
                        <td align="center" colspan="5">
                        <h1>当前个人信息</h1>
                        </td>
                        </tr>
                        <tr align="center">
                                <td><b>工号</b></td>
                                <td><b>姓名</b></td>
                                <td><b>性别</b></td>
                                <td><b>所在学院</b></td>
                                <td><b>职称</b></td>
                            </tr>
                       <%
                          for(School school:list){
                          String teacherID=school.getTeacherID();
                  %>
                  <tr align="center">
                          <td><%=school.getTeacherID() %></td>
                          <td><%=school.getTeachername()%></td>
                          <td><%=school.getTeachersex()%></td>
                          <td><%=school.getTeachercollege() %></td>
                          <td><%=school.getTeachercall() %></td>
                  </tr>
                  <tr align="center">
                  <font color="red" size="5"> <br> 如果不再修改 <br>

                请点击 <a href="teacher.jsp">这里回到主页面</a>!!! <br>

            </font>
                  </tr>
                  <%}
                      
                  %>
<form action="Teacherservlet?method=update" method="post">
<tr>
<td>输入修改后的信息:</td>
</tr>
  
    <tr>
    <td>教师工号:</td>
    <td> 
     <input pattern="[a-zA-Z0-9]{8,8}" name="teacherID" >(输入八位工号)  
     </td> 
    </tr>
<tr>
    <td>教师姓名:</td>
    <td>
    <input type="text" name="teachername">
    </td>
</tr>



<tr>
    <td>教师性别:</td>
    <td>
     <input type="radio" name="teachersex" value=""><input type="radio" name="teachersex" value="" checked></td>
</tr>

<tr>
    <td>教师所在学院:</td>
    <td>
    <input type="text" name="teachercollege">
    </td>
</tr>

<tr>
    <td>教师职称:</td>
    <td>
     <select name="teachercall"> 
     <option value="教授" selected>教授</option> 
     <option value="副教授">副教授</option> 
     <option value="助教">助教</option>
     <option value="讲师">讲师</option> 

      
     </select> 
    </td>
</tr>

<tr>
                      <td colspan="2"><div align="center">
                        <input type="submit" value="修改信息"> </tr>
                  </form>
                 <%} %>
                 
                 
                    </table>
            </div>

</body>
</html>

浏览选课学生界面

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="dao.SchoolDaoImpl"  %>
    <%@page import= "java.util.*" %>
    <%@page import="entity.*" %>
<!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">
<title>Insert title here</title>
</head>
<body>
<div id="stushow" align="center"><!--显示试题-->

            
                      <%
                      List<School> list=(List<School>)request.getAttribute("list");
                      
                      
                      if(list==null||list.size()<1){
                          response.setHeader("refresh",

                                "5;URL=Teacherservlet?method=showclass");
                      %>
                      <font color="red" size="5"> 查询信息时出现错误,未能读出您的信息<br> 五秒后将跳转到主页面 <br>

                如果没有跳转,请点击 <a href="Teacherservlet?method=showclass">这里</a>!!! <br>

            </font>
                      <% }
                      else{
                          
                      %>
                          <table border="0" cellspacing="10" cellpadding="0">
                        <tr>
                        <td align="center" colspan="5">
                        
                        <h1>当前选此课程的学生信息</h1>
                        </td>
                        </tr>
                        <tr align="center">
                                <td><b>学号</b></td>
                                <td><b>姓名</b></td>
                                <td><b>性别</b></td>
                                <td><b>班级</b></td>
                                <td><b>专业</b></td>
                            </tr>
                       <%
                          for(School school:list){
                          
                  %>
                  <tr align="center">
                          <td><%=school.getStuID() %></td>
                          <td><%=school.getStuname()%></td>
                          <td><%=school.getStusex()%></td>
                          <td><%=school.getStuclass() %></td>
                          <td><%=school.getStumajor() %></td>
                  </tr>
                  
                  
                  <%}
                       } %>
                      <font color="red" size="5"> 查看完毕后<br>  <br>

                请点击 <a href="Teacherservlet?method=showclass">这里</a>回到课程信息页面!!! <br>

            </font>
</body>
</html>

 

posted @ 2020-11-19 22:46  小陈的太阳  阅读(122)  评论(4编辑  收藏  举报