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

📄 managerproduct.java

📁 对学习 VC有所帮助的几个例子
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        throws Exception
    {
        String s2 = "";
        String s4 = "";
        Vector vector = new Vector();
        try
        {
            String s3 = "SELECT *,a.id AS pid,COUNT(*) AS talks FROM " + s + " AS a," + s1 + " AS b WHERE a.id=b.product_id GROUP BY a.id ORDER BY talks DESC LIMIT " + i;
            productBean productbean;
            for(ResultSet resultset = dbconn.ExeQuery(s3); resultset.next(); vector.addElement(productbean))
            {
                productbean = new productBean();
                productbean.setId(resultset.getInt("pid"));
                productbean.setName(resultset.getString("name"));
            }

            dbconn.CloseConn();
        }
        catch(SQLException sqlexception)
        {
            System.err.println("aq.executeQuery:" + sqlexception.getMessage());
        }
        return vector;
    }

    public Vector getImportanceShow(String s, String s1)
        throws Exception
    {
        String s2 = "";
        String s4 = "";
        Vector vector = new Vector();
        try
        {
            String s3 = "SELECT * FROM " + s1 + " WHERE importance_show=1 ORDER BY id DESC";
            productBean productbean;
            for(ResultSet resultset = dbconn.ExeQuery(s3); resultset.next(); vector.addElement(productbean))
            {
                productbean = new productBean();
                productbean.setId(resultset.getInt("id"));
                productbean.setName(resultset.getString("name"));
                productbean.setDescription(resultset.getString("description"));
                productbean.setImgPath(resultset.getString("img_path"));
                productbean.setPrice(resultset.getFloat("price"));
                String s5 = InTheCatalog(s, resultset.getInt("catalog_id"));
                productbean.setCatalogPC(s5);
            }

            dbconn.CloseConn();
        }
        catch(SQLException sqlexception)
        {
            System.err.println("aq.executeQuery:" + sqlexception.getMessage());
        }
        return vector;
    }

    public Hashtable getSearchResultVector(HttpServletRequest httpservletrequest, int i, String s, String s1)
        throws Exception
    {
        String s3 = "";
        int j = 0;
        boolean flag = false;
        Hashtable hashtable = new Hashtable();
        Hashtable hashtable1 = new Hashtable();
        String s7 = handle.getString(httpservletrequest, "CurrentPage", "0");
        String s8 = handle.getString(httpservletrequest, "keyword");
        s8 = handle.GBK2ISO(s8);
        String s9 = handle.getString(httpservletrequest, "type");
        try
        {
            String s2;
            if(s9.equals("name"))
                s2 = "SELECT * FROM " + s1 + " WHERE name LIKE '%" + s8 + "%' ORDER BY id DESC";
            else
                s2 = "SELECT * FROM " + s1 + " WHERE description LIKE '%" + s8 + "%' ORDER BY id DESC";
            ResultSet resultset = dbconn.ExeQuery(s2);
            resultset.last();
            j = resultset.getRow();
            hashtable = turn_page(s7, i, j);
            int j1 = Integer.parseInt(String.valueOf(hashtable.get("pt_st"))) + 1;
            int k1 = Integer.parseInt(String.valueOf(hashtable.get("pt_en"))) + 1;
            resultset.absolute(j1);
            for(int k = j1; k < k1; k++)
            {
                int l = resultset.getInt("id");
                String s4 = resultset.getString("img_path");
                String s5 = resultset.getString("name");
                String s6 = resultset.getString("description");
                if(s6.length() > 150)
                {
                    s6 = s6.substring(0, 150);
                    s6 = s6 + "......";
                }
                int i1 = resultset.getInt("price");
                s3 = s3 + "<table width=571 height=100 border=0 cellpadding=0 cellspacing=0>";
                s3 = s3 + "<tr>";
                s3 = s3 + "<td width=138 align=center valign=middle><a href=../../DetailProInfo.jsp?Pid=" + l + "><img src=../../" + s4 + " width=80 height=80 border=1></a></td>";
                s3 = s3 + "<td width=433 align=center valign=top><table width=100% height=78 border=0 cellpadding=3 cellspacing=0>";
                s3 = s3 + "<tr> ";
                s3 = s3 + "<td><font color=#0000FF>商品名称:</font>" + s5 + "</td>";
                s3 = s3 + "</tr>";
                s3 = s3 + "<tr> ";
                s3 = s3 + "<td height=18><font color=#0000FF>商品价格:<font color=red> ¥" + i1 + "</font></font></td>";
                s3 = s3 + "</tr>";
                s3 = s3 + "<tr> ";
                s3 = s3 + "<td height=25><font color=#0000FF>商品简介:</font><br>" + s6 + "</td>";
                s3 = s3 + "</tr>";
                s3 = s3 + "</table></td>";
                s3 = s3 + "</tr>";
                s3 = s3 + "</table>";
                s3 = s3 + "<table width=571 height=1 border=0 cellpadding=0 cellspacing=0>";
                s3 = s3 + "<tr>";
                s3 = s3 + "<td width=601 bgcolor=#000000></td>";
                s3 = s3 + "</tr>";
                s3 = s3 + "</table>";
                if(!resultset.next())
                    break;
            }

            dbconn.CloseConn();
        }
        catch(SQLException sqlexception)
        {
            System.err.println("aq.executeQuery:" + sqlexception.getMessage());
        }
        String s10 = searchNavigation(hashtable, s, s8, s9);
        hashtable1.put("RecordCount", String.valueOf(j));
        hashtable1.put("HtmlStr", s3);
        hashtable1.put("TurpageStr", s10);
        return hashtable1;
    }

    public void importanceShow(HttpServletRequest httpservletrequest, String s)
        throws Exception
    {
        int i = handle.getInt(httpservletrequest, "Pid");
        String s1 = "UPDATE " + s + " SET importance_show=1 WHERE id=" + i;
        dbconn.ExeUpdate(s1);
        dbconn.CloseConn();
    }

    public String searchNavigation(Hashtable hashtable, String s, String s1, String s2)
        throws Exception
    {
        String s3 = "";
        int k = Integer.parseInt(String.valueOf(hashtable.get("nextpage")));
        int l = Integer.parseInt(String.valueOf(hashtable.get("prevpage")));
        int i1 = Integer.parseInt(String.valueOf(hashtable.get("pagesize")));
        int j1 = Integer.parseInt(String.valueOf(hashtable.get("pagecount")));
        int k1 = Integer.parseInt(String.valueOf(hashtable.get("pagecount2")));
        int l1 = Integer.parseInt(String.valueOf(hashtable.get("page1")));
        int i2 = Integer.parseInt(String.valueOf(hashtable.get("page2")));
        s1 = handle.ISO2GBK(s1);
        s3 = s3 + "<table width=100% border=0 cellspacing=0 cellpadding=0 align=right>";
        s3 = s3 + "  <tr> ";
        s3 = s3 + "\t  <td align=center valign=middle>";
        s3 = s3 + "      <table><tr><td align=center valign=middle width=30%>";
        s3 = s3 + "        <SELECT onchange=\"var jmpURL1=this.options[this.selectedIndex].value; if(jmpURL1!='') {self.location=jmpURL1;} else {this.selectedIndex=0;}\" size=1 name=select>";
        s3 = s3 + "          <option value=''>选择翻页</option>";
        for(int i = 0; i < j1; i++)
        {
            int j = i + 1;
            s3 = s3 + "         <option value=" + s + "?CurrentPage=" + i + "&keyword=" + s1 + "&type=" + s2 + ">第 " + j + " 页</option>";
        }

        s3 = s3 + "        </select>";
        s3 = s3 + "     </td>";
        s3 = s3 + "     <td align=center valign=middle width=20%>";
        s3 = s3 + "       当前页:" + i2 + "/" + j1;
        s3 = s3 + "      </td>";
        s3 = s3 + "     <td align=center valign=middle width=40% style='font-family:Webdings'>";
        if(j1 != 0)
            s3 = s3 + "<a href=" + s + "?CurrentPage=0&keyword=" + s1 + "&type=" + s2 + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">7</a>&nbsp;&nbsp;";
        else
            s3 = s3 + "7&nbsp;&nbsp;";
        if(l1 != 0)
            s3 = s3 + "<a href=" + s + "?CurrentPage=" + l + "&keyword=" + s1 + "&type=" + s2 + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">3</a>";
        else
            s3 = s3 + "3";
        if(l1 != k1 && j1 != 0)
            s3 = s3 + "&nbsp;&nbsp;&nbsp;&nbsp;<a href=" + s + "?CurrentPage=" + k + "&keyword=" + s1 + "&type=" + s2 + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">4</a>&nbsp;&nbsp;";
        else
            s3 = s3 + "&nbsp;&nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;";
        int j2 = j1 - 1;
        if(j1 != 0)
            s3 = s3 + "<a href=" + s + "?CurrentPage=" + j2 + "&keyword=" + s1 + "&type=" + s2 + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">8</a>";
        else
            s3 = s3 + "8";
        s3 = s3 + "</td></tr></table>";
        s3 = s3 + "\t  </td>";
        s3 = s3 + "        </tr>";
        s3 = s3 + "      </table>";
        s3 = s3 + "    </td>";
        s3 = s3 + "  </tr>";
        s3 = s3 + "</table>";
        return s3;
    }

    public String search_turn(Hashtable hashtable, String s, String s1, String s2)
        throws Exception
    {
        String s3 = "";
        int k = Integer.parseInt(String.valueOf(hashtable.get("nextpage")));
        int l = Integer.parseInt(String.valueOf(hashtable.get("prevpage")));
        int i1 = Integer.parseInt(String.valueOf(hashtable.get("pagesize")));
        int j1 = Integer.parseInt(String.valueOf(hashtable.get("pagecount")));
        int k1 = Integer.parseInt(String.valueOf(hashtable.get("pagecount2")));
        int l1 = Integer.parseInt(String.valueOf(hashtable.get("page1")));
        int i2 = Integer.parseInt(String.valueOf(hashtable.get("page2")));
        s1 = handle.ISO2GBK(s1);
        s3 = s3 + "<form name=form1 method=post action=" + s + ">";
        s3 = s3 + "<table width=100% border=0 cellspacing=0 cellpadding=0 align=center>";
        s3 = s3 + "  <tr> ";
        s3 = s3 + "    <td bgcolor=#999999> ";
        s3 = s3 + "    <table width=100% border=0 cellspacing=1 cellpadding=3>";
        s3 = s3 + "  <tr bgcolor=f1f1f1>";
        s3 = s3 + "\t  <td align=center valign=middle width=50%>关键词: ";
        s3 = s3 + "      <input type=text name=keywords value=" + s1 + ">";
        s3 = s3 + " ";
        s3 = s3 + "<select name=type>";
        s3 = s3 + "  <option value=name>名 称</option>";
        s3 = s3 + "  <option value=description>简 介</option>";
        s3 = s3 + "</select>";
        s3 = s3 + "      <input type=submit name=Submit value=搜索>";
        s3 = s3 + "    </td>";
        s3 = s3 + "\t  <td align=center valign=middle width=50%>";
        s3 = s3 + "      <table><tr><td align=center valign=middle width=30%>";
        s3 = s3 + "        <SELECT onchange=\"var jmpURL1=this.options[this.selectedIndex].value; if(jmpURL1!='') {self.location=jmpURL1;} else {this.selectedIndex=0;}\" size=1 name=select>";
        s3 = s3 + "          <option value=''>选择翻页</option>";
        for(int i = 0; i < j1; i++)
        {
            int j = i + 1;
            s3 = s3 + "         <option value=" + s + "?CurrentPage=" + i + "&keywords=" + s1 + "&type=" + s2 + ">第 " + j + " 页</option>";
        }

        s3 = s3 + "        </select>";
        s3 = s3 + "     </td>";
        s3 = s3 + "     <td align=center valign=middle width=20%>";
        s3 = s3 + "       当前页:" + i2 + "/" + j1;
        s3 = s3 + "      </td>";
        s3 = s3 + "     <td align=center valign=middle width=40% style='font-family:Webdings'>";
        if(j1 != 0)
            s3 = s3 + "<a href=" + s + "?CurrentPage=0&keywords=" + s1 + "&type=" + s2 + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">7</a>&nbsp;&nbsp;";
        else
            s3 = s3 + "7&nbsp;&nbsp;";
        if(l1 != 0)
            s3 = s3 + "<a href=" + s + "?CurrentPage=" + l + "&keywords=" + s1 + "&type=" + s2 + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">3</a>";
        else
            s3 = s3 + "3";
        if(l1 != k1 && j1 != 0)
            s3 = s3 + "&nbsp;&nbsp;&nbsp;&nbsp;<a href=" + s + "?CurrentPage=" + k + "&keywords=" + s1 + "&type=" + s2 + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">4</a>&nbsp;&nbsp;";
        else
            s3 = s3 + "&nbsp;&nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;";
        int j2 = j1 - 1;
        if(j1 != 0)
            s3 = s3 + "<a href=" + s + "?CurrentPage=" + j2 + "&keywords=" + s1 + "&type=" + s2 + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">8</a>";
        else
            s3 = s3 + "8";
        s3 = s3 + "</td></tr></table>";
        s3 = s3 + "\t  </td>";
        s3 = s3 + "        </tr>";
        s3 = s3 + "      </table>";
        s3 = s3 + "    </td>";
        s3 = s3 + "  </tr>";
        s3 = s3 + "</table>";
        return s3;
    }

    public Hashtable turn_page(String s, int i, int j)
    {
        int i1 = 0;
        Hashtable hashtable = new Hashtable();
        if(!s.equals(""))
            i1 = Integer.parseInt(s);
        int k = j / i;
        if(i * k < j)
            k++;
        if(Integer.parseInt(s) > k)
            i1 = k - 1;
        else
        if(Integer.parseInt(s) < 0)
            i1 = 0;
        int l = k - 1;
        int j1 = i1 + 1;
        int k1 = i1 * i;
        int l1 = k1 + i;
        int i2 = i1 + 1;
        int j2 = i1 - 1;
        hashtable.put("pt_st", new Integer(k1));
        hashtable.put("pt_en", new Integer(l1));
        hashtable.put("nextpage", new Integer(i2));
        hashtable.put("prevpage", new Integer(j2));
        hashtable.put("pagesize", new Integer(i));
        hashtable.put("pagecount", new Integer(k));
        hashtable.put("pagecount2", new Integer(l));
        hashtable.put("page1", new Integer(i1));
        hashtable.put("page2", new Integer(j1));
        return hashtable;
    }

    public void unImportanceShow(HttpServletRequest httpservletrequest, String s)
        throws Exception
    {
        int i = handle.getInt(httpservletrequest, "Pid");
        String s1 = "UPDATE " + s + " SET importance_show=0 WHERE id=" + i;
        dbconn.ExeUpdate(s1);
        dbconn.CloseConn();
    }
}

⌨️ 快捷键说明

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