【DRP】-动态拼接数








/** * 递归读取分销商树 * * 第四步: 采用div生成树形结构 * @param conn * @param id * @param level 控制层次 */ private void readClientTree(Connection conn, int id, int level) throws SQLException { String sql = "select * from t_client where pid=?"; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = conn.prepareStatement(sql); pstmt.setInt(1, id); rs = pstmt.executeQuery(); while (rs.next()) { sbTreeHTML.append("
<div>"); sbTreeHTML.append("\n"); for (int i=0; i<level; i++) { sbTreeHTML.append("<img src=\"../images/white.gif\">"); sbTreeHTML.append("\n"); } //if ("N".equals(rs.getString("is_leaf"))) { if (Constants.NO.equals(rs.getString("is_leaf"))) { sbTreeHTML.append("<img alt=\"展开\" style=\"cursor:hand;\" onClick=\"display('" + rs.getInt("id") + "');\" id=\"img" + rs.getInt("id") + "\" src=\"../images/plus.gif\">"); sbTreeHTML.append("\n"); sbTreeHTML.append("<img id=\"im" + rs.getInt("id") + "\" src=\"../images/closedfold.gif\">"); sbTreeHTML.append("\n"); sbTreeHTML.append("<a href=\"client_node_crud.jsp?id=" + rs.getInt("id") + "\" target=\"clientDispAreaFrame\">" + rs.getString("name") + "</a>"); sbTreeHTML.append("\n"); sbTreeHTML.append("<div style=\"display:none;\" id=\"div" + rs.getInt("id") + "\">"); sbTreeHTML.append("\n"); readClientTree(conn, rs.getInt("id"), level + 1); sbTreeHTML.append("</div>"); sbTreeHTML.append("\n"); }else { sbTreeHTML.append("<img src=\"../images/minus.gif\">"); sbTreeHTML.append("\n"); sbTreeHTML.append("<img src=\"../images/openfold.gif\">"); sbTreeHTML.append("\n"); //if ("Y1".equals(rs.getString("is_client"))) { if (Constants.YES.equals(rs.getString("is_client"))) { sbTreeHTML.append("<a href=\"client_crud.jsp?id=" + rs.getInt("id") + "\" target=\"clientDispAreaFrame\">" + rs.getString("name") + "</a>"); }else { sbTreeHTML.append("<a href=\"client_node_crud.jsp?id=" + rs.getInt("id") + "\" target=\"clientDispAreaFrame\">" + rs.getString("name") + "</a>"); } sbTreeHTML.append("\n"); } sbTreeHTML.append("</div>"); sbTreeHTML.append("\n"); } }finally { DbUtil.close(rs); DbUtil.close(pstmt); } }

 

posted @ 2016-07-02 10:07  像大海一样生活  阅读(284)  评论(0编辑  收藏  举报