//填充菜單樹
public void fillmenu()
{
string sql = "select * from base_cata order by CATA_ID";
OracleDataAccess oda = new OracleDataAccess("myerpConnectionString");
DataSet ds = new DataSet();
ds = oda.getDataSet(sql);
this.TreeView1.Nodes.Clear();
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (dr["CATA_PID"].ToString() == string.Empty)
{
TreeNode tn = new TreeNode();
tn.Text = dr["CATA_NAME"].ToString();
tn.Value = dr["CATA_ID"].ToString().Trim();
this.TreeView1.Nodes.Add(tn);
getChildren(tn);
}
}
}
//查找節點的子節點
public void getChildren(TreeNode tvn)
{
string sql = "select * from base_cata order by CATA_ID";
OracleDataAccess oda = new OracleDataAccess("myerpConnectionString");
DataSet ds = new DataSet();
ds = oda.getDataSet(sql);
foreach (DataRow dr in ds.Tables[0].Rows)
{
string[] str = tvn.Value.Split(',');
if (dr["CATA_PID"].ToString().Trim() == str[0])
{
TreeNode tn = new TreeNode();
tn.Text = dr["CATA_NAME"].ToString();
tn.Value = dr["CATA_ID"].ToString();
tvn.ChildNodes.Add(tn);
getChildren(tn);
}
}
}