diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs index 3a2ed384..c9b323e4 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs @@ -2559,8 +2559,14 @@ namespace Volian.Controls.Library else // Properties was canceled out of: s1 = section.ItemID; } - if (s1 != -1) + if (s1 != -1) + { DeleteItemInfoAndChildren(_LastSectionInfo);// Delete Item and reset Previous and Next + // B2020-087 refresh the tree node after canceling the creation of the subsection + _LastTreeNode.ChildrenLoaded = false; + _LastTreeNode.RefreshNode(); + _LastTreeNode.Collapse(); + } } } else if (newtype == MenuSelections.SectionAfter || newtype == MenuSelections.SectionBefore) @@ -2601,7 +2607,13 @@ namespace Volian.Controls.Library s2 = section.ItemID; } if (s2 != -1) + { DeleteItemInfoAndChildren(_LastSectionInfo);// Delete Item and reset Previous and Next + // B2020-087 refresh the tree node after canceling the creation of the subsection + _LastTreeNode.ChildrenLoaded = false; + _LastTreeNode.RefreshNode(); + _LastTreeNode.Collapse(); + } } #endregion #region InsertStep @@ -2788,7 +2800,19 @@ namespace Volian.Controls.Library private Section CreateNewSection() { - if(_LastItemInfo.LastChild(E_FromType.Section) != null) + // B2020-087 the config for SubSection_Edit was sometimes set even when there wasn't any subsections, + // so make sure it's cleared if there are no existing subsections + SectionConfig sc = _LastItemInfo.MyConfig as SectionConfig; + if (sc.SubSection_Edit == "Y" && _LastItemInfo.Sections == null) + { + sc.SubSection_Edit = null; + using (Section mysect = Section.Get(_LastItemInfo.ItemID)) + { + mysect.MyContent.Config = sc.ToString(); + mysect.Save(); + } + } + if (_LastItemInfo.LastChild(E_FromType.Section) != null) return Section.MakeSection(_LastItemInfo, _LastItemInfo.LastChild(E_FromType.Section), null, "New Section", 10000); ItemInfo iii = _LastItemInfo.InsertChild(E_FromType.Section, 10000, "New Section", null); return Section.Get(iii.ItemID); @@ -3095,6 +3119,10 @@ namespace Volian.Controls.Library { return false; } + // B2020-087 refresh the tree node after the delete - needed when deleting the last subsection or canceling the creation of the first subsection + (this.SelectedNode as VETreeNode).ChildrenLoaded = false; + (this.SelectedNode as VETreeNode).RefreshNode(); + (this.SelectedNode as VETreeNode).Collapse(); WordSectionEventArgs args = new WordSectionEventArgs(_LastSectionInfo); OnWordSectionDeleted(this, args); _LastSectionInfo = null; @@ -3145,6 +3173,8 @@ namespace Volian.Controls.Library DateTime dtStart = DateTime.Now; try { + ItemInfo pii = ii.MyParent; + bool deletedSection = ii.IsSection; // send an event to frmVeproms that sends an event to the stepeditor to // do delete using RTBItem - this manages windowing from the step editor. // If the procedure is open & you're deleting procedure, you want to close open @@ -3154,6 +3184,20 @@ namespace Volian.Controls.Library Item.DeleteItemAndChildren(ii); OnProcessing(false,"Deleted"); OnProcessingComplete(dtStart,"Deleted"); + if (deletedSection) + { + // B2020-087 if we deleted the last sub section, then clear the SubSection_Edit in the parent's config + SectionConfig sc = pii.MyConfig as SectionConfig; + if (sc.SubSection_Edit == "Y" && pii.Sections == null) + { + sc.SubSection_Edit = null; + using (Section mysect = Section.Get(pii.ItemID)) + { + mysect.MyContent.Config = sc.ToString(); + mysect.Save(); + } + } + } return true; } catch (System.Data.SqlClient.SqlException ex)