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

📄 calldao.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.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import com.accp.oa.bean.Callbean;
import com.accp.oa.bean.Needbean;
import com.accp.oa.common.*;
import com.accp.oa.dao.inface.BaseDAO;

public class CallDAO implements BaseDAO {
	Connection con = null;

	PreparedStatement stmt = null;

	ResultSet rs = null;

	Statement st = null;

	public static CallDAO calldao = null;

	/**
	 * 获得CallDAO的对象
	 * 
	 * @return
	 */
	public static CallDAO getCallDAO() {
		if (calldao == null) {
			calldao = new CallDAO();
		}
		return calldao;
	}

	public CallDAO() {
	}

	/**
	 * 添加回访信息 true 为成功 false为失败
	 */
	public boolean add(Object obj) {
		boolean success = false;
		ArrayList list = (ArrayList) obj;
		int id = Integer.parseInt((String) list.get(0));
		try {
			String sql = Constants.ADD_Call;
			con = DbUtil.connectToDB();
			stmt = con.prepareStatement(sql);
			stmt.setInt(1, id);
			stmt.setString(2, list.get(1).toString());
			stmt.setString(3, list.get(2).toString());
			stmt.setString(4, list.get(3).toString());
			stmt.setString(5, list.get(4).toString());
			int a = stmt.executeUpdate();
			if (a > 0)
				success = true;
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			try {
				if (rs != null)
					rs.close();
				if (stmt != null) {
					stmt.close();
				}
				if (con != null) {
					con.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return success;
	}

	public boolean delete(Object obj) {

		return false;
	}

	/**
	 * /** 删除回访信息 true 为成功 false为失败
	 */
	public boolean delete(int id) {
		boolean success = false;
		try {
			String sql = Constants.DELETE_Call;
			con = DbUtil.connectToDB();
			stmt = con.prepareStatement(sql);
			stmt.setInt(1, id);
			int a = stmt.executeUpdate();
			if (a > 0)
				success = true;
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			try {
				if (rs != null)
					rs.close();
				if (stmt != null) {
					stmt.close();
				}
				if (con != null) {
					con.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return success;
	}
	/**
	 * 依据StcokaddID去删除信息
	 * @param id
	 * @return
	 */
	public boolean deletebyStockid(int StcokaddID){
		try {
			String sql = Constants.DELETE_Call1;
			con = TransDAO.getConnection();
			stmt = con.prepareStatement(sql);
			stmt.setInt(1, StcokaddID);
			stmt.executeUpdate();
		} catch (Exception ex) {
			ex.printStackTrace();
			return false;
		}
		return true;
	}
	/**
	 * 查询回访记录
	 * 
	 * @param num
	 *            查找的页数
	 * @param tablename
	 *            查找的表名
	 * @param selectname
	 *            查找的id
	 * @return 集合
	 */
	public ArrayList search(String num, String tablename, String selectname) {
		ArrayList list = new ArrayList();
		if (num == null || null == "")
			num = "1";
		int number = Integer.parseInt(num);
		
		String sql = commonDAO.GetcomonDAO().getSQL(number, tablename,
				selectname);
		if (number <= 0 || number > commonDAO.GetcomonDAO().gettatolpage()) {
			return null;
		}
		try {
			con = DbUtil.connectToDB();
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		try {
			stmt = con.prepareStatement(sql);
			rs = stmt.executeQuery();
			Callbean bean = null;
			while (rs.next()) {
				bean = new Callbean();
				bean.setId(rs.getInt("Id"));
				bean.setStcokaddID(rs.getInt("StcokaddID"));
				bean.setCallDate(rs.getString("CallDate"));
				bean.setCallConent(rs.getString("CallConent"));
				bean.setCallResult(rs.getString("CallResult"));
				bean.setProblemResult(rs.getString("ProblemResult"));
				list.add(bean);
			}
			commonDAO.GetcomonDAO().setpagenumber(number);
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				if (rs != null)
					rs.close();
				if (stmt != null) {
					stmt.close();
				}
				if (con != null) {
					con.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return list;
	}

	public boolean delete(String ag0) {

		return false;
	}

	

	public Object search(Object obj) {

		return null;
	}

	public Object search(int id) {

		return null;
	}

	public ArrayList search(String age0) {

		return null;
	}

	public ArrayList search(int ag0, int age1) {

		return null;
	}

	public boolean update(Object obj) {

		return false;
	}

	public ArrayList search() {
		// TODO 自动生成方法存根
		return null;
	}

	public int search(String ag0, String ag1) {
		// TODO 自动生成方法存根
		return 0;
	}

}

⌨️ 快捷键说明

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