Пример #1
0
        void menu_quickSetRights_Click(object sender, EventArgs e)
        {
            /*
            // 兑现本次树上修改
            if (treeView_resRightTree.Changed == true)
                treeView_resRightTree.FinishRightsParam();
            */

            TreeNode node = this.treeView_resRightTree.SelectedNode;
            if (node == null)
                node = this.treeView_resRightTree.Nodes[0];

            QuickSetDatabaseRightsDlg dlg = new QuickSetDatabaseRightsDlg();
            dlg.Font = GuiUtil.GetDefaultFont();

            dlg.CfgFileName = "quickrights.xml";
            dlg.AllObjectNames = new List<ObjectInfo>();

            // 根
            ObjectInfo objectinfo = new ObjectInfo();
            objectinfo.Path = "服务器";
            objectinfo.ImageIndex = ResTree.RESTYPE_SERVER;
            dlg.AllObjectNames.Add(objectinfo);

            for (int i = 0; i < treeView_resRightTree.Nodes[0].Nodes.Count; i++)
            {
                objectinfo = new ObjectInfo();
                objectinfo.Path = treeView_resRightTree.Nodes[0].Nodes[i].Text;
                objectinfo.ImageIndex = treeView_resRightTree.Nodes[0].Nodes[i].ImageIndex;
                dlg.AllObjectNames.Add(objectinfo);
            }

            dlg.SelectedObjectNames = new List<ObjectInfo>();
            if (node.ImageIndex == ResTree.RESTYPE_DB)
            {
                objectinfo = new ObjectInfo();
                objectinfo.Path = node.Text;
                objectinfo.ImageIndex = node.ImageIndex;

                // 如果选定的是数据库节点
                dlg.SelectedObjectNames.Add(objectinfo);
            }
            else if (node.ImageIndex == ResTree.RESTYPE_SERVER)
            {
                // 如果选定的是服务器节点
                dlg.SelectedObjectNames.AddRange(dlg.AllObjectNames);
            }
            else
            {
                // 如果选定的是其他类型节点
                // 得到路径
                string strPath = "";
                TreeNode nodeCur = node;
                while(nodeCur != null)
                {
                    if (nodeCur.ImageIndex == ResTree.RESTYPE_SERVER)
                        break;
                    if (strPath != "")
                        strPath = "/" + strPath;
                    strPath = nodeCur.Text + strPath;
                    nodeCur = nodeCur.Parent;
                }

                objectinfo = new ObjectInfo();
                objectinfo.Path = strPath;
                objectinfo.ImageIndex = node.ImageIndex;


                dlg.SelectedObjectNames.Add(objectinfo);
            }

    
            this.MainForm.AppInfo.LinkFormState(dlg, "QuickSetDatabaseRightsDlg_state");
            dlg.ShowDialog(this);
            this.MainForm.AppInfo.UnlinkFormState(dlg);

            if (dlg.DialogResult != DialogResult.OK)
                return;


            // 兑现修改
            ModiRights(dlg.SelectedObjectNames,
                dlg.QuickRights);

            this.listView_resRightList.RefreshList();

            this.textBox_objectRights_rights.Text = ResRightTree.GetNodeRights(treeView_resRightTree.SelectedNode);

        }
Пример #2
0
        void menu_quickSetRights_Click(object sender, EventArgs e)
        {
            /*
             * // 兑现本次树上修改
             * if (treeView_resRightTree.Changed == true)
             *  treeView_resRightTree.FinishRightsParam();
             */

            TreeNode node = this.treeView_resRightTree.SelectedNode;

            if (node == null)
            {
                node = this.treeView_resRightTree.Nodes[0];
            }

            QuickSetDatabaseRightsDlg dlg = new QuickSetDatabaseRightsDlg();

            dlg.Font = GuiUtil.GetDefaultFont();

            dlg.CfgFileName    = "quickrights.xml";
            dlg.AllObjectNames = new List <ObjectInfo>();

            // 根
            ObjectInfo objectinfo = new ObjectInfo();

            objectinfo.Path       = "服务器";
            objectinfo.ImageIndex = ResTree.RESTYPE_SERVER;
            dlg.AllObjectNames.Add(objectinfo);

            for (int i = 0; i < treeView_resRightTree.Nodes[0].Nodes.Count; i++)
            {
                objectinfo            = new ObjectInfo();
                objectinfo.Path       = treeView_resRightTree.Nodes[0].Nodes[i].Text;
                objectinfo.ImageIndex = treeView_resRightTree.Nodes[0].Nodes[i].ImageIndex;
                dlg.AllObjectNames.Add(objectinfo);
            }

            dlg.SelectedObjectNames = new List <ObjectInfo>();
            if (node.ImageIndex == ResTree.RESTYPE_DB)
            {
                objectinfo            = new ObjectInfo();
                objectinfo.Path       = node.Text;
                objectinfo.ImageIndex = node.ImageIndex;

                // 如果选定的是数据库节点
                dlg.SelectedObjectNames.Add(objectinfo);
            }
            else if (node.ImageIndex == ResTree.RESTYPE_SERVER)
            {
                // 如果选定的是服务器节点
                dlg.SelectedObjectNames.AddRange(dlg.AllObjectNames);
            }
            else
            {
                // 如果选定的是其他类型节点
                // 得到路径
                string   strPath = "";
                TreeNode nodeCur = node;
                while (nodeCur != null)
                {
                    if (nodeCur.ImageIndex == ResTree.RESTYPE_SERVER)
                    {
                        break;
                    }
                    if (strPath != "")
                    {
                        strPath = "/" + strPath;
                    }
                    strPath = nodeCur.Text + strPath;
                    nodeCur = nodeCur.Parent;
                }

                objectinfo            = new ObjectInfo();
                objectinfo.Path       = strPath;
                objectinfo.ImageIndex = node.ImageIndex;


                dlg.SelectedObjectNames.Add(objectinfo);
            }


            this.MainForm.AppInfo.LinkFormState(dlg, "QuickSetDatabaseRightsDlg_state");
            dlg.ShowDialog(this);
            this.MainForm.AppInfo.UnlinkFormState(dlg);

            if (dlg.DialogResult != DialogResult.OK)
            {
                return;
            }


            // 兑现修改
            ModiRights(dlg.SelectedObjectNames,
                       dlg.QuickRights);

            this.listView_resRightList.RefreshList();

            this.textBox_objectRights_rights.Text = ResRightTree.GetNodeRights(treeView_resRightTree.SelectedNode);
        }