From 895f65322d26f5d1d88f9e2bcffc67420a117a7a Mon Sep 17 00:00:00 2001 From: Kathy Date: Mon, 27 Apr 2015 15:08:53 +0000 Subject: [PATCH] =?UTF-8?q?B2015-052:=20For=20finding=20the=20Default=20St?= =?UTF-8?q?ep=20section,=20if=20none=20is=20specified=20look=20for=20?= =?UTF-8?q?=E2=80=98PROCEDURE=20STEPS=E2=80=99=20in=20the=20Display=20Text?= =?UTF-8?q?=20of=20the=20section?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DisplayTransition.cs | 70 +++++++++++++++---- 1 file changed, 57 insertions(+), 13 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DisplayTransition.cs b/PROMS/Volian.Controls.Library/DisplayTransition.cs index eaa5cdbf..5672b537 100644 --- a/PROMS/Volian.Controls.Library/DisplayTransition.cs +++ b/PROMS/Volian.Controls.Library/DisplayTransition.cs @@ -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); }