public void OnSelectCommand(object sender, EventArgs e)
        {
            frmSelectCommand form = WorkItem.Items.Get <frmSelectCommand>(SelectCommandForm);

            if (form == null)
            {
                form = WorkItem.Items.AddNew <frmSelectCommand>(SelectCommandForm);
            }

            AuthorizationNode authNode = CurrentAuthNode.Tag as AuthorizationNode;

            form.AuthNode = authNode;
            form.RefreshList();

            // 为授权节点添加操作
            if (form.ShowDialog() == DialogResult.OK)
            {
                List <AuthorizationCommand> lcs = form.GetSelection();
                foreach (AuthorizationCommand ac in lcs)
                {
                    authNode.AddCommand(ac);
                    View.ListAuthorizationCommands(authNode); // 刷新操作列表
                    AuthorizationNodeService.Save(authNode);
                    UpdateRoleAuthorization(authNode);
                    CurrentAuthNode.Tag = authNode;
                }
            }
        }
        public void OnNewAuthNode(object sender, EventArgs e)
        {
            frmAuthNode form = GetAuthNodeForm();

            form.EditMode(false);
            form.AuthId   = "";
            form.AuthName = "";
            if (form.ShowDialog() == DialogResult.OK)
            {
                TreeListNode node = View.TLAuth.AppendNode(new object[] { form.AuthName, form.AuthId }, CurrentAuthNode);
                node.Tag = new AuthorizationNode()
                {
                    Id   = form.AuthId,
                    Name = form.AuthName
                };

                AuthorizationNode authNode = node.Tag as AuthorizationNode;
                if (authNode != null)
                {
                    authNode.AuthorizationUri = View.GetAuthrizationNodePath(node);
                    AuthorizationNodeService.Save(authNode);
                    UpdateRoleAuthorization(authNode);
                }

                node.ImageIndex       = 0;
                node.SelectImageIndex = 1;
                CurrentAuthNode.ExpandAll();
            }
        }
        public void OnEditAuthNode(object sender, EventArgs e)
        {
            frmAuthNode       form     = GetAuthNodeForm();
            AuthorizationNode authNode = CurrentAuthNode.Tag as AuthorizationNode;

            form.EditMode(true);
            form.AuthId   = authNode.Id;
            form.AuthName = authNode.Name;
            if (form.ShowDialog() == DialogResult.OK)
            {
                authNode.Id   = form.AuthId;
                authNode.Name = form.AuthName;
                AuthorizationNodeService.Save(authNode);
                UpdateRoleAuthorization(authNode);
            }
        }
        /// <summary>
        /// 删除选定数据资料
        /// </summary>
        public override void Delete()
        {
            if (XtraMessageBox.Show("你真的要删除选定的操作项吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                base.Delete();

                AuthorizationCommand command = View.TLCommands.Selection[0].Tag as AuthorizationCommand; // 获取准备删除的操作项

                if (CurrentAuthNode != null)
                {
                    AuthorizationNode authNode = CurrentAuthNode.Tag as AuthorizationNode;
                    authNode.RemoveCommand(command);
                    View.TLCommands.DeleteNode(View.TLCommands.Selection[0]);
                    CurrentAuthNode.Tag = authNode;
                    AuthorizationNodeService.Save(authNode); // 将变化保存回后端数据库

                    UpdateRoleAuthorization(authNode);
                }
            }
        }