diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2022-01-28 15:21:58 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2022-01-28 15:21:58 +0300 |
commit | ca575bef2dae6bb50b87f3dc46e24b60d5bc222d (patch) | |
tree | c989b6bf2e3facb5c71ad9da7981e6fa55524b93 /src | |
parent | b4763bd03c410433e3f8b885e5db6704337318d5 (diff) |
Move FillPosition logic to separate method
Diffstat (limited to 'src')
-rw-r--r-- | src/PriceListTools/PriceListTool.cs | 77 |
1 files changed, 41 insertions, 36 deletions
diff --git a/src/PriceListTools/PriceListTool.cs b/src/PriceListTools/PriceListTool.cs index 9aebd25..a80010b 100644 --- a/src/PriceListTools/PriceListTool.cs +++ b/src/PriceListTools/PriceListTool.cs @@ -38,42 +38,7 @@ namespace RehauSku.PriceListTools foreach (var kvp in dictionary) { - Range foundCell = TargetFile.skuCell.EntireColumn.Find(kvp.Key.Sku); - if (foundCell == null) - { - missing.Add(kvp); - continue; - } - - string foundCellGroup = groupColumn[foundCell.Row, 1].ToString(); - - 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 - { - foreach (var column in columns) - { - Range sumCell = TargetFile.Sheet.Cells[foundCell.Row, column]; - if (sumCell.Value2 == null) - { - sumCell.Value2 = kvp.Value; - } - - else - { - sumCell.Value2 += kvp.Value; - } - } - } + FillPosition(kvp, columns, ref missing, ref groupColumn); } if (missing.Count > 0) @@ -86,6 +51,46 @@ namespace RehauSku.PriceListTools } } + protected private void FillPosition(KeyValuePair<Position, double> kvp, int[] columns, ref List<KeyValuePair<Position, double>> missing, ref object[,] groupColumn) + { + Range foundCell = TargetFile.skuCell.EntireColumn.Find(kvp.Key.Sku); + if (foundCell == null) + { + missing.Add(kvp); + return; + } + + string foundCellGroup = groupColumn[foundCell.Row, 1].ToString(); + + 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 + { + foreach (var column in columns) + { + Range sumCell = TargetFile.Sheet.Cells[foundCell.Row, column]; + if (sumCell.Value2 == null) + { + sumCell.Value2 = kvp.Value; + } + + else + { + sumCell.Value2 += kvp.Value; + } + } + } + } + protected private void FilterByAmount() { AutoFilter filter = TargetFile.Sheet.AutoFilter; |