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