From 952ca22316b4e4ac25004cd453baac1afac5adaf Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Fri, 28 Jan 2022 12:27:10 +0300 Subject: Implement filling positions to correct sku group --- src/PriceListTools/PriceListTool.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/PriceListTools/PriceListTool.cs') diff --git a/src/PriceListTools/PriceListTool.cs b/src/PriceListTools/PriceListTool.cs index 127912b..cf2cd59 100644 --- a/src/PriceListTools/PriceListTool.cs +++ b/src/PriceListTools/PriceListTool.cs @@ -34,19 +34,27 @@ namespace RehauSku.PriceListTools protected private void FillColumn(IEnumerable> dictionary, int column) { List> missing = new List>(); + object[,] groupColumn = TargetFile.groupCell.EntireColumn.Value2; foreach (var kvp in dictionary) { - Range cell = TargetFile.skuCell.EntireColumn.Find(kvp.Key.Sku); + Range foundCell = TargetFile.skuCell.EntireColumn.Find(kvp.Key.Sku); + string foundCellGroup = groupColumn[foundCell.Row, 1].ToString(); - if (cell == null) + while (foundCell != null && foundCellGroup != kvp.Key.Group) + { + foundCell = TargetFile.skuCell.EntireColumn.FindNext(foundCell); + foundCellGroup = groupColumn[foundCell.Row, 1].ToString(); + } + + if (foundCell == null) { missing.Add(kvp); } else { - Range sumCell = TargetFile.Sheet.Cells[cell.Row, column]; + Range sumCell = TargetFile.Sheet.Cells[foundCell.Row, column]; if (sumCell.Value2 == null) { -- cgit v1.2.3