Refactoring AbstractTool

This commit is contained in:
Sergey Chebotar 2022-02-08 16:27:53 +03:00
parent 81f3030373
commit 1272c0104e

View File

@ -45,49 +45,31 @@ namespace RehauSku.PriceListTools
{ {
foreach (int column in columns) foreach (int column in columns)
{ {
Range sumCell = TargetFile.Sheet.Cells[row, column]; Range cell = TargetFile.Sheet.Cells[row, column];
cell.AddValue(positionAmount.Value);
if (sumCell.Value2 == null)
{
sumCell.Value2 = positionAmount.Value;
}
else
{
sumCell.Value2 += positionAmount.Value;
}
} }
ResultBar.IncrementSuccess(); 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) foreach (int column in columns)
{ {
if (TargetFile.Sheet.Cells[row, column].Value2 == null) Range cell = TargetFile.Sheet.Cells[row, column];
{ cell.AddValue(positionAmount.Value);
TargetFile.Sheet.Cells[row, column].Value2 = positionAmount.Value; }
ResultBar.IncrementReplaced();
}
} }
else else
{ {
TargetFile.Sheet.Cells[row, column].Value2 += positionAmount.Value;
}
}
ResultBar.IncrementReplaced();
return;
}
}
string sku = positionAmount.Key.Sku.Substring(1, 6); string sku = positionAmount.Key.Sku.Substring(1, 6);
row = GetPositionRow(sku, positionAmount.Key.Group, TargetFile.skuCell.Column); row = GetPositionRow(sku, positionAmount.Key.Group, TargetFile.skuCell.Column);
@ -95,21 +77,11 @@ namespace RehauSku.PriceListTools
{ {
foreach (int column in columns) foreach (int column in columns)
{ {
Range amountCell = TargetFile.Sheet.Cells[row, column]; Range cell = TargetFile.Sheet.Cells[row, column];
cell.AddValue(positionAmount.Value);
if (amountCell.Value2 == null)
{
amountCell.Value2 = positionAmount.Value;
}
else
{
amountCell.Value2 += positionAmount.Value;
}
} }
ResultBar.IncrementReplaced(); ResultBar.IncrementReplaced();
return;
} }
else else
@ -118,6 +90,7 @@ namespace RehauSku.PriceListTools
ResultBar.IncrementNotFound(); ResultBar.IncrementNotFound();
} }
} }
}
protected private void FillMissing(KeyValuePair<Position, double> positionAmount, params int[] columns) protected private void FillMissing(KeyValuePair<Position, double> positionAmount, params int[] columns)
{ {
@ -151,15 +124,8 @@ namespace RehauSku.PriceListTools
foreach (int column in columns) foreach (int column in columns)
{ {
if (TargetFile.Sheet.Cells[row, column].Value2 == null) Range cell = TargetFile.Sheet.Cells[row, column];
{ cell.AddValue(positionAmount.Value);
TargetFile.Sheet.Cells[row, column].Value2 = positionAmount.Value;
}
else
{
TargetFile.Sheet.Cells[row, column].Value2 += positionAmount.Value;
}
} }
} }