diff --git a/PROMS/Volian.Controls.Library/EditItem.cs b/PROMS/Volian.Controls.Library/EditItem.cs index 91961930..decec0e1 100644 --- a/PROMS/Volian.Controls.Library/EditItem.cs +++ b/PROMS/Volian.Controls.Library/EditItem.cs @@ -704,14 +704,17 @@ namespace Volian.Controls.Library if (MyItemInfo.IsSection) { SectionConfig secc = MyItemInfo.MyConfig as SectionConfig; - if (secc.Section_LnkEnh=="Y")thisEnhs = secc.MyEnhancedDocuments; + if (secc.Section_LnkEnh == "Y") thisEnhs = secc.MyEnhancedDocuments; } } - + List enhIds = new List(); - foreach (EnhancedDocument ed in thisEnhs) + if (thisEnhs != null) { - if (ed.Type != 0) enhIds.Add(ed.ItemID); + foreach (EnhancedDocument ed in thisEnhs) + { + if (ed.Type != 0) enhIds.Add(ed.ItemID); + } } BeingRemoved = true; MyStepPanel.SelectedEditItem = null; // Unselect the item to be deleted @@ -723,7 +726,7 @@ namespace Volian.Controls.Library pnl.Size = new Size(10, 10); MyStepPanel.Controls.Add(pnl); pnl.BackColor = Color.Red; - pnl.Location = new Point(xOffset += 15, MyStepPanel.ClientSize.Height+10); + pnl.Location = new Point(xOffset += 15, MyStepPanel.ClientSize.Height + 10); EditItem newFocus = DeleteItem(); if (newFocus == null) { @@ -748,10 +751,10 @@ namespace Volian.Controls.Library MyStepPanel.Controls.Remove(pnl); foreach (int enhId in enhIds) { - ItemInfo ii = ItemInfo.Get(enhId); - bool success = this._MyStepPanel.MyStepTabPanel.MyDisplayTabControl.DeleteRTBItem(ii); - if (!success) // item was not displayed in editor, just delete from database (add tree if necessarY) - Item.DeleteItemAndChildren(ii); + ItemInfo ii = ItemInfo.Get(enhId); + bool success = this._MyStepPanel.MyStepTabPanel.MyDisplayTabControl.DeleteRTBItem(ii); + if (!success) + Item.DeleteItemAndChildren(ii); } } diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs index b0e10010..17548819 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs @@ -2278,7 +2278,7 @@ namespace Volian.Controls.Library // Enhanced section: Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem. if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y") - CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo); + CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo, sectiontmp.DisplayNumber, sectiontmp.MyContent.Text); sectiontmp.Dispose(); OnNodeSelect(this, new vlnTreeEventArgs(tn)); } @@ -2327,7 +2327,7 @@ namespace Volian.Controls.Library // Enhanced section: Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem. if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y") - CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo); + CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo, sectiontmp.DisplayNumber, sectiontmp.MyContent.Text); sectiontmp.Dispose(); } } @@ -2368,7 +2368,7 @@ namespace Volian.Controls.Library // Enhanced section: Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem. if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y") - CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo); + CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo, sectiontmp.DisplayNumber, sectiontmp.MyContent.Text); sectiontmp.Dispose(); } } @@ -2480,8 +2480,9 @@ namespace Volian.Controls.Library cs.Save(); } } - private void CreateEnhancedForSection(MenuSelections typ, Section sourceSect, SectionInfo lastSectionInfo) + private void CreateEnhancedForSection(MenuSelections typ, Section sourceSect, SectionInfo lastSectionInfo, string num, string title) { + MenuSelections tmptyp = typ; if (typ == MenuSelections.SectionAfter || typ == MenuSelections.SectionBefore) { ItemInfo tmpSI = lastSectionInfo; @@ -2494,6 +2495,8 @@ namespace Volian.Controls.Library eds = sc.MyEnhancedDocuments; break; } + // if had to skip unlinked sections, it becomes an 'after' a linked one: + tmptyp = MenuSelections.SectionAfter; tmpSI = tmpSI.MyPrevious; } if (eds != null) // found valid enhanced ids to insert from: @@ -2501,7 +2504,7 @@ namespace Volian.Controls.Library foreach (EnhancedDocument sed in eds) { SectionInfo esi = SectionInfo.Get(sed.ItemID); - using (Section newenhSection = Section.MakeSection((typ == MenuSelections.SectionAfter) ? null : esi.ActiveParent, (typ == MenuSelections.SectionAfter) ? esi : esi.MyPrevious, null, "New Section", 10000)) + using (Section newenhSection = Section.MakeSection((tmptyp == MenuSelections.SectionAfter) ? null : esi.ActiveParent, (tmptyp == MenuSelections.SectionAfter) ? esi : esi.MyPrevious, num, title, 10000)) { SaveEnhancedForSection(sourceSect, newenhSection, sed.Type); RefreshRelatedNode(SectionInfo.Get(newenhSection.ItemID)); @@ -2521,7 +2524,7 @@ namespace Volian.Controls.Library ProcedureInfo enhInfo = ProcedureInfo.Get(ed.ItemID); if (enhInfo.LastChild(E_FromType.Section) != null) { - using (Section newenhSection = Section.MakeSection(enhInfo, (enhInfo.Sections != null && enhInfo.Sections.Count != 0) ? enhInfo.Sections[enhInfo.Sections.Count - 1] : null, null, "New Section", 10000)) + using (Section newenhSection = Section.MakeSection(enhInfo, (enhInfo.Sections != null && enhInfo.Sections.Count != 0) ? enhInfo.Sections[enhInfo.Sections.Count - 1] : null, num, title, 10000)) { SaveEnhancedForSection(sourceSect, newenhSection, ed.Type); RefreshRelatedNode(SectionInfo.Get(newenhSection.ItemID)); @@ -2529,7 +2532,7 @@ namespace Volian.Controls.Library } else { - ItemInfo newenhSectionII = enhInfo.InsertChild(E_FromType.Section, 10000, "New Section", null); + ItemInfo newenhSectionII = enhInfo.InsertChild(E_FromType.Section, 10000, title, num); using (Section newenhSect = Section.Get(newenhSectionII.ItemID)) { SaveEnhancedForSection(sourceSect, newenhSect, ed.Type);