diff --git a/src/PriceListTools/Position.cs b/src/PriceListTools/Position.cs new file mode 100644 index 0000000..471aa59 --- /dev/null +++ b/src/PriceListTools/Position.cs @@ -0,0 +1,17 @@ +namespace RehauSku.PriceListTools +{ + public class Position + { + public string Group { get; private set; } + public string Sku { get; private set; } + public string Name { get; private set; } + + public Position(string group, string sku, string name) + { + Group = group; + Sku = sku; + Name = name; + } + } +} + 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) { diff --git a/src/PriceListTools/Source.cs b/src/PriceListTools/Source.cs index 8c71130..fd64012 100644 --- a/src/PriceListTools/Source.cs +++ b/src/PriceListTools/Source.cs @@ -35,7 +35,7 @@ namespace RehauSku.PriceListTools object[,] amountColumn = amountCell.EntireColumn.Value2; object[,] skuColumn = skuCell.EntireColumn.Value2; object[,] nameColumn = nameCell.EntireColumn.Value2; - object[,] groupColumn = nameCell.EntireColumn.Value2; + object[,] groupColumn = groupCell.EntireColumn.Value2; for (int row = amountCell.Row + 1; row < amountColumn.GetLength(0); row++) { @@ -60,19 +60,5 @@ namespace RehauSku.PriceListTools } } } - - public class Position - { - public string SkuGroup { get; private set; } - public string Sku { get; private set; } - public string Name { get; private set; } - - public Position(string group, string sku, string name) - { - SkuGroup = group; - Sku = sku; - Name = name; - } - } } diff --git a/src/RehauSku.Assist.csproj b/src/RehauSku.Assist.csproj index be4a8b0..af4489a 100644 --- a/src/RehauSku.Assist.csproj +++ b/src/RehauSku.Assist.csproj @@ -123,6 +123,7 @@ +