Compare commits

...
2 Commits
3 changed files with 38 additions and 6 deletions

No files matched your search

@@ -127,12 +127,13 @@ namespace ROEditor
private string origPrefix; private string origPrefix;
private string origValue; private string origValue;
private int dbtype; private int dbtype;
private bool IsNewGroup = false;
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.Container components = null; private System.ComponentModel.Container components = null;
public GroupDefFrm(VlnXmlElement pelem, RODB rodb, string gpname,int idbtype) public GroupDefFrm(VlnXmlElement pelem, RODB rodb, string gpname,int idbtype, bool newgrp = false)
{ {
myrodb = rodb; myrodb = rodb;
elem = pelem; elem = pelem;
@@ -143,6 +144,7 @@ namespace ROEditor
// //
InitializeComponent(); InitializeComponent();
FillInData(); FillInData();
IsNewGroup = newgrp;
} }
private string CvtUserFldToFld(string fldname) private string CvtUserFldToFld(string fldname)
@@ -655,10 +657,11 @@ namespace ROEditor
tmpn.FirstChild.Value = tmpstr2; //tmpn.FirstChild.Value.Replace(CvtUserFldToFld(origGroup), this.tbGroup.Text); tmpn.FirstChild.Value = tmpstr2; //tmpn.FirstChild.Value.Replace(CvtUserFldToFld(origGroup), this.tbGroup.Text);
modified=true; modified=true;
} }
if ((elem.HasAttribute("AccPageIDPrefix")&&this.tbPrefix.Text != origPrefix) || this.tbPrefix.Modified==true) if ((elem.HasAttribute("AccPageIDPrefix")&&(tbPrefix.Text != origPrefix || IsNewGroup)) || tbPrefix.Modified)
{ {
elem.SetAttribute("AccPageIDPrefix",this.tbPrefix.Text); elem.SetAttribute("AccPageIDPrefix",this.tbPrefix.Text);
modified=true; modified=true;
IsNewGroup = false;
if (myrodb.IsDuplicateAccPagePrefix(elem, tbPrefix.Text)) if (myrodb.IsDuplicateAccPagePrefix(elem, tbPrefix.Text))
{ {
@@ -666,6 +669,7 @@ namespace ROEditor
elem.SetAttribute("AccPageIDPrefix", origPrefix); elem.SetAttribute("AccPageIDPrefix", origPrefix);
modified = false; modified = false;
MessageBox.Show($"The Prefix field used for the \"Accessory Pages Access\" values should be unique. The fields used in these values can be found under \"Properties\" of an RO Group. If these are not unique, you may have trouble utilizing these ROs within Word Sections in PROMS. Cannot save.", "Problem saving data"); MessageBox.Show($"The Prefix field used for the \"Accessory Pages Access\" values should be unique. The fields used in these values can be found under \"Properties\" of an RO Group. If these are not unique, you may have trouble utilizing these ROs within Word Sections in PROMS. Cannot save.", "Problem saving data");
DialogResult = DialogResult.Cancel;
return; return;
} }
} }
@@ -44,9 +44,7 @@
*********************************************************************************************/ *********************************************************************************************/
using System; using System;
using System.Drawing;
using System.Collections; using System.Collections;
using System.ComponentModel;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml; using System.Xml;
using System.Text; using System.Text;
@@ -399,11 +397,13 @@ namespace ROEditor
} }
} }
nelem.SetAttribute("GroupFieldsInUse", Inuse.ToString()); nelem.SetAttribute("GroupFieldsInUse", Inuse.ToString());
string defaultPfix = "UD";
if (dbtype == 2) // Setpoint if (dbtype == 2) // Setpoint
{ {
nelem.SetAttribute("RetVal", "<Setpoint__Value>"); nelem.SetAttribute("RetVal", "<Setpoint__Value>");
nelem.SetAttribute("MenuItem", "<Setpoint__Value,5,17> <Short__Description>"); nelem.SetAttribute("MenuItem", "<Setpoint__Value,5,17> <Short__Description>");
nelem.SetAttribute("GroupMenuItem", "<Parameter>"); nelem.SetAttribute("GroupMenuItem", "<Parameter>");
defaultPfix = "SP";
nelem.SetAttribute("AccPageIDPrefix", "SP2"); nelem.SetAttribute("AccPageIDPrefix", "SP2");
nelem.SetAttribute("AccPageID", "<Setpoint__ID>"); nelem.SetAttribute("AccPageID", "<Setpoint__ID>");
} }
@@ -412,16 +412,42 @@ namespace ROEditor
nelem.SetAttribute("RetVal", "<Image>"); nelem.SetAttribute("RetVal", "<Image>");
nelem.SetAttribute("MenuItem", "<Name>"); nelem.SetAttribute("MenuItem", "<Name>");
nelem.SetAttribute("GroupMenuItem", "<Group>"); nelem.SetAttribute("GroupMenuItem", "<Group>");
defaultPfix = "IG";
nelem.SetAttribute("AccPageIDPrefix", "IG2"); nelem.SetAttribute("AccPageIDPrefix", "IG2");
nelem.SetAttribute("AccPageID", "<Image__ID>"); nelem.SetAttribute("AccPageID", "<Image__ID>");
} }
//B2026-091 RO Editor - Change Default Prefix to take existing prefixes into account for Setpoint/Graphics DBs
//if duplicate prefix - then change it so it will be unique
int x = 2;
while (nelem.HasAttribute("AccPageIDPrefix") && myrodb.IsDuplicateAccPagePrefix(nelem, nelem.GetAttribute("AccPageIDPrefix")))
{
nelem.SetAttribute("AccPageIDPrefix", $"{defaultPfix}{x}");
x++;
}
success = myrodb.RODB_WriteRO(nelem); success = myrodb.RODB_WriteRO(nelem);
if (success == false) return; if (success == false) return;
} }
// now let the user specify the group name, etc to define the group. // now let the user specify the group name, etc to define the group.
GroupDefFrm grdef = new GroupDefFrm(nelem,myrodb,nelem.InnerText,dbtype); DialogResult dlgrslt = DialogResult.OK;
grdef.ShowDialog(); using (GroupDefFrm grdef = new GroupDefFrm(nelem, myrodb, nelem.InnerText, dbtype, true))
{
dlgrslt = grdef.ShowDialog();
}
//If New Group and prefix would not be unique, remove the group
//needed because groups get autoadded with defaults
//before user has a chance to enter things like Acc Page Prefix
if (dlgrslt == DialogResult.Cancel)
{
XmlNode pn = nelem.ParentNode;
XmlNode nd = (XmlNode)nelem;
myrodb.RODB_DeleteGroup(nd, null, null);
pn.RemoveChild(nelem);
DialogResult = DialogResult.Cancel;
Close();
}
} }
private void txtBox_KeyDown(object sender, KeyEventArgs e) private void txtBox_KeyDown(object sender, KeyEventArgs e)
{ {
@@ -2117,6 +2117,8 @@ namespace RODBInterface
if (retele != null && tbl != ro.GetAttribute("Table") && retele.GetAttribute("AccPageIDPrefix").ToLower() == pfix.ToLower()) if (retele != null && tbl != ro.GetAttribute("Table") && retele.GetAttribute("AccPageIDPrefix").ToLower() == pfix.ToLower())
{ {
DBE.CommandDispose();
DBE.ReaderClose();
return true; //another table contains the prefix - return true return true; //another table contains the prefix - return true
} }
} }