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 (var source in SourceFiles)
|
||||
foreach (Source 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;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
TargetFile.Sheet.Cells[cell.Row, TargetFile.amountCell.Column - 1].Value2 = kvp.Value;
|
||||
}
|
||||
}
|
||||
FillColumn(source.SkuAmount, TargetFile.amountCell.Column - 1);
|
||||
FillColumn(source.SkuAmount, TargetFile.amountCell.Column);
|
||||
}
|
||||
|
||||
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,12 +67,18 @@ 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,37 +31,37 @@ 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)
|
||||
foreach (var kvp in dictionary)
|
||||
{
|
||||
if (dictionary.Count == 0)
|
||||
continue;
|
||||
Range cell = TargetFile.Sheet.Columns[TargetFile.skuCell.Column].Find(kvp.Key);
|
||||
|
||||
foreach (var kvp in dictionary)
|
||||
if (cell == null)
|
||||
{
|
||||
Range cell = TargetFile.Sheet.Columns[TargetFile.skuCell.Column].Find(kvp.Key);
|
||||
System.Windows.Forms.MessageBox.Show
|
||||
($"Артикул {kvp.Key} отсутствует в таблице заказов {RegistryUtil.PriceListPath}",
|
||||
"Отсутствует позиция в конечной таблице заказов",
|
||||
System.Windows.Forms.MessageBoxButtons.OK,
|
||||
System.Windows.Forms.MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
if (cell == null)
|
||||
else
|
||||
{
|
||||
Range sumCell = TargetFile.Sheet.Cells[cell.Row, column];
|
||||
|
||||
if (sumCell.Value2 == null)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show
|
||||
($"Артикул {kvp.Key} отсутствует в таблице заказов {RegistryUtil.PriceListPath}",
|
||||
"Отсутствует позиция в конечной таблице заказов",
|
||||
System.Windows.Forms.MessageBoxButtons.OK,
|
||||
System.Windows.Forms.MessageBoxIcon.Information);
|
||||
sumCell.Value2 = kvp.Value;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Range sumCell = TargetFile.Sheet.Cells[cell.Row, TargetFile.amountCell.Column];
|
||||
|
||||
if (sumCell.Value2 == null)
|
||||
sumCell.Value2 = kvp.Value;
|
||||
else
|
||||
sumCell.Value2 += kvp.Value;
|
||||
sumCell.Value2 += kvp.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected private void FilterByAmount()
|
||||
|
Loading…
Reference in New Issue
Block a user