aboutsummaryrefslogtreecommitdiff
path: root/src/PriceListTools/CombineTool.cs
blob: c634309d52c11c9326c65bc2e6f2b4d517140d8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using Microsoft.Office.Interop.Excel;
using System.Collections.Generic;
using System.Linq;

namespace RehauSku.PriceListTools
{
    internal class CombineTool : PriceListTool
    {
        public List<Source> SourceFiles;

        public void FillTarget()
        {
            ExcelApp.ScreenUpdating = false;

            foreach (Source source in SourceFiles)
            {
                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}";

                FillColumn(source.SkuAmount, TargetFile.amountCell.Column - 1);
                FillColumn(source.SkuAmount, TargetFile.amountCell.Column);
            }

            FilterByAmount();
            ExcelApp.ScreenUpdating = true;

            Forms.Dialog.SaveWorkbookAs();
        }
    }
}