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

OA系统

开发平台:

Java

  1. /*
  2.  * Created on 2004-9-24
  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.bumf;
  8. import oa.data.Bumf;
  9. import oa.sys.*;
  10. import oa.sys.Time;
  11. import java.io.*;
  12. import java.sql.*;
  13. import java.util.*;
  14. import javax.servlet.*;
  15. import javax.servlet.http.*;
  16. /**
  17.  ****************************************************
  18.  *类名称: Send<br>
  19.  *类功能: 公文发送(附件)<br>
  20.  *创建: 白伟明 2004年10月7日<br>
  21.  ****************************************************
  22.  * To change the template for this generated type comment go to
  23.  * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  24.  */
  25. public class Send extends HttpServlet{
  26. private int sign;
  27. private int examine;
  28. private int id;
  29. private int accepter;
  30. private int sendter;
  31. private int bumfid;
  32. private String axffix;
  33. private String content;
  34. private String title;
  35. private String time;
  36. private String sqls;
  37. private String sqli;
  38. private String submit;
  39. private String bumf;
  40. private HttpSession session=null;
  41. private ResultSet rs=null;
  42. private Statement stmt=null;
  43. public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  44. request.setCharacterEncoding("gb2312");
  45. response.setContentType("text/html; charset=gb2312");
  46. PrintWriter out=response.getWriter();
  47. session=request.getSession();
  48. Str str=new Str();
  49. Db db=new Db();
  50. Time times=new Time();
  51. Collection coll=new ArrayList();
  52. //获取发送人id
  53. try{
  54. id=Integer.parseInt((String)session.getAttribute("id"));
  55. }catch(Exception e){
  56. e.printStackTrace();
  57. }
  58. //查看发送人是否有临时公文
  59. sqls="SELECT * FROM bumf WHERE sendter="+id+" AND sign="+0;
  60. out.print(sqls+"<br>");
  61. try{
  62. stmt=db.getStmtread();
  63. rs=stmt.executeQuery(sqls);
  64. //如果没有生成一个临时文件
  65. if(!rs.next()){
  66. db.close();
  67. sqli="INSERT INTO bumf(sendter,accepter,title,time,content,affix,examine,sign) VALUES("+id+","+id+",'','"+times.getYMDHMS()+"',' ','',1,0)";
  68. stmt=db.getStmt();
  69. stmt.executeUpdate(sqli);
  70. }
  71. db.close();
  72. //调出临时文件
  73. stmt=db.getStmtread();
  74. rs=stmt.executeQuery(sqls);
  75. if(rs.next()){
  76. bumfid=rs.getInt(1);
  77. sendter=rs.getInt(2);
  78. accepter=rs.getInt(3);
  79. title=rs.getString(4);
  80. time=rs.getString(5);
  81. content=rs.getString(6);
  82. axffix=rs.getString(7);
  83. examine=rs.getInt(8);
  84. sign=rs.getInt(9);
  85. content=str.outStr(content);
  86. axffix=str.outStr(axffix);
  87. Bumf bumf=new Bumf();
  88. bumf.setId(bumfid);
  89. bumf.setSendter(sendter);
  90. bumf.setAccepter(accepter);
  91. bumf.setTitle(title);
  92. bumf.setTime(time);
  93. bumf.setContent(content);
  94. bumf.setExamine(examine);
  95. bumf.setSign(sign);
  96. bumf.setAffix(axffix);
  97. coll.add(bumf);
  98. }
  99. request.setAttribute("msg",coll);
  100.  coll=(Collection)request.getAttribute("msg");
  101. if(coll!=null){
  102. Iterator it=coll.iterator();
  103. if(it.hasNext()){
  104. Bumf bumf=(Bumf)it.next();
  105. out.print(bumf.getId());
  106. }
  107. }
  108. }catch(Exception e){
  109. e.printStackTrace();
  110. out.print(e);
  111. }finally{
  112. db.close();
  113. RequestDispatcher dispatcher=request.getRequestDispatcher("send.jsp");
  114. dispatcher.forward(request,response);
  115. }
  116. }
  117. public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  118. doPost(request,response);
  119. }
  120. }