高校学生考勤管理系统设计与简单实现

高校学生考勤管理系统设计与简单实现

我进行这次设计的初衷是想把这个系统放到易班上,所以正常的情况下是应该是两个端口访问的,但是这里我就只用一个index链过去了吗,方便测试。

index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>


  
    学生请假管理系统
  
  
    学生端
教师端

mysql:这里使用的mysql管理工具是 Navicat Premium 12百度网盘链接:https://pan.baidu.com/s/1MMmK_o5LiviNQkxGnG4R4g 提取码:dmdi 强烈推荐,非常好用。
高校学生考勤管理系统设计与简单实现_第1张图片
student.jsp
高校学生考勤管理系统设计与简单实现_第2张图片

<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" import=" java.util.Date"%>
<%@ page language="java" import=" java.text.SimpleDateFormat"%>

<%
	Date date=new Date();
	SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); 
	System.out.println(sdf.format(date)); 
	String qingjia_time =(String)sdf.format(date);
%>

请假

学号:
班级:
姓名:
请假开始时间:
请假结束时间:
请假原因:

teacher.jsp
高校学生考勤管理系统设计与简单实现_第3张图片

<%@ page contentType="text/html;charset=GB2312" %>




 

班级查询

输入班级:

学号查询

输入学号:

showRecord.jsp
高校学生考勤管理系统设计与简单实现_第4张图片

<%@ page contentType="text/html;charset=gb2312" %>




  
  <%  String []columnName=resultBean.getColumnName(); 
  %>
  
  <%  String [][] record = resultBean.getTableRecord();
      for(int i=0;i    
  <%     for(int j=0;j        
  <%     }
  %>    
  <%  }
  %>
  
编号 学生学号 班级 姓名 开始时间 结束时间 申请请假时间 请假原因 辅导员审批状态 辅导员审批时间 辅导员回复
<%= record[i][j] %>

输入ID删除请假记录

ID:
学号:

showRecord_teacher.jsp
高校学生考勤管理系统设计与简单实现_第5张图片

<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" import=" java.util.Date"%>
<%@ page language="java" import=" java.text.SimpleDateFormat"%>




  
  <%
	Date date=new Date();
	SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); 
	System.out.println(sdf.format(date)); 
	String class_teacher_sp_time =(String)sdf.format(date);
	%>
  <%  String []columnName=resultBean.getColumnName(); 
  %>
 
  <%  String [][] record = resultBean.getTableRecord();
      for(int i=0;i    
  <%     for(int j=0;j        
  <%     }
  %>    
  <%  }
  %>
  
编号 学生学号 班级 姓名 开始时间 结束时间 申请请假时间 请假原因 辅导员审批状态 辅导员审批时间 辅导员回复
<%= record[i][j] %>

输入ID进行审批

注:0为等待审批,1为同意请假,2为不同意请假
ID:
辅导员审批状态:
辅导员回复:

web.xml



  
  
    This is the description of my J2EE component
    This is the display name of my J2EE component
    Insert_Servlet
    myservlet.control.Insert_Servlet
  
  
    This is the description of my J2EE component
    This is the display name of my J2EE component
    Delete_Servlet
    myservlet.control.Delete_Servlet
  
  
    This is the description of my J2EE component
    This is the display name of my J2EE component
    Select_class_Servlet
    myservlet.control.Select_class_Servlet
  
  
    This is the description of my J2EE component
    This is the display name of my J2EE component
    Select_number_Servlet
    myservlet.control.Select_number_Servlet
  
  
    This is the description of my J2EE component
    This is the display name of my J2EE component
    Insert_Sp_Servlet
    myservlet.control.Insert_Sp_Servlet
  





  
    Insert_Servlet
    /insert_Servlet
  
  
    Delete_Servlet
    /delete_Servlet
  
  
    Select_class_Servlet
    /Select_class_Servlet
  
  
    Select_number_Servlet
    /Select_number_Servlet
  
  
    Insert_Sp_Servlet
    /insert_Sp_Servlet
  	
  
    index.jsp
  


studentinfo.java

package mybean.data;

public class studentinfo {
		String []columnName ;           //存放列名
	   String [][] tableRecord=null;   //存放查询到的记录
	   public studentinfo() {
	      tableRecord = new String[1][1];
	      columnName = new String[1]; 
	   }
	   public void setTableRecord(String [][] s){
	      tableRecord=s;
	   }
	   public String [][] getTableRecord(){
	      return tableRecord;
	   }
	   public void setColumnName(String [] s) {
	      columnName = s;
	   }
	   public String [] getColumnName() {
	      return columnName;
	   }
}

Delete_Servlet.java

package myservlet.control;
import mybean.data.studentinfo; 
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Delete_Servlet extends HttpServlet{
   public void init(ServletConfig config) throws ServletException{
      super.init(config);
   }
   public void doPost(HttpServletRequest request,HttpServletResponse response)
               throws ServletException,IOException{
	   studentinfo resultBean=null;
      try{  resultBean=(studentinfo)request.getAttribute("resultBean");
            if(resultBean==null){
                resultBean=new studentinfo(); //创建Javabean对象
                request.setAttribute("resultBean",resultBean);
            }
      }
      catch(Exception exp){
            resultBean=new studentinfo();  //创建Javabean对象
            request.setAttribute("resultBean",resultBean);
      } 
     try{  Class.forName("com.mysql.jdbc.Driver");//加载驱动
     }
     catch(Exception e){} 
     request.setCharacterEncoding("gb2312");
     String dataBase  = request.getParameter("dataBase");
     String tableName = request.getParameter("tableName");
     
     String stu_number=request.getParameter("stu_number");
     String id=request.getParameter("ID");
     String stu_name=request.getParameter("stu_name");
     String start_time=request.getParameter("start_time");
     String end_time=request.getParameter("end_time");
     String qingjia_time=request.getParameter("qingjia_time");
     String qingjia_yuanyin=request.getParameter("qingjia_yuanyin");
     
     
    
     
     if(id==null||id.length()==0) {
        fail(request,response,"添加记录失败,必须给出记录");
        return;
     }
     String condition = "DELETE FROM "+tableName+" where id='"+id+"'";
     System.out.println(condition);
     Connection con;
     Statement sql; 
     ResultSet rs;
     try{ 
    	 
    	 String uri= "jdbc:mysql://localhost/"+dataBase+"?characterEncoding=utf8";
    		
       	 con=DriverManager.getConnection(uri,"root","root1");//建立连接
       
   	
          sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                                 ResultSet.CONCUR_READ_ONLY);
          sql.executeUpdate(condition);
          
         // System.out.println("SELECT * FROM "+tableName+" where stu_number='"+stu_number+"'");
          
          rs=sql.executeQuery("SELECT * FROM "+tableName+" where stu_number='"+stu_number+"'");
 
          ResultSetMetaData metaData = rs.getMetaData();
          int columnCount = metaData.getColumnCount(); //得到结果集的列数
          String []columnName = new String[columnCount];
          for(int i=0;i");
         out.println("

"+backNews+"

") ; out.println("返回"); out.println("输入记录"); out.println(""); } catch(IOException exp){} } }

Insert_Servlet.java

package myservlet.control;
import mybean.data.studentinfo; 
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Insert_Servlet extends HttpServlet{
   public void init(ServletConfig config) throws ServletException{
      super.init(config);
   }
   public void doPost(HttpServletRequest request,HttpServletResponse response)
               throws ServletException,IOException{
	   studentinfo resultBean=null;
      try{  resultBean=(studentinfo)request.getAttribute("resultBean");
            if(resultBean==null){
                resultBean=new studentinfo(); //创建Javabean对象
                request.setAttribute("resultBean",resultBean);
            }
      }
      catch(Exception exp){
            resultBean=new studentinfo();  //创建Javabean对象
            request.setAttribute("resultBean",resultBean);
      } 
     try{  Class.forName("com.mysql.jdbc.Driver");//加载驱动
     }
     catch(Exception e){} 
     request.setCharacterEncoding("gb2312");
     String dataBase  = request.getParameter("dataBase");
     String tableName = request.getParameter("tableName");
     
     String stu_number=request.getParameter("stu_number");
     String class_id=request.getParameter("class_id");
     String stu_name=request.getParameter("stu_name");
     String start_time=request.getParameter("start_time");
     String end_time=request.getParameter("end_time");
     String qingjia_time=request.getParameter("qingjia_time");
     String qingjia_yuanyin=request.getParameter("qingjia_yuanyin");
     
     
    
     
     if(stu_number==null||stu_number.length()==0) {
        fail(request,response,"添加记录失败,必须给出记录");
        return;
     }
     String condition = "INSERT INTO "+tableName+"(stu_number,class_id,stu_name,start_time,end_time,qingjia_time,qingjia_yuanyin) VALUES"+
      "('"+stu_number+"','"+class_id+"','"+stu_name+"','"+start_time+"','"+end_time+"','"+qingjia_time+"','"+qingjia_yuanyin+"')";
     //System.out.println(condition);
     Connection con;
     Statement sql; 
     ResultSet rs;
     try{ 
    	 
    	 String uri= "jdbc:mysql://localhost/"+dataBase+"?characterEncoding=utf8";
    		
       	 con=DriverManager.getConnection(uri,"root","root1");//建立连接
       
   	
          sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                                 ResultSet.CONCUR_READ_ONLY);
          sql.executeUpdate(condition);
          
          System.out.println("SELECT * FROM "+tableName+" where stu_number='"+stu_number+"'");
          
          rs=sql.executeQuery("SELECT * FROM "+tableName+" where stu_number='"+stu_number+"'");
 
          ResultSetMetaData metaData = rs.getMetaData();
          int columnCount = metaData.getColumnCount(); //得到结果集的列数
          String []columnName = new String[columnCount];
          for(int i=0;i");
         out.println("

"+backNews+"

") ; out.println("返回"); out.println("输入记录"); out.println(""); } catch(IOException exp){} } }

Insert_Sp_Servlet.java

package myservlet.control;
import mybean.data.studentinfo; 
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Insert_Sp_Servlet extends HttpServlet{
   public void init(ServletConfig config) throws ServletException{
      super.init(config);
   }
   public void doPost(HttpServletRequest request,HttpServletResponse response)
               throws ServletException,IOException{
	   studentinfo resultBean=null;
      try{  resultBean=(studentinfo)request.getAttribute("resultBean");
            if(resultBean==null){
                resultBean=new studentinfo(); //创建Javabean对象
                request.setAttribute("resultBean",resultBean);
            }
      }
      catch(Exception exp){
            resultBean=new studentinfo();  //创建Javabean对象
            request.setAttribute("resultBean",resultBean);
      } 
     try{  Class.forName("com.mysql.jdbc.Driver");//加载驱动
     }
     catch(Exception e){} 
     request.setCharacterEncoding("gb2312");
     String dataBase  = request.getParameter("dataBase");
     String tableName = request.getParameter("tableName");
     
     String id=request.getParameter("ID");
     String class_teacher_status=request.getParameter("class_teacher_status");
     String class_teacher_sp_time=request.getParameter("class_teacher_sp_time");
     String class_teacher_restore=request.getParameter("class_teacher_restore");
     
     if(class_teacher_sp_time==null||class_teacher_sp_time.length()==0) {
        fail(request,response,"添加记录失败,必须给出记录");
        return;
     }
     
     String condition = "UPDATE "+tableName+" SET class_teacher_status='"+class_teacher_status+"' , class_teacher_sp_time='"+class_teacher_sp_time+"' ,class_teacher_restore='"+class_teacher_restore+"'"+" where id='"+id+"'";
     System.out.println(condition);
     Connection con;
     Statement sql; 
     ResultSet rs;
     try{ 
    	 
    	 String uri= "jdbc:mysql://localhost/"+dataBase+"?characterEncoding=utf8";
    		
       	 con=DriverManager.getConnection(uri,"root","root1");//建立连接
       
   	
          sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                                 ResultSet.CONCUR_READ_ONLY);
          sql.executeUpdate(condition);
          
          System.out.println("SELECT * FROM "+tableName+" where id='"+id+"'");
          
          rs=sql.executeQuery("SELECT * FROM "+tableName+" where id='"+id+"'");
 
          ResultSetMetaData metaData = rs.getMetaData();
          int columnCount = metaData.getColumnCount(); //得到结果集的列数
          String []columnName = new String[columnCount];
          for(int i=0;i");
         out.println("

"+backNews+"

") ; out.println("返回"); out.println("输入记录"); out.println(""); } catch(IOException exp){} } }

Select_class_Servlet.java

package myservlet.control;
import mybean.data.studentinfo; 
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Select_class_Servlet extends HttpServlet{
   public void init(ServletConfig config) throws ServletException{
      super.init(config);
   }
   public void doPost(HttpServletRequest request,HttpServletResponse response)
               throws ServletException,IOException{
	   studentinfo resultBean=null;
      try{  resultBean=(studentinfo)request.getAttribute("resultBean");
            if(resultBean==null){
                resultBean=new studentinfo(); //创建Javabean对象
                request.setAttribute("resultBean",resultBean);
            }
      }
      catch(Exception exp){
            resultBean=new studentinfo();  //创建Javabean对象
            request.setAttribute("resultBean",resultBean);
      } 
     try{  Class.forName("com.mysql.jdbc.Driver");//加载驱动
     }
     catch(Exception e){} 
     request.setCharacterEncoding("gb2312");
     String dataBase  = request.getParameter("dataBase");
     String tableName = request.getParameter("tableName");
     
     String class_id=request.getParameter("class_id");
  
     if( class_id==null||class_id.length()==0) {
        fail(request,response,"添加记录失败,必须给出记录");
        return;
     }
     Connection con;
     Statement sql; 
     ResultSet rs;
     try{ 
    	 
    	 String uri= "jdbc:mysql://localhost/"+dataBase+"?characterEncoding=utf8";
    		
       	 con=DriverManager.getConnection(uri,"root","root1");//建立连接
       
   	
          sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                                 ResultSet.CONCUR_READ_ONLY);         
         // System.out.println("SELECT * FROM "+tableName+" where stu_number='"+stu_number+"'");
          
          rs=sql.executeQuery("SELECT * FROM "+tableName+" where class_id='"+ class_id+"'");
 
          ResultSetMetaData metaData = rs.getMetaData();
          int columnCount = metaData.getColumnCount(); //得到结果集的列数
          String []columnName = new String[columnCount];
          for(int i=0;i");
         out.println("

"+backNews+"

") ; out.println("返回"); out.println("输入记录"); out.println(""); } catch(IOException exp){} } }

Select_number_Servlet.java

package myservlet.control;
import mybean.data.studentinfo; 
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Select_number_Servlet extends HttpServlet{
   public void init(ServletConfig config) throws ServletException{
      super.init(config);
   }
   public void doPost(HttpServletRequest request,HttpServletResponse response)
               throws ServletException,IOException{
	   studentinfo resultBean=null;
      try{  resultBean=(studentinfo)request.getAttribute("resultBean");
            if(resultBean==null){
                resultBean=new studentinfo(); //创建Javabean对象
                request.setAttribute("resultBean",resultBean);
            }
      }
      catch(Exception exp){
            resultBean=new studentinfo();  //创建Javabean对象
            request.setAttribute("resultBean",resultBean);
      } 
     try{  Class.forName("com.mysql.jdbc.Driver");//加载驱动
     }
     catch(Exception e){} 
     request.setCharacterEncoding("gb2312");
     String dataBase  = request.getParameter("dataBase");
     String tableName = request.getParameter("tableName");
     
     String stu_number=request.getParameter("stu_number");
  
     if( stu_number==null||stu_number.length()==0) {
        fail(request,response,"添加记录失败,必须给出记录");
        return;
     }
     Connection con;
     Statement sql; 
     ResultSet rs;
     try{ 
    	 
    	 String uri= "jdbc:mysql://localhost/"+dataBase+"?characterEncoding=utf8";
    		
       	 con=DriverManager.getConnection(uri,"root","root1");//建立连接
       
   	
          sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                                 ResultSet.CONCUR_READ_ONLY);         
         // System.out.println("SELECT * FROM "+tableName+" where stu_number='"+stu_number+"'");
          
          rs=sql.executeQuery("SELECT * FROM "+tableName+" where stu_number='"+stu_number+"'");
 
          ResultSetMetaData metaData = rs.getMetaData();
          int columnCount = metaData.getColumnCount(); //得到结果集的列数
          String []columnName = new String[columnCount];
          for(int i=0;i");
         out.println("

"+backNews+"

") ; out.println("返回"); out.println("输入记录"); out.println(""); } catch(IOException exp){} } }

值得注意的是,jdbc要用5.0的

你可能感兴趣的:(java)