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

📄 bossdao.java

📁 oa rar it is the jsp
💻 JAVA
字号:
package com.accp.oa.dao.imple;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import com.accp.oa.bean.Boss;
import com.accp.oa.bean.Type;
import com.accp.oa.common.*;
import com.accp.oa.dao.inface.*;

/*
 * 此类用于对
 * 数据库中表供应商的一些
 * 操作
 */
public class BossDAO implements BaseDAO {

	/*
	 * 此方法用于添加
	 * 供应商信息
	 * @see com.accp.oa.dao.inface.BaseDAO#add(java.lang.Object)
	 */
	public boolean add(Object boss) {
		boolean success = false;
		Boss objboss = (Boss)boss;
		Connection con = null;
		PreparedStatement stmt = null;
		try{
			con = DbUtil.connectToDB();
			stmt = con.prepareStatement(Constants.ADD_BOSS);
			stmt.setString(1, objboss.getName());
			stmt.setString(2, objboss.getAddress());
			stmt.setString(3, objboss.getTel());
			stmt.setString(4, objboss.getFax());
			stmt.setString(5, objboss.getEmail());
			stmt.setString(6, objboss.getLkname());
			stmt.setString(7, objboss.getLkduty());
			stmt.setString(8, objboss.getLktel());
			stmt.setString(9, objboss.getLkhandset());
			if(stmt.executeUpdate() > 0){
				success = true;
			}
		}catch(Exception ex){
			ex.printStackTrace();
			return false;
		}finally{
			try{
				stmt.close();
				con.close();
			}catch(Exception ex){
				
			}
		}
		return success;
	}

	public boolean delete(Object obj) {
		return false;
	}

	/*
	 * 此方法用于删除供应商信息
	 * @see com.accp.oa.dao.inface.BaseDAO#delete(int)
	 */
	public boolean delete(int bossId) {
		boolean success = false;
		Connection con = null;
		PreparedStatement stmt = null;
		try{
			con = DbUtil.connectToDB();
			stmt = con.prepareStatement(Constants.DELETE_BOSS);
			stmt.setInt(1, bossId);
			if(stmt.executeUpdate() > 0){
				success = true;
			}
		}catch(Exception ex){
			return false;
		}finally{
			try{
				stmt.close();
				con.close();
			}catch(Exception ex){
				
			}
		}
		return success;
	}

	public boolean delete(String ag0) {
		return false;
	}

	public Object search(Object obj) {
		return null;
	}

	public int search(String ag0, String ag1) {
		return 0;
	}

	public Object search(int id) {
		return null;
	}

	public ArrayList search(String age0) {
		return null;
	}

	public ArrayList search(int ag0, int age1) {
		return null;
	}

	/*
	 * 此方法用于
	 * 查询出所有的
	 * 供应商信息
	 * @see com.accp.oa.dao.inface.BaseDAO#search()
	 */
	public ArrayList search() {
		ArrayList bosses = new ArrayList();
		Connection con = null;
		PreparedStatement stmt = null;
		ResultSet rs = null;
		try{
			con = DbUtil.connectToDB();
			stmt = con.prepareStatement(Constants.SEARCH_ALL_BOSS);
			rs = stmt.executeQuery();
			while(rs.next()){
				Boss boss = new Boss();
				boss.setId(rs.getInt("Id"));
				boss.setName(rs.getString("Name"));
				boss.setAddress(rs.getString("Address"));
				boss.setTel(rs.getString("Tel"));
				boss.setFax(rs.getString("Fax"));
				boss.setEmail(rs.getString("Email"));
				boss.setLkname(rs.getString("Lkname"));
				boss.setLkduty(rs.getString("Lkduty"));
				boss.setLktel(rs.getString("Lktel"));
				boss.setLkhandset(rs.getString("Lkhandset"));
				bosses.add(boss);
			}
		}catch(Exception ex){
			ex.printStackTrace();
			return null;
		}finally{
			try{
				rs.close();
				stmt.close();
				con.close();
			}catch(Exception ex){
				
			}
		}
		return bosses;
	}

	/*
	 * 在此方法中对供应商信息进行编辑
	 * @see com.accp.oa.dao.inface.BaseDAO#update(java.lang.Object)
	 */
	public boolean update(Object boss) {
		boolean success = false;
		Boss objboss = (Boss)boss;
		Connection con = null;
		PreparedStatement stmt = null;
		try{
			con = DbUtil.connectToDB();
			stmt = con.prepareStatement(Constants.UPDATE_BOSS);
			stmt.setString(1, objboss.getName());
			stmt.setString(2, objboss.getAddress());
			stmt.setString(3, objboss.getTel());
			stmt.setString(4, objboss.getFax());
			stmt.setString(5, objboss.getEmail());
			stmt.setString(6, objboss.getLkname());
			stmt.setString(7, objboss.getLkduty());
			stmt.setString(8, objboss.getLktel());
			stmt.setString(9, objboss.getLkhandset());
			stmt.setInt(10, objboss.getId());
			if(stmt.executeUpdate() > 0){
				success = true;
			}
		}catch(Exception ex){
			ex.printStackTrace();
			return false;
		}finally{
			try{
				stmt.close();
				con.close();
			}catch(Exception ex){
				
			}
		}
		return success;
	}

}

⌨️ 快捷键说明

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