From 596a59d0f6e37b50ca155321d94bf80bd92d671a Mon Sep 17 00:00:00 2001 From: Kathy Date: Tue, 2 Feb 2016 14:07:25 +0000 Subject: [PATCH] =?UTF-8?q?B2016-030:=20Crash=20when=20deleting=20a=20sour?= =?UTF-8?q?ce=20(has=20linked=20enhanced)=20sections=20when=20all=20are=20?= =?UTF-8?q?displayed=20in=20editor.=20B2016-029:=20Title=20of=20newly=20cr?= =?UTF-8?q?eated=20enhanced=20section=20is=20not=20correct=20if=20source?= =?UTF-8?q?=20section=20not=20titled=20=E2=80=98New=20Section=E2=80=99.=20?= =?UTF-8?q?B2016-031:=20Insert=20from=20tree=20of=20section=20after=20a=20?= =?UTF-8?q?non-linked=20section=20does=20not=20get=20inserted=20in=20enhan?= =?UTF-8?q?ced=20procedure=20in=20correct=20location.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PROMS/Volian.Controls.Library/EditItem.cs | 21 +++++++++++--------- PROMS/Volian.Controls.Library/vlnTreeView.cs | 17 +++++++++------- 2 files changed, 22 insertions(+), 16 deletions(-) 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);