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

📄 empadddao.java

📁 实现银行系统中某个部门的计算机设备管理、公共信息管理、权限用户管理、系统设置等,为系统的安全正常运行提供保障
💻 JAVA
字号:
package com.isoftstone.banktearm1.dao;


import java.sql.*;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.StringTokenizer;

import com.isoftstone.banktearm1.db.*;
import com.isoftstone.banktearm1.vo.BankTeam1EmpVo;




//添加vo到emp表中
public class EmpAddDao  extends DB  {
	public void insertRecort(BankTeam1EmpVo myvo) throws Exception{
		int i=0;
		String sql="insert into emp values("+this.SelectRecort()+","+myvo.getWorkerId()+",'"+myvo.getName()+"','"+myvo.getSex()+"','"+myvo.getBirthdayStr()+"','"+myvo.getDepartment()+"','"+myvo.getJobName()+"','"+myvo.getPassword()+"')";
		Connection cn= this.getConnection();
		Statement stmt=cn.createStatement();
		
		i=stmt.executeUpdate(sql);
		
		if(stmt!=null){
			stmt.close();
			}
		if(cn!=null){
			cn.close();
			}
		}
	
	public int SelectRecort() throws SQLException, ClassNotFoundException{
		int i=0;
		Connection cn= this.getConnection();
		Statement stmt=cn.createStatement();
		String sql="select max(id) from emp";
		ResultSet rs=stmt.executeQuery(sql);
		if(rs.next()){
			i=rs.getInt(1)+1;
			
			}
		
		if(rs!=null){rs.close();}
		if(stmt!=null){stmt.close();}
		if(cn!=null){cn.close();};
		
				return i; 
	}
	public int getNextWorkId(String st)throws Exception{
		int depID = 0;
		Connection cn= this.getConnection();
		Statement stmt=cn.createStatement();
		String sql="SELECT DISTINCT UnitName+':'+DepartmentName AS str, dep.DepartmentId FROM dep, unit WHERE mid(dep.DepartmentId,1,2)=cstr(unit.unitid)";

	    ResultSet rs = stmt.executeQuery(sql);
	    while(rs.next()){
	    	String dst =rs.getString("str");
	    	
			if(st.equals(dst)){
	    	    	 depID = rs.getInt("DepartmentId");
	    	    	 return depID;
			}
	    }
		if(stmt!=null){
			stmt.close();
			}
		if(cn!=null){
			cn.close();
			}
		return  depID;
	}
	
	public int grewWorkID(String st) throws Exception{
		int i = this.getNextWorkId(st);
		int index=0;
		Connection cn= this.getConnection();
		Statement stmt=cn.createStatement();
		String sql="SELECT WorkerID from emp";
	    ResultSet rs = stmt.executeQuery(sql);
		while(rs.next()){
			index = rs.getInt("WorkerID");
		}
		index++;
		String s = index+"";
		
		
		return Integer.parseInt(i+s.substring(4, s.length()));
	}
	
	}

⌨️ 快捷键说明

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