Esempio n. 1
0
        /// <summary>
        /// Bind Device With Recursion.
        /// </summary>
        /// <param name="collection">collection</param>
        /// <param name="parentId">parent id</param>
        /// <param name="nodes">result node</param>
        private void BindDeviceRecursion(TreeNodeCollection collection, Int32 pId)
        {
            var SubNodes = CurNodes.FindAll(n => n.LastNodeID == pId);

            foreach (var node in SubNodes)
            {
                if (CurBehavior == EnmSaveBehavior.Add && node.NodeType == EnmNodeType.Dev && CurExistsNodes.ContainsKey(node.NodeID))
                {
                    continue;
                }
                var tnode = new TreeNode(Common.GetTreeNodeName(node));
                tnode.Tag              = new IDValuePair <Int32, EnmNodeType>(node.NodeID, node.NodeType);
                tnode.ImageKey         = node.NodeType == EnmNodeType.Dev ? "Device" : "Area";
                tnode.SelectedImageKey = node.NodeType == EnmNodeType.Dev ? "Device" : "Area";

                BindDeviceRecursion(tnode.Nodes, node.NodeID);
                if (CurBehavior == EnmSaveBehavior.Edit)
                {
                    if (tnode.Nodes.Count > 0 || (node.NodeType == EnmNodeType.Dev && CurCardAuth.Any(c => c.DevId == node.NodeID)))
                    {
                        tnode.Checked = true;
                        collection.Add(tnode);
                    }
                }
                else if (CurBehavior == EnmSaveBehavior.Add)
                {
                    if (tnode.Nodes.Count > 0 || node.NodeType == EnmNodeType.Dev)
                    {
                        collection.Add(tnode);
                    }
                }
            }
        }
        /// <summary>
        /// Bind Device With Recursion.
        /// </summary>
        private void BindDeviceRecursion(TreeNode pNode, Int32 pId)
        {
            var SubNodes = CurNodes.FindAll(n => n.LastNodeID == pId);

            foreach (var node in SubNodes)
            {
                var tnode = pNode.Nodes.Add(Common.GetTreeNodeName(node));
                tnode.Tag              = new IDValuePair <Int32, EnmNodeType>(node.NodeID, node.NodeType);
                tnode.ImageKey         = node.NodeType == EnmNodeType.Dev ? "Device" : "Area";
                tnode.SelectedImageKey = node.NodeType == EnmNodeType.Dev ? "Device" : "Area";

                BindDeviceRecursion(tnode, node.NodeID);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Bind Station With Recursion.
        /// </summary>
        /// <param name="collection">collection</param>
        /// <param name="parentId">parent id</param>
        private void BindStationRecursion(TreeNodeCollection collection, Int32 pId)
        {
            var nodes = Common.CurUser.Role.Nodes.FindAll(n => n.LastNodeID == pId);

            foreach (var node in nodes)
            {
                if (node.NodeType == EnmNodeType.Dev)
                {
                    continue;
                }
                var tn = collection.Add(Common.GetTreeNodeName(node));
                tn.Tag = new IDValuePair <Int32, EnmNodeType>(node.NodeID, node.NodeType);

                BindStationRecursion(tn.Nodes, node.NodeID);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Bind Nodes TreeView.
        /// </summary>
        /// <param name="collection">parent collection</param>
        /// <param name="lastId">parent id</param>
        /// <param name="nodes">nodes</param>
        private void BindNodesTreeView(TreeNodeCollection collection, Int32 lastId, List <NodeLevelInfo> nodes)
        {
            if (nodes != null && nodes.Count > 0)
            {
                var SubNodes = nodes.FindAll(n => { return(n.LastNodeID == lastId); }).OrderBy(a => a.SortIndex).ToList();
                if (SubNodes.Count > 0)
                {
                    foreach (var sn in SubNodes)
                    {
                        var treeNode = new TreeNode();
                        treeNode.Text             = Common.GetTreeNodeName(sn);
                        treeNode.Tag              = new IDValuePair <Int32, EnmNodeType>(sn.NodeID, sn.NodeType);
                        treeNode.ImageKey         = sn.NodeType == EnmNodeType.Dev ? "Device" : "Area";
                        treeNode.SelectedImageKey = sn.NodeType == EnmNodeType.Dev ? "Device" : "Area";
                        collection.Add(treeNode);

                        BindNodesTreeView(treeNode.Nodes, sn.NodeID, nodes);
                    }
                }
            }
        }