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

📄 managernews.java

📁 jsp开发常用信息管理系统适合初学者学习 新闻管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        hashtable.put("sumSubClick", new Integer(i));
        return hashtable;
    }

    public Vector getTypeBeanVector(HttpServletRequest httpservletrequest,
            String s, String s1) throws Exception {
        Vector vector = new Vector();
        typeBean typebean = new typeBean();
        typeBean typebean2 = new typeBean();
        try {
            String s2 = "SELECT * FROM " + s1 + " ORDER BY id DESC";
            dbConn.getPreparedStatement(s2);
            typeBean typebean1;
            for (ResultSet resultset = dbConn.ExeQuery(); resultset.next(); vector
                    .addElement(typebean1)) {
                typeBean typebean3 = getTypeNewsCount(httpservletrequest,
                        resultset.getInt("id"), s);
                typebean1 = new typeBean();
                typebean1.setId(resultset.getInt("id"));
                typebean1.setTitle(resultset.getString("title"));
                typebean1.setNewsCount(typebean3.getNewsCount());
                typebean1.setClickCount(typebean3.getClickCount());
                typebean1.setAvgClick(typebean3.getAvgClick());
                typebean1.setMaxClick(typebean3.getMaxClick());
                typebean1.setMinClick(typebean3.getMinClick());
            }

            dbConn.CloseConn();
        } catch (SQLException sqlexception) {
            System.err.println("getTypeBeanVector():"
                    + sqlexception.getMessage());
        }
        return vector;
    }

    public Vector getTypeModuleBeanVector(
            HttpServletRequest httpservletrequest, String s, String s1,
            String s2) throws Exception {
        Vector vector = new Vector();
        try {
            String s3 = "SELECT * FROM "
                    + s
                    + " AS a,"
                    + s1
                    + " AS b,"
                    + s2
                    + " AS c WHERE a.id=c.tid AND b.mid=c.mid ORDER BY a.id DESC";
            moduleBean modulebean;
            for (ResultSet resultset = dbConn.ExeQuery(s3); resultset.next(); vector
                    .addElement(modulebean)) {
                modulebean = new moduleBean();
                modulebean.setTid(resultset.getInt("id"));
                modulebean.setTypeTitle(resultset.getString("title"));
                modulebean.setModule(resultset.getString("module"));
            }

            dbConn.CloseConn();
        } catch (SQLException sqlexception) {
            System.err.println("getTypeModuleBeanVector():"
                    + sqlexception.getMessage());
        }
        return vector;
    }

    public String getTypeName(String s, int i) throws Exception {
        String s2 = null;
        try {
            String s1 = "SELECT * FROM " + s + " WHERE id = ?";
            dbConn.getPreparedStatement(s1);
            dbConn.setInt(1, i);
            ResultSet resultset = dbConn.ExeQuery();
            if (resultset.next())
                s2 = resultset.getString("title");
            dbConn.CloseConn();
        } catch (SQLException sqlexception) {
            System.err.println("getTypeName():" + sqlexception.getMessage());
        }
        return s2;
    }

    public typeBean getTypeNewsCount(HttpServletRequest httpservletrequest,
            int i, String s) throws Exception {
        boolean flag = false;
        typeBean typebean = new typeBean();
        String s2 = handle.getString(httpservletrequest, "yearSt", "");
        String s3 = handle.getString(httpservletrequest, "monthSt", "");
        String s4 = s2 + "-" + s3;
        String s5 = handle.getString(httpservletrequest, "yearEn", "");
        String s6 = handle.getString(httpservletrequest, "monthEn", "");
        String s7 = s5 + "-" + s6;
        try {
            String s1;
            if (s2.equals(""))
                s1 = "SELECT COUNT(*) AS newsCount,AVG(click) AS avgClick,SUM(click) AS clickCount,MAX(click) AS maxClick,MIN(click) AS minClick FROM "
                        + s + " WHERE type_id=?";
            else
                s1 = "SELECT COUNT(*) AS newsCount,AVG(click) AS avgClick,SUM(click) AS clickCount,MAX(click) AS maxClick,MIN(click) AS minClick FROM "
                        + s
                        + " WHERE type_id=? AND date_time>='"
                        + s4
                        + "' AND date_time<='" + s7 + "'";
            dbConn.getPreparedStatement(s1);
            dbConn.setInt(1, i);
            ResultSet resultset = dbConn.ExeQuery();
            if (resultset.next()) {
                typebean.setNewsCount(resultset.getInt("newsCount"));
                typebean.setClickCount(resultset.getInt("clickCount"));
                typebean.setAvgClick(resultset.getFloat("avgClick"));
                typebean.setMinClick(resultset.getInt("minClick"));
                typebean.setMaxClick(resultset.getInt("maxClick"));
                typebean.setMinClick(resultset.getInt("minClick"));
            }
            dbConn.CloseConn();
        } catch (SQLException sqlexception) {
            System.err.println("getTypeNewsCount():"
                    + sqlexception.getMessage());
        }
        return typebean;
    }

    public String getVisitorConditionStr(HttpServletRequest httpservletrequest,
            String s) throws Exception {
        String s1 = "";
        HttpSession httpsession = httpservletrequest.getSession(true);
        adminBean adminbean = (adminBean) httpsession.getAttribute("loginAccount");
        try {
            String s2 = "SELECT * FROM " + s + " WHERE admin_id="
                    + adminbean.getId();
            System.out.println("s2=" + s2);
            for (ResultSet resultset = dbConn.ExeQuery(s2); resultset.next();)
                s1 = s1 + "type_id=" + resultset.getInt("type_id") + " OR ";

            dbConn.CloseConn();
            if (!s1.equals(""))
                s1 = s1.substring(0, s1.length() - 4);
            else
                s1 = "0";
        } catch (SQLException sqlexception) {
            System.err.println("getVisitorConditionStr():"
                    + sqlexception.getMessage());
        }
        return s1;
    }

    public void moveNews(HttpServletRequest httpservletrequest, String s)
            throws Exception {
        int i = handle.getInt(httpservletrequest, "type_id");
        boolean flag = false;
        String as[] = httpservletrequest.getParameterValues("topicIds");
        for (int k = 0; k < as.length; k++) {
            int j = Integer.parseInt(as[k]);
            String s1 = "UPDATE " + s + " SET type_id=? WHERE id=?";
            dbConn.getPreparedStatement(s1);
            dbConn.setInt(1, i);
            dbConn.setInt(2, j);
            dbConn.ExeUpdate();
        }

        dbConn.CloseConn();
    }

    public String navigationSearch(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> ";
        s3 = s3 + "    <table width=100% border=0 cellspacing=0 cellpadding=3>";
        s3 = s3 + "  <tr>";
        s3 = s3 + "\t  <td align=center valign=middle width=50%>关键词: ";
        s3 = s3 + "      <input type=text name=keywords value=" + s1 + ">";
        s3 = s3
                + "       <input type=radio name=type value=topic checked> 主 题 <input type=radio name=type value=content> 内 容";
        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 void relateModule(HttpServletRequest httpservletrequest, String s)
            throws Exception {
        int i = handle.getInt(httpservletrequest, "tid");
        String s4 = handle.getString(httpservletrequest, "mid_module");
        String as[] = handle.Split(",", s4);
        int j = Integer.parseInt(as[0]);
        String s5 = as[1];
        try {
            String s1 = "SELECT * FROM " + s + " WHERE tid=?";
            dbConn.getPreparedStatement(s1);
            dbConn.setInt(1, i);
            ResultSet resultset = dbConn.ExeQuery();
            if (resultset.next()) {
                String s2 = "UPDATE " + s + " SET mid=? WHERE tid=?";
                dbConn.getPreparedStatement(s2);
                dbConn.setInt(1, j);
                dbConn.setInt(2, i);
                dbConn.ExeUpdate();
            } else {
                String s3 = "INSERT INTO " + s + "(tid,mid) VALUES(?,?)";
                dbConn.getPreparedStatement(s3);
                dbConn.setInt(1, i);
                dbConn.setInt(2, j);
                dbConn.ExeUpdate();
            }
            dbConn.CloseConn();
        } catch (SQLException sqlexception) {
            System.err.println("relateModule():" + sqlexception.getMessage());
        }
    }

    public String search_turn(Hashtable hashtable, String s, String s1,
            Str

⌨️ 快捷键说明

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