From c867d4e4b155d0df8792bcd8ce9913596615febd Mon Sep 17 00:00:00 2001 From: mschill Date: Wed, 23 Oct 2024 13:20:20 -0400 Subject: [PATCH] =?UTF-8?q?C2024-027=20RO=20Editor=20=E2=80=93=20Add=20add?= =?UTF-8?q?itional=20feature=20to=20allow=20Cut/Paste=20(Moving)=20a=20RO?= =?UTF-8?q?=20within=20the=20same=20table.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Exe/RefObj/ROEditor/ROEditor.cs | 995 +++++++++++------- .../Exe/RefObj/ROEditor/ROEditor.resx | 4 +- .../LibSource/RODBInterface/RODBInterface.cs | 15 +- .../LibSource/RODBInterface/SqlRODB.cs | 9 +- PROMS/VEPROMS User Interface/ROBuild.Sql | 6 +- 5 files changed, 661 insertions(+), 368 deletions(-) diff --git a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs index e2f8ed31..4cf8fc47 100644 --- a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs +++ b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs @@ -300,6 +300,8 @@ using RODBInterface; using ROFields; using Org.Mentalis.Files; using System.Runtime.InteropServices; +using System.Linq; +using System.Collections.Generic; //using IniFileIO; @@ -333,7 +335,9 @@ namespace ROEditor private System.Windows.Forms.MenuItem menuRO; private System.Windows.Forms.MenuItem menuRONew; private System.Windows.Forms.MenuItem menuNewRefObj; - private System.Windows.Forms.MenuItem menuROEdit; + private System.Windows.Forms.MenuItem menuROEdit; + private System.Windows.Forms.MenuItem menuROCut; + private System.Windows.Forms.MenuItem menuROPaste; private System.Windows.Forms.MenuItem menuRODelete; private System.Windows.Forms.MenuItem menuROSave; private System.Windows.Forms.MenuItem menuROProperties; @@ -352,11 +356,15 @@ namespace ROEditor private TextBox _CurrentTextBox; // currently selected TextBox field public static string[] PCChildren; //C2021-026 list of Parent/Child Children - public TextBox CurrentTextBox + public TextBox CurrentTextBox { get { return _CurrentTextBox; } set { _CurrentTextBox = value; } } + + public List ROsSelectedforMultiMove { get; set; } //to allow multiple RO nodes to be selected + public bool ROCutWasSelected { get; set; } = false; + private VlnXmlElement rootXml; private TreeNode rootNode; @@ -379,6 +387,7 @@ namespace ROEditor private const int ROGROUPIMAGE = 0; private System.Windows.Forms.Panel panel2; private const int ROIMAGE = 1; + private Color MULTISELECTCOLOR = Color.LightGreen; //back color that multiselected ROs will show private ToolBarButton tbtnSave; private ToolBarButton tbtnRestore; @@ -388,7 +397,7 @@ namespace ROEditor private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.ImageList imageListToolBar; private Label lblDuplicateRO; - private ToolBarButton tbtnZoom; + private ToolBarButton tbtnZoom; public Form1(string PassedInPath, string specificro) { @@ -405,13 +414,15 @@ namespace ROEditor DbConnectPath = PassedInPath; // Setup the context menu - MenuItem[] ContextMenuItemList = new MenuItem[6]; + MenuItem[] ContextMenuItemList = new MenuItem[8]; ContextMenuItemList[0] = new MenuItem("Expand/Collaspe",new EventHandler(roTreeView_ToggleExpandCollapse)); ContextMenuItemList[1] = menuRONew.CloneMenu(); ContextMenuItemList[2] = menuROEdit.CloneMenu(); - ContextMenuItemList[3] = menuRODelete.CloneMenu(); - ContextMenuItemList[4] = menuROSave.CloneMenu(); - ContextMenuItemList[5] = menuROProperties.CloneMenu(); + ContextMenuItemList[3] = menuROCut.CloneMenu(); + ContextMenuItemList[4] = menuROPaste.CloneMenu(); + ContextMenuItemList[5] = menuRODelete.CloneMenu(); + ContextMenuItemList[6] = menuROSave.CloneMenu(); + ContextMenuItemList[7] = menuROProperties.CloneMenu(); ContextMenu treePopupMenu = new ContextMenu(ContextMenuItemList); @@ -589,6 +600,8 @@ namespace ROEditor protected void roTreeView_AfterSelect (object sender, System.Windows.Forms.TreeViewEventArgs e) { + TreeNode PreviousNode = LastSelectedNode; + // if the same node was selected, don't do anything. if (LastSelectedNode != null && LastSelectedNode.Equals(roTreeView.SelectedNode)) return; @@ -622,7 +635,7 @@ namespace ROEditor // Enable the Save item if changes were made // Just copy the state of the Save Button menuROSave.Enabled = tbtnSave.Enabled; - roTreeView.ContextMenu.MenuItems[4].Enabled = tbtnSave.Enabled; + roTreeView.ContextMenu.MenuItems[6].Enabled = tbtnSave.Enabled; // Should the properties menu item be available? VlnXmlElement curelem = (VlnXmlElement) CurrentNode.Tag; @@ -651,9 +664,82 @@ namespace ROEditor EditRO(curelem); else updateRoListView(CurrentNode); + + //cut is only enabled on RO Values + menuROCut.Enabled = roTreeView_IsSubgroupOrRO() && curelem.Name != "vlnGroup"; + roTreeView.ContextMenu.MenuItems[3].Enabled = menuROCut.Enabled; + //paste is only enabled on subgroups and only once Cut has been selected + menuROPaste.Enabled = roTreeView_IsSubgroupOrRO() && curelem.Name == "vlnGroup" && ROCutWasSelected && (ROsSelectedforMultiMove.Count > 0); + roTreeView.ContextMenu.MenuItems[4].Enabled = menuROPaste.Enabled; + + //code to allow selection of multiple nodes for Move + //if Ctrl/Shift Key is held down + if (ROsSelectedforMultiMove == null) + ROsSelectedforMultiMove = new List(); + + if ((Control.ModifierKeys & Keys.Shift) != 0) + { + //if shift is held down, clear existing nodes then add the range of nodes + roTreeView_ClearAllMultiSelect(); + + if (PreviousNode.Index < CurrentNode.Index) + { + //Traverse Down + TreeNode nodeIter = PreviousNode; + do + { + VlnXmlElement curelemforNodeIter = (VlnXmlElement)nodeIter.Tag; + if (curelemforNodeIter.Name != "RO_Root" && curelemforNodeIter.Name != "vlnGroup") + { + nodeIter.BackColor = MULTISELECTCOLOR; + ROsSelectedforMultiMove.Add(nodeIter); + } + } + while (nodeIter != CurrentNode && (nodeIter = nodeIter.NextNode) != null); + } + else + { + //Traverse Up + TreeNode nodeIter = PreviousNode; + do + { + VlnXmlElement curelemforNodeIter = (VlnXmlElement)nodeIter.Tag; + if (curelemforNodeIter.Name != "RO_Root" && curelemforNodeIter.Name != "vlnGroup") + { + nodeIter.BackColor = MULTISELECTCOLOR; + ROsSelectedforMultiMove.Add(nodeIter); + } + } + while (nodeIter != CurrentNode && (nodeIter = nodeIter.PrevNode) != null); + } + } + else + { + //deselect all currently selected if ctrl key not held down, + //add the current item that is clicked + //ignoring if a group or subgroup is clicked + if (curelem.Name != "RO_Root" && curelem.Name != "vlnGroup") + { + if ((Control.ModifierKeys & Keys.Control) == 0) + roTreeView_ClearAllMultiSelect(); + + roTreeView.SelectedNode.BackColor = MULTISELECTCOLOR; + ROsSelectedforMultiMove.Add(roTreeView.SelectedNode); + } + } + } } + //clear all multiselected items + protected void roTreeView_ClearAllMultiSelect() + { + foreach (TreeNode tn in ROsSelectedforMultiMove) + tn.BackColor = Color.White; + + ROsSelectedforMultiMove.Clear(); + } + private string CvtUserFldToFld(string fldname) { if (fldname.Length < 2) @@ -783,25 +869,25 @@ namespace ROEditor // Should the save option be available? // Just reflect the Save button state. - roTreeView.ContextMenu.MenuItems[4].Enabled = tbtnSave.Enabled; + roTreeView.ContextMenu.MenuItems[6].Enabled = tbtnSave.Enabled; menuROSave.Enabled = tbtnSave.Enabled; // Should the properties menu item be available? VlnXmlElement curelem = (VlnXmlElement) CurrentNode.Tag; if (curelem.Name == "vlnGroup") - roTreeView.ContextMenu.MenuItems[5].Enabled = true; + roTreeView.ContextMenu.MenuItems[7].Enabled = true; else - roTreeView.ContextMenu.MenuItems[5].Enabled = false; + roTreeView.ContextMenu.MenuItems[7].Enabled = false; // should delete menu item be available, i.e. top node NO! if (curelem.Name == "RO_Root") { - roTreeView.ContextMenu.MenuItems[3].Enabled = false; + roTreeView.ContextMenu.MenuItems[5].Enabled = false; roTreeView.ContextMenu.MenuItems[1].MenuItems[1].Enabled = false; } else { - roTreeView.ContextMenu.MenuItems[3].Enabled = true; + roTreeView.ContextMenu.MenuItems[5].Enabled = true; roTreeView.ContextMenu.MenuItems[1].MenuItems[1].Enabled = true; } @@ -1069,7 +1155,7 @@ namespace ROEditor tbtnSave.Enabled = true; tbtnRestore.Enabled = true; tbtnSaveAs.Enabled = true; - } + } menuROSave.Enabled = tbtnSave.Enabled; } @@ -1146,6 +1232,7 @@ namespace ROEditor { chldnd = new TreeNode(TheMenuTitle,ROIMAGE,ROIMAGE); chldnd.Tag = echild; + chldnd.Name = echild.GetAttribute("RecID"); enode.Nodes.Add(chldnd); } } @@ -1184,155 +1271,173 @@ namespace ROEditor /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); - this.imageListRoTree = new System.Windows.Forms.ImageList(this.components); - this.splitter1 = new System.Windows.Forms.Splitter(); - this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components); - this.menuRO = new System.Windows.Forms.MenuItem(); - this.menuRONew = new System.Windows.Forms.MenuItem(); - this.menuNewGroup = new System.Windows.Forms.MenuItem(); - this.menuNewRefObj = new System.Windows.Forms.MenuItem(); - this.menuItem1 = new System.Windows.Forms.MenuItem(); - this.menuROEdit = new System.Windows.Forms.MenuItem(); + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + this.imageListRoTree = new System.Windows.Forms.ImageList(this.components); + this.splitter1 = new System.Windows.Forms.Splitter(); + this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components); + this.menuRO = new System.Windows.Forms.MenuItem(); + this.menuRONew = new System.Windows.Forms.MenuItem(); + this.menuNewGroup = new System.Windows.Forms.MenuItem(); + this.menuNewRefObj = new System.Windows.Forms.MenuItem(); + this.menuItem1 = new System.Windows.Forms.MenuItem(); + this.menuROEdit = new System.Windows.Forms.MenuItem(); + this.menuROCut = new System.Windows.Forms.MenuItem(); + this.menuROPaste = new System.Windows.Forms.MenuItem(); this.menuRODelete = new System.Windows.Forms.MenuItem(); - this.menuROSave = new System.Windows.Forms.MenuItem(); - this.menuROProperties = new System.Windows.Forms.MenuItem(); - this.menuItem10 = new System.Windows.Forms.MenuItem(); - this.menuROExit = new System.Windows.Forms.MenuItem(); - this.menuEdit = new System.Windows.Forms.MenuItem(); - this.menuEditUndo = new System.Windows.Forms.MenuItem(); - this.menuItem3 = new System.Windows.Forms.MenuItem(); - this.menuEditCut = new System.Windows.Forms.MenuItem(); - this.menuEditCopy = new System.Windows.Forms.MenuItem(); - this.menuEditPaste = new System.Windows.Forms.MenuItem(); - this.menuEditDelete = new System.Windows.Forms.MenuItem(); - this.menuItem5 = new System.Windows.Forms.MenuItem(); - this.menuEditSelAll = new System.Windows.Forms.MenuItem(); - this.menuTools = new System.Windows.Forms.MenuItem(); - this.menuToolsROFST = new System.Windows.Forms.MenuItem(); - this.menuHelp = new System.Windows.Forms.MenuItem(); - this.menuHelpAbout = new System.Windows.Forms.MenuItem(); - this.menuItem2 = new System.Windows.Forms.MenuItem(); - this.panel1 = new System.Windows.Forms.Panel(); - this.panel2 = new System.Windows.Forms.Panel(); - this.roTreeView = new System.Windows.Forms.TreeView(); - this.tbar = new System.Windows.Forms.ToolBar(); - this.tbtnSave = new System.Windows.Forms.ToolBarButton(); - this.tbtnCancel = new System.Windows.Forms.ToolBarButton(); - this.tbtnRestore = new System.Windows.Forms.ToolBarButton(); - this.tbtnSaveAs = new System.Windows.Forms.ToolBarButton(); - this.tbtnDuplicate = new System.Windows.Forms.ToolBarButton(); - this.tbtnZoom = new System.Windows.Forms.ToolBarButton(); - this.imageListToolBar = new System.Windows.Forms.ImageList(this.components); - this.lblDuplicateRO = new System.Windows.Forms.Label(); - this.panel1.SuspendLayout(); - this.SuspendLayout(); - // - // imageListRoTree - // - this.imageListRoTree.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListRoTree.ImageStream"))); - this.imageListRoTree.TransparentColor = System.Drawing.Color.Transparent; - this.imageListRoTree.Images.SetKeyName(0, ""); - this.imageListRoTree.Images.SetKeyName(1, ""); - // - // splitter1 - // - this.splitter1.Location = new System.Drawing.Point(220, 28); - this.splitter1.Name = "splitter1"; - this.splitter1.Size = new System.Drawing.Size(8, 591); - this.splitter1.TabIndex = 4; - this.splitter1.TabStop = false; - // - // mainMenu1 - // - this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuROSave = new System.Windows.Forms.MenuItem(); + this.menuROProperties = new System.Windows.Forms.MenuItem(); + this.menuItem10 = new System.Windows.Forms.MenuItem(); + this.menuROExit = new System.Windows.Forms.MenuItem(); + this.menuEdit = new System.Windows.Forms.MenuItem(); + this.menuEditUndo = new System.Windows.Forms.MenuItem(); + this.menuItem3 = new System.Windows.Forms.MenuItem(); + this.menuEditCut = new System.Windows.Forms.MenuItem(); + this.menuEditCopy = new System.Windows.Forms.MenuItem(); + this.menuEditPaste = new System.Windows.Forms.MenuItem(); + this.menuEditDelete = new System.Windows.Forms.MenuItem(); + this.menuItem5 = new System.Windows.Forms.MenuItem(); + this.menuEditSelAll = new System.Windows.Forms.MenuItem(); + this.menuTools = new System.Windows.Forms.MenuItem(); + this.menuToolsROFST = new System.Windows.Forms.MenuItem(); + this.menuHelp = new System.Windows.Forms.MenuItem(); + this.menuHelpAbout = new System.Windows.Forms.MenuItem(); + this.menuItem2 = new System.Windows.Forms.MenuItem(); + this.panel1 = new System.Windows.Forms.Panel(); + this.panel2 = new System.Windows.Forms.Panel(); + this.roTreeView = new System.Windows.Forms.TreeView(); + this.tbar = new System.Windows.Forms.ToolBar(); + this.tbtnSave = new System.Windows.Forms.ToolBarButton(); + this.tbtnCancel = new System.Windows.Forms.ToolBarButton(); + this.tbtnRestore = new System.Windows.Forms.ToolBarButton(); + this.tbtnSaveAs = new System.Windows.Forms.ToolBarButton(); + this.tbtnDuplicate = new System.Windows.Forms.ToolBarButton(); + this.tbtnZoom = new System.Windows.Forms.ToolBarButton(); + this.imageListToolBar = new System.Windows.Forms.ImageList(this.components); + this.lblDuplicateRO = new System.Windows.Forms.Label(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // imageListRoTree + // + this.imageListRoTree.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListRoTree.ImageStream"))); + this.imageListRoTree.TransparentColor = System.Drawing.Color.Transparent; + this.imageListRoTree.Images.SetKeyName(0, ""); + this.imageListRoTree.Images.SetKeyName(1, ""); + // + // splitter1 + // + this.splitter1.Location = new System.Drawing.Point(220, 28); + this.splitter1.Name = "splitter1"; + this.splitter1.Size = new System.Drawing.Size(8, 591); + this.splitter1.TabIndex = 4; + this.splitter1.TabStop = false; + // + // mainMenu1 + // + this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuRO, this.menuEdit, this.menuTools, this.menuHelp, this.menuItem2}); - // - // menuRO - // - this.menuRO.Index = 0; - this.menuRO.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + // + // menuRO + // + this.menuRO.Index = 0; + this.menuRO.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuRONew, this.menuItem1, this.menuROEdit, + this.menuROCut, + this.menuROPaste, this.menuRODelete, this.menuROSave, this.menuROProperties, this.menuItem10, this.menuROExit}); - this.menuRO.Text = "RO"; - // - // menuRONew - // - this.menuRONew.Index = 0; - this.menuRONew.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuRO.Text = "RO"; + // + // menuRONew + // + this.menuRONew.Index = 0; + this.menuRONew.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuNewGroup, this.menuNewRefObj}); - this.menuRONew.Text = "New ..."; + this.menuRONew.Text = "New ..."; + // + // menuNewGroup + // + this.menuNewGroup.Index = 0; + this.menuNewGroup.Text = "Group"; + this.menuNewGroup.Click += new System.EventHandler(this.menuNewGroup_Click); + // + // menuNewRefObj + // + this.menuNewRefObj.Index = 1; + this.menuNewRefObj.Text = "Referenced Object"; + this.menuNewRefObj.Click += new System.EventHandler(this.menuNewRefObj_Click); + // + // menuItem1 + // + this.menuItem1.Index = 1; + this.menuItem1.Text = "-"; + // + // menuROEdit + // + this.menuROEdit.Enabled = false; + this.menuROEdit.Index = 2; + this.menuROEdit.Text = "Edit"; + this.menuROEdit.Click += new System.EventHandler(this.menuROEdit_Click); // - // menuNewGroup + // menuROCut // - this.menuNewGroup.Index = 0; - this.menuNewGroup.Text = "Group"; - this.menuNewGroup.Click += new System.EventHandler(this.menuNewGroup_Click); + this.menuROCut.Enabled = false; + this.menuROCut.Index = 3; + this.menuROCut.Text = "Cut (Move RO)"; + this.menuROCut.Click += new System.EventHandler(this.menuROCut_Click); // - // menuNewRefObj + // menuROPaste // - this.menuNewRefObj.Index = 1; - this.menuNewRefObj.Text = "Referenced Object"; - this.menuNewRefObj.Click += new System.EventHandler(this.menuNewRefObj_Click); - // - // menuItem1 - // - this.menuItem1.Index = 1; - this.menuItem1.Text = "-"; - // - // menuROEdit - // - this.menuROEdit.Enabled = false; - this.menuROEdit.Index = 2; - this.menuROEdit.Text = "Edit"; - this.menuROEdit.Click += new System.EventHandler(this.menuROEdit_Click); + this.menuROPaste.Enabled = false; + this.menuROPaste.Index = 4; + this.menuROPaste.Text = "Paste (Move RO)"; + this.menuROPaste.Click += new System.EventHandler(this.menuROPaste_Click); // // menuRODelete // - this.menuRODelete.Index = 3; - this.menuRODelete.Text = "Delete"; - this.menuRODelete.Click += new System.EventHandler(this.menuRODelete_Click); - // - // menuROSave - // - this.menuROSave.Enabled = false; - this.menuROSave.Index = 4; - this.menuROSave.Text = "Save"; - this.menuROSave.Click += new System.EventHandler(this.menuROSave_Click); - // - // menuROProperties - // - this.menuROProperties.Index = 5; - this.menuROProperties.Text = "Properties"; - this.menuROProperties.Click += new System.EventHandler(this.menuROProperties_Click); - // - // menuItem10 - // - this.menuItem10.Index = 6; - this.menuItem10.Text = "-"; - // - // menuROExit - // - this.menuROExit.Index = 7; - this.menuROExit.Text = "Exit RO Editor"; - this.menuROExit.Click += new System.EventHandler(this.menuROExit_Click); - // - // menuEdit - // - this.menuEdit.Index = 1; - this.menuEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuRODelete.Index = 5; + this.menuRODelete.Text = "Delete"; + this.menuRODelete.Click += new System.EventHandler(this.menuRODelete_Click); + // + // menuROSave + // + this.menuROSave.Enabled = false; + this.menuROSave.Index = 6; + this.menuROSave.Text = "Save"; + this.menuROSave.Click += new System.EventHandler(this.menuROSave_Click); + // + // menuROProperties + // + this.menuROProperties.Index = 7; + this.menuROProperties.Text = "Properties"; + this.menuROProperties.Click += new System.EventHandler(this.menuROProperties_Click); + // + // menuItem10 + // + this.menuItem10.Index = 8; + this.menuItem10.Text = "-"; + // + // menuROExit + // + this.menuROExit.Index = 9; + this.menuROExit.Text = "Exit RO Editor"; + this.menuROExit.Click += new System.EventHandler(this.menuROExit_Click); + // + // menuEdit + // + this.menuEdit.Index = 1; + this.menuEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuEditUndo, this.menuItem3, this.menuEditCut, @@ -1341,225 +1446,392 @@ namespace ROEditor this.menuEditDelete, this.menuItem5, this.menuEditSelAll}); - this.menuEdit.Text = "Edit"; - // - // menuEditUndo - // - this.menuEditUndo.Enabled = false; - this.menuEditUndo.Index = 0; - this.menuEditUndo.Text = "&Undo"; - this.menuEditUndo.Click += new System.EventHandler(this.menuEditUndo_Click); - // - // menuItem3 - // - this.menuItem3.Index = 1; - this.menuItem3.Text = "-"; - // - // menuEditCut - // - this.menuEditCut.Enabled = false; - this.menuEditCut.Index = 2; - this.menuEditCut.Text = "Cu&t"; - this.menuEditCut.Click += new System.EventHandler(this.menuEditCut_Click); - // - // menuEditCopy - // - this.menuEditCopy.Enabled = false; - this.menuEditCopy.Index = 3; - this.menuEditCopy.Text = "&Copy"; - this.menuEditCopy.Click += new System.EventHandler(this.menuEditCopy_Click); - // - // menuEditPaste - // - this.menuEditPaste.Enabled = false; - this.menuEditPaste.Index = 4; - this.menuEditPaste.Text = "&Paste"; - this.menuEditPaste.Click += new System.EventHandler(this.menuEditPaste_Click); - // - // menuEditDelete - // - this.menuEditDelete.Enabled = false; - this.menuEditDelete.Index = 5; - this.menuEditDelete.Text = "&Delete"; - this.menuEditDelete.Click += new System.EventHandler(this.menuEditDelete_Click); - // - // menuItem5 - // - this.menuItem5.Index = 6; - this.menuItem5.Text = "-"; - // - // menuEditSelAll - // - this.menuEditSelAll.Enabled = false; - this.menuEditSelAll.Index = 7; - this.menuEditSelAll.Text = "Select &All"; - this.menuEditSelAll.Click += new System.EventHandler(this.menuEditSelAll_Click); - // - // menuTools - // - this.menuTools.Index = 2; - this.menuTools.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuEdit.Text = "Edit"; + // + // menuEditUndo + // + this.menuEditUndo.Enabled = false; + this.menuEditUndo.Index = 0; + this.menuEditUndo.Text = "&Undo"; + this.menuEditUndo.Click += new System.EventHandler(this.menuEditUndo_Click); + // + // menuItem3 + // + this.menuItem3.Index = 1; + this.menuItem3.Text = "-"; + // + // menuEditCut + // + this.menuEditCut.Enabled = false; + this.menuEditCut.Index = 2; + this.menuEditCut.Text = "Cu&t"; + this.menuEditCut.Click += new System.EventHandler(this.menuEditCut_Click); + // + // menuEditCopy + // + this.menuEditCopy.Enabled = false; + this.menuEditCopy.Index = 3; + this.menuEditCopy.Text = "&Copy"; + this.menuEditCopy.Click += new System.EventHandler(this.menuEditCopy_Click); + // + // menuEditPaste + // + this.menuEditPaste.Enabled = false; + this.menuEditPaste.Index = 4; + this.menuEditPaste.Text = "&Paste"; + this.menuEditPaste.Click += new System.EventHandler(this.menuEditPaste_Click); + // + // menuEditDelete + // + this.menuEditDelete.Enabled = false; + this.menuEditDelete.Index = 5; + this.menuEditDelete.Text = "&Delete"; + this.menuEditDelete.Click += new System.EventHandler(this.menuEditDelete_Click); + // + // menuItem5 + // + this.menuItem5.Index = 6; + this.menuItem5.Text = "-"; + // + // menuEditSelAll + // + this.menuEditSelAll.Enabled = false; + this.menuEditSelAll.Index = 7; + this.menuEditSelAll.Text = "Select &All"; + this.menuEditSelAll.Click += new System.EventHandler(this.menuEditSelAll_Click); + // + // menuTools + // + this.menuTools.Index = 2; + this.menuTools.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuToolsROFST}); - this.menuTools.Text = "Tools"; - // - // menuToolsROFST - // - this.menuToolsROFST.Index = 0; - this.menuToolsROFST.Text = "Create RO.FST"; - this.menuToolsROFST.Click += new System.EventHandler(this.menuToolsROFST_Click); - // - // menuHelp - // - this.menuHelp.Index = 3; - this.menuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuTools.Text = "Tools"; + // + // menuToolsROFST + // + this.menuToolsROFST.Index = 0; + this.menuToolsROFST.Text = "Create RO.FST"; + this.menuToolsROFST.Click += new System.EventHandler(this.menuToolsROFST_Click); + // + // menuHelp + // + this.menuHelp.Index = 3; + this.menuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuHelpAbout}); - this.menuHelp.Text = "Help"; - // - // menuHelpAbout - // - this.menuHelpAbout.Index = 0; - this.menuHelpAbout.Text = "About"; - this.menuHelpAbout.Click += new System.EventHandler(this.menuHelpAbout_Click); - // - // menuItem2 - // - this.menuItem2.Index = 4; - this.menuItem2.Text = ""; - // - // panel1 - // - this.panel1.AutoScroll = true; - this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.panel1.Controls.Add(this.panel2); - this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel1.Location = new System.Drawing.Point(228, 28); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(710, 591); - this.panel1.TabIndex = 5; - // - // panel2 - // - this.panel2.AutoScroll = true; - this.panel2.Location = new System.Drawing.Point(0, 0); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(235, 118); - this.panel2.TabIndex = 0; - this.panel2.Visible = false; - // - // roTreeView - // - this.roTreeView.Dock = System.Windows.Forms.DockStyle.Left; - this.roTreeView.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.roTreeView.ImageIndex = 0; - this.roTreeView.ImageList = this.imageListRoTree; - this.roTreeView.ItemHeight = 18; - this.roTreeView.Location = new System.Drawing.Point(0, 28); - this.roTreeView.Name = "roTreeView"; - this.roTreeView.SelectedImageIndex = 0; - this.roTreeView.Size = new System.Drawing.Size(220, 591); - this.roTreeView.TabIndex = 3; - this.roTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.roTreeView_AfterSelect_1); - // - // tbar - // - this.tbar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { + this.menuHelp.Text = "Help"; + // + // menuHelpAbout + // + this.menuHelpAbout.Index = 0; + this.menuHelpAbout.Text = "About"; + this.menuHelpAbout.Click += new System.EventHandler(this.menuHelpAbout_Click); + // + // menuItem2 + // + this.menuItem2.Index = 4; + this.menuItem2.Text = ""; + // + // panel1 + // + this.panel1.AutoScroll = true; + this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.panel1.Controls.Add(this.panel2); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(228, 28); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(752, 591); + this.panel1.TabIndex = 5; + // + // panel2 + // + this.panel2.AutoScroll = true; + this.panel2.Location = new System.Drawing.Point(0, 0); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(235, 118); + this.panel2.TabIndex = 0; + this.panel2.Visible = false; + // + // roTreeView + // + this.roTreeView.Dock = System.Windows.Forms.DockStyle.Left; + this.roTreeView.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.roTreeView.ImageIndex = 0; + this.roTreeView.ImageList = this.imageListRoTree; + this.roTreeView.ItemHeight = 18; + this.roTreeView.Location = new System.Drawing.Point(0, 28); + this.roTreeView.Name = "roTreeView"; + this.roTreeView.SelectedImageIndex = 0; + this.roTreeView.Size = new System.Drawing.Size(220, 591); + this.roTreeView.TabIndex = 3; + this.roTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.roTreeView_AfterSelect_1); + // + // tbar + // + this.tbar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { this.tbtnSave, this.tbtnCancel, this.tbtnRestore, this.tbtnSaveAs, this.tbtnDuplicate, this.tbtnZoom}); - this.tbar.DropDownArrows = true; - this.tbar.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tbar.ImageList = this.imageListToolBar; - this.tbar.Location = new System.Drawing.Point(0, 0); - this.tbar.Name = "tbar"; - this.tbar.ShowToolTips = true; - this.tbar.Size = new System.Drawing.Size(938, 28); - this.tbar.TabIndex = 0; - this.tbar.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right; - this.tbar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbar_OnClick); - // - // tbtnSave - // - this.tbtnSave.Enabled = false; - this.tbtnSave.ImageIndex = 0; - this.tbtnSave.Name = "tbtnSave"; - this.tbtnSave.Text = "Save"; - // - // tbtnCancel - // - this.tbtnCancel.Enabled = false; - this.tbtnCancel.ImageIndex = 1; - this.tbtnCancel.Name = "tbtnCancel"; - this.tbtnCancel.Text = "Cancel"; - // - // tbtnRestore - // - this.tbtnRestore.Enabled = false; - this.tbtnRestore.ImageIndex = 2; - this.tbtnRestore.Name = "tbtnRestore"; - this.tbtnRestore.Text = "Restore"; - // - // tbtnSaveAs - // - this.tbtnSaveAs.Enabled = false; - this.tbtnSaveAs.ImageIndex = 3; - this.tbtnSaveAs.Name = "tbtnSaveAs"; - this.tbtnSaveAs.Text = "Save As"; - // - // tbtnDuplicate - // - this.tbtnDuplicate.Enabled = false; - this.tbtnDuplicate.ImageIndex = 4; - this.tbtnDuplicate.Name = "tbtnDuplicate"; - this.tbtnDuplicate.Text = "Duplicate"; - // - // tbtnZoom - // - this.tbtnZoom.Enabled = false; - this.tbtnZoom.ImageIndex = 5; - this.tbtnZoom.Name = "tbtnZoom"; - this.tbtnZoom.Text = "Zoom"; - // - // imageListToolBar - // - this.imageListToolBar.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListToolBar.ImageStream"))); - this.imageListToolBar.TransparentColor = System.Drawing.Color.Transparent; - this.imageListToolBar.Images.SetKeyName(0, ""); - this.imageListToolBar.Images.SetKeyName(1, ""); - this.imageListToolBar.Images.SetKeyName(2, ""); - this.imageListToolBar.Images.SetKeyName(3, ""); - this.imageListToolBar.Images.SetKeyName(4, ""); - this.imageListToolBar.Images.SetKeyName(5, ""); - // - // lblDuplicateRO - // - this.lblDuplicateRO.AutoSize = true; - this.lblDuplicateRO.ForeColor = System.Drawing.Color.Red; - this.lblDuplicateRO.Location = new System.Drawing.Point(491, 9); - this.lblDuplicateRO.Name = "lblDuplicateRO"; - this.lblDuplicateRO.Size = new System.Drawing.Size(139, 13); - this.lblDuplicateRO.TabIndex = 6; - this.lblDuplicateRO.Text = "Working With Duplicate RO"; - this.lblDuplicateRO.Visible = false; - // - // Form1 - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(980, 619); - this.Controls.Add(this.lblDuplicateRO); - this.Controls.Add(this.panel1); - this.Controls.Add(this.splitter1); - this.Controls.Add(this.roTreeView); - this.Controls.Add(this.tbar); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Menu = this.mainMenu1; - this.Name = "Form1"; - this.Text = "RO Edit"; - this.panel1.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); + this.tbar.DropDownArrows = true; + this.tbar.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tbar.ImageList = this.imageListToolBar; + this.tbar.Location = new System.Drawing.Point(0, 0); + this.tbar.Name = "tbar"; + this.tbar.ShowToolTips = true; + this.tbar.Size = new System.Drawing.Size(980, 28); + this.tbar.TabIndex = 0; + this.tbar.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right; + this.tbar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbar_OnClick); + // + // tbtnSave + // + this.tbtnSave.Enabled = false; + this.tbtnSave.ImageIndex = 0; + this.tbtnSave.Name = "tbtnSave"; + this.tbtnSave.Text = "Save"; + // + // tbtnCancel + // + this.tbtnCancel.Enabled = false; + this.tbtnCancel.ImageIndex = 1; + this.tbtnCancel.Name = "tbtnCancel"; + this.tbtnCancel.Text = "Cancel"; + // + // tbtnRestore + // + this.tbtnRestore.Enabled = false; + this.tbtnRestore.ImageIndex = 2; + this.tbtnRestore.Name = "tbtnRestore"; + this.tbtnRestore.Text = "Restore"; + // + // tbtnSaveAs + // + this.tbtnSaveAs.Enabled = false; + this.tbtnSaveAs.ImageIndex = 3; + this.tbtnSaveAs.Name = "tbtnSaveAs"; + this.tbtnSaveAs.Text = "Save As"; + // + // tbtnDuplicate + // + this.tbtnDuplicate.Enabled = false; + this.tbtnDuplicate.ImageIndex = 4; + this.tbtnDuplicate.Name = "tbtnDuplicate"; + this.tbtnDuplicate.Text = "Duplicate"; + // + // tbtnZoom + // + this.tbtnZoom.Enabled = false; + this.tbtnZoom.ImageIndex = 5; + this.tbtnZoom.Name = "tbtnZoom"; + this.tbtnZoom.Text = "Zoom"; + // + // imageListToolBar + // + this.imageListToolBar.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListToolBar.ImageStream"))); + this.imageListToolBar.TransparentColor = System.Drawing.Color.Transparent; + this.imageListToolBar.Images.SetKeyName(0, ""); + this.imageListToolBar.Images.SetKeyName(1, ""); + this.imageListToolBar.Images.SetKeyName(2, ""); + this.imageListToolBar.Images.SetKeyName(3, ""); + this.imageListToolBar.Images.SetKeyName(4, ""); + this.imageListToolBar.Images.SetKeyName(5, ""); + // + // lblDuplicateRO + // + this.lblDuplicateRO.AutoSize = true; + this.lblDuplicateRO.ForeColor = System.Drawing.Color.Red; + this.lblDuplicateRO.Location = new System.Drawing.Point(570, 9); + this.lblDuplicateRO.Name = "lblDuplicateRO"; + this.lblDuplicateRO.Size = new System.Drawing.Size(139, 13); + this.lblDuplicateRO.TabIndex = 6; + this.lblDuplicateRO.Text = "Working With Duplicate RO"; + this.lblDuplicateRO.Visible = false; + // + // Form1 + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(980, 619); + this.Controls.Add(this.lblDuplicateRO); + this.Controls.Add(this.panel1); + this.Controls.Add(this.splitter1); + this.Controls.Add(this.roTreeView); + this.Controls.Add(this.tbar); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Menu = this.mainMenu1; + this.Name = "Form1"; + this.Text = "RO Edit"; + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + //Cut/Paste (Move ROs) added as part of CSM-C2024-027 / Part of 2024 PROMS Upgrades + private void menuROCut_Click(object sender, EventArgs e) + { + ROCutWasSelected = true; + + string msgstr = "It is recommended that after moving ROs, you create a FST an use it to update RO Values in PROMS to ensure RO Links properly move to the new location as well.\n\n Are you sure you wish to move the RO(s)?"; + + DialogResult AnswerYN = MessageBox.Show(msgstr, "RO Editor", MessageBoxButtons.YesNo); + if (AnswerYN != DialogResult.Yes) + ROCutWasSelected = false; + + } + + //part of CSM-C2024-027 / Part of 2024 PROMS Upgrades + //Paste Selected - will move individual ROs + private void menuROPaste_Click(object sender, EventArgs e) + { + if (ROCutWasSelected && ROsSelectedforMultiMove.Count == 0) + { + MessageBox.Show("Cut must be selected before able to Paste/Move a RO"); + return; + } + + foreach (TreeNode tnToCut in ROsSelectedforMultiMove) + { + VlnXmlElement ROtoCut = ((VlnXmlElement) tnToCut.Tag); + if (((VlnXmlElement)roTreeView.SelectedNode.Tag).GetAttribute("Table") != ROtoCut.GetAttribute("Table")) + { + MessageBox.Show("You can only move a RO within the same table."); + break; //exit foreach loop + } + string TheMenuTitle = ROtoCut.GetAttribute("MenuTitle"); + if (!string.IsNullOrEmpty(TheMenuTitle)) + { + TreeNode orig_parent = tnToCut.Parent; + if (moveRO(ROtoCut)) + { + //if move was successful, remove the moved item from it's previous parent + //so it will only have a parent of where it moved to + XmlNode node = ROtoCut.ParentNode; + node.RemoveChild(ROtoCut); + + if (orig_parent != null) + { + roTreeView.Nodes.Remove(tnToCut); + updateRoListView(orig_parent); + roTreeView.Refresh(); + } + } + } + } + + roTreeView_ClearAllMultiSelect(); + tbtnRestore.Enabled = false; + tbtnSave.Enabled = false; + tbtnCancel.Enabled = true; + tbtnSaveAs.Enabled = false; + tbtnDuplicate.Enabled = true; + duplicate_active = false; + ROCutWasSelected = false; + menuROCut.Enabled = false; + roTreeView.ContextMenu.MenuItems[3].Enabled = menuROCut.Enabled; + menuROPaste.Enabled = false; + roTreeView.ContextMenu.MenuItems[4].Enabled = menuROPaste.Enabled; + roTreeView.Refresh(); + + } + + //part of CSM-C2024-027 / Part of 2024 PROMS Upgrades + //Will move individual ROs + private bool moveRO(VlnXmlElement ROtoMove) + { + //making a copy into newro + //if everything is successful, once done + //will remove ROtoMove and keep the Clone with the changed position + //if any errors/issues, will remove the cloned newro and keep ROtoMove + VlnXmlElement newro = (VlnXmlElement)ROtoMove.Clone(); + VlnXmlElement placetomoveroto = (VlnXmlElement)roTreeView.SelectedNode.Tag; + string orig_title = ROtoMove.GetMenuString(ROtoMove.GetMenuValueTemplate("MenuItem"), false); + + //remove original link, and put it at new place in the menu + //set table to be new place that you are moving item to + //put at new place in menu + newro.SetAttribute("Table", placetomoveroto.GetAttribute("Table")); + newro.SetAttribute("ParentID", placetomoveroto.GetAttribute("RecID")); + placetomoveroto.AppendChild((XmlNode)newro); + + //Check that must have the same Fields in use + string dummy = ""; // need for RODB_GetFIeldsInUse call, won't be used. + ArrayList AvailList_ROtoMove = myrodb.RODB_GetFields(ROtoMove, (uint)RecordType.Schema); + IEnumerable InUseList_ROtoMove = myrodb.RODB_GetFieldsInUse(ROtoMove, AvailList_ROtoMove, "FieldsInUse", ref dummy, false).OfType(); + List flds_InUseList_ROtoMove = InUseList_ROtoMove.Select(x => x.GetFieldname).OrderBy(t => t).ToList(); + ArrayList AvailList_placetomoveroto = myrodb.RODB_GetFields(placetomoveroto, (uint)RecordType.Schema); + List flds_InUseList_placetomoveroto = myrodb.RODB_GetFieldsInUse(placetomoveroto, AvailList_placetomoveroto, "FieldsInUse", ref dummy, false).OfType().Select(x => x.GetFieldname).OrderBy(t => t).ToList(); + if (!Enumerable.SequenceEqual(flds_InUseList_ROtoMove, flds_InUseList_placetomoveroto)) + { + MessageBox.Show($"RO: {orig_title}. The fields in use must be the same between the item you are moving and where you are moving the item. The fields used in these values can be found under \"Properties => Referenced Object Definition\" of an RO Group. Cannot move.", "Problem moving RO item."); + placetomoveroto.RemoveChild(newro); + return false; + } + + //if duplicate Accessory Page Id, return with Error message + string acctmpl = newro.GetAccPageIDTemplate(); + string newacc = newro.GetAccPageIDString(acctmpl); + if (newacc == null) + { + MessageBox.Show($"RO: {orig_title}. Values for the fields used for the \"Accessory Pages Access\" are missing. The template required for the place this RO is moving to is: {acctmpl}", "Problem saving data"); + placetomoveroto.RemoveChild(newro); + + return false; + } + else if (myrodb.IsDuplicateAccPageID(newro, newacc)) + { + MessageBox.Show($"RO: {orig_title}. The fields used for the \"Accessory Pages Access\" values must be unique. The fields used in these values can be found under \"Properties\" of an RO Group. Cannot save.", "Problem saving data"); + placetomoveroto.RemoveChild(newro); + + return false; + } + + //if already an item in the menu with the same title, then return with Error message + string mnutmp = newro.GetMenuValueTemplate("MenuItem"); + string mnutitle = newro.GetMenuString(mnutmp, false); + if (newro.IsDuplicateMenuTitle(mnutitle)) + { + MessageBox.Show($"RO: {orig_title}. The fields used for the \"Menu\" values must be unique. The fields used in these values can be found under \"Properties\" of an RO Group. Cannot save.", "Problem saving data"); + placetomoveroto.RemoveChild(newro); + return false; + } + newro.SetAttribute("MenuTitle", mnutitle); + + //Check that required Fields have Values + ArrayList reqfields = newro.GetRequiredFields(); + foreach (string fldname in reqfields) + { + string fname_inxml = fldname.Split(new string[] { "\t" }, StringSplitOptions.None)[0]; + string fname = CvtFldToUserFld(fname_inxml); + if (!InUseList_ROtoMove.Any(x=> x.GetFieldname == CvtFldToUserFld(fldname.Split(new string[] { "\t" }, StringSplitOptions.None)[0])) || newro.ChildNodes.Cast().Any(x => x.Name == fname_inxml && x.InnerText.Length == 0)) + { + MessageBox.Show($"RO: {orig_title}. Required field \"{fname}\" is missing a value that is required. Please be sure RO has a value for this field before moving the RO.", "Problem saving data"); + placetomoveroto.RemoveChild(newro); + return false; + } + } + + bool success = myrodb.RODB_WriteRO(newro, true); + + //if successful, update the UI + if (success) + { + TreeNode newt = new TreeNode(mnutitle, ROIMAGE, ROIMAGE); + newt.Tag = newro; + newt.Name = newro.GetAttribute("RecID"); + roTreeView.SelectedNode.Nodes.Add(newt); + updateRoListView(newt.Parent); + roTreeView.Refresh(); + } + else + { + MessageBox.Show($"RO: {orig_title}. Unable to Move Item. An unexpected error occurred while moving the item, please contact Volian Support", "Problem saving moved item"); + placetomoveroto.RemoveChild(newro); + roTreeView.Refresh(); + } + + return success; } #endregion @@ -2301,7 +2573,7 @@ namespace ROEditor private void tbar_OnClick(object obj, ToolBarButtonClickEventArgs tbbcea) { ToolBarButton tbb = tbbcea.Button; - + // see which event should be called. if (tbb.Text == "Cancel") tbar_CancelClick(); @@ -2313,7 +2585,7 @@ namespace ROEditor tbar_DuplicateClick(); else if (tbb.Text == "Restore") tbar_RestoreClick(); - else if (tbb.Text == "Zoom"||tbb.Text == "View Image") + else if (tbb.Text == "Zoom" || tbb.Text == "View Image") ctlXMLEdit2.btnZoom_click(null, null); } @@ -2404,6 +2676,7 @@ namespace ROEditor int img = (myro.Name=="vlnGroup")?ROGROUPIMAGE:ROIMAGE; newt = new TreeNode(mnutitle,img,img); newt.Tag = myro; + newt.Name = myro.GetAttribute("RecID"); TreeNewparent.Nodes.Add(newt); } } @@ -2506,18 +2779,20 @@ namespace ROEditor if (acctmpl!=null)newro.SetAttribute("AccPageID", newro.GetAccPageIDString(acctmpl)); newro.SetAttribute("MenuTitle",mnutitle); newro.RemoveAttribute("RecID"); // get a new one. + success = myrodb.RODB_InsertRO(newro); - if (success == true) + if (success) { - int img = (newro.Name=="vlnGroup")?ROGROUPIMAGE:ROIMAGE; - TreeNode newt = new TreeNode(mnutitle,img,img); + int img = (newro.Name == "vlnGroup") ? ROGROUPIMAGE : ROIMAGE; + TreeNode newt = new TreeNode(mnutitle, img, img); newt.Tag = newro; + newt.Name = newro.GetAttribute("RecID"); roTreeView.SelectedNode.Parent.Nodes.Add(newt); roTreeView.SelectedNode.Tag = origro; LastSelectedNode = newt; //do this so that no prompt for data save on node select newt.TreeView.SelectedNode = newt; roTreeView.Refresh(); - tbtnRestore.Enabled=false; + tbtnRestore.Enabled = false; tbtnSave.Enabled = false; tbtnCancel.Enabled = true; tbtnSaveAs.Enabled = false; @@ -2525,10 +2800,10 @@ namespace ROEditor duplicate_active = false; } else - newro.SetAttribute("RecID",savrec); - + newro.SetAttribute("RecID", savrec); + newone = null; - } + } private void tbar_DuplicateClick() { diff --git a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.resx b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.resx index bb1d7760..5c3b99ac 100644 --- a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.resx +++ b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.resx @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACE - CAAAAk1TRnQBSQFMAgEBAgEAARwBAAEcAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CAAAAk1TRnQBSQFMAgEBAgEAASwBAAEsAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA @@ -175,7 +175,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAe - CwAAAk1TRnQBSQFMAgEBBgEAARwBAAEcAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CwAAAk1TRnQBSQFMAgEBBgEAASwBAAEsAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/PROMS/ReferencedObjects/LibSource/RODBInterface/RODBInterface.cs b/PROMS/ReferencedObjects/LibSource/RODBInterface/RODBInterface.cs index c73b191b..a00c0b63 100644 --- a/PROMS/ReferencedObjects/LibSource/RODBInterface/RODBInterface.cs +++ b/PROMS/ReferencedObjects/LibSource/RODBInterface/RODBInterface.cs @@ -336,7 +336,7 @@ namespace RODBInterface public abstract bool RODB_GetChildData(VlnXmlElement node, bool CheckChildCount); public abstract bool IsDuplicateAccPageID(VlnXmlElement ro, string newacc); public abstract VlnXmlElement RODB_ReadRO(string tbl, string recid); - public abstract bool RODB_WriteRO(VlnXmlElement ro); + public abstract bool RODB_WriteRO(VlnXmlElement ro, bool movedRO = false); public abstract bool RODB_InsertRO(VlnXmlElement ro); public abstract ushort RODB_GetFieldType(VlnXmlElement elem, string TableName, string Fld); public abstract ArrayList RODB_GetFields(VlnXmlElement elem, uint rtype, bool refresh = false); @@ -2120,7 +2120,7 @@ namespace RODBInterface return retele; } - public override bool RODB_WriteRO(VlnXmlElement ro) + public override bool RODB_WriteRO(VlnXmlElement ro, bool movedRO = false) { bool success; if (ro.Name == "vlnGroup") @@ -2140,6 +2140,13 @@ namespace RODBInterface string dt = string.Format("{0:yyyyMMddHHmmss}", System.DateTime.Now); string xmlstr = GenerateXmlString(ro, false); string strUpdate = "UPDATE " + ro.GetAttribute("Table") + " SET Info = '" + xmlstr + "'"; + if (movedRO) + { + VlnXmlElement parent = (VlnXmlElement)ro.ParentNode; + ro.SetAttribute("ParentID", parent.GetAttribute("RecID")); + strUpdate += ", ParentID = '" + ro.GetAttribute("ParentID") + "'"; + } + strUpdate = strUpdate + ", ModDateTime = '" + dt + "', AccPageID = '" + wraccid + "' WHERE RecID='" + ro.GetAttribute("RecID") + "'"; try { @@ -2192,6 +2199,8 @@ namespace RODBInterface ro.SetAttribute("HasChild", "False"); if (ro.HasAttribute("AccPageID")) { + // Code is never reached, but this was noticed - this next line should likely be: + // strInsert = "INSERT INTO " + parent.GetAttribute("Table") + "( RecID, RecType, ParentID, AccPageID, ModDateTime, Info ) "; strInsert = "INSERT INTO " + parent.GetAttribute("Table") + "( RecID, RecType, ParentID, ModDateTime, AccPageID, Info ) "; strInsert = strInsert + " VALUES ('" + ro.GetAttribute("RecID") + "'," + (uint)RecordType.Group + ",'" + ro.GetAttribute("ParentID"); strInsert = strInsert + "','" + wraccid + "','" + dt + "','" + xmlstr + "');"; @@ -2396,7 +2405,7 @@ namespace RODBInterface Info = null; DBE.ReaderClose(); DBE.CommandDispose(); - return Info.Replace("'", "\'"); + return Info?.Replace("'", "\'"); } public override bool RODB_NewSchemaPiece(string recid, string parentid, string table, string schpiece, uint rtype) diff --git a/PROMS/ReferencedObjects/LibSource/RODBInterface/SqlRODB.cs b/PROMS/ReferencedObjects/LibSource/RODBInterface/SqlRODB.cs index 1e629bca..5e73dc07 100644 --- a/PROMS/ReferencedObjects/LibSource/RODBInterface/SqlRODB.cs +++ b/PROMS/ReferencedObjects/LibSource/RODBInterface/SqlRODB.cs @@ -1557,7 +1557,7 @@ namespace RODBInterface } return retele; } - public override bool RODB_WriteRO(VlnXmlElement ro) + public override bool RODB_WriteRO(VlnXmlElement ro, bool movedRO = false) { bool success; if (ro.Name == "vlnGroup") @@ -1589,6 +1589,13 @@ namespace RODBInterface command.Parameters.AddWithValue("@ModDateTime", dt); command.Parameters.AddWithValue("@AccPageID", wraccid); // B2020-003: set accpageid to correct value command.Parameters.AddWithValue("@RecID", ro.GetAttribute("RecID")); + if (movedRO) + { + VlnXmlElement parent = (VlnXmlElement)ro.ParentNode; + ro.SetAttribute("ParentID", parent.GetAttribute("RecID")); + command.Parameters.AddWithValue("@ParentID", ro.GetAttribute("ParentID")); + } + using (SqlDataReader reader = command.ExecuteReader()) { success = true; diff --git a/PROMS/VEPROMS User Interface/ROBuild.Sql b/PROMS/VEPROMS User Interface/ROBuild.Sql index df3f11af..02e04be7 100644 --- a/PROMS/VEPROMS User Interface/ROBuild.Sql +++ b/PROMS/VEPROMS User Interface/ROBuild.Sql @@ -674,7 +674,8 @@ CREATE PROCEDURE [dbo].[updateInfoAccidByRecid] @RecID char(8), @AccPageID char(32), @Info nvarchar(max), - @ModDateTime char(14) + @ModDateTime char(14), + @ParentID varchar(8) = NULL ) WITH EXECUTE AS OWNER AS @@ -684,7 +685,8 @@ BEGIN TRY -- Try Block SET [Info]=@Info, [ModDateTime]=@ModDateTime, - [AccPageID]=@AccPageID + [AccPageID]=@AccPageID, + [ParentID]=ISNULL(@ParentID, ParentID) WHERE [ROTable]=@ROTable AND [RecID]=@RecID IF @@ROWCOUNT = 0 BEGIN -- 2.47.2