AddNode("0", cbProcessperson.TreeView.Nodes);
private void AddNode(string strUserID, TreeNodeCollection NodeParent)
{
SaleBLL.Department_BLL deptBll = new SaleBLL.Department_BLL();
SaleBLL.employee_BLL empBll = new SaleBLL.employee_BLL();
DataTable deptDT = deptBll.DepartMentView();
DataView dv = deptDT.DefaultView;
dv.RowFilter = "dept_level='" + strUserID + "'";
TreeNode tempNode;
for (int i = 0; i < dv.Count; i++)
{
tempNode = new TreeNode();
tempNode.Text = dv[i]["dept_name"].ToString();//要显示的值
tempNode.Tag = dv[i]["dept_id"].ToString();
tempNode.Checked = true;//这个是当有checkbox时设置
tempNode.Collapse();
NodeParent.Add(tempNode);
string strWhere = " where dept_id=" + dv[i]["dept_id"].ToString();
DataTable dt = empBll.ViewEmployeeStatus(strWhere);
for (int j = 0; j < dt.Rows.Count; j++)
{
TreeNode tempNode1 = new TreeNode(dt.Rows[j]["employee_name"].ToString());
tempNode1.Tag = dt.Rows[i]["employee_id"].ToString();
tempNode.Nodes.Add(tempNode1);
}
AddNode(dv[i]["dept_id"].ToString(), tempNode.Nodes);
}
}