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

📄 .#perofficedao.java.1.5

📁 实现办公自动化系统
💻 5
字号:
package com.oa.struts.perOffice.modle;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import com.oa.util.DBConn;

public class PerOfficeDAO 
{
	Connection con=null;
	PreparedStatement pstmt=null;
	ResultSet rs=null;
	DBConn db=null;
    
	public PerOfficeDAO() {
		super();
		// TODO Auto-generated constructor stub
	}	
	//插入待办事项
	public boolean insertItem(Tdothing thing)
	{
		boolean result=false;
		try
		{
			String sql="insert into tb_toDo values(?,?)";
			db=new DBConn();
			con=db.getConnection();
			pstmt=con.prepareStatement(sql);
			pstmt.setString(1,thing.getTopic());
			pstmt.setString(2,thing.getContet());
			
		
			int i=pstmt.executeUpdate();
			System.out.println("i="+i);
			if(i>0)
			{
				result=true;
			}
				
			if(pstmt!=null) pstmt.close();
			if(con!=null) con.close();		
			
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
		return result;
}
	
	//修改待办事项
	public int updateItem(String topic,String content,int id)
	{
		int i=0;
		try
		{
			String sql="update tb_toDo set topic=?,content=? where id=?";
			db=new DBConn();
			con=db.getConnection();
			pstmt=con.prepareStatement(sql);
			pstmt.setString(1,topic);
			pstmt.setString(2,content);
			pstmt.setInt(3,id);
     
				
			i=pstmt.executeUpdate();
			if(i>0)
			{
				i=1;
			}
				
			if(pstmt!=null) pstmt.close();
			if(con!=null) con.close();		
			
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
		return i;
	}
	
	//删除待办事项
	public int deleteItem(int id)
	{
		int i=0;
		try
		{
			String sql="delete from tb_toDo where id=?";
			db=new DBConn();
			con=db.getConnection();
			pstmt=con.prepareStatement(sql);
			pstmt.setInt(1,id);
			i=pstmt.executeUpdate();
			if(i>0)
			{
				i=1;
			}
				
			if(pstmt!=null) pstmt.close();
			if(con!=null) con.close();		
			
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
		return i;
	
	}
	
	//显示所有的待办事项
	
	public List allItem(int founder)
	{
		Tdothing thing=new Tdothing();
		List list=new ArrayList();
		try
		{
			String sql="select * from tb_toDo";
			db=new DBConn();
			con=db.getConnection();
			pstmt=con.prepareStatement(sql);
			rs=pstmt.executeQuery();
			String topic="";
			String content="";
			int id;
			int complete;
			while(rs.next())
			{
				id=rs.getInt(1);
				topic=rs.getString(2);
				content=rs.getString(3);
				thing.setID(id);
				thing.setTopic(topic);
				thing.setContet(content);
				list.add(thing);
			}
			
			
			
			if(rs!=null) rs.close();
			if(pstmt!=null) pstmt.close();
			if(con!=null) con.close();		
			
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}	
		return list;
	}
}

⌨️ 快捷键说明

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