日期:2014-05-17 浏览次数:21279 次
public boolean insert(Bills bill) {
		//连接数据库
		openConnection();
		String sql = "insert into bill(Bill_id,Good_name,Good_amount,Good_price," +
				"Order_status,PROVIDER_ID,Good_describe,Bill_date,unit)  " +
				"values(?,?,?,?,?,?,?,?,?)";
		boolean isInserted = false;
		try {
			ps=con.prepareStatement(sql);
			ps.setLong(1,bill.getBid());
			ps.setString(2,bill.getProductName());
			ps.setInt(3, bill.getAmount());
			ps.setDouble(4, bill.getMoney());
			ps.setString(5, bill.getIsPay());
			ps.setLong(6, bill.getSid());
			ps.setString(7, bill.getDescription());
			ps.setDate(8, bill.getTradeTime());
			ps.setString(9, bill.getUnit());
			int rows=ps.executeUpdate();
			isInserted = rows > 0 ? true:false;
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			shutdown();
		}
		return isInserted;
	}