B2015-052: For finding the Default Step section, if none is specified look for ‘PROCEDURE STEPS’ in the Display Text of the section
This commit is contained in:
parent
45d311bdfe
commit
895f65322d
@ -169,8 +169,13 @@ namespace Volian.Controls.Library
|
||||
if ((etm & E_TransUI.SectDefault) == E_TransUI.SectDefault)
|
||||
{
|
||||
secStartId = FindSectionStart(_CurrentProcedure);
|
||||
secitm = ItemInfo.Get(secStartId);
|
||||
selitm = (secitm.Steps.Count > 0) ? secitm.Steps[0] : null;
|
||||
if (secStartId > -1)
|
||||
{
|
||||
secitm = ItemInfo.Get(secStartId);
|
||||
selitm = (secitm.Steps.Count > 0) ? secitm.Steps[0] : null;
|
||||
}
|
||||
else
|
||||
btnTranSave.Enabled = false; // if there is an invalid section start - don't allow save.
|
||||
}
|
||||
cbTranSectsFillIn(secitm, secitm == null ? -1 : secStartId, true);
|
||||
// Fill step items, passing in the active step to the selected item, or the first
|
||||
@ -740,6 +745,7 @@ namespace Volian.Controls.Library
|
||||
tmpitm = tmpitm.MyParent;
|
||||
}
|
||||
int sectstartid = FindSectionStart(_CurrentProcedure);
|
||||
if (sectstartid==-1) btnTranSave.Enabled = false; // if there is an invalid section start - don't allow save.
|
||||
IList chldrn = _CurrentProcedure.GetChildren();
|
||||
if (chldrn != null && chldrn.Count > 0) cbTranSectsFillIn((ItemInfo)chldrn[0], secitm==null?sectstartid:secitm.ItemID, true); //sectstartid);
|
||||
}
|
||||
@ -824,28 +830,65 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private int FindSectionStart(ItemInfo prcitm)
|
||||
{
|
||||
// Steps to get the section start. continue down list until finding a valid id. If none is found
|
||||
// put up a message dialog - and if returns a result of -1, caller should disable the 'ok' button
|
||||
// so that a transition cannot be entered until the default section is defined:
|
||||
// 1) Look in ProcedureConfig/SectionStart
|
||||
// 2) Look in SectionConfig/OriginalSteps
|
||||
// 3) Search through the procedure's sections for 'Procedure Steps' as the title
|
||||
// 4) Display message box telling user to set the default section on section properties/format dialog
|
||||
// (this returns a -1, i.e. error)
|
||||
|
||||
// 1) Look in ProcedureConfig/SectionStart
|
||||
ProcedureConfig pc = (ProcedureConfig)prcitm.MyConfig;
|
||||
int sectstartid = -1;
|
||||
string ss = pc == null ? null : pc.SectionStart;
|
||||
if (ss != null && ss != "") sectstartid = System.Convert.ToInt32(ss);
|
||||
SectionInfo si = SectionInfo.Get(sectstartid);
|
||||
if (si == null) return -1;
|
||||
if (si.MyProcedure.ItemID == prcitm.ItemID) return sectstartid;
|
||||
foreach (SectionInfo si1 in prcitm.Sections)
|
||||
SectionInfo si = null;
|
||||
if (ss != null && ss != "")
|
||||
{
|
||||
if (si.DisplayNumber == si1.DisplayNumber && si.DisplayText == si1.DisplayText)
|
||||
sectstartid = System.Convert.ToInt32(ss);
|
||||
si = SectionInfo.Get(sectstartid);
|
||||
}
|
||||
if (si != null)
|
||||
{
|
||||
if (si.MyProcedure.ItemID == prcitm.ItemID) return sectstartid;
|
||||
// The following code fixes the sectionstart property for the Copy Procedure function. This code will correct
|
||||
// any procedures that were copied prior to the implementation of this the copy procedure function fix.
|
||||
foreach (SectionInfo si1 in prcitm.Sections)
|
||||
{
|
||||
using (Procedure p = Procedure.Get(prcitm.ItemID))
|
||||
if (si.DisplayNumber == si1.DisplayNumber && si.DisplayText == si1.DisplayText)
|
||||
{
|
||||
if (p.ProcedureConfig.SectionStart != si1.ItemID.ToString())
|
||||
using (Procedure p = Procedure.Get(prcitm.ItemID))
|
||||
{
|
||||
p.ProcedureConfig.SectionStart = si1.ItemID.ToString();
|
||||
p.Save();
|
||||
if (p.ProcedureConfig.SectionStart != si1.ItemID.ToString())
|
||||
{
|
||||
p.ProcedureConfig.SectionStart = si1.ItemID.ToString();
|
||||
p.Save();
|
||||
}
|
||||
}
|
||||
return si1.ItemID;
|
||||
}
|
||||
return si1.ItemID;
|
||||
}
|
||||
}
|
||||
// 2) Look in SectionConfig/OriginalSteps = 'Y'
|
||||
foreach (SectionInfo sio in prcitm.Sections)
|
||||
{
|
||||
SectionConfig sc = sio.MyConfig as SectionConfig;
|
||||
if (sc != null && sc.Section_OriginalSteps == "Y")
|
||||
{
|
||||
return sio.ItemID;
|
||||
}
|
||||
}
|
||||
|
||||
// 3) Find if any of the section titles contain 'PROCEDURES STEPS'
|
||||
foreach (SectionInfo sit in prcitm.Sections)
|
||||
{
|
||||
if (sit.DisplayText.ToUpper().Contains("PROCEDURE STEPS"))
|
||||
return sit.ItemID;
|
||||
}
|
||||
|
||||
// 4) Display messagebox to tell user to specify which section should be used as the 'default section'.
|
||||
MessageBox.Show("No default step section was found. Set the appropriate Step Section as the default by using the Section Property Page, Format Tab.", "Transition using Default Step Sction in Format", MessageBoxButtons.OK,MessageBoxIcon.Error);
|
||||
return -1;
|
||||
}
|
||||
private void cbTranProcs_SelectedIndexChanged(object sender, EventArgs e)
|
||||
@ -859,6 +902,7 @@ namespace Volian.Controls.Library
|
||||
return;
|
||||
}
|
||||
int sectstartid = FindSectionStart(prcitm);
|
||||
if (sectstartid == -1) btnTranSave.Enabled = false; // if there is an invalid section start - don't allow save.
|
||||
IList chldrn = prcitm.GetChildren();
|
||||
cbTranSectsFillIn((ItemInfo)chldrn[0], sectstartid, true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user