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

📄 stcokadddao.java

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

import java.util.ArrayList;

import com.accp.oa.bean.*;
import com.accp.oa.common.*;
import com.accp.oa.dao.inface.BaseDAO;
import java.sql.*;

/*******************************************************************************
 * StcokaddDAO用于对购信息表(tb_Stcokadd)表的操作
 * 
 * @author zhaogenfei
 * 
 */
public class StcokaddDAO implements BaseDAO {
	Connection con = null;

	PreparedStatement stmt = null;

	ResultSet rs = null;

	Statement st = null;

	public static StcokaddDAO stockadddao = null;

	/**
	 * 获得StcokaddDAO的对象 返回StcokaddDAO的对象
	 */
	public static StcokaddDAO getStcokaddDAO() {
		if (stockadddao == null) {
			stockadddao = new StcokaddDAO();
		}
		return stockadddao;
	}

	/**
	 * 添加客户的采购信息
	 * @return 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_Stcokadd;
			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;
	}
	/**
	 * 获得采购信息
	 * @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();
			Stcokaddbean bean = null;
			while (rs.next()) {
				bean = new Stcokaddbean();
				bean.setId(rs.getInt("Id"));
				bean.setClientId(rs.getInt("ClientId"));
				bean.setDatetime(rs.getString("Dattime"));
				bean.setMoney(rs.getString("Item"));
				bean.setItem(rs.getString("Money"));
				bean.setRemark(rs.getString("Remark"));
				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(Object obj) {

		return false;
	}
	/**
	 * 按照客户id去删除记录
	 * @param clientid 客户id
	 * @return true删除成功 false删除失败 
	 */
	public boolean deletebyStockid(int clientid){
		try {
			String sql = Constants.DELETE_Stock;
			con = TransDAO.getConnection();
			stmt = con.prepareStatement(sql);
			stmt.setInt(1, clientid);
			stmt.executeUpdate();
		} catch (Exception ex) {
			ex.printStackTrace();
			return false;
		}
		return true;
	}
	/**
	 * 按照id去删除记录
	 * @return true删除成功 false删除失败 
	 */
	public boolean delete(int id) {
		boolean success = false;
		try {
			String sql = Constants.DELETE_Stock1;
			con = TransDAO.getConnection();
			stmt = con.prepareStatement(sql);
			stmt.setInt(1, id);
			
			int a = stmt.executeUpdate();
			if (a > 0)
				success = true;
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return success;
	}

	public boolean delete(String ag0) {

		return false;
	}

	

	public Object search(Object obj) {

		return null;
	}

	public Object search(int id) {
		// TODO Auto-generated method stub
		return null;
	}

	public ArrayList search(String age0) {
		// TODO Auto-generated method stub
		return null;
	}

	public ArrayList search(int ag0, int age1) {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean update(Object obj) {
		// TODO Auto-generated method stub
		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 + -