diff --git a/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs b/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs index 78d22e75..cdbfc521 100644 --- a/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs +++ b/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs @@ -1337,24 +1337,37 @@ namespace VEPROMS pi.ClearChangeBarOverrides(); //B2019-140 Change bars do not get refreshed when approval is run. - ProcedureInfo newproc = ItemInfo.ResetProcedure(pi.ItemID); + ProcedureInfo newproc; - //// Refresh the StepPanel for the current Procedure - //// so change bars update - //// on any open StepPanel - DisplayTabItem dti = MyFrmVEPROMS.GetTabContainingProcedure(pi.ItemID); + //// Refresh the StepPanel for the current Procedure + //// so change bars update + //// on any open StepPanel + + //B2026-019 Attempt to prevent an Access Error by utilizing a different Refresh if a Procedure is Open + DisplayTabItem dti = MyFrmVEPROMS.GetTabContainingProcedure(pi.ItemID); if (dti != null) { if (!dti.MyStepTabPanel.MyStepPanel.ContainsFocus) dti.MyStepTabPanel.MyStepPanel.Focus(); foreach (EditItem eitm in dti.MyStepTabPanel.MyStepPanel.Controls.OfType()) - eitm.ChangeBar = eitm.MyItemInfo.HasChangeBar; - } + { + eitm.ChangeBar = eitm.MyItemInfo.HasChangeBar; + } - //since in a separate form, need to update the tree view - //so "Showing Change Bars" Content Menu Item is correct - MyFrmVEPROMS.RefreshProcedureNode(newproc); + dti.MyStepTabPanel.MyStepTabRibbon.RefreshProcedure(); + Application.DoEvents(); + newproc = ProcedureInfo.Get(pi.ItemID); + + } + else + { + newproc = ItemInfo.ResetProcedure(pi.ItemID); + } + + //since in a separate form, need to update the tree view + //so "Showing Change Bars" Content Menu Item is correct + MyFrmVEPROMS.RefreshProcedureNode(newproc); } else UpdateProcedureConfig(pi, ap.RevNumber, ap.RevDate, myDTS, selectedSlave); diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 5e071de9..1b170bd6 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -626,22 +626,31 @@ namespace VEPROMS itm.UserID = Volian.Base.Library.VlnSettings.UserID; itm.Save(); - //B2019-140 Change bars do not get refreshed when approval is run. - // Reset a Procedure and sub items in the cache - ProcedureInfo newproc = ItemInfo.ResetProcedure(pi.ItemID); + //B2019-140 Change bars do not get refreshed when approval is run. + // Reset a Procedure and sub items in the cache - //// Refresh the StepPanel for the current Procedure - //// so change bars update - //// on any open StepPanel - DisplayTabItem dti = GetTabContainingProcedure(pi.ItemID); - if (dti != null) - { - if (!dti.MyStepTabPanel.MyStepPanel.ContainsFocus) - dti.MyStepTabPanel.MyStepPanel.Focus(); + //// Refresh the StepPanel for the current Procedure + //// so change bars update + //// on any open StepPanel + + //B2026-019 Attempt to prevent an Access Error by utilizing a different Refresh if a Procedure is Open + DisplayTabItem dti = GetTabContainingProcedure(pi.ItemID); + if (dti != null) + { + if (!dti.MyStepTabPanel.MyStepPanel.ContainsFocus) + dti.MyStepTabPanel.MyStepPanel.Focus(); foreach (EditItem eitm in dti.MyStepTabPanel.MyStepPanel.Controls.OfType()) + { eitm.ChangeBar = eitm.MyItemInfo.HasChangeBar; + } + + dti.MyStepTabPanel.MyStepTabRibbon.RefreshProcedure(); } + else + { + _ = ItemInfo.ResetProcedure(pi.ItemID); + } } } } diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index a7293be4..6be5e7f9 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -3839,9 +3839,17 @@ namespace VEPROMS.CSLA.Library _SupInfos = null; } - //B2019-140 Change bars do not get refreshed when approval is run. - // Reset a Procedure and sub items in the cache - public static ProcedureInfo ResetProcedure(int procID) + //B2019-140 Change bars do not get refreshed when approval is run. + // Reset a Procedure and sub items in the cache + // ********************** + // Be carefull calling this when the Procedure is Open + // When the Procedure is Open - use StepTabRibbon.RefreshProcedure(); instead + // When a Procedure is open and you try to refresh it, + // events can fire behind the scenes - causing data to try to be accessed while you are trying to refresh it + // When This occurs, it will cause a + // "ThreadException ... Collection was modified; enumeration operation may not execute.” + // ********************** + public static ProcedureInfo ResetProcedure(int procID) { // The following lines reload the procedure info cache ProcedureInfo newproc = ProcedureInfo.Get(procID, true);