欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
不用迭代算法而快速實(shí)現的jsp樹(shù)結構

在web頁(yè)面上實(shí)現樹(shù)狀結構,有點(diǎn)麻煩.
在最近的一個(gè)MIS系統的開(kāi)發(fā)中,我們項目組大量用到了樹(shù)結構:比如人員的選擇,單位的選擇等待.
這個(gè)MIS系統所用的數據庫是oracle 9i.  oracle 9i 的sql支持迭代查詢(xún).我們的樹(shù)是由牛人彭越寫(xiě)的,不過(guò)
也參照了網(wǎng)絡(luò )上比較著(zhù)名的xtree(可以到此下載:http://webfx.eae.net/),他的樹(shù)算法支持無(wú)限級的樹(shù)結構,不過(guò)性能好像
很慢.我持保留態(tài)度.
他用到的關(guān)鍵技術(shù)就是這句話(huà):
String sql = "select dwxh,dwbh,dwmc,dwfxh,level cc from xt_dw connect by  prior dwxh = dwfxh start with dwfxh = 0";
可是許多數據庫不支持迭代查詢(xún),并且迭代查詢(xún)速度真是不能忍受.有什么更好的辦法呢.下面說(shuō)說(shuō)我的解決方案.

一:需求的提出
1:客戶(hù)需要一個(gè)關(guān)于部門(mén)人員的樹(shù)結構,數據庫為mysql4.1
2:java實(shí)現
二:建表:
1:
用戶(hù)信息表:
各字段為:用戶(hù)序號,用戶(hù)編號,用戶(hù)名稱(chēng),單位序號,密碼,用戶(hù)登陸號
create table XT_YH
(
  YHXH  INT(9) NOT NULL auto_increment PRIMARY KEY,
  YHBH  VARCHAR(30),
  YHMC  VARCHAR(30),
  DWXH  INT(9),
  PWD   VARCHAR(20),
  YHDLH VARCHAR(30)
)
--插入三條測試數據:
--insert into xt_yh(yhbh,yhmc,dwxh,pwd,yhdlh) values(‘licl‘,‘李春雷‘,2,‘password‘,‘licl‘)
--insert into xt_yh(yhbh,yhmc,dwxh,pwd,yhdlh) values(‘fengx‘,‘馮欣‘,2,‘password‘,‘fengx‘)
--insert into xt_yh(yhbh,yhmc,dwxh,pwd,yhdlh) values(‘wangqx‘,‘王慶香‘,6,‘password‘,‘wangqx‘)
2:
單位部門(mén)表
各字段為:單位序號,單位編號,單位名稱(chēng),單位父序號
create table XT_DW
(
  DWXH  int(9) NOT NULL auto_increment PRIMARY KEY,
  DWBH  VARCHAR(10),
  DWMC  VARCHAR(30),
  DWFXH int(9)
)
--插入5條測試數據
--insert into xt_dw(dwbh,dwmc,dwfxh) values(‘0100000000‘,‘武漢科技局‘,0);
--insert into xt_dw(dwbh,dwmc,dwfxh) values(‘0101000000‘,‘人事處‘,1);
--insert into xt_dw(dwbh,dwmc,dwfxh) values(‘0102000000‘,‘后勤處‘,1);
--insert into xt_dw(dwbh,dwmc,dwfxh) values(‘0101010000‘,‘人事處son1‘,2);
--insert into xt_dw(dwbh,dwmc,dwfxh) values(‘0101020000‘,‘人事處son2‘,2);
--insert into xt_dw(dwbh,dwmc,dwfxh) values(‘0102010000‘,‘后勤處son1‘,3);

注意:
為了實(shí)現快速的樹(shù)結構實(shí)現,我需要充分利用單位編號DWBH,DWBH才有10位編碼,其中,第一第二位表示一級單位,第三第四位表示二級單位,
第五六位表示三級單位...那么10位編碼就可以實(shí)現五級單位的樹(shù)結構.
比如:測試數據的樹(shù)結構如下:
  1  武漢科技局:
 2  人事處
  3  人事處son1
  3  人事處son2
 2  后勤處
  3后勤處son1

其實(shí)XT_DW表中的父序號是多余的.不過(guò)如果你要用迭代算法來(lái)實(shí)現,就是必須的
才有10位編碼,我只需要一句簡(jiǎn)單快速的sql語(yǔ)句就可以實(shí)現樹(shù)結構:
String sql = "select dwxh,dwbh,dwmc,dwfxh from xt_dw order by dwbh"
這句sql在幾乎所有的數據庫平臺都能執行,速度也快.
下面貼出采用xtree,用10位編碼而不是迭代算法實(shí)現的樹(shù):

/*******Constants.java**********/

package com.lcl.common;

public class Constants {
 
 public static final String DBDRIVER = "com.my 
 public static final String DBUrl="jdbc:my
數據庫url
 
 public static final String USERNAME="root";                       //數據庫用戶(hù)名
 
 public static final String PASSWORD="root";     //數據庫密碼
 
 
}


/**********DbAccess.java****************/

package com.lcl.common;

import java.sql.*;
import java.lang.*;

/**
 * @author 李春雷
 *
 * TODO 要更改此生成的類(lèi)型注釋的模板,請轉至
 * 數據庫訪(fǎng)問(wèn)類(lèi)
 */
public class DbAccess

 String strDBDriver = Constants.DBDRIVER;
 String strDBUrl = Constants.DBUrl;
 String username = Constants.USERNAME;
 String password = Constants.PASSWORD;
 private Connection conn = null;
 private Statement stmt = null;
 ResultSet rs=null;
 //注冊數據庫驅動(dòng)程序
 public DbAccess()
 { 
  try
  { 
   Class.forName(strDBDriver);
  }
  //異常處理
  catch( java.lang.ClassNotFoundException e)
  {
   System.err.println("DbAccess():"+e.getMessage());
  }
 }
 //建立數據庫連接及定義數據查詢(xún)
 public ResultSet executeQuery(String sql)
 {
  rs=null;
  try
  {
   conn=DriverManager.getConnection(strDBUrl,username,password);
   stmt=conn.createStatement();
   rs=stmt.executeQuery(sql);
  }
  catch(SQLException ex)
  {
   System.err.println("ap.executeQuery:"+ex.getMessage());
  }
 
  return rs;
 }
 //定義數據操庫作
 public void executeUpdate(String sql)
 {
  stmt=null;
  rs=null;
  try
  {
   conn=DriverManager.getConnection(strDBUrl,username,password);
   stmt=conn.createStatement();
   stmt.executeQuery(sql);
   stmt.close();
   conn.close();
  }
  catch(SQLException ex)
  {
   System.err.println("ap.executeQuery:"+ex.getMessage());
  }
 }
 //關(guān)閉數據庫
 public void closeStmt()
 {
  try
  {
   stmt.close();
  }
  catch(SQLException e)
  {
   e.printStackTrace();
  }
 }
 public void closeConn()
 {
  try
  {
   conn.close();
  }
  catch(SQLException e)
  {
   e.printStackTrace();
  }
 }
 public static void main(String[] args){
  System.out.println("hello,it‘s test");
  DbAccess dbaccess = new DbAccess();
  String sql = "select * from xt_yh";
  ResultSet rs = dbaccess.executeQuery(sql);
  try
  {
   while(rs.next()){
    System.out.print(rs.getString(1)+rs.getString(2)+rs.getString(3)+rs.getString(4)+rs.getString(5)+rs.getString(6));
    System.out.println();
   }
  dbaccess.closeStmt();
  dbaccess.closeConn();
  }
  catch (SQLException e)
  {
   // TODO 自動(dòng)生成 catch 塊
   e.printStackTrace();
  }
 }
 }

 /*********DepEmplConfig.jsp************/

 <%@ page contentType="text/html; charset=gb2312" language="java.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>無(wú)標題文檔</title>
<HEAD>
<script type="text/
<link type="text/css" rel="stylesheet" href="../resources/xtree.css" />
<style type="text/css">

body {
 background: white;
 color:  black;
}
</style>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script type="text/
webFXTreeConfig.rootIcon  = "../resources/images/xp/folder.png";
webFXTreeConfig.openRootIcon = "../resources/images/xp/openfolder.png";
webFXTreeConfig.folderIcon  = "../resources/images/xp/folder.png";
webFXTreeConfig.openFolderIcon = "../resources/images/xp/openfolder.png";
webFXTreeConfig.fileIcon  = "../resources/images/xp/file.png";
webFXTreeConfig.lMinusIcon  = "../resources/images/xp/Lminus.png";
webFXTreeConfig.lPlusIcon  = "../resources/images/xp/Lplus.png";
webFXTreeConfig.tMinusIcon  = "../resources/images/xp/Tminus.png";
webFXTreeConfig.tPlusIcon  = "../resources/images/xp/Tplus.png";
webFXTreeConfig.iIcon   = "../resources/images/xp/I.png";
webFXTreeConfig.lIcon   = "../resources/images/xp/L.png";
webFXTreeConfig.tIcon   = "../resources/images/xp/T.png";
webFXTreeConfig.blankIcon       = "../resources/images/blank.png";

var tree = new WebFXTree("單位人員基本情況","R0");
var child;
var nodeToAddPerson;

function addDeptTreeNode(preNodeLevel,curNodeLevel,dispLabel,sKey,sTag) {
  if(curNodeLevel==1) {
     child = tree.add(new WebFXTreeItem(dispLabel,sKey,sTag));
  }
  else {
    if(curNodeLevel==preNodeLevel) {
       if(child.parentNode)
        child = child.parentNode.add(new WebFXTreeItem(dispLabel,sKey,sTag));
    }
    if(curNodeLevel>preNodeLevel) {
       child = child.add(new WebFXTreeItem(dispLabel,sKey,sTag));
    }
    if(curNodeLevel<preNodeLevel) {
        for(i=0;i<preNodeLevel-curNodeLevel+1;i++)
           child = child.parentNode;
        child = child.add(new WebFXTreeItem(dispLabel,sKey,sTag));
    }
  }
  return child;
}

function treeClick() {
 if(tree.getSelected()) {
     if(tree.getSelected().childNodes.length==0&&tree.getSelected().key!="R0")
       cmdDelete.disabled = false;
     else
       cmdDelete.disabled = true;
     if(tree.getSelected().key.substr(0,2)=="RZ") {
       cmdAddDept.disabled = true;
       cmdAddPeople.disabled = true;
       var strYhxh;
       strYhxh = tree.getSelected().key.substr(2);
       //window.open("../userAdm/editYh.do?yhxh="+strYhxh,"main");
     }
     else if(tree.getSelected().key.substr(0,2)=="RB") {
       cmdAddDept.disabled = false;
       cmdAddPeople.disabled = false;
       var strDwxh;
       strDwxh = tree.getSelected().key.substr(2);
       //window.open("../userAdm/editBm.do?dwxh="+strDwxh,"main");
     }
     else {
       cmdAddDept.disabled = false;
       cmdAddPeople.disabled = true;
       //window.open("yhroot.jsp","main");
     }
 }
}

function addPeople() {
    var strDwxh;
    if(tree.getSelected()) {
   if (tree.getSelected().key.substr(0,2)=="RB") {
        strDwxh = tree.getSelected().key.substr(2);
  //window.open("../userAdm/addYh.do?dwxh="+strDwxh,"main");
  alert("addPeople");
   }
    }
}

function addDept() {
    var strDwxh;
    if(tree.getSelected()) {
   if (tree.getSelected().key.substr(0,2)=="RB") {
        strDwfxh = tree.getSelected().key.substr(2);
  //window.open("../userAdm/addBm.do?dwfxh="+strDwfxh,"main");
    alert("addDept");
   }
      else if(tree.getSelected().key=="R0") {
        //window.open("../userAdm/addBm.do?dwfxh=0","main");
        alert("addDept");
      }
    }
}

function deleSelected() {
  if(!confirm("確認刪除該節點(diǎn)嗎?"))
      return;
  if(tree.getSelected()) {
    if(tree.getSelected().key.substr(0,2)=="RB") {
       var strDwxh;
       strDwxh = tree.getSelected().key.substr(2);
       //window.open("../userAdm/delBm.do?dwxh="+strDwxh,"main");
       alert("deleSelected");
    }
    else if(tree.getSelected().key.substr(0,2)==‘RZ‘) {
       var strYhxh,strYhbh;
       strYhxh = tree.getSelected().key.substr(2);
       strYhbh = tree.getSelected().tag;
       //window.open("../userAdm/delYh.do?yhxh="+strYhxh+"&yhbh="+strYhbh,"main");
       alert("deleSelected");
    }
  }
}

function removeNode() {
  if(tree.getSelected()) {
    var node = tree.getSelected();
    node.remove();
  }
}

function addPeopleNode(strParentKey,strKey,strText,strTag) {
  if(tree.getSelected()) {
    var node = tree.getSelected();
    var childNode;
    //node.expand();
    childNode = node.add(new WebFXTreeItem(strText,strKey,strTag,"","","../resources/images/people1.png"));
    node.expand(); //why I do so? I dont want to tell you,hah!
    childNode.focus();
    treeClick();
  }
}

function addDeptNode(strParentKey,strKey,strText,strTag) {
  if(tree.getSelected()) {
    var node = tree.getSelected();
    var childNode;
    childNode = node.add(new WebFXTreeItem(strText,strKey,strTag));
    node.expand();
    childNode.focus();
    treeClick();
  }
}

function updateDeptNode(strTag,strText) {
  if(tree.getSelected()) {
    var node = tree.getSelected();
    node.text = strText;
    node.tag  = strTag;
    node.focus();
  }
}

function updatePeopleNode(strTag,strText) {
  if(tree.getSelected()) {
    var node = tree.getSelected();
    node.text = strText;
    node.tag  = strTag;
    node.focus();
  }
}
</script>
<%
int dwxh;
int dwfxh;
int yhxh;
String dwbh = null;
String dwmc = null;
String yhmc = null;
String yhbh = null;
int preLevel =1;
int level = 1;
DbAccess dbaccess = new DbAccess();
String
sql = "select dwxh,dwbh,dwmc,dwfxh from xt_dw order by dwbh";
ResultSet rs = dbaccess.executeQuery(sql);
try
{
 while(rs.next())
 {
        dwxh = rs.getInt(1);
        dwbh = rs.getString(2);
        dwmc = rs.getString(3);
        dwfxh = rs.getInt(4);
//通過(guò)單位編號計算level
  String last = dwbh.substring(9,10);
  int i = 9;
  while(last.equals("0") && i>0){
   i--;
   last = dwbh.substring(i,i+1);
  
  }
  
  if(i==0 || i==1) level =1;
  if(i==2 || i==3) level =2;
  if(i==4 || i==5) level =3;
  if(i==6 || i==7) level =4;
  if(i==8 || i==9) level =5;
//
  %>
           <script type="text/     nodeToAddPerson = addDeptTreeNode(<%=preLevel%>,<%=level%>,"<%=dwmc%>","RB<%=dwxh%>","<%=dwbh%>");
        </script>  
  
  <%
  preLevel = level;
  String sub
sql = "select yhxh,yhmc,yhbh from xt_yh where dwxh = "+Integer.toString(dwxh);
  ResultSet subRs = dbaccess.executeQuery(subsql);
       while(subRs.next()) {
              yhxh = subRs.getInt(1);
              yhmc = subRs.getString(2);
              yhbh = subRs.getString(3);
  %>
             <script type="text/     nodeToAddPerson.add(new WebFXTreeItem("<%=yhmc%>","RZ<%=yhxh%>","<%=yhbh%>","","","../resources/images/people1.png"));
        </script>
     <%
  }
  
 }
 dbaccess.closeStmt();
 dbaccess.closeConn();
}
catch(Exception e)
{

}
%>

<base target="_self">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</head>
<body>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td width="273" colspan="2">
       <font face="宋體" size="3">    
       </font>
    </td>
  </tr>
  <tr>
    <th width="33%" align="center" nowrap>
      <p align="center">
      <INPUT id=cmdAddDept name="AddDept" type=button value="增加部門(mén)" onclick="addDept()" style="FONT-FAMILY: 楷體_GB2312; FONT-SIZE: 12pt; FONT-WEIGHT: bold; HEIGHT: 24px; WIDTH: 80px" >
      </p>
    </th>
    <th width="33%" align="center" nowrap>
      <p align="center">
      <INPUT id=cmdAddPeople name="AddPeople" type=button value="增加用戶(hù)" onclick="addPeople()" style="FONT-FAMILY: 楷體_GB2312; FONT-SIZE: 12pt; FONT-WEIGHT: bold; HEIGHT: 24px; WIDTH: 80px" >
      </p>
    </th>
    <th width="33%" align="center" nowrap>
      <p align="center">
      <INPUT id=cmdDelete name="Delete" type=button value=" 刪除 " onclick="deleSelected()" style="FONT-FAMILY: 楷體_GB2312; FONT-SIZE: 12pt; FONT-WEIGHT: bold; HEIGHT: 24px; WIDTH: 80px" disabled>
      </p>
    </th>
  </tr>
  <tr>
    <td width="273" height="8"  colspan="2"> 
     
    </td>
  </tr>
</table>
</body>
<div onclick="treeClick()">
<script type="text/
 document.write(tree);
</script>
</div>
</HTML>

//其中jsp頁(yè)面上的幾個(gè)javascript函數為同事牛人彭越所寫(xiě),我沒(méi)改動(dòng),在此說(shuō)明.

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
easyui tree 節點(diǎn)選中
xloadtree的一個(gè)改造
JS的dtree和xtree介紹
DES加密解密(JavaScript
JQuery與JQuery EasyUI部分基礎內容總結
grid
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久