private void CreateTree()
{
TreeNode rootnode = new TreeNode();
rootnode.Text = "部门用户信息";
TreeView1.Nodes.Add(rootnode);
DataSet dsbm = new DataSet();
DataSet dsxm = new DataSet();
CommonDB = new Common();
CommonXM = new Common();
string sql,sqlsub;
sql = "Select Distinct B.BuMMC From BuMXXB B";
sql += " Order By BuMMC ";
dsbm = CommonDB.DataSets(sql);
foreach (DataRow dr in dsbm.Tables[0].Rows)
{
TreeNode treenode = new TreeNode();
treenode.Text = dr["BuMMC"].ToString().Trim();
rootnode.ChildNodes.Add(treenode);
sqlsub = "Select B.BuMMC,Y.XingM From BuMXXB B ,YongHXXB Y ";
sqlsub += "Where B.BuMBH=Y.QuanXBH And B.BuMMC= '" + treenode.Text + "'";
dsxm = CommonXM.DataSets(sqlsub);
foreach (DataRow drxm in dsxm.Tables[0].Rows)
{
TreeNode nodeXm = new TreeNode();
if (drxm["BuMMC"].ToString() == treenode.Text)
{
nodeXm.Text = drxm["XingM"].ToString();
treenode.ChildNodes.Add(nodeXm);
}
}
}
}