C2024-027 RO Editor – Add additional feature to allow Cut/Paste (Moving) a RO within the same table.

This commit is contained in:
Matthew Schill 2024-10-23 13:20:20 -04:00
parent 0f541142cc
commit c867d4e4b1
5 changed files with 661 additions and 368 deletions

View File

@ -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;
@ -334,6 +336,8 @@ namespace ROEditor
private System.Windows.Forms.MenuItem menuRONew;
private System.Windows.Forms.MenuItem menuNewRefObj;
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;
@ -357,6 +361,10 @@ namespace ROEditor
get { return _CurrentTextBox; }
set { _CurrentTextBox = value; }
}
public List<TreeNode> 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;
@ -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,8 +664,81 @@ 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<TreeNode>();
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)
{
@ -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;
}
@ -1146,6 +1232,7 @@ namespace ROEditor
{
chldnd = new TreeNode(TheMenuTitle,ROIMAGE,ROIMAGE);
chldnd.Tag = echild;
chldnd.Name = echild.GetAttribute("RecID");
enode.Nodes.Add(chldnd);
}
}
@ -1195,6 +1282,8 @@ namespace ROEditor
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();
@ -1260,6 +1349,8 @@ namespace ROEditor
this.menuRONew,
this.menuItem1,
this.menuROEdit,
this.menuROCut,
this.menuROPaste,
this.menuRODelete,
this.menuROSave,
this.menuROProperties,
@ -1298,34 +1389,48 @@ namespace ROEditor
this.menuROEdit.Index = 2;
this.menuROEdit.Text = "Edit";
this.menuROEdit.Click += new System.EventHandler(this.menuROEdit_Click);
//
// menuROCut
//
this.menuROCut.Enabled = false;
this.menuROCut.Index = 3;
this.menuROCut.Text = "Cut (Move RO)";
this.menuROCut.Click += new System.EventHandler(this.menuROCut_Click);
//
// menuROPaste
//
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.Index = 5;
this.menuRODelete.Text = "Delete";
this.menuRODelete.Click += new System.EventHandler(this.menuRODelete_Click);
//
// menuROSave
//
this.menuROSave.Enabled = false;
this.menuROSave.Index = 4;
this.menuROSave.Index = 6;
this.menuROSave.Text = "Save";
this.menuROSave.Click += new System.EventHandler(this.menuROSave_Click);
//
// menuROProperties
//
this.menuROProperties.Index = 5;
this.menuROProperties.Index = 7;
this.menuROProperties.Text = "Properties";
this.menuROProperties.Click += new System.EventHandler(this.menuROProperties_Click);
//
// menuItem10
//
this.menuItem10.Index = 6;
this.menuItem10.Index = 8;
this.menuItem10.Text = "-";
//
// menuROExit
//
this.menuROExit.Index = 7;
this.menuROExit.Index = 9;
this.menuROExit.Text = "Exit RO Editor";
this.menuROExit.Click += new System.EventHandler(this.menuROExit_Click);
//
@ -1434,7 +1539,7 @@ namespace ROEditor
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.Size = new System.Drawing.Size(752, 591);
this.panel1.TabIndex = 5;
//
// panel2
@ -1475,7 +1580,7 @@ namespace ROEditor
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.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);
@ -1537,7 +1642,7 @@ namespace ROEditor
//
this.lblDuplicateRO.AutoSize = true;
this.lblDuplicateRO.ForeColor = System.Drawing.Color.Red;
this.lblDuplicateRO.Location = new System.Drawing.Point(491, 9);
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;
@ -1561,6 +1666,173 @@ namespace ROEditor
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<ROField> InUseList_ROtoMove = myrodb.RODB_GetFieldsInUse(ROtoMove, AvailList_ROtoMove, "FieldsInUse", ref dummy, false).OfType<ROField>();
List<string> flds_InUseList_ROtoMove = InUseList_ROtoMove.Select(x => x.GetFieldname).OrderBy(t => t).ToList();
ArrayList AvailList_placetomoveroto = myrodb.RODB_GetFields(placetomoveroto, (uint)RecordType.Schema);
List<string> flds_InUseList_placetomoveroto = myrodb.RODB_GetFieldsInUse(placetomoveroto, AvailList_placetomoveroto, "FieldsInUse", ref dummy, false).OfType<ROField>().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<XmlNode>().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
@ -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,12 +2779,14 @@ 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);
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

View File

@ -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

View File

@ -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("&apos;", "\'");
return Info?.Replace("&apos;", "\'");
}
public override bool RODB_NewSchemaPiece(string recid, string parentid, string table, string schpiece, uint rtype)

View File

@ -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;

View File

@ -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