Fix missing exact sku-group search and fill.
This commit is contained in:
parent
acaea67920
commit
41317cab71
@ -58,7 +58,7 @@ namespace RehauSku.PriceListTools
|
|||||||
|
|
||||||
protected private void FillPositionAmountToColumns(KeyValuePair<Position, double> positionAmount, params int[] columns)
|
protected private void FillPositionAmountToColumns(KeyValuePair<Position, double> positionAmount, params int[] columns)
|
||||||
{
|
{
|
||||||
int? row = GetPositionRow(positionAmount.Key.Sku, positionAmount.Key.Group, TargetFile.skuCell.Column);
|
int? row = GetPositionRow(TargetFile.skuCell.EntireColumn, positionAmount.Key.Sku, positionAmount.Key.Group);
|
||||||
|
|
||||||
if (row != null)
|
if (row != null)
|
||||||
{
|
{
|
||||||
@ -69,11 +69,12 @@ namespace RehauSku.PriceListTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResultBar.IncrementSuccess();
|
ResultBar.IncrementSuccess();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (TargetFile.oldSkuCell != null)
|
if (TargetFile.oldSkuCell != null)
|
||||||
{
|
{
|
||||||
row = GetPositionRow(positionAmount.Key.Sku, positionAmount.Key.Group, TargetFile.oldSkuCell.Column);
|
row = GetPositionRow(TargetFile.oldSkuCell.EntireColumn, positionAmount.Key.Sku, positionAmount.Key.Group);
|
||||||
|
|
||||||
if (row != null)
|
if (row != null)
|
||||||
{
|
{
|
||||||
@ -84,31 +85,27 @@ namespace RehauSku.PriceListTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResultBar.IncrementReplaced();
|
ResultBar.IncrementReplaced();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
string sku = positionAmount.Key.Sku.Substring(1, 6);
|
||||||
|
row = GetPositionRow(TargetFile.skuCell.EntireColumn, sku, positionAmount.Key.Group);
|
||||||
|
|
||||||
|
if (row != null)
|
||||||
{
|
{
|
||||||
string sku = positionAmount.Key.Sku.Substring(1, 6);
|
foreach (int column in columns)
|
||||||
row = GetPositionRow(sku, positionAmount.Key.Group, TargetFile.skuCell.Column);
|
|
||||||
|
|
||||||
if (row != null)
|
|
||||||
{
|
{
|
||||||
foreach (int column in columns)
|
Range cell = TargetFile.Sheet.Cells[row, column];
|
||||||
{
|
cell.AddValue(positionAmount.Value);
|
||||||
Range cell = TargetFile.Sheet.Cells[row, column];
|
|
||||||
cell.AddValue(positionAmount.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
ResultBar.IncrementReplaced();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
ResultBar.IncrementReplaced();
|
||||||
{
|
return;
|
||||||
FillMissing(positionAmount, columns);
|
|
||||||
ResultBar.IncrementNotFound();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FillMissing(positionAmount, columns);
|
||||||
|
ResultBar.IncrementNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected private void FillMissing(KeyValuePair<Position, double> positionAmount, params int[] columns)
|
protected private void FillMissing(KeyValuePair<Position, double> positionAmount, params int[] columns)
|
||||||
@ -148,32 +145,34 @@ namespace RehauSku.PriceListTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected private int? GetPositionRow(string sku, string group, int column)
|
protected private int? GetPositionRow(Range range, string sku, string group)
|
||||||
{
|
{
|
||||||
int? row = null;
|
Range found = range.Find(sku);
|
||||||
Range foundCell = TargetFile.Sheet.Columns[column].Find(sku);
|
|
||||||
string foundGroupValue;
|
string foundGroupValue;
|
||||||
|
|
||||||
if (foundCell == null) return null;
|
if (found == null)
|
||||||
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
row = foundCell.Row;
|
return null;
|
||||||
foundGroupValue = TargetFile.Sheet.Cells[foundCell.Row, TargetFile.groupCell.Column].Value2.ToString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(group) || group.Equals(foundGroupValue))
|
int firstFoundRow = found.Row;
|
||||||
return row;
|
|
||||||
|
|
||||||
else
|
while (true)
|
||||||
while (true)
|
{
|
||||||
|
foundGroupValue = TargetFile.Sheet.Cells[found.Row, TargetFile.groupCell.Column].Value2.ToString();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(group) || group.Equals(foundGroupValue))
|
||||||
{
|
{
|
||||||
foundCell = TargetFile.skuCell.EntireColumn.FindNext(foundCell);
|
return found.Row;
|
||||||
if (foundCell == null) return row;
|
|
||||||
|
|
||||||
foundGroupValue = TargetFile.Sheet.Cells[foundCell.Row, TargetFile.groupCell.Column].Value2.ToString();
|
|
||||||
if (group.Equals(foundGroupValue)) return foundCell.Row;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
found = range.FindNext(found);
|
||||||
|
|
||||||
|
if (found.Row == firstFoundRow)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected private void FilterByAmount()
|
protected private void FilterByAmount()
|
||||||
|
Loading…
Reference in New Issue
Block a user