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 OrderSelectBean {
String s_year = "1700", s_month = "1", s_day = "1", e_year = "2099",
e_month = "1", e_day = "1", status = "0", num=null;
public void setNum(String num) {
this.num = num;
}
public void setStatus(String status) {
this.status = status;
}
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 selectOrder(String userID) {
String type1 = null;
int j = Integer.parseInt(status);
switch (j) {
case 0:
type1 = "Any";
break;
case 1:
type1 = "正在处理";
break;
case 2:
type1 = "支付成功";
break;
case 3:
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 orderid,type,price,datetime,productname from buy.order where USERID ='"+ userID + "' and orderid = "+num+"";
}else{
condition = "select orderid,type,price,datetime,productname from buy.order where USERID ='"+ userID + "' and datetime <= '"+ e_date+ "'and datetime >= '" + s_date +"'";
if(j != 0){
condition += "and type ='"+type1+"'";
}
}
System.out.println(condition);
ResultSet rs = null;
Statement sql = null;
String status, coin, date, num,name;
StringBuffer buffer = new StringBuffer();
try {
Connection conn = DBConnect.getConnection();
System.out.println(conn.isClosed());
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=" + "150" + "height=" + "25"
+ " class=" + "cal_td12" + ">订单号</td>");
buffer.append("<td width=" + "180" + "height=" + "25"
+ " class=" + "cal_td12" + ">订单状态</td>");
buffer.append("<td width=" + "150" + "height=" + "25"
+ " class=" + "cal_td12" + ">金额</td>");
buffer.append("<td width=" + "150" + "height=" + "25"
+ " class=" + "cal_td12" + ">订单创建时间</td>");
buffer.append("<td width=" + "150" + "height=" + "25"
+ " class=" + "cal_td12" + ">订购商品名称</td>");
buffer.append("</TR>");
while (rs.next()) {
buffer.append("<tr align=" + "center" + ">");
if (i % 2 == 1) {
//取得结果集中一条记录的第一个字段,付给num
num = rs.getString(1);
buffer.append("<TD width=" + 180 + " height=" + "20"
+ " class=" + "cal_td06" + ">" + num
+ "</TD>");
// 取得结果集中一条记录的第一个字段,付给num
status = rs.getString(2);
buffer.append("<TD width=" + 150 + " height=" + "20"
+ " class=" + "cal_td06" + ">" + status
+ "</TD>");
// 取得结果集中一条记录的第一个字段,付给num
coin = rs.getString(3);
buffer.append("<TD width=" + 150 + " height=" + "20"
+ " class=" + "cal_td06" + ">" + coin
+ "</TD>");
// 取得结果集中一条记录的第一个字段,付给num
date = rs.getString(4);
buffer.append("<TD width=" + 150 + " height=" + "20"
+ " class=" + "cal_td06" + ">" + date
+ "</TD>");
// 取得结果集中一条记录的第一个字段,付给num
name = rs.getString(5);
buffer.append("<TD width=" + 150 + " height=" + "20"
+ " class=" + "cal_td06" + ">" + name
+ "</TD>");
} else {
// 取得结果集中一条记录的第一个字段,付给num
num = rs.getString(1);
buffer.append("<TD width=" + 180 + " height=" + "20"
+ " class=" + "cal_td08" + ">" + num
+ "</TD>");
// 取得结果集中一条记录的第一个字段,付给num
status = rs.getString(2);
buffer.append("<TD width=" + 150 + " height=" + "20"
+ " class=" + "cal_td08" + ">" + status
+ "</TD>");
// 取得结果集中一条记录的第一个字段,付给num
coin = rs.getString(3);
buffer.append("<TD width=" + 150 + " height=" + "20"
+ " class=" + "cal_td08" + ">" + coin
+ "</TD>");
// 取得结果集中一条记录的第一个字段,付给num
date = rs.getString(4);
buffer.append("<TD width=" + 150 + " height=" + "20"
+ " class=" + "cal_td08" + ">" + date
+ "</TD>");
// 取得结果集中一条记录的第一个字段,付给num
name = rs.getString(5);
buffer.append("<TD width=" + 150 + " height=" + "20"
+ " class=" + "cal_td08" + ">" + name
+ "</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;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
J2EE源代码ch01
共31个文件
class:7个
java:7个
jsp:5个
需积分: 0 3 下载量 55 浏览量
2008-10-25
22:03:28
上传
评论
收藏 1.44MB RAR 举报
温馨提示
精通J2EE源代码-ch01 人民邮电出版社 叶磊
资源详情
资源评论
资源推荐
收起资源包目录
Buy.rar (31个子文件)
Buy
src
com
buy
bean
comm
database
Config.java 784B
DBConnect.java 774B
config.properties 126B
coin
ConsumeSelectBean.java 4KB
UsercoinSelectBean.java 1KB
AddcoinSelectBean.java 4KB
ConsumeSelectBean1.java 1KB
OrderSelectBean.java 5KB
.project 1KB
WebRoot
Buy
style
cal
rightcal_style01.css 15KB
style.css 14KB
scripts
images
Thumbs.db 4KB
META-INF
MANIFEST.MF 39B
WEB-INF
web.xml 329B
classes
com
buy
bean
comm
database
DBConnect.class 1KB
Config.class 2KB
config.properties 126B
coin
ConsumeSelectBean1.class 2KB
AddcoinSelectBean.class 4KB
UsercoinSelectBean.class 2KB
OrderSelectBean.class 5KB
ConsumeSelectBean.class 4KB
lib
mysql-connector-java-3.1.12-bin.jar 436KB
classes12.jar 1.07MB
COIN
order.jsp 9KB
addcoinrecord.jsp 8KB
consumerecord.jsp 8KB
left.jsp 2KB
usercoin.jsp 4KB
.mymetadata 282B
.classpath 506B
.myeclipse
共 31 条
- 1
sjliu1202
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0