📄 managerproduct.java
字号:
public String SearchTurn_UnderCatalogPro(Hashtable APageParam,String SelfPage,int Cid,String Catalog_f,String Catalog_s) throws Exception {
String turnpage_str="";
int i,j;
int nextpage = Integer.parseInt(java.lang.String.valueOf(APageParam.get("nextpage")));
int prevpage = Integer.parseInt(java.lang.String.valueOf(APageParam.get("prevpage")));
int pagesize = Integer.parseInt(java.lang.String.valueOf(APageParam.get("pagesize")));
int pagecount = Integer.parseInt(java.lang.String.valueOf(APageParam.get("pagecount")));
int pagecount2 = Integer.parseInt(java.lang.String.valueOf(APageParam.get("pagecount2")));
int page_inside = Integer.parseInt(java.lang.String.valueOf(APageParam.get("page1")));
int page2 = Integer.parseInt(java.lang.String.valueOf(APageParam.get("page2")));
//--- 显示搜索引擎 ---
turnpage_str += "<table width=100% border=0 cellspacing=0 cellpadding=0 align=right>";
turnpage_str += " <tr> ";
turnpage_str += " <td align=center valign=middle>";
turnpage_str += " <table><tr><td align=center valign=middle width=30%>";
turnpage_str += " <SELECT onchange=\"var jmpURL1=this.options[this.selectedIndex].value; if(jmpURL1!='') {self.location=jmpURL1;} else {this.selectedIndex=0;}\" size=1 name=select>";
turnpage_str += " <option value=''>选择翻页</option>";
for (i=0; i<pagecount; i++) {
j = i + 1;
turnpage_str += " <option value=" + SelfPage + "?CurrentPage=" + i + "&Cid=" + Cid + "&Catalog_f=" + Catalog_f + "&Catalog_s=" + Catalog_s + ">第 " + j + " 页</option>";
}
turnpage_str += " </select>";
turnpage_str += " </td>";
turnpage_str += " <td align=center valign=middle width=20%>";
turnpage_str += " 当前页:" + page2 + "/" + pagecount;
turnpage_str += " </td>";
//--- 显示翻页按钮 ---
turnpage_str = turnpage_str + " <td align=center valign=middle width=40% style='font-family:Webdings'>";
if (pagecount != 0) turnpage_str = turnpage_str + "<a href=" + SelfPage + "?CurrentPage=0&Cid=" + Cid + "&Catalog_f=" + Catalog_f + "&Catalog_s=" + Catalog_s + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">7</a> ";
else turnpage_str = turnpage_str + "7 ";
if (page_inside != 0) turnpage_str = turnpage_str + "<a href=" + SelfPage + "?CurrentPage=" + prevpage + "&Cid=" + Cid + "&Catalog_f=" + Catalog_f + "&Catalog_s=" + Catalog_s + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">3</a>";
else turnpage_str += "3";
if (page_inside != pagecount2 && pagecount != 0) turnpage_str = turnpage_str + " <a href=" + SelfPage + "?CurrentPage=" + nextpage + "&Cid=" + Cid + "&Catalog_f=" + Catalog_f + "&Catalog_s=" + Catalog_s + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">4</a> ";
else turnpage_str = turnpage_str + " 4 ";
int t_pagecount = pagecount-1;
if (pagecount != 0) turnpage_str = turnpage_str + "<a href=" + SelfPage + "?CurrentPage=" + t_pagecount + "&Cid=" + Cid + "&Catalog_f=" + Catalog_f + "&Catalog_s=" + Catalog_s + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">8</a>";
else turnpage_str = turnpage_str + "8";
turnpage_str += "</td></tr></table>";
turnpage_str += " </td>";
turnpage_str += " </tr>";
turnpage_str += " </table>";
turnpage_str += " </td>";
turnpage_str += " </tr>";
turnpage_str += "</table>";
return(turnpage_str);
}
//--- 统计信息 ---
public String StatInfo(String tb_shop_product_info,String tb_member_info) throws Exception {
String SqlStr,HtmlStr="";
ResultSet rs;
int ProductSum=0,MemberSum=0;
try {
SqlStr = "SELECT * FROM " + tb_shop_product_info;
rs = dbconn.ExeQuery(SqlStr);
rs.last();
ProductSum = rs.getRow();
SqlStr = "SELECT * FROM " + tb_member_info;
rs = dbconn.ExeQuery(SqlStr);
rs.last();
MemberSum = rs.getRow();
dbconn.CloseConn();
}
catch (SQLException ex) {
System.err.println("aq.executeQuery:"+ex.getMessage());
}
HtmlStr += "<tr bgcolor=eeeeee> ";
HtmlStr += " <td width=54%>商品总数:</td>";
HtmlStr += " <td width=46% align=center valign=middle>" + ProductSum + "</td>";
HtmlStr += "</tr>";
HtmlStr += "<tr bgcolor=eeeeee> ";
HtmlStr += " <td>注册会员:</td>";
HtmlStr += " <td align=center valign=middle>" + MemberSum + "</td>";
HtmlStr += "</tr>";
return(HtmlStr);
}
//--- 增加点击 ---
public void AddClick(String tb_shop_product_info,int Pid) throws Exception {
String SqlStr = "UPDATE " + tb_shop_product_info + " SET click=click+1 WHERE id=" + Pid;
dbconn.ExeUpdate(SqlStr);
dbconn.CloseConn();
}
//--- 搜索商品 ---
public Hashtable getSearchResultVector(HttpServletRequest request,int pagesize,String SelfPage,String tb_shop_product_info) throws Exception {
String qry_string;
String HtmlStr="";
String str_rows_count;
String img_path,name,description;
int rows_count = 0;
int ii=0;
int Pid;
float price;
Statement stmt;
ResultSet rs;
Hashtable APageParam = new Hashtable();
Hashtable AOutParam = new Hashtable();
String page = handle.getString(request,"CurrentPage","0");
String keyword = handle.getString(request,"keyword");
keyword = handle.GBK2ISO(keyword);
String type = handle.getString(request,"type");
try {
if (type.equals("name")) qry_string = "SELECT * FROM " + tb_shop_product_info + " WHERE name LIKE '%" + keyword + "%' ORDER BY id DESC";
else qry_string = "SELECT * FROM " + tb_shop_product_info + " WHERE description LIKE '%" + keyword + "%' ORDER BY id DESC";
rs = dbconn.ExeQuery(qry_string);
rs.last();
rows_count = rs.getRow();
APageParam = turn_page(page, pagesize, rows_count);
int pt_st = Integer.parseInt(java.lang.String.valueOf(APageParam.get("pt_st"))) + 1;
int pt_en = Integer.parseInt(java.lang.String.valueOf(APageParam.get("pt_en"))) + 1;
rs.absolute(pt_st);
for (ii=pt_st; ii<pt_en; ii++) {
Pid = rs.getInt("id");
img_path = rs.getString("img_path");
name = rs.getString("name");
description = rs.getString("description");
if (description.length() > 150) {
description = description.substring(0,150);
description += "......";
}
price = rs.getFloat("price");
HtmlStr += "<table width=571 height=100 border=0 cellpadding=0 cellspacing=0>";
HtmlStr += "<tr>";
HtmlStr += "<td width=138 align=center valign=middle><a href=../../DetailProInfo.jsp?Pid=" + Pid + "><img src=../../" + img_path + " width=80 height=80 border=1></a></td>";
HtmlStr += "<td width=433 align=center valign=top><table width=100% height=78 border=0 cellpadding=3 cellspacing=0>";
HtmlStr += "<tr> ";
HtmlStr += "<td><font color=#0000FF>商品名称:</font>" + name + "</td>";
HtmlStr += "</tr>";
HtmlStr += "<tr> ";
HtmlStr += "<td height=18><font color=#0000FF>商品价格:<font color=red> ¥" + price + "</font></font></td>";
HtmlStr += "</tr>";
HtmlStr += "<tr> ";
HtmlStr += "<td height=25><font color=#0000FF>商品简介:</font><br>" + description + "</td>";
HtmlStr += "</tr>";
HtmlStr += "</table></td>";
HtmlStr += "</tr>";
HtmlStr += "</table>";
HtmlStr += "<table width=571 height=1 border=0 cellpadding=0 cellspacing=0>";
HtmlStr += "<tr>";
HtmlStr += "<td width=601 bgcolor=#000000></td>";
HtmlStr += "</tr>";
HtmlStr += "</table>";
if (!rs.next()) break;
}
dbconn.CloseConn();
}
catch(SQLException ex) {
System.err.println("aq.executeQuery:"+ex.getMessage());
}
String turnpage_str = searchNavigation(APageParam,SelfPage,keyword,type);
AOutParam.put("RecordCount",java.lang.String.valueOf(rows_count));
AOutParam.put("HtmlStr",HtmlStr);
AOutParam.put("TurpageStr",turnpage_str);
return(AOutParam);
}
public String searchNavigation(Hashtable APageParam,String SelfPage,String keyword,String type) throws Exception {
String turnpage_str="";
int i,j;
int nextpage = Integer.parseInt(java.lang.String.valueOf(APageParam.get("nextpage")));
int prevpage = Integer.parseInt(java.lang.String.valueOf(APageParam.get("prevpage")));
int pagesize = Integer.parseInt(java.lang.String.valueOf(APageParam.get("pagesize")));
int pagecount = Integer.parseInt(java.lang.String.valueOf(APageParam.get("pagecount")));
int pagecount2 = Integer.parseInt(java.lang.String.valueOf(APageParam.get("pagecount2")));
int page_inside = Integer.parseInt(java.lang.String.valueOf(APageParam.get("page1")));
int page2 = Integer.parseInt(java.lang.String.valueOf(APageParam.get("page2")));
keyword = handle.ISO2GBK(keyword);
//--- 显示搜索引擎 ---
turnpage_str += "<table width=100% border=0 cellspacing=0 cellpadding=0 align=right>";
turnpage_str += " <tr> ";
turnpage_str += " <td align=center valign=middle>";
turnpage_str += " <table><tr><td align=center valign=middle width=30%>";
turnpage_str += " <SELECT onchange=\"var jmpURL1=this.options[this.selectedIndex].value; if(jmpURL1!='') {self.location=jmpURL1;} else {this.selectedIndex=0;}\" size=1 name=select>";
turnpage_str += " <option value=''>选择翻页</option>";
for (i=0; i<pagecount; i++) {
j = i + 1;
turnpage_str += " <option value=" + SelfPage + "?CurrentPage=" + i + "&keyword=" + keyword + "&type=" + type + ">第 " + j + " 页</option>";
}
turnpage_str += " </select>";
turnpage_str += " </td>";
turnpage_str += " <td align=center valign=middle width=20%>";
turnpage_str += " 当前页:" + page2 + "/" + pagecount;
turnpage_str += " </td>";
//--- 显示翻页按钮 ---
turnpage_str = turnpage_str + " <td align=center valign=middle width=40% style='font-family:Webdings'>";
if (pagecount != 0) turnpage_str = turnpage_str + "<a href=" + SelfPage + "?CurrentPage=0&keyword=" + keyword + "&type=" + type + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">7</a> ";
else turnpage_str = turnpage_str + "7 ";
if (page_inside != 0) turnpage_str = turnpage_str + "<a href=" + SelfPage + "?CurrentPage=" + prevpage + "&keyword=" + keyword + "&type=" + type + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">3</a>";
else turnpage_str += "3";
if (page_inside != pagecount2 && pagecount != 0) turnpage_str = turnpage_str + " <a href=" + SelfPage + "?CurrentPage=" + nextpage + "&keyword=" + keyword + "&type=" + type + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">4</a> ";
else turnpage_str = turnpage_str + " 4 ";
int t_pagecount = pagecount-1;
if (pagecount != 0) turnpage_str = turnpage_str + "<a href=" + SelfPage + "?CurrentPage=" + t_pagecount + "&keyword=" + keyword + "&type=" + type + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">8</a>";
else turnpage_str = turnpage_str + "8";
turnpage_str += "</td></tr></table>";
turnpage_str += " </td>";
turnpage_str += " </tr>";
turnpage_str += " </table>";
turnpage_str += " </td>";
turnpage_str += " </tr>";
turnpage_str += "</table>";
return(turnpage_str);
}
//--- 首页重点推荐 ---
public Vector getImportanceShow(String tb_shop_catalog,String tb_shop_product_info) throws Exception {
String sqlStr="",catalogPC="";
ResultSet rs;
Vector productBeanVector = new Vector();
try {
sqlStr = "SELECT * FROM " + tb_shop_product_info + " WHERE importance_show=1 ORDER BY id DESC";
rs = dbconn.ExeQuery(sqlStr);
while (rs.next()) {
productBean productBean = new productBean();
productBean.setId(rs.getInt("id"));
productBean.setName(rs.getString("name"));
productBean.setDescription(rs.getString("description"));
productBean.setImgPath(rs.getString("img_path"));
productBean.setPrice(rs.getFloat("price"));
productBean.setMember_price(rs.getFloat("member_price"));
catalogPC = InTheCatalog(tb_shop_catalog,rs.getInt("catalog_id"));
productBean.setCatalogPC(catalogPC);
productBeanVector.addElement(productBean);
}
dbconn.CloseConn();
}
catch (SQLException ex) {
System.err.println("aq.executeQuery:"+ex.getMessage());
}
return(productBeanVector);
}
//--- 评论最多商品 ---
public Vector getHotTalkPro(String tb_shop_product_info,String tb_gbook_info,int n) throws Exception {
String sqlStr="",catalogPC="";
ResultSet rs;
Vector productBeanVector = new Vector();
try {
sqlStr = "SELECT *,a.id AS pid,COUNT(*) AS talks FROM " + tb_shop_product_info + " AS a," + tb_gbook_info + " AS b WHERE a.id=b.product_id GROUP BY a.id ORDER BY talks DESC LIMIT " + n;
rs = dbconn.ExeQuery(sqlStr);
while (rs.next()) {
productBean productBean = new productBean();
productBean.setId(rs.getInt("pid"));
productBean.setName(rs.getString("name"));
productBeanVector.addElement(productBean);
}
dbconn.CloseConn();
}
catch (SQLException ex) {
System.err.println("aq.executeQuery:"+ex.getMessage());
}
return(productBeanVector);
}
//--- 人气商品 ---
public Vector getHotClick(String tb_shop_product_info,int n) throws Exception {
String sqlStr="",catalogPC="";
ResultSet rs;
Vector productBeanVector = new Vector();
try {
sqlStr = "SELECT * FROM " + tb_shop_product_info + " ORDER BY click DESC LIMIT " + n;
rs = dbconn.ExeQuery(sqlStr);
while (rs.next()) {
productBean productBean = new productBean();
productBean.setId(rs.getInt("id"));
productBean.setName(rs.getString("name"));
productBeanVector.addElement(productBean);
}
dbconn.CloseConn();
}
catch (SQLException ex) {
System.err.println("aq.executeQuery:"+ex.getMessage());
}
return(productBeanVector);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -