From a2c3844ffd92c7c6f9aec4b3e9997f55863af7bb Mon Sep 17 00:00:00 2001 From: Kathy Date: Tue, 28 Aug 2018 15:10:55 +0000 Subject: [PATCH] B2018-118: Enhanced tabs are incorrect when mix of (linked & unlinked) Cautions/Notes --- .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 6a7afe23..7ab0d9c3 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -3750,9 +3750,34 @@ namespace VEPROMS.CSLA.Library EnhancedDocuments eds = GetMyEnhancedDocuments(); if (eds != null && eds.Count == 1 && eds[0].Type == 0) { + // B2018-114 check for a null before getting the Ordinal value (code that uses this handles a Null return value from this Get ItemInfo srcItem = ItemInfo.Get(eds[0].ItemID); - if (srcItem != null) // B2018-114 check for a null before getting the Ordinal value (code that uses this handles a Null return value from this Get - return srcItem.Ordinal; + if (srcItem == null) return null; + if (srcItem.IsHigh) return srcItem.Ordinal; + // B2018-118: the LinkedOrdinal count must take into account cautions versus notes types: + ItemInfo hls = srcItem.MyHLS; + bool enIsCaution = this.IsCaution; + // get the first sibling and go through list for each type - go through notes first then cautions checking for each type: + // go through cautions first because these are the first parts: + int? ord = 0; + if (hls.Cautions != null && hls.Cautions.Count > 0) + { + foreach (ItemInfo caut in hls.Cautions) + { + if (caut.IsCaution && enIsCaution) ord++; + if (caut.IsNote && !enIsCaution) ord++; + if (caut.ItemID == srcItem.ItemID) return ord; + } + } + if (hls.Notes != null && hls.Notes.Count > 0) + { + foreach (ItemInfo note in hls.Notes) + { + if (note.IsCaution && enIsCaution) ord++; + if (note.IsNote && !enIsCaution) ord++; + if (note.ItemID == srcItem.ItemID) return ord; + } + } } return null; }