Add FillColumn method
This commit is contained in:
parent
935d48fc5f
commit
7bb0a82ffb
@ -11,42 +11,23 @@ namespace RehauSku.PriceListTools
|
|||||||
public void FillTarget()
|
public void FillTarget()
|
||||||
{
|
{
|
||||||
ExcelApp.ScreenUpdating = false;
|
ExcelApp.ScreenUpdating = false;
|
||||||
FillAmountColumn(SourceFiles.Select(x => x.SkuAmount).ToArray());
|
|
||||||
AddAndFillSourceColumns();
|
|
||||||
FilterByAmount();
|
|
||||||
ExcelApp.ScreenUpdating = true;
|
|
||||||
|
|
||||||
Forms.Dialog.SaveWorkbookAs();
|
foreach (Source source in SourceFiles)
|
||||||
}
|
|
||||||
|
|
||||||
private void AddAndFillSourceColumns()
|
|
||||||
{
|
{
|
||||||
foreach (var source in SourceFiles)
|
|
||||||
{
|
|
||||||
if (source.SkuAmount.Count == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
TargetFile.Sheet.Columns[TargetFile.amountCell.Column]
|
TargetFile.Sheet.Columns[TargetFile.amountCell.Column]
|
||||||
.EntireColumn
|
.EntireColumn
|
||||||
.Insert(XlInsertShiftDirection.xlShiftToRight, XlInsertFormatOrigin.xlFormatFromRightOrBelow);
|
.Insert(XlInsertShiftDirection.xlShiftToRight, XlInsertFormatOrigin.xlFormatFromRightOrBelow);
|
||||||
|
|
||||||
TargetFile.Sheet.Cells[TargetFile.amountCell.Row, TargetFile.amountCell.Column - 1].Value2 = $"{source.Name}";
|
TargetFile.Sheet.Cells[TargetFile.amountCell.Row, TargetFile.amountCell.Column - 1].Value2 = $"{source.Name}";
|
||||||
|
|
||||||
foreach (var kvp in source.SkuAmount)
|
FillColumn(source.SkuAmount, TargetFile.amountCell.Column - 1);
|
||||||
{
|
FillColumn(source.SkuAmount, TargetFile.amountCell.Column);
|
||||||
Range cell = TargetFile.Sheet.Columns[TargetFile.skuCell.Column].Find(kvp.Key);
|
|
||||||
|
|
||||||
if (cell == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
FilterByAmount();
|
||||||
{
|
ExcelApp.ScreenUpdating = true;
|
||||||
TargetFile.Sheet.Cells[cell.Row, TargetFile.amountCell.Column - 1].Value2 = kvp.Value;
|
|
||||||
}
|
Forms.Dialog.SaveWorkbookAs();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ namespace RehauSku.PriceListTools
|
|||||||
{
|
{
|
||||||
ExcelApp.ScreenUpdating = false;
|
ExcelApp.ScreenUpdating = false;
|
||||||
GetSelected();
|
GetSelected();
|
||||||
FillAmountColumn(new [] {SkuAmount});
|
FillColumn(SkuAmount, TargetFile.amountCell.Column);
|
||||||
FilterByAmount();
|
FilterByAmount();
|
||||||
ExcelApp.ScreenUpdating = true;
|
ExcelApp.ScreenUpdating = true;
|
||||||
|
|
||||||
@ -67,14 +67,20 @@ namespace RehauSku.PriceListTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sku == null || amount == null)
|
if (sku == null || amount == null)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (SkuAmount.ContainsKey(sku))
|
if (SkuAmount.ContainsKey(sku))
|
||||||
|
{
|
||||||
SkuAmount[sku] += amount.Value;
|
SkuAmount[sku] += amount.Value;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
SkuAmount.Add(sku, amount.Value);
|
SkuAmount.Add(sku, amount.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,12 @@ namespace RehauSku.PriceListTools
|
|||||||
public void FillTarget()
|
public void FillTarget()
|
||||||
{
|
{
|
||||||
ExcelApp.ScreenUpdating = false;
|
ExcelApp.ScreenUpdating = false;
|
||||||
FillAmountColumn(SourceFiles.Select(x => x.SkuAmount).ToArray());
|
|
||||||
|
foreach (Source source in SourceFiles)
|
||||||
|
{
|
||||||
|
FillColumn(source.SkuAmount, TargetFile.amountCell.Column);
|
||||||
|
}
|
||||||
|
|
||||||
FilterByAmount();
|
FilterByAmount();
|
||||||
ExcelApp.ScreenUpdating = true;
|
ExcelApp.ScreenUpdating = true;
|
||||||
|
|
||||||
|
@ -31,13 +31,8 @@ namespace RehauSku.PriceListTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected private void FillAmountColumn(Dictionary<string, double>[] dictionaries)
|
protected private void FillColumn(Dictionary<string, double> dictionary, int column)
|
||||||
{
|
{
|
||||||
foreach (var dictionary in dictionaries)
|
|
||||||
{
|
|
||||||
if (dictionary.Count == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
foreach (var kvp in dictionary)
|
foreach (var kvp in dictionary)
|
||||||
{
|
{
|
||||||
Range cell = TargetFile.Sheet.Columns[TargetFile.skuCell.Column].Find(kvp.Key);
|
Range cell = TargetFile.Sheet.Columns[TargetFile.skuCell.Column].Find(kvp.Key);
|
||||||
@ -53,15 +48,20 @@ namespace RehauSku.PriceListTools
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Range sumCell = TargetFile.Sheet.Cells[cell.Row, TargetFile.amountCell.Column];
|
Range sumCell = TargetFile.Sheet.Cells[cell.Row, column];
|
||||||
|
|
||||||
if (sumCell.Value2 == null)
|
if (sumCell.Value2 == null)
|
||||||
|
{
|
||||||
sumCell.Value2 = kvp.Value;
|
sumCell.Value2 = kvp.Value;
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
sumCell.Value2 += kvp.Value;
|
sumCell.Value2 += kvp.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected private void FilterByAmount()
|
protected private void FilterByAmount()
|
||||||
|
Loading…
Reference in New Issue
Block a user