2022-01-09 10:37:25 +03:00
|
|
|
|
using Microsoft.Office.Interop.Excel;
|
2021-12-24 16:22:03 +03:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace RehauSku.PriceListTools
|
|
|
|
|
{
|
2022-01-09 10:37:25 +03:00
|
|
|
|
internal class MergeTool : AbstractPriceListTool, IDisposable
|
2021-12-24 16:22:03 +03:00
|
|
|
|
{
|
2022-01-09 10:37:25 +03:00
|
|
|
|
public override void FillPriceList()
|
2021-12-24 16:22:03 +03:00
|
|
|
|
{
|
2022-01-09 10:37:25 +03:00
|
|
|
|
int exportedValues = 0;
|
2021-12-24 16:22:03 +03:00
|
|
|
|
|
2022-01-26 18:17:44 +03:00
|
|
|
|
foreach (var sheet in sourcePriceLists)
|
2022-01-09 10:37:25 +03:00
|
|
|
|
{
|
2022-01-26 17:41:46 +03:00
|
|
|
|
if (sheet.SkuAmount.Count == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
foreach (var kvp in sheet.SkuAmount)
|
2021-12-24 17:42:20 +03:00
|
|
|
|
{
|
2022-01-26 18:37:24 +03:00
|
|
|
|
Range cell = NewPriceList.Sheet.Columns[NewPriceList.skuCell.Column].Find(kvp.Key);
|
2022-01-09 10:37:25 +03:00
|
|
|
|
|
2022-01-26 17:41:46 +03:00
|
|
|
|
if (cell == null)
|
2022-01-09 10:37:25 +03:00
|
|
|
|
{
|
2022-01-26 17:41:46 +03:00
|
|
|
|
System.Windows.Forms.MessageBox.Show
|
|
|
|
|
($"Артикул {kvp.Key} отсутствует в таблице заказов {RegistryUtil.PriceListPath}",
|
|
|
|
|
"Отсутствует позиция в конечной таблице заказов",
|
|
|
|
|
System.Windows.Forms.MessageBoxButtons.OK,
|
|
|
|
|
System.Windows.Forms.MessageBoxIcon.Information);
|
|
|
|
|
}
|
2022-01-09 10:37:25 +03:00
|
|
|
|
|
2022-01-26 17:41:46 +03:00
|
|
|
|
else
|
|
|
|
|
{
|
2022-01-26 18:37:24 +03:00
|
|
|
|
Range sumCell = NewPriceList.Sheet.Cells[cell.Row, NewPriceList.amountCell.Column];
|
2022-01-09 10:37:25 +03:00
|
|
|
|
|
2022-01-26 17:41:46 +03:00
|
|
|
|
if (sumCell.Value2 == null)
|
|
|
|
|
sumCell.Value2 = kvp.Value;
|
2022-01-09 10:37:25 +03:00
|
|
|
|
else
|
2022-01-26 17:41:46 +03:00
|
|
|
|
sumCell.Value2 += kvp.Value;
|
2022-01-09 10:37:25 +03:00
|
|
|
|
|
2022-01-26 17:41:46 +03:00
|
|
|
|
exportedValues++;
|
2022-01-09 10:37:25 +03:00
|
|
|
|
}
|
2021-12-24 17:42:20 +03:00
|
|
|
|
}
|
2021-12-24 16:22:03 +03:00
|
|
|
|
}
|
2021-12-24 17:42:20 +03:00
|
|
|
|
|
2022-01-26 18:37:24 +03:00
|
|
|
|
FilterByAmount();
|
2022-01-09 15:47:54 +03:00
|
|
|
|
AddIn.Excel.StatusBar = $"Экспортировано {exportedValues} строк из {sourcePriceLists.Count} файлов";
|
|
|
|
|
Forms.Dialog.SaveWorkbookAs();
|
2021-12-24 16:22:03 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|