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

📄 updateinfodao.java

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

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

import com.lovo.dao.xy.UpdateInfoDao;
import com.lovo.po.xy.*;
import com.lovo.util.*;
import com.lovo.vo.xy.*;

public class UpdateInfoDao {
	/**
	 * @param args
	 */
	Connection con=null;
	String sqlsel;
	Statement stmt = null;
	ResultSet rs = null;
	public static void main(String[] args) {
		// TODO 自动生成方法存根
		UpdateInfoDao ed = new UpdateInfoDao();
		ed.select();
	}
	//测试方法
	public void select(){
		sqlsel = "select depName from t_department";
		
		con=DBConnection.getConnection();
		try {
			PreparedStatement ps = con.prepareStatement(sqlsel);
		
			rs = ps.executeQuery(sqlsel);
			System.out.println(rs.next());
			while(rs.next()){
				System.out.println("111");
			}
		} catch (SQLException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
	}
	

	
	//更新基本信息
	public void updateEmp(EmpPo po){
		con = DBConnection.getConnection();
		try {
			String id = po.getId();
			String st = "update t_basicinfo set name=?,oldName=?,idCard=?,sex=?,nation=?,birthday=?,birthPlace=?,hometown=?,background=?,politicsFeature=?,Degree=?,isMarryed=?,gratuateSchool=?,phone=?,firstWorkDate=?,remark=?,discipline=? where ID="+id;
		System.out.println(st);
			PreparedStatement pss =  con.prepareStatement(st);
			pss.setString(1, 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();
			//PreparedStatement ps =  con.prepareStatement("select LAST_INSERT_ID()");
			//rs= ps.executeQuery();
			//while(rs.next()){
				//po.setId(rs.getInt(1));
			//}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		System.out.println(po.getId());
	}
	//更新工作信息
	public void updateWorkInfo(WorkInfoPo po){
		con = DBConnection.getConnection();
		try {
			String id =po.getMyEmpPo().getId();
			String st = "update t_workinfo set startTime=?,position=?,department=?,rank=?,workDescribe=?,achievement=? where empId="+id;
			PreparedStatement pss =  con.prepareStatement(st);
			System.out.println(st);
			pss.setString(1, po.getStartTime());
			pss.setInt(2, Integer.parseInt(po.getMyPosition().getId()));
			pss.setInt(3, Integer.parseInt(po.getMyDepartment().getId()));
			pss.setString(4, po.getRank());
			pss.setString(5, po.getWorkDescribe());
			pss.setString(6, po.getAchievement());
			pss.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	//更新奖惩信息
	public void updateAwordInfo(AwardInfoPo po){
		con = DBConnection.getConnection();
		try {
			String id = po.getMyEmpPo().getId();
			String st = "update t_awardinfo set award=?,punishment=? where empId="+id;
			System.out.println(st);
			PreparedStatement pss =  con.prepareStatement(st);
//			pss.setInt(1, 1);
			
			pss.setString(1, po.getAward());
			pss.setString(2, po.getPunishment());
			pss.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
	}
	//更新家庭信息
	public void updateFamilyInfo(FamilyInfoPo po){
		con = DBConnection.getConnection();
		try {
			String id = po.getMyEmpPo().getId();
			String st = "update t_familyinfo set momName=?,dadName=?,mateName=?,momVocation=?,dadVocation=?,mateVocation=?,childName=?,childDegree=?,familyPhone=?,postCode=?,position=? where empId="+id;
			System.out.println(st);
			PreparedStatement pss =  con.prepareStatement(st);
//			pss.setInt(1, 1);
			pss.setString(1, po.getMName());
			pss.setString(2, po.getFName());
			pss.setString(3, po.getOtherName());
			pss.setString(4, po.getMVocation());
			pss.setString(5, po.getFVocation());
			pss.setString(6, po.getOtherVocation());
			pss.setString(7, po.getChildName());
			pss.setString(8, "");//学历
			pss.setString(9, po.getFamilyPhone());
			pss.setString(10, po.getPostcode());
			pss.setString(11, po.getPosition());
			pss.executeUpdate();
		} catch (SQLException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		
	}
	
	//取部门信息
	public Vector<Department> selectDep(){
		con = DBConnection.getConnection();
		String st = "select * from t_department ";
		try {
			PreparedStatement ps = con.prepareStatement(st);
			rs = ps.executeQuery(st);
			Vector<Department> depvct = new Vector<Department>();
			while(rs.next()){
				Department dep = new Department();
				dep.setId(rs.getString(1));
				dep.setName(rs.getString(2));
				depvct.add(dep);
			}
			return depvct;
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			try {
				con.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	
	//取职位信息
	public Vector<Position> selectPos(){
		con = DBConnection.getConnection();
		String st = "select * from t_position ";
		try {
			PreparedStatement ps = con.prepareStatement(st);
			rs = ps.executeQuery(st);
			Vector<Position> posvct = new Vector<Position>();
			while(rs.next()){
				Position pos = new Position();
				pos.setId(rs.getString(1));
				pos.setName(rs.getString(2));
				posvct.add(pos);
			}
			return posvct;
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			try {
				con.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
}

⌨️ 快捷键说明

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