示例#1
0
        private void 新增节点ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddTreeNode frm = new AddTreeNode();

            this.AddNodeName = "";
            frm.myDelMsg     = new DelegateParam(SetNodeName);
            frm.ShowDialog();

            string addName = this.AddNodeName;
            //AccountGameMg/UpdateGameModel

            string strController = "";
            string strAction     = "";
            string strLink       = "";

            if (this.AddStrLink != "")
            {
                strLink       = "/" + this.AddStrLink;
                strController = this.AddStrLink.Split('/')[0];
                strAction     = this.AddStrLink.Split('/')[1];
            }


            if (addName != "")
            {
                TreeNode node = (sender as ToolStripMenuItem).GetCurrentParent().Tag as TreeNode;
                if (node != null)
                {
                    //计算ItemID
                    TreeNode tnLast    = node.LastNode;
                    long     l         = 0;
                    int      order     = 1;
                    string   xml       = "";
                    int      hierarchy = 0; //层级
                    if (tnLast != null)
                    {
                        xml   = tnLast.Tag.ToString();
                        l     = long.Parse(GetXmlNodeStringByAttribute(xml, "ID")) + 1;
                        order = int.Parse(GetXmlNodeStringByAttribute(xml, "Order")) + 1;
                    }
                    else
                    {
                        xml = node.Tag.ToString();
                        l   = long.Parse(GetXmlNodeStringByAttribute(xml, "ID") + "01");
                    }

                    xml = node.Tag.ToString();
                    long ParentId = long.Parse(GetXmlNodeStringByAttribute(xml, "ID"));
                    hierarchy = int.Parse(GetXmlNodeStringByAttribute(xml, "Hierarchy")) + 1; //层级
                    string tagString = "<Item ID=\"" + l.ToString() + "\" Hierarchy=\"" + hierarchy + "\" ParentId=\"" + ParentId + "\" Order=\"" + order + "\" Remark=\"New\" Controller=\"" + strController + "\" Action=\"" + strAction + "\" Link=\"" + strLink + "\">" + addName + "</Item>";
                    string copystr   = "[PermissionAccountFilter(ItemIdByChildCompany = \"" + l.ToString() + "\")]";
                    Clipboard.SetDataObject(copystr); //复制新增的ItemId 到粘贴板
                    NewListItem.Add(tagString);

                    TreeNode nodeChild = InitTreeNode(addName + "_" + l.ToString() + "_" + hierarchy.ToString(), tagString);
                    node.Nodes.Add(nodeChild);
                }
            }
        }
示例#2
0
        private void 新增节点ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddTreeNode frm = new AddTreeNode();

            this.AddNodeName = "";
            frm.myDelMsg     = new DelegateParam(SetNodeName);
            frm.ShowDialog();

            string addName = this.AddNodeName;

            if (addName != "")
            {
                TreeNode node = (sender as ToolStripMenuItem).GetCurrentParent().Tag as TreeNode;
                if (node != null)
                {
                    //计算ItemID
                    TreeNode tnLast = node.LastNode;
                    long     l      = 0;
                    int      order  = 1;
                    string   xml    = "";
                    if (tnLast != null)
                    {
                        xml   = tnLast.Tag.ToString();
                        l     = long.Parse(GetXmlNodeStringByAttribute(xml, "ID")) + 1;
                        order = int.Parse(GetXmlNodeStringByAttribute(xml, "Order")) + 1;
                    }
                    else
                    {
                        xml = node.Tag.ToString();
                        l   = long.Parse(GetXmlNodeStringByAttribute(xml, "ID") + "01");
                    }

                    xml = node.Tag.ToString();
                    long   ParentId  = long.Parse(GetXmlNodeStringByAttribute(xml, "ID"));
                    string tagString = "<Item ID=\"" + l.ToString() + "\" ParentId=\"" + ParentId + "\" Order=\"" + order + "\">" + addName + "</Item>";
                    Clipboard.SetDataObject(l.ToString()); //复制新增的ItemId 到粘贴板
                    NewListItem.Add(tagString);

                    TreeNode nodeChild = InitTreeNode(addName + "_" + l.ToString(), tagString);
                    node.Nodes.Add(nodeChild);
                }
            }
        }