TcompanyDao.java
资源名称:(J2EE)oa.rar [点击查看]
上传用户:lm2018
上传日期:2015-12-12
资源大小:30449k
文件大小:3k
源码类别:
Jsp/Servlet
开发平台:
Java
- package com.oa.module.email.company;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import com.oa.util.OracleTools;
- /**
- * 公司类
- * @author student
- *
- */
- public class TcompanyDao {
- /**
- * 获取整个公司用户列表
- * @return
- */
- public Tcompany getCompany(){
- Tcompany company = null;
- Connection conn = null;
- ResultSet rs = null;
- ResultSet rs2 = null;
- PreparedStatement ps = null;
- String sql = null;
- Tdept dept = null;
- try {
- sql = "select did, dname, uno, dfunction, dmemo, dflag from tdept where dflag=?";
- conn = OracleTools.getConn();
- ps = conn.prepareStatement(sql);
- ps.setString(1, "0");
- rs = ps.executeQuery();
- company = new Tcompany();
- company.setComid("1");
- company.setComName("中国微软");
- while(rs.next()){
- dept = new Tdept();
- dept.setDid(rs.getString("did"));
- dept.setDname(rs.getString("dname"));
- dept.setUno(rs.getLong("uno"));
- dept.setDfunction(rs.getString("dfunction"));
- dept.setDmemo(rs.getString("dmemo"));
- dept.setDflag(rs.getString("dflag"));
- company.getDeptList().add(dept);
- String temp = " select uno, did, uname, upwd, usex, uarea, uwork, "+
- " uphone, uemail, umobile, uaddress, uismarryed, uisonline, "+
- " uislocked, umemo, uidcard, uaddtime, utruename from tuser where UISLOCKED=? and did=?";
- ps = conn.prepareStatement(temp);
- ps.setString(1,"0");
- ps.setString(2,rs.getString("did"));
- rs2 = ps.executeQuery();
- TUser user = null;
- while(rs2.next()){
- user = new TUser();
- user.setDid(rs2.getString("uno"));
- user.setUno(rs2.getString("uno"));
- user.setUname(rs2.getString("uname"));
- user.setUpwd(rs2.getString("upwd"));
- user.setUsex(rs2.getString("usex"));
- user.setUarea(rs2.getString("uarea"));
- user.setUwork(rs2.getString("uwork"));
- user.setUphone(rs2.getString("uphone"));
- user.setUemail(rs2.getString("uemail"));
- user.setUmobile(rs2.getString("umobile"));
- user.setUaddress(rs2.getString("uaddress"));
- user.setUismarryed(rs2.getString("uismarryed"));
- user.setUisonline(rs2.getString("uisonline"));
- user.setUislocked(rs2.getString("uislocked"));
- user.setUmemo(rs2.getString("umemo"));
- user.setUidcard(rs2.getString("uidcard"));
- user.setUaddtime(rs2.getString("uaddtime"));
- user.setUtruename(rs2.getString("utruename"));
- dept.getUserList().add(user);
- }
- }
- } catch (SQLException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }finally{
- OracleTools.closeConn(rs, ps, conn);
- if(rs2!=null){
- try {
- rs2.close();
- rs2 = null;
- } catch (SQLException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- }
- }
- return company;
- }
- }