2022-01-09 10:37:25 +03:00
|
|
|
|
using Microsoft.Office.Interop.Excel;
|
2022-02-02 10:23:50 +03:00
|
|
|
|
using RehauSku.Interface;
|
2022-02-12 16:02:55 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2022-02-02 10:23:50 +03:00
|
|
|
|
using System.Linq;
|
2022-02-12 16:02:55 +03:00
|
|
|
|
using Dialog = RehauSku.Interface.Dialog;
|
2022-01-07 19:04:07 +03:00
|
|
|
|
|
|
|
|
|
namespace RehauSku.PriceListTools
|
|
|
|
|
{
|
2022-02-02 18:02:17 +03:00
|
|
|
|
internal class CombineTool : AbstractTool
|
2022-01-07 19:04:07 +03:00
|
|
|
|
{
|
2022-02-12 16:02:55 +03:00
|
|
|
|
private List<SourcePriceList> SourceFiles { get; set; }
|
|
|
|
|
|
|
|
|
|
public CombineTool()
|
|
|
|
|
{
|
|
|
|
|
string[] files = Dialog.GetMultiplyFiles();
|
|
|
|
|
|
|
|
|
|
if (files != null)
|
|
|
|
|
{
|
|
|
|
|
SourceFiles = SourcePriceList.GetSourceLists(files);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Не выбраны файлы");
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-27 17:34:03 +03:00
|
|
|
|
|
2022-03-30 12:26:18 +03:00
|
|
|
|
public override void FillTarget()
|
2022-01-07 19:04:07 +03:00
|
|
|
|
{
|
2022-04-01 17:55:36 +03:00
|
|
|
|
using (ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(file => file.PositionAmount.Count)))
|
|
|
|
|
using (ResultBar = new ResultBar())
|
2022-01-07 19:04:07 +03:00
|
|
|
|
{
|
2022-04-01 17:55:36 +03:00
|
|
|
|
foreach (SourcePriceList source in SourceFiles)
|
2022-02-02 10:23:50 +03:00
|
|
|
|
{
|
2022-04-01 17:55:36 +03:00
|
|
|
|
TargetFile.Sheet.Columns[TargetFile.AmountCell.Column]
|
|
|
|
|
.EntireColumn
|
|
|
|
|
.Insert(XlInsertShiftDirection.xlShiftToRight, XlInsertFormatOrigin.xlFormatFromRightOrBelow);
|
|
|
|
|
|
|
|
|
|
Range newColumnHeader = TargetFile.Sheet.Cells[TargetFile.AmountCell.Row, TargetFile.AmountCell.Column - 1];
|
|
|
|
|
newColumnHeader.Value2 = $"{source.Name}";
|
|
|
|
|
newColumnHeader.WrapText = true;
|
|
|
|
|
|
|
|
|
|
foreach (var kvp in source.PositionAmount)
|
|
|
|
|
{
|
|
|
|
|
FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column - 1, TargetFile.AmountCell.Column);
|
|
|
|
|
ProgressBar.Update();
|
|
|
|
|
}
|
2022-02-02 10:23:50 +03:00
|
|
|
|
}
|
2022-01-09 10:37:25 +03:00
|
|
|
|
|
2022-04-01 17:55:36 +03:00
|
|
|
|
FilterByAmount();
|
|
|
|
|
ResultBar.Update();
|
|
|
|
|
}
|
2022-01-07 19:04:07 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|