日期:2014-05-18 浏览次数:21048 次
/// <summary> /// 设置所有功能模块信息 /// </summary> private void GetAllModuleInfo() { this.tvModules.Nodes.Clear(); DataSet ds = new ModelOperation.ManageModules().GetAllListModules(); TreeNode parent = null; foreach (DataRow row in ds.Tables[0].Rows) { if (row["parentid"].ToString() == "NULL") { parent = new TreeNode(); parent.Tag = row["MODULEID"].ToString(); parent.Text = row["MODULENAME"].ToString(); FillTree(parent, ds.Tables[0]); tvModules.Nodes.Add(parent); } } string roleId = ""; if (tvRoles.SelectedNode != null) { roleId = tvRoles.SelectedNode.Tag.ToString(); } string strWhere = " roleId= '" + roleId + "'"; DataSet moduleRoleDataSet = new ModelOperation.ModuleRolesOperation().GetRolesByWhere(strWhere); if (moduleRoleDataSet != null) { SetModulesChecked(tvModules.Nodes, moduleRoleDataSet); } } public void SetModulesChecked(TreeNodeCollection nodes, DataSet ds) { foreach (TreeNode item in nodes) { item.Checked = false; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (item.Tag.ToString() == ds.Tables[0].Rows[i]["moduleid"].ToString()) { item.Checked = true; } } SetModulesChecked(item.Nodes, ds); } }