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

📄 addcoinselectbean.java

📁 jspjava实现的购物系统
💻 JAVA
字号:
package com.buy.bean.coin;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.buy.bean.comm.database.DBConnect;
public class AddcoinSelectBean {
	String s_year= "1700", s_month = "1", s_day= "1", e_year= "2099" ,e_month= "1" ,e_day= "1",type="0",num=null;
	
	public AddcoinSelectBean(){
		
	}
	public void setNum(String num) {
		this.num = num;
	}
	
	public void setType(String type){
		this.type = type;
	}
	public void setS_year(String s_year) {
		this.s_year = s_year;
	}
	
	public void setS_month(String s_month) {
		this.s_month = s_month;
	}
	
	public void setS_day(String s_day) {
		this.s_day = s_day;
	}
	public void setE_year(String e_year) {
		this.e_year = e_year;
	}
	
	public void setE_month(String e_month) {
		this.e_month = e_month;
	}
	public void setE_day(String e_day) {
		this.e_day = e_day;
	}
	public StringBuffer selectAddcoin(String userID){
		String type1 = null;
		int j = Integer.parseInt(type);
		switch (j){
		case 0:
			type1 = "Any";break;
		case 1:
			type1 = "在线充值";break;
		case 2:
			type1 = "个人银行充值";break;
		case 3:
			type1 = "代理充值";break;
		case 4:
			type1 = "汇款充值";break;
		}
		String s_date = s_year + "-" + s_month + "-" + s_day;
		String e_date = e_year + "-" + e_month + "-" + e_day;
		String condition;
		
		if(num!=null){
			condition = "select addid,type,coin,datetime from buy.add where USERID ='"+ userID + "' and addid = "+num+""; 
		}else{
			condition = "select addid,type,coin,datetime from buy.add where USERID ='"+ userID + "' and datetime <= '"+ e_date+ "'and datetime >= '" + s_date +"'";
			
			if(j != 0){
				condition +=  "and type ='"+type1+"'";  
			}
		}	
		ResultSet rs = null;
		String type, coin, date,num;
		Statement sql = null;
		StringBuffer buffer = new StringBuffer();
		try {
			Connection conn = DBConnect.getConnection();
			sql = conn.createStatement();
			rs = sql.executeQuery(condition);
			int i = 1;	
			buffer.append("<table width="+"100%"+" border="+"0"+" cellpadding="+"0"+" cellspacing="+"1"+">");
			buffer.append("<tr align=" + "center" + ">");
			buffer.append("<td width=" + "190" + "height=" + "25" + " class="
					+ "cal_td12" + ">充值编号</td>");
			buffer.append("<td width=" + "190" + "height=" + "25" + " class="
					+ "cal_td12" + ">充值类型</td>");
			buffer.append("<td width=" + "190" + "height=" + "25" + " class="
					+ "cal_td12" + ">充值金额</td>");
			buffer.append("<td height=" + "25" + " class="
					+ "cal_td12" + ">充值时间</td>");
			buffer.append("</TR>");
			while (rs.next()) {
				buffer.append("<tr align=" + "center" + ">");
				num = rs.getString(1);//取得第一个字段的值
				if(i%2==1){//根据奇偶行显示不同的样式
				buffer.append("<TD height=" + "20"
						+ " class=" + "cal_td06" + ">" + num + "</TD>");
				type = rs.getString(2);//取得第二个字段的值
				buffer.append("<TD height=" + "20"
						+ " class=" + "cal_td06" + ">" + type + "</TD>");
				coin = rs.getString(3);//取得第三个字段的值
				buffer.append("<TD height=" + "20"
						+ " class=" + "cal_td06" + ">" + coin + "</TD>");
				date = rs.getString(4);//取得第四个字段的值
				buffer.append("<TD height=" + "20"
						+ " class=" + "cal_td06" + ">" + date + "</TD>");
				}else{//偶数行的显示
					buffer.append("<TD height=" + "20"
							+ " class=" + "cal_td08" + ">" + num + "</TD>");
					type = rs.getString(2);
					buffer.append("<TD height=" + "20"
							+ " class=" + "cal_td08" + ">" + type + "</TD>");
					coin = rs.getString(3);
					buffer.append("<TD height=" + "20"
							+ " class=" + "cal_td08" + ">" + coin + "</TD>");
					date = rs.getString(4);
					buffer.append("<TD height=" + "20"
							+ " class=" + "cal_td08" + ">" + date + "</TD>");
				}
				buffer.append("</TR>");
				i++;
			}
			buffer.append("</Table>");
			rs.close();
			sql.close();
			conn.close();
		} catch (SQLException ex) {
			System.out.println("TradeDB SQLException: " + ex.getMessage());
			return new StringBuffer("查询错误");
		}
		return buffer;
	}
}

⌨️ 快捷键说明

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