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

📄 deptdao.java

📁 实现银行系统中某个部门的计算机设备管理、公共信息管理、权限用户管理、系统设置等,为系统的安全正常运行提供保障
💻 JAVA
字号:
package com.isoftstone.banktearm1.dao;
/*
 * 07作成部门及机构
 */
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Iterator;

import com.isoftstone.banktearm1.db.DB;
import com.isoftstone.banktearm1.vo.BankTeam1DepVo;
import com.isoftstone.banktearm1.vo.UnitDepVo;

public class DeptDao extends com.isoftstone.banktearm1.db.DB{
	
	public int getDepId(int depid) throws SQLException, ClassNotFoundException{

		UnitDepVo udvo=new UnitDepVo();
		udvo=this.getRow(depid);
		int id=0;
		Connection con=this.getConnection();
		Statement stmt=con.createStatement();
		String sql="select * from dep where DepartmentName='"+udvo.getDepartmentName()+"'";
		ResultSet rs=stmt.executeQuery(sql);
		while(rs.next()){
			id=rs.getInt("ID");
		}
		return id;
	}
	
	public void updateDep(int i,int unitid,String depname) throws SQLException, ClassNotFoundException{
		int departmentId=0;
		int departmentType=0;
		String str="科技部";
		if(i>10)
		    departmentId=Integer.parseInt(unitid+""+i);
		else
			departmentId=Integer.parseInt(unitid+"0"+i);
		if(!str.equals(depname))
			departmentType=1;
		Connection con=this.getConnection();
		Statement stmt=con.createStatement();
		String sql="update dep Set DepartmentName='"+depname+"',DepartmentID="+departmentId+",DepartmentUnit='"+unitid+"',DepartmentType="+departmentType+" where ID="+i;
		stmt.executeUpdate(sql);
	}
	
	public ArrayList getDep() throws SQLException, ClassNotFoundException{
		ArrayList list=new ArrayList();
		Connection con=this.getConnection();
		Statement stmt=con.createStatement();
		String sql="select DepartmentID,DepartmentName,UnitName,UnitID from dep,unit where mid(DepartmentID,1,2)=cstr(UnitID) order by DepartmentID asc";
		ResultSet rs=stmt.executeQuery(sql);
		while(rs.next()){
			int departmentId=rs.getInt("departmentId");
			String departmentName=rs.getString("departmentName");
			String unitName=rs.getString("unitName");
			int unitId=rs.getInt("unitId");
			UnitDepVo udvo=new UnitDepVo(departmentId,departmentName,unitName,unitId);
			list.add(udvo);
		}
		this.closs(rs,stmt,con);
		return list;
	}
	
	public void deleteDep(int i) throws SQLException, ClassNotFoundException{
		ArrayList list=this.getDep();
		Connection con=this.getConnection();
		Statement stmt=con.createStatement();
		String sql="delete * from dep where DepartmentID="+i;
		stmt.executeUpdate(sql);
		this.closs(stmt,con);
	}
	
	public void insertDep(int id,int departmentId,String departmentName,String departmentUnit,int departmentType) throws SQLException, ClassNotFoundException{
		DB db=new DB();
		Connection con=db.getConnection();
		Statement stmt=con.createStatement();
		String sql="insert into dep values("+id+","+departmentId+",'"+departmentName+"','"+departmentUnit+"',"+departmentType+")";
		stmt.executeUpdate(sql);
		this.closs(stmt,con);
	}
	
	public UnitDepVo getRow(int i) throws SQLException, ClassNotFoundException{
		ArrayList list=this.getDep();
		Iterator it=list.iterator();
		UnitDepVo udvo=null;
		while(it.hasNext()){
			udvo=(UnitDepVo)it.next();
			if(udvo.getDepartmentId()==i){
			    int departmentId=udvo.getDepartmentId();
			    String departmentName=udvo.getDepartmentName();
			    String unitName=udvo.getUnitName();
			    int unitId=udvo.getUnitId();
				udvo=new UnitDepVo(departmentId,departmentName,unitName,unitId);
			}
		}
		return udvo;
	}
	
	public void getDelflag(String []delflag) throws NumberFormatException, SQLException, ClassNotFoundException{
		for(int i=0;i<delflag.length;i++)
			this.deleteDep(Integer.parseInt(delflag[i]));
	}
	
	public int getMax(String s) throws SQLException, ClassNotFoundException{
		int i=0;
		Connection con=this.getConnection();
		Statement stmt=con.createStatement();
		String sql="select max("+s+")  from dep";
		ResultSet rs=stmt.executeQuery(sql);
		if(rs.next()){
			i=rs.getInt(1);
		}
		return i;
	}

}

⌨️ 快捷键说明

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