if (!Page.IsPostBack)
{
//TreeView1.Nodes.Clear();
TreeNode nNode = new TreeNode("在职");
TreeNode pNode = new TreeNode("离职");
TreeView1.Nodes.Add(nNode);
TreeView1.Nodes.Add(pNode);
}
}
protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e)
{
if (e.Node.ChildNodes.Count == 0)
{
if (e.Node.Depth == 0)
{ tiancong_geng(e.Node); }
else if (e.Node.Depth == 1)
{ tiancong_ye(e.Node); }
/*else if (e.Node.Depth == 2)
{ tiancong_ye1(e.Node); }
else if (e.Node.Depth == 3)
{ tiancong_ye2(e.Node); }*/
}
}
void tiancong_geng(TreeNode Node)
{
Socut.Reader MinCheng = new Socut.Reader("SELECT * FROM GJ_ZIYUAN order by GJ_ID asc");
while (MinCheng.Read())
{
bool KG = false;
TreeNode geng = new TreeNode(MinCheng["GJ_QUYU"].ToString());
geng.PopulateOnDemand = true;
geng.SelectAction = TreeNodeSelectAction.Expand;
int a = Node.ChildNodes.Count;
if (a > 0)
{
for (int jie = 0; jie < a; jie++)
{
if (Node.ChildNodes[jie].Text == MinCheng["GJ_QUYU"].ToString())
{ KG = true; break; }
}
if (KG == false) { Node.ChildNodes.Add(geng); }
}
else { Node.ChildNodes.Add(geng); }
}
MinCheng.Close();
}
void tiancong_ye(TreeNode Node)
{
Socut.Reader MinCheng = new Socut.Reader("SELECT * FROM GJ_ZIYUAN order by GJ_ID asc");
while (MinCheng.Read())
{
TreeNode geng = new TreeNode(MinCheng["GJ_JIFAN"].ToString(), "", MinCheng["GJ_JIFAN"].ToString());
geng.PopulateOnDemand = true;//false
geng.SelectAction = TreeNodeSelectAction.None;
if (Node.Text == MinCheng["GJ_QUYU"].ToString())
{ Node.ChildNodes.Add(geng); }
}
MinCheng.Close();
}
void tiancong_ye1(TreeNode Node)
{
Socut.Reader MinCheng = new Socut.Reader("SELECT * FROM GJ_ZIYUAN");
while (MinCheng.Read())
{
TreeNode geng = new TreeNode(MinCheng["GJ_JIFAN"].ToString(), MinCheng["GJ_JIFAN"].ToString());
geng.PopulateOnDemand = false;//true
geng.SelectAction = TreeNodeSelectAction.None;
Node.ChildNodes.Add(geng);
}
MinCheng.Close();
}
void tiancong_ye2(TreeNode Node)
{
Socut.Reader MinCheng = new Socut.Reader("SELECT * FROM Fo_Xian");
while (MinCheng.Read())
{
TreeNode geng = new TreeNode(MinCheng["Ming_Cheng"].ToString(), MinCheng["ChuanJian_Ren"].ToString());
geng.PopulateOnDemand = false;
geng.SelectAction = TreeNodeSelectAction.None;
Node.ChildNodes.Add(geng);
}
MinCheng.Close();
}