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

📄 leavedao.java

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

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

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

public class LeaveDao {

	StringBuffer queryUnsetAll = new StringBuffer("select * from v_leaveUnset where leaveConfirm=1");
	StringBuffer queryUnset = new StringBuffer("select * from v_leaveunsetpre where ID=?");
	StringBuffer passUnset = new StringBuffer("update t_leave set leaveConfirm=? where ID=?");
	DBConnection dbc;
	PreparedStatement pre;
	Connection con;
	ResultSet rs = null;
	public LeaveDao(){
		dbc = new DBConnection();
		con =dbc.getConnection();
	}
	/**
	 * 查询所有员工待办情况的方法
	 * @param i
	 * @return
	 */
	public Vector leaveQueryUnsetAll(int i,DepartmentPo po){
		
		Vector<LeavePo> leap = new Vector();
		
		try {
		
			if(i!=-1){
				i = i*2;
				//queryUnsetAll.append(" and department = "+ po.getId());
				queryUnsetAll.append(" limit ");
				queryUnsetAll.append(i);
				queryUnsetAll.append(",2");
			}
			pre = con.prepareStatement(queryUnsetAll.toString());
			rs = pre.executeQuery();
			while(rs.next()){
				LeavePo lp = new LeavePo();
				EmpPo mp = new EmpPo();
				WorkInfoPo wp = new WorkInfoPo();
				DepartmentPo dt = new DepartmentPo();
				dt.setName(rs.getString(3));
				PositionPo pt = new PositionPo();
				pt.setName(rs.getString(2));
				wp.setMyDepartment(dt);
				wp.setMyPosition(pt);
				mp.setMyWorkInfoPo(wp);
				mp.setName(rs.getString(4));
				lp.setLeaveType(rs.getString(1));
				lp.setPosition(rs.getString(5));
				lp.setMyEmpPo(mp);
				lp.setId(rs.getInt(6));
				leap.add(lp);
			}
			return leap;
		} catch (SQLException e) {
			// TODO �Զ���� catch ��
			e.printStackTrace();
		}finally{
			try {
				rs.close();
				pre.close();
				con.close();
			} catch (SQLException e) {
				// TODO �Զ���� catch ��
				e.printStackTrace();
			}
			
		}
		return null;
		
	}
	/**
	 * 查询需要待办员工请假详细信息的方法
	 * @param po
	 * @return
	 */
	public LeavePo  leaveQueryUnset(LeavePo po){
		try {
			pre = con.prepareStatement(queryUnset.toString(),ResultSet.TYPE_SCROLL_SENSITIVE);
			pre.setInt(1, po.getId());
			rs = pre.executeQuery();
			LeavePo lp = new LeavePo();
			if(rs.next()){
				//rs.absolute(po.getId());
				EmpPo mp = new EmpPo();
				WorkInfoPo wp = new WorkInfoPo();
				DepartmentPo dt = new DepartmentPo();
				dt.setName(rs.getString(3));
				PositionPo pt = new PositionPo();
				pt.setName(rs.getString(2));
				wp.setMyDepartment(dt);
				wp.setMyPosition(pt);
				mp.setMyWorkInfoPo(wp);
				mp.setName(rs.getString(4));
				mp.setTanqing(rs.getInt(11));
				mp.setGongli(rs.getInt(10));
				mp.setId(rs.getInt(13));
				lp.setLeaveType(rs.getString(1));
				lp.setPosition(rs.getString(5));
				lp.setStartTime(rs.getDate(6).toString());
				lp.setOverTime(rs.getDate(7).toString());
				lp.setReason(rs.getString(8));
				lp.setRemark(rs.getString(9));
				lp.setMyEmpPo(mp);
				lp.setId(rs.getInt(12));
			}
			return lp;
		} catch (SQLException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}finally{
			try {
				rs.close();
				pre.close();
				con.close();
			} catch (SQLException e) {
				// TODO �Զ���� catch ��
				e.printStackTrace();
			}
		}
		return null;
	}
	
	public boolean leavePass(LeavePo po){
		int tan = po.getMyEmpPo().getTanqing();
		int gong = po.getMyEmpPo().getGongli();
		int empid = po.getMyEmpPo().getId();
		PreparedStatement prep = null;
		try {
			pre = con.prepareStatement(passUnset.toString());
			pre.setInt(2, po.getId());
			
			if(po.getConfirm()==2){
				pre.setInt(1, 2);
				if(po.getLeaveType().equals("tan")){
					prep = con.prepareStatement("update t_basicinfo set tanqin = ? where id = ?");
					prep.setInt(1, tan-1);
					prep.setInt(2, empid);
					prep.executeUpdate();
				}else if(po.getLeaveType().equals("gong")){
					prep = con.prepareStatement("update t_basicinfo set gongling = ? where id = ?");
					prep.setInt(1, gong-1);
					prep.setInt(2, empid);
					prep.executeUpdate();
					
				}
				prep.close();
			}else if(po.getConfirm()==3){
				pre.setInt(1, 3);
			}
			if(pre.executeUpdate()!=1){
				return false;
			}
		} catch (SQLException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}finally{
			try {
				
				pre.close();
				con.close();
			} catch (SQLException e) {
				// TODO �Զ���� catch ��
				e.printStackTrace();
			}
		}
		return true;
	}
}

⌨️ 快捷键说明

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