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

📄 leaveapplydao.java

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

import com.lovo.po.*;
import com.lovo.util.DBConnection;
import java.sql.*;

public class LeaveApplyDAo {

	public EmpPo findAll(EmpPo po) {
		Connection con = DBConnection.getConnection();
		Statement stmt = null;
		ResultSet set = null;
		EmpPo emp = new EmpPo();
		String sql = "select c.ID,c.name,c.gongling,c.tanqin,p.postName,d.depName from t_department d,t_position p,(select b.ID,b.name,b.gongling,b.tanqin,w.position,w.department from t_basicinfo b,t_workinfo w  where b.ID="
				+ po.getId()
				+ " and w.empId = "
				+ po.getId()
				+ " ) c where c.position = p.postId and c.department = d.depId";
		System.out.println(sql);

		try {
			stmt = con.createStatement();
			set = stmt.executeQuery(sql);
			set.next();
			emp = new EmpPo();
			Integer id = set.getInt(1);
			emp.setId(id);
			emp.setName(set.getString(2));
			emp.setGongli(set.getInt(3));
			emp.setTanqing(set.getInt(4));
			emp.myWorkInfoPo.myPosition.setName(set.getString(5));
			emp.myWorkInfoPo.myDepartment.setName(set.getString(6));

		} catch (SQLException e) {
			// TODO �Զ���� catch ��
			e.printStackTrace();
		} finally {
			if (set != null) {
				try {
					set.close();
				} catch (SQLException e) {
					// TODO �Զ���� catch ��
					e.printStackTrace();
				}
			}
			if (stmt != null) {
				try {
					stmt.close();
				} catch (SQLException e) {
					// TODO �Զ���� catch ��
					e.printStackTrace();
				}
			}
			DBConnection.close(con);
		}

		return emp;

	}

	public boolean applyLeave(LeavePo po) {
		Connection con = DBConnection.getConnection();
		PreparedStatement pstmt = null;
		String sql = "insert t_leave (empId,leaveType,leavePosition,startTime,overTime,leaveReason,leaveRemark) values(?,?,?,?,?,?,?)";
		try {
			pstmt = con.prepareStatement(sql);
			pstmt.setInt(1, po.myEmpPo.getId());
			pstmt.setString(2, po.getLeaveType());
			pstmt.setString(3, po.getPosition());
			pstmt.setString(4, po.getStartTime());
			pstmt.setString(5, po.getOverTime());
			pstmt.setString(6, po.getReason());
			pstmt.setString(7, po.getRemark());
			if (pstmt.executeUpdate() != -1) {
				return true;
			}
		} catch (SQLException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}finally{
			if(pstmt!=null){
				try {
					pstmt.close();
				} catch (SQLException e) {
					// TODO 自动生成 catch 块
					e.printStackTrace();
				}
			}
			DBConnection.close(con);
		}
		return false;

	}

}

⌨️ 快捷键说明

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