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

📄 typedao.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.Roes;
import com.accp.oa.common.Constants;
import com.accp.oa.common.DbUtil;
import com.accp.oa.dao.inface.*;
import com.accp.oa.bean.*;

/*
 * 此类用于
 * 对物资类型表进
 * 行操作
 */
public class TypeDAO implements BaseDAO {

	/*
	 * 此方法用于添加物资类型
	 * @see com.accp.oa.dao.inface.BaseDAO#add(java.lang.Object)
	 */
	public boolean add(Object type) {
		boolean success = false;
		Type objtype = (Type)type;
		Connection con = null;
		PreparedStatement stmt = null;
		try{
			con = DbUtil.connectToDB();
			stmt = con.prepareStatement(Constants.ADD_TYPE);
			stmt.setString(1, objtype.getTypeName());
			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(Object obj) {
		return false;
	}

	/*
	 * 此方法用于删除
	 * 物资类型
	 * @see com.accp.oa.dao.inface.BaseDAO#delete(int)
	 */
	public boolean delete(int typeId) {
		boolean success = false;
		Connection con = null;
		PreparedStatement stmt = null;
		try{
			con = DbUtil.connectToDB();
			stmt = con.prepareStatement(Constants.DELETE_TYPE);
			stmt.setInt(1, typeId);
			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 types = new ArrayList();
		Connection con = null;
		PreparedStatement stmt = null;
		ResultSet rs = null;
		try{
			con = DbUtil.connectToDB();
			stmt = con.prepareStatement(Constants.SEARCH_ALL_TYPE);
			rs = stmt.executeQuery();
			while(rs.next()){
				Type type = new Type();
				type.setId(rs.getInt("Id"));
				type.setTypeName(rs.getString("Types"));
				types.add(type);
			}
		}catch(Exception ex){
			return null;
		}finally{
			try{
				rs.close();
				stmt.close();
				con.close();
			}catch(Exception ex){
				
			}
		}
		return types;
	}

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

⌨️ 快捷键说明

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