}
return true;
}
catch (SQLException e) {
System.out.print(e.getMessage());
return false;
}
}
/**
* 查询指定用户id的所有订单
* @param userid
* @return
*/
public boolean getOrder(long userid) {
sqlStr = "select * from orders where userid = '" + userid +
"' order by id desc";
try {
DataBase db = new DataBase();
db.connect();
stmt = db.conn.createStatement ();
rs = stmt.executeQuery(sqlStr);
allorder = new Vector();
while (rs.next()) {
order ind = new order();
ind.setId(rs.getLong("id"));
ind.setOrderId(rs.getString("orderId"));
ind.setUserId(rs.getLong("userid"));
ind.setSubmitTime(rs.getString("submitTime"));
ind.setConsignmentTime(rs.getString("ConsignmentTime"));
ind.setTotalPrice(rs.getFloat("TotalPrice"));
ind.setContent(rs.getString("content"));
ind.setIPAddress(rs.getString("IpAddress"));
if (rs.getInt("IsPayoff") == 1)
ind.setIsPayoff(false);
else
ind.setIsPayoff(true);
if (rs.getInt("IsSales") == 1)
ind.setIsSales(false);
else
ind.setIsSales(true);
allorder.addElement(ind);
}
close();
return true;
}
catch (SQLException e) {
return false;
}
}
/**
* 查询指定订单编号的订单
* @param iid
* @return
*/
public boolean getSinggleOrder(String order_id) {
sqlStr = "select * from orders where orderId = '" + order_id +
"' ";
try {
DataBase db = new DataBase();
db.connect();
stmt = db.conn.createStatement ();
rs = stmt.executeQuery(sqlStr);
allorder = new Vector();
while (rs.next()) {
order ind = new order();
ind.setId(rs.getLong("id"));
ind.setOrderId(rs.getString("orderId"));
ind.setUserId(rs.getLong("userid"));
ind.setSubmitTime(rs.getString("submitTime"));
ind.setConsignmentTime(rs.getString("ConsignmentTime"));
ind.setTotalPrice(rs.getFloat("TotalPrice"));
ind.setContent(rs.getString("content"));
ind.setIPAddress(rs.getString("IpAddress"));
if (rs.getInt("IsPayoff") == 1)
ind.setIsPayoff(false);
else
ind.setIsPayoff(true);
if (rs.getInt("IsSales") == 1)
ind.setIsSales(false);
else
ind.setIsSales(true);
allorder.addElement(ind);
System.out.print("allorder:"+allorder.size());
}
close();
return true;
}
catch (SQLException e) {
System.out.print(e.getMessage());
return false;
}
}
/**
* 查询商店的所有订单数据
* @return
*/
public boolean getOrder() {
sqlStr = "select count(*) from orders"; //取出记录数
int rscount = pageSize;
try {
DataBase db = new DataBase();
db.connect();
stmt = db.conn.createStatement ();
ResultSet rs1 = stmt.executeQuery(sqlStr);
if (rs1.next())
recordCount = rs1.getInt(1);
rs1.close();
}
catch (SQLException e) {
return false;
}
//设定有多少pageCount
if (recordCount < 1)
pageCount = 0;
else
pageCount = (int) (recordCount - 1) / pageSize + 1;
//检查查看的页面数是否在范围内
if (page < 1)
page = 1;
else if (page > pageCount)
page = pageCount;
rscount = (int) recordCount % pageSize; // 最后一页记录数
//sql为倒序取值
sqlStr = "select * from orders ";
if (page == 1) {
sqlStr = sqlStr + " order by Id desc";
}
else {
sqlStr = sqlStr + " order by Id desc limit "+(recordCount - pageSize * page) +","+ (recordCount - pageSize * (page - 1));
}
try {
DataBase db = new DataBase();
db.connect();
stmt = db.conn.createStatement ();
rs = stmt.executeQuery(sqlStr);
allorder = new Vector();
while (rs.next()) {
order ind = new order();
ind.setId(rs.getLong("id"));
ind.setOrderId(rs.getString("orderid"));
ind.setUserId(rs.getLong("userid"));
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>