State.java
上传用户:sxwtmm
上传日期:2022-08-11
资源大小:2183k
文件大小:3k
源码类别:

OA系统

开发平台:

Java

  1. /*
  2.  * Created on 2004-9-22
  3.  *
  4.  * To change the template for this generated file go to
  5.  * Window>Preferences>Java>Code Generation>Code and Comments
  6.  */
  7. package com.sign;
  8. import oa.sys.*;
  9. import oa.sys.Time;
  10. import oa.data.Signstate;
  11. import oa.data.Sign;
  12. import java.io.*;
  13. import java.sql.*;
  14. import java.util.*;
  15. import javax.servlet.*;
  16. import javax.servlet.http.*;
  17. /**
  18.  ****************************************************
  19.  *类名称: State<br>
  20.  *类功能: 获取员工作息时间<br>
  21.  *创建: 白伟明 2004年10月4日<br>
  22.  *修改: 白伟明 2004年10月5日<br>
  23.  ****************************************************
  24.  * To change the template for this generated type comment go to
  25.  * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  26.  */
  27. public class State extends HttpServlet{
  28. private int signstateid;
  29. private int quit;
  30. private int late;
  31. private int employeeid;
  32. private String time;
  33. private String describestate;
  34. private int id;
  35. private Db db=null;
  36. private Str str=null;
  37. private Time day=new Time();
  38. private int temp=0;
  39. private String up=null;
  40. private String down=null;
  41. private HttpSession session=null;
  42. private PrintWriter out=null;
  43. private ResultSet rs=null;
  44. private Statement stmt=null;
  45. private String sqls="SELECT * FROM signstate WHERE signstateid=1 or signstateid=2";
  46. private String sqls1="";
  47. public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  48. request.setCharacterEncoding("gb2312");
  49. response.setContentType("text/html; charset=gb2312");
  50. out = response.getWriter();
  51. session=request.getSession();
  52. str=new Str();
  53. db=new Db();
  54. //在数据库取得作息时间
  55. try {
  56. stmt=db.getStmtread();
  57. rs=stmt.executeQuery(sqls);
  58. Collection coll=new ArrayList();
  59. while(rs.next()){
  60. id=rs.getInt(1);
  61. describestate=rs.getString(2);
  62. time=rs.getString(3);
  63. Signstate ss=new Signstate();
  64. describestate=str.outStr(describestate);
  65. ss.setId(id);
  66. ss.setDescribestate(describestate);
  67. ss.setTime(time);
  68. coll.add(ss);
  69. }
  70. request.setAttribute("msg",coll);
  71. request.setAttribute("advmsg","注意:签到只能操作一次");
  72. } catch (SQLException e) {
  73. request.setAttribute("advmsg","签到失败,请予管理员联系");
  74. }finally{
  75. db.close();
  76. }
  77. //根据session,在数据库取得签到人的签到状态
  78. try{
  79. id=Integer.parseInt((String)session.getAttribute("id"));
  80. sqls1="SELECT * FROM sign WHERE employeeid="+id+" AND time >= '"+day.getYMD()+"'";
  81. stmt=db.getStmtread();
  82. rs=stmt.executeQuery(sqls1);
  83. Collection coll=new ArrayList();
  84. while(rs.next()){
  85. id=rs.getInt(1);
  86. time=rs.getString(2);
  87. employeeid=rs.getInt(3);
  88. late=rs.getInt(4);
  89. quit=rs.getInt(5);
  90. signstateid=rs.getInt(8);
  91. Sign sign=new Sign();
  92. sign.setId(id);
  93. sign.setTime(time);
  94. sign.setEmid(employeeid);
  95. sign.setLate(late);
  96. sign.setQuit(quit);
  97. sign.setSignstateid(signstateid);
  98. out.print(id);
  99. coll.add(sign);
  100. }
  101. request.setAttribute("singmsg",coll);
  102. }catch(Exception e){
  103. e.printStackTrace();
  104. }finally{
  105. db.close();
  106. RequestDispatcher dispatcher=request.getRequestDispatcher("sign.jsp");
  107. dispatcher.forward(request,response);
  108. }
  109. }
  110. public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  111. doPost(request,response);
  112. }
  113. }