📄 follwdao.java
字号:
package com.accp.oa.dao.imple;
import java.sql.*;
import java.util.ArrayList;
import com.accp.oa.bean.Follwbean;
import com.accp.oa.bean.Stcokaddbean;
import com.accp.oa.common.Constants;
import com.accp.oa.common.DbUtil;
import com.accp.oa.dao.inface.BaseDAO;
public class FollwDAO implements BaseDAO {
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
Statement st = null;
public static FollwDAO follwdao = null;
/**
* 获得FollwDAO的对象 返回FollwDAO的对象
*/
public static FollwDAO getFollwDAO() {
if (follwdao == null) {
follwdao = new FollwDAO();
}
return follwdao;
}
/**
* 添加跟进信息
*/
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_Follow;
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 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();
Follwbean bean = null;
while (rs.next()) {
bean = new Follwbean();
bean.setId(rs.getInt("Id"));
bean.setStcokaddID(rs.getInt("StcokaddID"));
bean.setFollwDate(rs.getString("FollwDate"));
bean.setLinkmans(rs.getString("Linkman"));
bean.setFollwContent(rs.getString("FollwContent"));
bean.setFollwResult(rs.getString("FollwResult"));
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) {
// TODO Auto-generated method stub
return false;
}
/**
* 依据id去删除跟进信息
*/
public boolean delete(int id) {
boolean success = false;
try {
String sql = Constants.DELETE_FOLLOW1;
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_FOLLOW;
con = TransDAO.getConnection();
stmt = con.prepareStatement(sql);
stmt.setInt(1, StcokaddID);
stmt.executeUpdate();
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
}
public boolean delete(String ag0) {
// TODO Auto-generated method stub
return false;
}
public Object search(Object obj) {
// TODO Auto-generated method stub
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 + -