using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OracleClient ;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace ldter
{
///
1<summary>
2/// WebForm4 的摘要说明。
3/// </summary>
public class WebForm4 : System.Web.UI.Page
{
DataSet ds;
string str;
OracleConnection con;
string strTree="
1<center><table cellpadding="0" cellspacing="0" width="80%"><tr valign="top"><td align="center" width="50%"><table cellpadding="0" cellspacing="0" width="100%">";
2Int32 c=0;
3bool havechild=false;
4public string strsort
5{
6get
7{
8return strTree+"</table></td></tr></table></center>
";
}
}
private void LocalDataSet()
{
OracleDataAdapter ad;
OracleDataAdapter adpar;
str="SELECT * FROM CODESORT ORDER BY CS_ID";
ad=new OracleDataAdapter(str,con);
adpar=new OracleDataAdapter("SELECT CS_PAR FROM CODESORT ORDER BY CS_ID",con);
con.Open();
ds=new DataSet();
try
{
ad.Fill(ds,"maindoc");
adpar.Fill(ds,"par");
this.ViewState["ds"]=ds;
}
catch
{
throw;
}
finally
{
con.Close();
}
}
public void InitTree(string parent)
{
DataView dv=new DataView(ds.Tables["maindoc"]);
DataView dvpar=new DataView(ds.Tables["par"]);
dv.RowFilter="cs_par = '" + parent + "'";
foreach(DataRowView row in dv)
{
string nbsp="";
string div="";
string td="";
string checkbox="";
if(parent=="000") c=c+1;
for (Int32 i=1;i<=Int32.Parse(row["cs_clas"].ToString());i++) nbsp+=" ";
if (parent!="000")
{
div="
1<tr valign="top"><td height="100%" width="100%"><div height="100%" id='div"+ row["cs_code"].ToString()
2+"' style="display:none" width="100%"><table cellpadding="0" cellspacing="0" height="100%" width="100%"><tr valign="top"><td width="100%">";
3}
4else
5{
6div="<tr valign="top"><td height="100%" width="100%"><div height="100%" id='div"+ row["cs_code"].ToString()
7+"' style="display:none" width="100%"><table cellpadding="0" cellspacing="0" width="100%"><tr valign="top"><td width="100%">";
8}
9if(c==4)
10{
11td="</td></tr></table></div></td><td align="center" width="50%"><table cellpadding="0" cellspacing="0" width="100%"><tr valign="top"><td align="left" width="80%">";
12}
13else{if(havechild)td=""; else td="<tr valign="top"><td align="left" valign="top" width="80%">";}
14foreach(DataRowView rowpar in dvpar) //是否父节点
15if (row["cs_code"].ToString()==rowpar[0].ToString()){havechild=true;break;}else{havechild=false;}
16if(havechild||parent=="000"){checkbox="<img border="0" id='img"+row["cs_code"]+"' src="gif/plus.gif"/>";}
17else{checkbox="<img border="0" id='img"+row["cs_code"]+"' src="gif/T.gif"/>"+"<input classname='" +row["cs_name"]+ "' id='" +row["cs_code"]+ "' onclick="javascript:subsel(this)" type="checkbox"/>";}
18string newname="";
19if(row["cs_name"].ToString().Length.CompareTo(14)!=1){newname=row["cs_name"].ToString();}else{newname=row["cs_name"].ToString().Substring(0,10).ToString()+"...";}
20strTree+=td + nbsp + checkbox +"<a "','"+="" +="" +"="" +"')"="" class="ainfo" cursor="hand" href="javascript:expit('"" row["cs_clas"].tostring()="" row["cs_code"].tostring()="" title='"+row["cs_name"]+"'>" + newname +"</a></td></tr>";
21if(havechild){strTree+=div;InitTree(row["cs_code"].ToString());strTree+="</td></tr></table></td></tr></td></tr></table></div></td></tr>
";}
}}
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
ds=(DataSet)this.ViewState["ds"];
InitTree("000");
DataBind();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
con=new OracleConnection("Data Source=ora9;User Id=system;Password=manager;Integrated Security=no");
LocalDataSet();
}
///
1<summary>
2/// 设计器支持所需的方法 - 不要使用代码编辑器修改
3/// 此方法的内容。
4/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}