📄 cardsortdao.java
字号:
package com.oa.struts.perOffice.modle;
import java.sql.*;
import com.oa.struts.vo.*;
import com.oa.util.DBConn;
public class CardSortDAO {Connection con=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
DBConn db=null;
public CardSortDAO() {
super();
// TODO Auto-generated constructor stub
}
//插入名片夹
public boolean insertCardSort(CardSortInfo cs)
{
boolean result=false;
try
{
String sql="insert into tb_cardfile values(CARDF_SEQ.nextval,?,?,?)";
db=new DBConn();
con=db.getConnection();
pstmt=con.prepareStatement(sql);
pstmt.setString(1,cs.getCardfilename());
pstmt.setInt(2,cs.getIsshare());
pstmt.setInt(3,cs.getFounder());
int i=pstmt.executeUpdate();
if(i>0)
{
result=true;
}
if(pstmt!=null) pstmt.close();
if(con!=null) con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return result;
}
//显示名片夹信息
public String displayAllCardFile(int founder)
{
StringBuffer stf=new StringBuffer();
try
{
String sql="select * from tb_cardfile where founder="+founder;
db=new DBConn();
con=db.getConnection();
pstmt=con.prepareStatement(sql);
rs=pstmt.executeQuery();
stf.append("<table width='90%' border='1' align='center' class='t1'>");
stf.append("<tr>");
stf.append(" <tr class='a1'>"+
"<td colspan='4' width='25%'><strong><a href='/F-YOA/personalOffice/cardSort.jsp'>名片夹</a>|<a href='/F-YOA/personalOffice/cardSortNew.jsp'>新建名片夹</a>|<a href='/F-YOA/personalOffice/allCard.jsp'>名片</a>|<a href='/F-YOA/personalOffice/newCard.jsp'>新建名片</a></strong></td></tr>");
stf.append("</tr>");
stf.append("<tr>");
stf.append("<td>名片夹名称</td>");
stf.append("<td>是否共享</td>");
stf.append("<td>删除</td>");
stf.append("<td>修改</td>");
stf.append("</tr>");
while(rs.next())
{
int id=rs.getInt("id");
String cardfilename=rs.getString("cardfilename");
int isshare=rs.getInt("isshare");
stf.append("<tr>");
stf.append("<td>"+cardfilename+"</td>");
stf.append("<td>"+isshare+"</td>");
stf.append("<td><a href=/" +
"F-YOA/cardSort.do?action=del&id="+id+">删除</a></td>");
stf.append("<td><a href=/"+"F-YOA/personalOffice/modifyCard.jsp?id="+id+"&cardfilename="+cardfilename+"&isshare="+isshare+">修改</a></td>");
stf.append("</tr>");
}
stf.append("</table>");
//System.out.println("stf="+stf);
if(rs!=null) rs.close();
if(pstmt!=null) pstmt.close();
if(con!=null) con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return stf.toString();
}
//删除Cardfile根据id
public boolean deleteCardfile(int id)
{
boolean result=false;
try
{
String sql="delete from tb_cardfile where id=?";
db=new DBConn();
con=db.getConnection();
pstmt=con.prepareStatement(sql);
pstmt.setInt(1,id);
int i=pstmt.executeUpdate();
if(i>0)
{
result=true;
}
if(pstmt!=null) pstmt.close();
if(con!=null) con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return result;
}
//修改Cardfile
public boolean updateCardfile(CardSortInfo cs)
{
boolean result=false;
try
{
String sql="update tb_cardfile set cardfilename=?,isshare=? where id=?";
db=new DBConn();
con=db.getConnection();
pstmt=con.prepareStatement(sql);
pstmt.setString(1,cs.getCardfilename());
pstmt.setInt(2,cs.getIsshare());
pstmt.setInt(3,cs.getId());
int i=pstmt.executeUpdate();
if(i>0)
{
result=true;
}
if(pstmt!=null) pstmt.close();
if(con!=null) con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return result;
}
//根据id查询Cardfile
/*public CardSortDAO searchCardfile(int id)
{
Cardfile td=new Tdothing();
try
{
String sql="select * from tb_cardfile where id="+id;
db=new DBConn();
con=db.getConnection();
pstmt=con.prepareStatement(sql);
pstmt.setInt(1,id);
rs=pstmt.executeQuery();
String Cardfilename="";
int Isshare;
int Founder;
while(rs.next())
{
Cardfilename=rs.getString("cardfilename");
Isshare=rs.getInt("isshare");
Founder=rs.getInt("founder");
}
cs.setCardfilename(Cardfilename);
cs.setIsshare(Isshare);
cs.setFounder(Founder);
if(rs!=null) rs.close();
if(pstmt!=null) pstmt.close();
if(con!=null) con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return cs;
}
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -