diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2022-02-08 16:27:53 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2022-02-08 16:27:53 +0300 |
commit | 1272c0104e19a111674beab2558cd0a8a9f9295b (patch) | |
tree | b02b4527280bba8a8e8975b4e68120fd5143003e | |
parent | 81f30303735c0a9cd367a2e624e2444726611fcf (diff) |
Refactoring AbstractTool
-rw-r--r-- | src/PriceListTools/AbstractTool.cs | 80 |
1 files changed, 23 insertions, 57 deletions
diff --git a/src/PriceListTools/AbstractTool.cs b/src/PriceListTools/AbstractTool.cs index ea713c7..b9e3c29 100644 --- a/src/PriceListTools/AbstractTool.cs +++ b/src/PriceListTools/AbstractTool.cs @@ -45,77 +45,50 @@ namespace RehauSku.PriceListTools { foreach (int column in columns) { - Range sumCell = TargetFile.Sheet.Cells[row, column]; - - if (sumCell.Value2 == null) - { - sumCell.Value2 = positionAmount.Value; - } - - else - { - sumCell.Value2 += positionAmount.Value; - } + Range cell = TargetFile.Sheet.Cells[row, column]; + cell.AddValue(positionAmount.Value); } ResultBar.IncrementSuccess(); - return; } - if (TargetFile.oldSkuCell != null) + else if (TargetFile.oldSkuCell != null) { - Range foundCell = TargetFile.oldSkuCell.EntireColumn.Find(positionAmount.Key.Sku); + row = GetPositionRow(positionAmount.Key.Sku, positionAmount.Key.Group, TargetFile.oldSkuCell.Column); - if (foundCell != null) + if (row != null) { - row = foundCell.Row; - foreach (int column in columns) { - if (TargetFile.Sheet.Cells[row, column].Value2 == null) - { - TargetFile.Sheet.Cells[row, column].Value2 = positionAmount.Value; - } - - else - { - TargetFile.Sheet.Cells[row, column].Value2 += positionAmount.Value; - } + Range cell = TargetFile.Sheet.Cells[row, column]; + cell.AddValue(positionAmount.Value); } ResultBar.IncrementReplaced(); - return; } } - string sku = positionAmount.Key.Sku.Substring(1, 6); - row = GetPositionRow(sku, positionAmount.Key.Group, TargetFile.skuCell.Column); - - if (row != null) + else { - foreach (int column in columns) - { - Range amountCell = TargetFile.Sheet.Cells[row, column]; + string sku = positionAmount.Key.Sku.Substring(1, 6); + row = GetPositionRow(sku, positionAmount.Key.Group, TargetFile.skuCell.Column); - if (amountCell.Value2 == null) + if (row != null) + { + foreach (int column in columns) { - amountCell.Value2 = positionAmount.Value; + Range cell = TargetFile.Sheet.Cells[row, column]; + cell.AddValue(positionAmount.Value); } - else - { - amountCell.Value2 += positionAmount.Value; - } + ResultBar.IncrementReplaced(); } - ResultBar.IncrementReplaced(); - return; - } - - else - { - FillMissing(positionAmount, columns); - ResultBar.IncrementNotFound(); + else + { + FillMissing(positionAmount, columns); + ResultBar.IncrementNotFound(); + } } } @@ -151,15 +124,8 @@ namespace RehauSku.PriceListTools foreach (int column in columns) { - if (TargetFile.Sheet.Cells[row, column].Value2 == null) - { - TargetFile.Sheet.Cells[row, column].Value2 = positionAmount.Value; - } - - else - { - TargetFile.Sheet.Cells[row, column].Value2 += positionAmount.Value; - } + Range cell = TargetFile.Sheet.Cells[row, column]; + cell.AddValue(positionAmount.Value); } } |