op_buy.java类:
package cdshop.run;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @Singer not attributable
* @version 1.0
*/
import java.sql.*;
import java.util.Vector;
import cdshop.util.*;
import cdshop.cd.*;
import javax.servlet.http.*;
import java.util.*;
public class op_buy extends DataBase {
private javax.servlet.http.HttpServletRequest request; //建立页面请求
private HttpSession session; //页面的session;
private boolean sqlflag = true; //对接收到的数据是否正确
private Vector purchaselist; //显示CD列表向量数组
private Vector allorder; //订购单列表
private Vector order_list; //订单清单列表
private int cdnumber = 0; //购买CD总数量
private float all_price = 0; //购买CD总价钱
private boolean isEmpty = false; //库中的CD数量是否够购买的数
private int leavecd = 0; //库存数量
private String orderId = ""; //用户订单号
private boolean isLogin = true; //用户是否登录!
private int page = 1; //显示的页码
private int pageSize = 15; //每页显示的订单数
private int pageCount = 0; //页面总数
private long recordCount = 0; //查询的记录总数
Calendar date = Calendar.getInstance();
long time=date.getTimeInMillis();
public op_buy() {
super();
}
public Vector getPurchaselist() {
return purchaselist;
}
public Vector getOrder_list() {
return order_list;
}
public Vector getAllorder() {
return allorder;
}
public boolean getSqlflag() {
return sqlflag;
}
public void setIsEmpty(boolean flag) {
isEmpty = flag;
}
public boolean getIsEmpty() {
return isEmpty;
}
public void setLeavecd(int bknum) {
leavecd = bknum;
}
public int getLeavecd() {
return leavecd;
}
public void setOrderId(String newId) {
orderId = newId;
}
public String getOrderId() {
return orderId;
}
public void setIsLogin(boolean flag) {
isLogin = flag;
}
public boolean getIsLogin() {
return isLogin;
}
public int getPage() { //显示的页码
return page;
}
public void setPage(int newpage) {
page = newpage;
}
public int getPageSize() { //每页显示的图书数
return pageSize;
}
public void setPageSize(int newpsize) {
pageSize = newpsize;
}
public int getPageCount() { //页面总数
return pageCount;
}
public void setPageCount(int newpcount) {
pageCount = newpcount;
}
public long getRecordCount() {
return recordCount;
}
public void setRecordCount(long newrcount) {
recordCount = newrcount;
}
public String getGbk(String str) {
try {
return new String(str.getBytes("ISO8859-1"));
}
catch (Exception e) {
return str;
}
}
public String getSql() {
sqlStr = "select id,classname from cd order by id";
return sqlStr;
}
/**
* 往购物车中添加选购的图书
* @param newrequest
* @return
*/
public boolean addnew(HttpServletRequest newrequest) {
request = newrequest;
String ID = request.getParameter("cdid");
String Amount = request.getParameter("amount");
long cdid = 0;
int amount = 0;
try {
cdid = Long.parseLong(ID);
amount = Integer.parseInt(Amount);
}
catch (Exception e) {
return false;
}
if (amount < 1)
return false;
session = request.getSession(false);
if (session == null) {
return false;
}
purchaselist = (Vector) session.getAttribute("shopcar");
sqlStr = "select leav_number from cd where id=" + cdid;
try {
DataBase db = new DataBase();
db.connect();
stmt = db.conn.createStatement ();
rs = stmt.executeQuery(sqlStr);
if (rs.next()) {
if (amount > rs.getInt(1)) {
leavecd = rs.getInt(1);
isEmpty = true;
return false;
}
}
close();
}
catch (SQLException e) {
return false;
}
allorder iList = new allorder();
iList.setcdNo(cdid);
iList.setAmount(amount);
boolean match = false; //是否购买过该图书
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>