diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2022-01-28 12:27:10 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2022-01-28 12:27:10 +0300 |
commit | 952ca22316b4e4ac25004cd453baac1afac5adaf (patch) | |
tree | 7a9fab04599cc5b9d0e64a7dd70005c3cbd1f9cd /src | |
parent | 711cc313e0eaed646c5058ef294de6d89770e352 (diff) |
Implement filling positions to correct sku group
Diffstat (limited to 'src')
-rw-r--r-- | src/PriceListTools/Position.cs | 17 | ||||
-rw-r--r-- | src/PriceListTools/PriceListTool.cs | 14 | ||||
-rw-r--r-- | src/PriceListTools/Source.cs | 16 | ||||
-rw-r--r-- | src/RehauSku.Assist.csproj | 1 |
4 files changed, 30 insertions, 18 deletions
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<KeyValuePair<Position, double>> dictionary, int column) { List<KeyValuePair<Position, double>> missing = new List<KeyValuePair<Position, double>>(); + 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 @@ <Compile Include="Assistant\SkuExtensions.cs" /> <Compile Include="PriceListTools\CombineTool.cs" /> <Compile Include="PriceListTools\ConvertTool.cs" /> + <Compile Include="PriceListTools\Position.cs" /> <Compile Include="PriceListTools\PriceListTool.cs" /> <Compile Include="PriceListTools\MergeTool.cs" /> <Compile Include="PriceListTools\PriceList.cs" /> |