예제 #1
0
        /// <summary>
        /// Add Node to root node  and tree bar(favorite) list
        /// </summary>
        /// <param name="Node_ID">node key id</param>
        /// <param name="Parent_ID">parent node id </param>
        /// <param name="seqNo"> seq no</param>
        /// <param name="onBar">node is in favorite tree or not</param>
        private void AddToTree(int Node_ID, int Parent_ID, int seqNo, bool onBar)
        {
            //  Create new Node
            VTreeNode child = GetNodeDetail(Node_ID, Parent_ID, seqNo, onBar);

            if (child == null)
            {
                return;
            }

            //  Add to Tree
            VTreeNode parent = null;

            if (onBar == true) // if in favorite (short -cut)
            {
                VTreeNode childBar = GetNodeDetail(Node_ID, Parent_ID, seqNo, onBar);
                barNodes.Insert(barNodes.Count, childBar);
            }

            if (root != null)
            {
                if (child.Parent_ID == 0)
                {
                    root.Nodes.Add(child);
                }
                else
                {
                    mnuNodes.Add(child);
                }   //  addToTree
            }
        }
예제 #2
0
        /// <summary>
        /// Constructor copy node and its child nodes
        /// </summary>
        /// <param name="node"></param>
        /// <param name="copyChild"></param>
        public VTreeNode(VTreeNode node, bool copyChild)
        {
            _Node_ID  = node.Node_ID;
            this.Name = node.Node_ID.ToString();
            _seqNo    = int.Parse(node.GetSeqNo());
            _name     = node.Text;
            this.Text = node.Text;

            this.ImageKey         = node.ImageKey;
            this.SelectedImageKey = node.SelectedImageKey;

            _description     = node.GetDescription;
            this.ToolTipText = node.ToolTipText;

            _Parent_ID = node.Parent_ID;

            _isSummary = node.IsSummary;        /** Image Indicator				*/

            _imageIndicator = node.ImageKey;

            _AD_Window_ID = node.AD_Window_ID;

            _AD_Process_ID = node.AD_Process_ID;

            _AD_Form_ID = node.AD_Form_ID;

            _AD_Workflow_ID = node.AD_Workflow_ID;

            _AD_Task_ID = node.AD_Task_ID;

            _AD_Workbench_ID = node.AD_Workflow_ID;

            _imageIndex = 0;
            /**	On Bar			*/
            _onBar = node.OnBar;

            //  TreeNodeCollection myTreeNodeCollection = node.Nodes;
            // Create an array of 'TreeNodes'.
            TreeNode[] myTreeNodeArray = new TreeNode[node.Nodes.Count];
            // Copy the tree nodes to the 'myTreeNodeArray' array.
            node.Nodes.CopyTo(myTreeNodeArray, 0);
            // Remove all the tree nodes from the 'myTreeViewBase' TreeView.

            try
            {
                node.Nodes.Clear();
                this.Nodes.AddRange(myTreeNodeArray);
            }
            catch
            {
            }
        }
예제 #3
0
 /// <summary>
 ///Return the Node with ID in list of children
 /// </summary>
 /// <param name="ID"></param>
 /// <returns></returns>
 public VTreeNode FindNode(int ID)
 {
     if (_Node_ID == ID)
     {
         return(this);
     }
     ////
     if (ID == _lastID && _lastNode != null)
     {
         return(_lastNode);
     }
     ////
     TreeNode[] node = this.Nodes.Find(ID.ToString(), true);
     if (node.GetLength(0) > 0)
     {
         _lastID   = ID;
         _lastNode = (VTreeNode)node[0];
         return(_lastNode);
     }
     return(null);
 }
예제 #4
0
        }  //  VTreeNode

        /// <summary>
        /// copy Node Attribute(clone)
        /// </summary>
        /// <param name="node">TreeNode</param>
        public VTreeNode(VTreeNode node)
        {
            _Node_ID  = node.Node_ID;
            this.Name = node.Node_ID.ToString();
            _seqNo    = int.Parse(node.GetSeqNo());
            _name     = node.Text;
            this.Text = node.Text;

            this.ImageKey         = node.ImageKey;
            this.SelectedImageKey = node.SelectedImageKey;

            _description     = node.GetDescription;
            this.ToolTipText = node.ToolTipText;

            _Parent_ID = node.Parent_ID;

            _isSummary = node.IsSummary;        /** Image Indicator				*/

            _imageIndicator = node.ImageKey;

            _AD_Window_ID = node.AD_Window_ID;

            _AD_Process_ID = node.AD_Process_ID;

            _AD_Form_ID = node.AD_Form_ID;

            _AD_Workflow_ID = node.AD_Workflow_ID;

            _AD_Task_ID = node.AD_Task_ID;

            _AD_Workbench_ID = node.AD_Workflow_ID;

            _imageIndex = 0;
            /**	On Bar			*/
            _onBar = node.OnBar;
            if (_imageIndex < 0)
            {
                _imageIndex = 0;
            }
        }
예제 #5
0
        /// <summary>
        /// remove summery node having no children
        /// </summary>
        /// <param name="tn">tree node</param>
        private void TrimTree(TreeNode tn)
        {
            for (int i = 0; i < tn.Nodes.Count; i++)
            {
                VTreeNode node = (VTreeNode)tn.Nodes[i];
                if (node.IsSummary && node.Nodes.Count < 1)
                {
                    root.Nodes.Remove(node);

                    if (barNodes.Contains(node))
                    {
                        barNodes.Remove(node);
                    }
                    i = -1;
                }
                else
                {
                    if (node.Nodes.Count > 0)
                    {
                        TrimTree(node);
                    }
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Initilize tree loading process
        /// </summary>
        /// <param name="AD_Tree_ID">tree key id</param>
        public void InitTree(int AD_Tree_ID)
        {
            //Get Root node info
            string      str = "Select name,description from ad_tree where ad_tree_id =" + AD_Tree_ID;
            IDataReader drRoot = DataBase.DB.ExecuteReader(str);
            string      strRootName, strDesc;

            drRoot.Read();
            strRootName = drRoot[0].ToString();
            strDesc     = drRoot[1].ToString();
            drRoot.Close();
            //
            StringBuilder sql = new StringBuilder("SELECT ")
                                .Append(" tn.Node_ID,tn.Parent_ID,tn.SeqNo,tb.IsActive ")
                                .Append(" FROM " + GetTableName() + "  tn")
                                .Append(" LEFT OUTER JOIN AD_TreeBar tb ON (tn.AD_Tree_ID=tb.AD_Tree_ID")
                                .Append(" AND tn.Node_ID=tb.Node_ID AND tb.AD_User_ID=" + ctx.GetAD_User_ID() + ") ") //	#1
                                .Append(" WHERE tn.AD_Tree_ID=" + AD_Tree_ID);

            if (!_editable)
            {
                sql.Append(" AND tn.IsActive='Y' ");
            }
            sql.Append(" ORDER BY COALESCE(tn.Parent_ID, -1), tn.SeqNo");

            //Get All Nodes Info (eg. name description etc);
            GetNodeDetail();

            IDataReader dr = DataBase.DB.ExecuteReader(sql.ToString());

            // Create Root node
            root = new VTreeNode(0, 0, strRootName, strDesc, 0, false, "O", false);

            while (dr.Read())
            {
                int Node_ID   = Utility.Util.GetValueOfInt(dr[0].ToString());
                int Parent_ID = 0;
                try
                {
                    Parent_ID = Utility.Util.GetValueOfInt(dr[1].ToString());
                }
                catch
                {
                    Parent_ID = 0;
                }
                int seqNo = Utility.Util.GetValueOfInt(dr[2].ToString());
                //Node in Favorite menu or not
                bool onBar = (dr[3] != null) ? ((dr[3].ToString() == "Y") ? true : false) : false;
                if (Node_ID == 0 && Parent_ID == 0)
                {
                }
                else
                {
                    AddToTree(Node_ID, Parent_ID, seqNo, onBar);        //	get node detail and add to root node
                }
            }
            dr.Close();

            // Get From list
            for (int i = 0; i < mnuNodes.Count; i++)
            {
                VTreeNode node   = mnuNodes[i];
                VTreeNode parent = FindTreeNode(root.Nodes, node.Parent_ID.ToString());
                if (parent != null)
                {
                    parent.Nodes.Add(node);
                    if (parent.FirstNode.Level > maxLevel)
                    {
                        maxLevel = parent.FirstNode.Level;
                    }
                    //CheckList(node);
                    mnuNodes.RemoveAt(i);
                    i = -1;             //	start again with i=0
                }
            }


            //	Nodes w/o parent
            if (mnuNodes.Count != 0)
            {
                //log.severe ("Nodes w/o parent - adding to root - " + m_buffer);
                for (int i = 0; i < mnuNodes.Count; i++)
                {
                    VTreeNode node = mnuNodes[i];
                    root.Nodes.Add(node);
                    mnuNodes.RemoveAt(i);
                    i = -1;
                }
            }

            //remove summary node, not having  child node
            if (!_editable)
            {
                TrimTree(root);
            }
        }
예제 #7
0
        /// <summary>
        /// set node properties
        /// </summary>
        /// <param name="Node_ID">node key id</param>
        /// <param name="Parent_ID">parent node id</param>
        /// <param name="seqNo">seq no</param>
        /// <param name="onBar">node in favorite tree</param>
        /// <returns>VTreeNode </returns>

        private VTreeNode GetNodeDetail(int Node_ID, int Parent_ID, int seqNo, bool onBar)
        {
            int AD_Window_ID    = 0;
            int AD_Process_ID   = 0;
            int AD_Form_ID      = 0;
            int AD_Workflow_ID  = 0;
            int AD_Task_ID      = 0;
            int AD_Workbench_ID = 0;

            VTreeNode retValue = null;

            string strColumnName = "";

            if (treeType == TreeType.MM)
            {
                strColumnName = "Ad_Menu_Id";
            }
            else
            {
                strColumnName = "Ad_ORG_ID";
            }

            // Serch For Node details
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int node1 = Utility.Util.GetValueOfInt(dt.Rows[i][0].ToString());
                if (Node_ID != node1)   //	search for correct one
                {
                    continue;
                }
                DataRow dr = dt.Rows[i];

                int node  = Utility.Util.GetValueOfInt(dr[0].ToString());
                int index = 1;

                string name        = dr[index++].ToString();
                string description = dr[index++].ToString();
                bool   isSummary   = "Y".Equals(dr[index++].ToString());
                string actionColor = "";
                //	Menu only
                //if (getTreeType().equals(TREETYPE_Menu) && !isSummary)
                if (!isSummary)
                {
                    bool?blnAccess = null;
                    if (treeType == TreeType.MM)
                    {
                        actionColor  = dr[index++].ToString();
                        AD_Window_ID = (dr[index].ToString().Trim() == "") ? 0 : Utility.Util.GetValueOfInt(dr[index].ToString());
                        index++;
                        AD_Process_ID = (dr[index].ToString().Trim() == "") ? 0 : Utility.Util.GetValueOfInt(dr[index].ToString());
                        index++;
                        AD_Form_ID = (dr[index].ToString().Trim() == "") ? 0 : Utility.Util.GetValueOfInt(dr[index].ToString());
                        index++;
                        AD_Workflow_ID = (dr[index].ToString().Trim() == "") ? 0 : Utility.Util.GetValueOfInt(dr[index].ToString());
                        index++;
                        AD_Task_ID = (dr[index].ToString().Trim() == "") ? 0 : Utility.Util.GetValueOfInt(dr[index].ToString());
                        index++;
                        AD_Workbench_ID = (dr[index].ToString().Trim() == "") ? 0 : Utility.Util.GetValueOfInt(dr[index].ToString());
                        index++;
                        MRole role = MRole.GetDefault(ctx);
                        if (VTreeNode.ACTION_WINDOW.Equals(actionColor))
                        {
                            blnAccess = role.GetWindowAccess(AD_Window_ID);
                        }
                        else if (VTreeNode.ACTION_PROCESS.Equals(actionColor) ||
                                 VTreeNode.ACTION_REPORT.Equals(actionColor))
                        {
                            blnAccess = role.GetProcessAccess(AD_Process_ID);
                        }
                        else if (VTreeNode.ACTION_FORM.Equals(actionColor))
                        {
                            blnAccess = role.GetFormAccess(AD_Form_ID);
                        }
                        else if (VTreeNode.ACTION_WORKFLOW.Equals(actionColor))
                        {
                            blnAccess = role.GetWorkflowAccess(AD_Workflow_ID);
                        }
                        else if (VTreeNode.ACTION_TASK.Equals(actionColor))
                        {
                            blnAccess = role.GetTaskAccess(AD_Task_ID);
                        }
                    }
                    if (blnAccess != null || _editable)         //	rw or ro for Role
                    {
                        retValue = new VTreeNode(Node_ID, seqNo,
                                                 name, description, Parent_ID, isSummary,
                                                 actionColor, onBar); //	menu has no color
                    }
                }
                else
                {
                    retValue = new VTreeNode(Node_ID, seqNo,
                                             name, description, Parent_ID, isSummary,
                                             actionColor, onBar);
                }
                break;
            }

            if (retValue != null && treeType == TreeType.MM)
            {
                // set VTreeNode ID's
                retValue.AD_Window_ID    = AD_Window_ID;
                retValue.AD_Process_ID   = AD_Process_ID;
                retValue.AD_Form_ID      = AD_Form_ID;
                retValue.AD_Workflow_ID  = AD_Workflow_ID;
                retValue.AD_Task_ID      = AD_Task_ID;
                retValue.AD_Workbench_ID = AD_Workbench_ID;
            }
            return(retValue);
        }