⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 empdao.java

📁 办公自动化系统,有人事资源管理模块,考勤管理,审批管理,权限设定等.
💻 JAVA
字号:
package com.lovo.dao.zhaobing;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;


import com.lovo.po.AwardInfoPo;
import com.lovo.po.DepartmentPo;
import com.lovo.po.EmpPo;
import com.lovo.po.FamilyInfoPo;
import com.lovo.po.PositionPo;
import com.lovo.po.WorkInfoPo;
import com.lovo.util.DBConnection;


public class EmpDao {

	/**
	 * @param args
	 */
	Connection con=null;
	String sqlsel;
	Statement stmt = null;
	ResultSet rs = null;
	//查询职业
	public ArrayList selectPosition(){
		sqlsel = "select * from t_position";
		PreparedStatement  pre=null;
		con=DBConnection.getConnection();
		ArrayList<PositionPo> array = new ArrayList<PositionPo>();
        try {
        	pre = con.prepareStatement(sqlsel);
            rs = pre.executeQuery();
            while(rs.next())
            {
            	PositionPo po = new PositionPo();
            	po.setId(rs.getInt(1));
            	po.setName(rs.getString(2));
                array.add(po);
            }
          return array;
            } catch (SQLException e) {
                e.printStackTrace();
            }
            finally
            {
                try {
                    pre.close();
                  } catch (SQLException e) {
                  e.printStackTrace();
                  }
                try {
                    con.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
          return null;
		}
	//查询部门
	public ArrayList selectDepartment(){
		sqlsel = "select * from t_department";
		PreparedStatement  pre=null;
		con=DBConnection.getConnection();
		ArrayList<DepartmentPo> array = new ArrayList<DepartmentPo>();
        try {
        	pre = con.prepareStatement(sqlsel);
            rs = pre.executeQuery();
            while(rs.next())
            {
            	DepartmentPo de = new DepartmentPo();
            	de.setId(rs.getInt(1));
            	de.setName(rs.getString(2));
                array.add(de);
            }
            return array;
            } catch (SQLException e) {
                e.printStackTrace();
            }
            finally
            {
                try {
                    pre.close();
                  } catch (SQLException e) {
                  e.printStackTrace();
                  }
                try {
                    con.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
                 return null;
	}
	//登记基本信息
	public EmpPo insertemp(EmpPo po){
		con = DBConnection.getConnection();
		PreparedStatement pss  =null;
		try {
			pss =  con.prepareStatement("insert into t_basicinfo (name,oldName,idCard,sex,nation,birthday,birthPlace,hometown,background,politicsFeature,Degree,isMarryed,gratuateSchool,phone,firstWorkDate,remark,discipline) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
			pss.setString(1, po.getName());
			System.out.println(po.getName());
			pss.setString(2, po.getOldName());
			pss.setString(3, po.getIdCard());
			pss.setInt(4, po.getSex());
			pss.setString(5, po.getNation());
			pss.setString(6, po.getBirthDay());
			pss.setString(7, po.getBirthPlace());
			pss.setString(8, po.getHomeTown());
			pss.setString(9, po.getBackGround());
			pss.setString(10, po.getPoliticsFeature());
			pss.setString(11, po.getDegree());
			pss.setInt(12, po.getIsMarryed());
			pss.setString(13, po.getGraduateSchool());
			pss.setString(14, po.getPhone());
			pss.setString(15, po.getFirstWorkDate());
			pss.setString(16, po.getRemark());
			pss.setString(17, po.getDiscipline());
			pss.executeUpdate();
			//System.out.println(pss.executeUpdate());
			PreparedStatement ps =  con.prepareStatement("select * from t_basicinfo");
			rs= ps.executeQuery();
			while(rs.next()){
				po.setId(rs.getInt(1));
			}
			return po;
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}
	      finally
          {
              try {
                  pss.close();
                } catch (SQLException e) {
                e.printStackTrace();
                }
              try {
                  con.close();
              } catch (SQLException e) {
                  e.printStackTrace();
              }
          }
	}
	//登记工作信息
	public boolean insertWordInfo(WorkInfoPo po){
		con = DBConnection.getConnection();
		PreparedStatement pss=null;
		try {
			pss =  con.prepareStatement("insert into t_workinfo(empId,startTime,position,department,rank,workDescribe,achievement) values(?,?,?,?,?,?,?)");
			pss.setInt(1, po.getMyEmpPo().getId());
			pss.setString(2, po.getStartTime());
			pss.setInt(3, po.myPosition.getId());
			pss.setInt(4, po.myDepartment.getId());
			pss.setString(5, po.getRank());
			pss.setString(6, po.getWorkDescribe());
			pss.setString(7, po.getAchievement());
			pss.executeUpdate();
			return true;
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		}  
		finally
        {
            try {
                pss.close();
              } catch (SQLException e) {
              e.printStackTrace();
              }
            try {
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
	}
	//登记家庭信息
	public boolean insertFamilyInfo(FamilyInfoPo po){
		con = DBConnection.getConnection();
		PreparedStatement pss=null;
		try {
			pss =  con.prepareStatement("insert into t_familyinfo(empId,momName,dadName,mateName,momVocation,dadVocation,mateVocation,childName,childDegree,familyPhone,postCode,position) values(?,?,?,?,?,?,?,?,?,?,?,?)");
			pss.setInt(1, po.getMyEmpPo().getId());
			pss.setString(2, po.getMName());
			pss.setString(3, po.getFName());
			pss.setString(4, po.getOtherName());
			pss.setString(5, po.getMVocation());
			pss.setString(6, po.getFVocation());
			pss.setString(7, po.getOtherVocation());
			pss.setString(8, po.getChildName());
			pss.setString(9, po.getDegree());//学历
			pss.setString(10, po.getPhone());
			pss.setString(11, po.getPostcode());
			pss.setString(12, po.getPosition());
			pss.executeUpdate();
			return true;
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		}
		finally
        {
            try {
                pss.close();
              } catch (SQLException e) {
              e.printStackTrace();
              }
            try {
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
	}
	//登记奖惩信息
	public boolean insertAwordInfo(AwardInfoPo po){
		con = DBConnection.getConnection();
		PreparedStatement pss=null;
		try {
			pss =  con.prepareStatement("insert into t_awardinfo(empId,award,punishment) values(?,?,?)");
			pss.setInt(1, po.getMyEmpPo().getId());
			pss.setString(2, po.getAward());
			pss.setString(3, po.getPunishment());
			pss.executeUpdate();
			return true;
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		}
		finally
        {
            try {
                pss.close();
              } catch (SQLException e) {
              e.printStackTrace();
              }
            try {
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
		
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -