C2021-026 Parent/Child applicability in RO Editor
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*********************************************************************************************
|
||||
* Copyright 2002 - Volian Enterprises, Inc. All rights reserved.
|
||||
* Copyright 2021 - Volian Enterprises, Inc. All rights reserved.
|
||||
* Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
* ------------------------------------------------------------------------------
|
||||
* $Workfile: RODBInterface.cs $ $Revision: 48 $
|
||||
@@ -264,6 +264,7 @@ using Org.Mentalis.Files;
|
||||
using System.Data.SqlClient;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace RODBInterface
|
||||
{
|
||||
/// <summary>
|
||||
@@ -273,7 +274,6 @@ namespace RODBInterface
|
||||
{
|
||||
Master = 0, SubDatabase = 1, Schema = 2, Group = 3, GroupSchema = 4, RRO = 5, SchemaStart = 6, SchemaEnd = 7, ConvertedToSql = 8
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The following class handles generation of sql strings to get/put requested parts of
|
||||
/// XML RO Tree. And performs the database access using the VLN_DB class.
|
||||
@@ -314,6 +314,13 @@ namespace RODBInterface
|
||||
get { return _OnlyConnectOnce; }
|
||||
set { _OnlyConnectOnce = value; }
|
||||
}
|
||||
// C2021-026 used to access in the list of P/C Children
|
||||
private static string[] _PCChildList = null;
|
||||
public static string[] PCChildList
|
||||
{
|
||||
get { return _PCChildList; }
|
||||
set { _PCChildList = value; }
|
||||
}
|
||||
#endregion
|
||||
#region abstracts // need these for each method that must be defined for each database type
|
||||
public abstract string RODB_GetNextGroupTable();
|
||||
@@ -354,7 +361,6 @@ namespace RODBInterface
|
||||
|
||||
}
|
||||
#region GeneralDB
|
||||
|
||||
|
||||
public void GetDbServerInfo(string ROdir)
|
||||
{
|
||||
@@ -504,6 +510,84 @@ namespace RODBInterface
|
||||
}
|
||||
return inuse;
|
||||
}
|
||||
|
||||
//C2021-026 adding ability to have field values based on Parent/Child applicability
|
||||
// This reads the database and returns a list of the field where applicability was enabled
|
||||
public ArrayList RODB_GetApplicabilityEnabledFields(VlnXmlElement elem, ArrayList fieldsInUse, ref string origApplcFields, bool pcApplicabilityEnabled)
|
||||
{
|
||||
ArrayList newApplicList = new ArrayList();
|
||||
if (!pcApplicabilityEnabled)
|
||||
{
|
||||
origApplcFields = null;
|
||||
return newApplicList;
|
||||
}
|
||||
VlnXmlElement startelem = elem;
|
||||
string atribApplicFields = "ApplicabilityEnabled"; //xml attribute containing list of field recids
|
||||
// if this element doesn't have any fields in use, walk up the tree until
|
||||
// we find them.
|
||||
string applicFields = "";
|
||||
if (startelem.HasAttribute(atribApplicFields) == false)
|
||||
{
|
||||
VlnXmlElement parent;
|
||||
parent = (VlnXmlElement)startelem.ParentNode;
|
||||
while (parent != null && applicFields == "")
|
||||
{
|
||||
applicFields = parent.GetAttribute(atribApplicFields);
|
||||
if (parent.Name != "RO_Root")
|
||||
parent = (VlnXmlElement)parent.ParentNode;
|
||||
else
|
||||
parent = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
applicFields = startelem.GetAttribute(atribApplicFields);
|
||||
|
||||
origApplcFields = applicFields; // make a copy to compare to later.
|
||||
|
||||
// if there are no fields with applicability (may be inserting a top group)
|
||||
// return an empty list.
|
||||
if (applicFields == "") return newApplicList;
|
||||
// Go through the FieldsInUse list and copy elements to newApplicList
|
||||
int strpos = 0;
|
||||
string recid;
|
||||
recid = applicFields.Substring(strpos, 8);
|
||||
MyRecID = recid;
|
||||
while (recid != null)
|
||||
{
|
||||
// find it in avail list and add to newApplicList
|
||||
for (int i = 0; i < fieldsInUse.Count; i++)
|
||||
{
|
||||
ROField rof = (ROField)fieldsInUse[i];
|
||||
string lrecid = rof.GetRecID;
|
||||
if (lrecid == recid)
|
||||
{
|
||||
// add to newApplilcList if it is not already there list
|
||||
ROField inuserof = new ROField(rof.GetFieldname, rof.GetRecID, rof.GetMasterRecID, rof.GetFieldType);
|
||||
bool addit = true;
|
||||
foreach (ROField arof in newApplicList)
|
||||
{
|
||||
if (arof.GetRecID == inuserof.GetRecID)
|
||||
{
|
||||
addit = false; //this field is already in the list
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (addit)
|
||||
newApplicList.Add((object)inuserof);
|
||||
break;
|
||||
}
|
||||
}
|
||||
strpos = strpos + 9;
|
||||
if (strpos > applicFields.Length)
|
||||
recid = null;
|
||||
else
|
||||
{
|
||||
recid = applicFields.Substring(strpos, 8);
|
||||
}
|
||||
}
|
||||
return newApplicList;
|
||||
}
|
||||
|
||||
public string CvtUserFldToFld(string fldname)
|
||||
{
|
||||
if (fldname.Length < 2)
|
||||
@@ -649,6 +733,12 @@ namespace RODBInterface
|
||||
xmlTextWriter.WriteString(enode.GetAttribute("FieldsInUse"));
|
||||
xmlTextWriter.WriteEndAttribute();
|
||||
}
|
||||
if (enode.HasAttribute("ApplicabilityEnabled")) //C2021-026 save field applicability
|
||||
{
|
||||
xmlTextWriter.WriteStartAttribute("ApplicabilityEnabled", null);
|
||||
xmlTextWriter.WriteString(enode.GetAttribute("ApplicabilityEnabled"));
|
||||
xmlTextWriter.WriteEndAttribute();
|
||||
}
|
||||
if (enode.HasAttribute("GroupMenuItem"))
|
||||
{
|
||||
xmlTextWriter.WriteStartAttribute("GroupMenuItem", null);
|
||||
@@ -755,12 +845,31 @@ namespace RODBInterface
|
||||
success = RODB_NewSchemaPiece(lrecid, parent.GetAttribute("RecID"), myelem.GetAttribute("Table"), strbld.ToString(), editlevel);
|
||||
return success;
|
||||
}
|
||||
// C2021-026 rename any P/C Child fields
|
||||
public string DoReplaceParentChildField(string infstr, string oldName, string newName)
|
||||
{
|
||||
string rtnInfoStr = infstr;
|
||||
if (PCChildList == null) return rtnInfoStr;
|
||||
int pcChildIdx = 0; // children indexing starts at one so initialize with zero
|
||||
foreach (string chld in PCChildList)
|
||||
{
|
||||
pcChildIdx++;
|
||||
string csufx = string.Format("_PCCHILD{0}", pcChildIdx); // Create child field name
|
||||
string oldFldNameChild = oldName.Insert(oldName.Length - 1, CvtUserFldToFld(csufx));
|
||||
string newFldNameChild = newName.Insert(newName.Length - 1, CvtUserFldToFld(csufx));
|
||||
rtnInfoStr = rtnInfoStr.Replace(oldFldNameChild, newFldNameChild);
|
||||
}
|
||||
return rtnInfoStr;
|
||||
}
|
||||
|
||||
public string DoCmbFieldReplace(string repstring, string oname, string nname, string letter)
|
||||
{
|
||||
string cmboname, cmbnname;
|
||||
cmboname = oname.Insert(oname.Length - 1, letter);
|
||||
cmbnname = nname.Insert(nname.Length - 1, letter);
|
||||
return (repstring.Replace(cmboname, cmbnname));
|
||||
string rtnstr = repstring.Replace(cmboname, cmbnname);
|
||||
rtnstr = DoReplaceParentChildField(rtnstr, cmboname, cmbnname); // C2021-026 create child fields in combo group
|
||||
return rtnstr;
|
||||
}
|
||||
|
||||
// RODB_UpdateNamesInROs: goes through subtree (top node is 'fld') and if this
|
||||
@@ -2333,11 +2442,9 @@ namespace RODBInterface
|
||||
DBE.CommandDispose();
|
||||
return success;
|
||||
}
|
||||
|
||||
public override bool RODB_ProcessRROFieldChange(VlnXmlElement child, string oldname, string newname, uint editlevel,
|
||||
VlnStatusMessage StatMsgWindow, bool combofield)
|
||||
{
|
||||
|
||||
bool success;
|
||||
string str;
|
||||
string info;
|
||||
@@ -2464,7 +2571,9 @@ namespace RODBInterface
|
||||
if (combofield == false)
|
||||
{
|
||||
tinfo1 = info.Replace(onameOpen, nnameOpen);
|
||||
tinfo1 = DoReplaceParentChildField(tinfo1, onameOpen, nnameOpen); //C2021-0226 also update Parent/Child fields
|
||||
tinfo2 = tinfo1.Replace(onameClose, nnameClose);
|
||||
tinfo2 = DoReplaceParentChildField(tinfo2, onameClose, nnameClose); //C2021-0226 also update Parent/Child fields
|
||||
XmlNodeList nodeList;
|
||||
nodeList = echild.SelectNodes(oldname);
|
||||
foreach (XmlNode nod in nodeList)
|
||||
@@ -2499,7 +2608,6 @@ namespace RODBInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StatMsgWindow.StatusMessage = echild.GetAttribute("MenuTitle");
|
||||
str = "UPDATE " + echild.GetAttribute("Table") + " SET Info = '" + tinfo2 + "'";
|
||||
str = str + ", ModDateTime = '" + dt + "' WHERE RecID = '" + echild.GetAttribute("RecID") + "';";
|
||||
|
Reference in New Issue
Block a user