TcompanyDao.java
上传用户:lm2018
上传日期:2015-12-12
资源大小:30449k
文件大小:3k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. package com.oa.module.email.company;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import com.oa.util.OracleTools;
  7. /**
  8.  * 公司类
  9.  * @author student
  10.  *
  11.  */
  12. public class TcompanyDao {
  13. /**
  14.  * 获取整个公司用户列表
  15.  * @return
  16.  */
  17. public Tcompany getCompany(){
  18. Tcompany company = null;
  19. Connection conn = null;
  20. ResultSet rs = null;
  21. ResultSet rs2 = null;
  22. PreparedStatement ps = null;
  23. String sql = null;
  24. Tdept dept = null;
  25. try {
  26. sql = "select did, dname, uno, dfunction, dmemo, dflag from tdept where dflag=?";
  27. conn = OracleTools.getConn();
  28. ps = conn.prepareStatement(sql);
  29. ps.setString(1, "0");
  30. rs = ps.executeQuery();
  31. company = new Tcompany();
  32. company.setComid("1");
  33. company.setComName("中国微软");
  34. while(rs.next()){
  35. dept = new Tdept();
  36. dept.setDid(rs.getString("did"));
  37. dept.setDname(rs.getString("dname"));
  38. dept.setUno(rs.getLong("uno"));
  39. dept.setDfunction(rs.getString("dfunction"));
  40. dept.setDmemo(rs.getString("dmemo"));
  41. dept.setDflag(rs.getString("dflag"));
  42. company.getDeptList().add(dept);
  43. String temp = " select uno, did, uname, upwd, usex, uarea, uwork, "+
  44. " uphone, uemail, umobile, uaddress, uismarryed, uisonline, "+
  45. " uislocked, umemo, uidcard, uaddtime, utruename from tuser where UISLOCKED=? and did=?";
  46. ps = conn.prepareStatement(temp);
  47. ps.setString(1,"0");
  48. ps.setString(2,rs.getString("did"));
  49. rs2 = ps.executeQuery();
  50. TUser user = null;
  51. while(rs2.next()){
  52. user = new TUser();
  53. user.setDid(rs2.getString("uno"));
  54. user.setUno(rs2.getString("uno"));
  55. user.setUname(rs2.getString("uname"));
  56. user.setUpwd(rs2.getString("upwd"));
  57. user.setUsex(rs2.getString("usex"));
  58. user.setUarea(rs2.getString("uarea"));
  59. user.setUwork(rs2.getString("uwork"));
  60. user.setUphone(rs2.getString("uphone"));
  61. user.setUemail(rs2.getString("uemail"));
  62. user.setUmobile(rs2.getString("umobile"));
  63. user.setUaddress(rs2.getString("uaddress"));
  64. user.setUismarryed(rs2.getString("uismarryed"));
  65. user.setUisonline(rs2.getString("uisonline"));
  66. user.setUislocked(rs2.getString("uislocked"));
  67. user.setUmemo(rs2.getString("umemo"));
  68. user.setUidcard(rs2.getString("uidcard"));
  69. user.setUaddtime(rs2.getString("uaddtime"));
  70. user.setUtruename(rs2.getString("utruename"));
  71. dept.getUserList().add(user);
  72. }
  73. }
  74. } catch (SQLException e) {
  75. // TODO 自动生成 catch 块
  76. e.printStackTrace();
  77. }finally{
  78. OracleTools.closeConn(rs, ps, conn);
  79. if(rs2!=null){
  80. try {
  81. rs2.close();
  82. rs2 = null;
  83. } catch (SQLException e) {
  84. // TODO 自动生成 catch 块
  85. e.printStackTrace();
  86. }
  87. }
  88. }
  89. return company;
  90. }
  91. }