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

📄 applydao.java

📁 招标网站
💻 JAVA
字号:
package com.jblack.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;


import com.jblack.model.Tapply;
import com.jblack.model.Tpublish;
import com.jblack.tool.DBConnection;

public class ApplyDAO {
	private DBConnection dbConn= new DBConnection(); 
	private SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
	
	public List<Tpublish> query(String sql) {
		List<Tpublish> list = new ArrayList<Tpublish>();
		ResultSet rs = dbConn.executeQuery(sql);
		if (rs != null) {
			try {
				while (rs.next()) {
					list.add(new Tpublish(rs.getInt("TP_id"), rs.getInt("TC_id"),
							rs.getInt("TP_winner"),rs.getString("TP_name"), 
							rs.getDouble("TP_initPrice"), rs.getDouble("TP_modPrice"),
							rs.getString("TP_description"), rs.getDate("TP_pubDate"),
							rs.getDate("TP_deadline"),rs.getDate("TP_gameDate"),
							rs.getDate("TP_gameDeadline"),rs.getInt("TP_status")));
					
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		dbConn.close();
		return list;
		
	}
	
	public List<Tapply> aquery(String sql) {
		List<Tapply> list = new ArrayList<Tapply>();
		ResultSet rs = dbConn.executeQuery(sql);
		if (rs != null) {
			try {
				while (rs.next()) {
					list.add(new Tapply(rs.getInt("TA_id"), rs.getInt("TC_id"),
							rs.getInt("TP_id"),rs.getDate("TA_applyDate"),rs.getInt("TA_status")));
					
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		dbConn.close();
		return list;
		
	}
	
	public int save(Tapply s) {	
		String sql = "insert into tapply (TC_id,TP_id,TA_applyDate,TA_status) values ("
			+ s.getTcid()
			+ ", "
			+ s.getTpid()
			+ ", date('"
			+ date.format(s.getTaapplydate())
			+ "'),"
			+ s.getTastatus() + ")";

		int num = dbConn.insertAndGetPKKey(sql);
		dbConn.close();
		return num;
	}
	public Tapply get(int no) {
		Tapply s = null;
		ResultSet rs = dbConn
				.executeQuery("select * from tapply where TA_id=" + no);
		try {
			while (rs.next()) {
				s = new Tapply(rs.getInt("TA_id"), rs.getInt("TC_id"),
						rs.getInt("TP_id"),rs.getDate("TA_applyDate"),rs.getInt("TA_status"));
						
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			dbConn.close();
		}
		return s;
	}


}

⌨️ 快捷键说明

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