private void SaveChildRight(string roleCode, Model.TreeModel tree, ref string sql) { foreach (Model.TreeModel child in tree.Children) { sql += GetRightSql(roleCode, child.Id, child.IsChecked); SaveChildRight(roleCode, child, ref sql); } }
private void ShowChildRight(Model.TreeModel tree, IList <string> rs) { foreach (Model.TreeModel child in tree.Children) { child.IsChecked = rs.Contains(child.Id); ShowChildRight(child, rs); } }
/// <summary> /// 选中所有子项菜单事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void menuSelectAllChild_Click(object sender, RoutedEventArgs e) { if (tvZsmTree.SelectedItem != null) { Model.TreeModel tree = (Model.TreeModel)tvZsmTree.SelectedItem; tree.IsChecked = true; tree.SetChildrenChecked(true); } }
private void ShowAllRole() { IList <Model.TreeModel> treeList = new List <Model.TreeModel>(); string sql = "select rolecode,rolename from sys_role order by rolecode"; DataTable dtRole; csSql.ExecuteSelect(sql, Config.Soft.ConnString, out dtRole); if (dtRole != null && dtRole.Rows.Count > 0) { foreach (DataRow row in dtRole.Rows) { Model.TreeModel tree = new Model.TreeModel(); tree.Id = row["rolecode"].ToString().Trim(); tree.Name = row["rolename"].ToString().Trim(); tree.IsExpanded = true; treeList.Add(tree); } } tvRole.ItemsSourceData = treeList; }
private void ShowAllRight() { IList <Model.TreeModel> treeList = new List <Model.TreeModel>(); string sql = "select menucode,menuname from sys_menu where parentcode='0'"; DataTable dtRight; csSql.ExecuteSelect(sql, Config.Soft.ConnString, out dtRight); if (dtRight != null && dtRight.Rows.Count > 0) { foreach (DataRow row in dtRight.Rows) { Model.TreeModel tree = new Model.TreeModel(); tree.Id = row["menucode"].ToString().Trim(); tree.Name = row["menuname"].ToString().Trim(); tree.IsExpanded = true; treeList.Add(tree); AddTreeNode(tree, tree.Id); } } tvRight.ItemsSourceData = treeList; }
private void AddTreeNode(Model.TreeModel tree, string parCode) { string sql = "select menucode,menuname from sys_menu where parentcode='{0}'"; sql = string.Format(sql, parCode); DataTable dtRight; csSql.ExecuteSelect(sql, Config.Soft.ConnString, out dtRight); if (dtRight != null && dtRight.Rows.Count > 0) { foreach (DataRow row in dtRight.Rows) { Model.TreeModel child = new Model.TreeModel(); child.Id = row["menucode"].ToString().Trim(); child.Name = row["menuname"].ToString().Trim(); child.IsExpanded = true; child.Parent = tree; tree.Children.Add(child); AddTreeNode(child, child.Id); } } }