let it be
行到水穷处 坐看云起时

    public void ParentNode()    //创建父节点
    {
        string sql;
        if (p == "999999")
        {
            sql = "select id,LBMC from WJLBB where parent_id=0";
        }
        else
        {
            sql = "select id,LBMC from WJLBB where parent_id=0 and bmbh='" + bmbh + "'";
        }
        DataSet ds = newdbclient.DataSets(sql);
        if (ds.Tables[0].Rows.Count != 0)
        {
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                TreeNode tn = new TreeNode();
                tn.Text = ds.Tables[0].Rows[i]["LBMC"].ToString();
                tn.Value = ds.Tables[0].Rows[i]["id"].ToString();
                TreeView1.Nodes.Add(tn);
                ChildNode(tn, tn.Value);
                //this.treeView1.Nodes.Add("onclick", "CheckEvent()");
            }
        }

    }

    public void ChildNode(TreeNode node, string fdeptid)    //递归取出父节点下的子节点
    {
        string sql = "select id,LBMC from WJLBB where kf='开放' and parent_id='" + fdeptid + "'";
        DataSet ds = newdbclient.DataSets(sql);
        if (ds.Tables[0].Rows.Count != 0)
        {
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                TreeNode tn = new TreeNode();
                tn.Text = ds.Tables[0].Rows[i]["LBMC"].ToString();
                tn.Value = ds.Tables[0].Rows[i]["id"].ToString();
                node.ChildNodes.Add(tn);
                //UserNode(tn, tn.Value);     //在子节点下创建人员节点
                ChildNode(tn, tn.Value);
            }
        }
    }

posted on 2012-01-04 13:09  流浪浪  阅读(253)  评论(0编辑  收藏  举报