aboutsummaryrefslogtreecommitdiff
path: root/src/PriceListTools/Target.cs
blob: ac9154422e3354f4ffd1eaf4cda320bf0d1e86ff (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;
using System.Linq;

namespace RehauSku.PriceListTools
{
    internal class Target : AbstractPriceList
    {
        private const string oldSkuHeader = "Прежний материал";
        public Range oldSkuCell { get; private set; }

        public Target(Workbook workbook)
        {
            Sheet = workbook.ActiveSheet;
            Name = workbook.FullName;

            Range[] cells = new[]
            {
                amountCell = Sheet.Cells.Find(amountHeader),
                skuCell = Sheet.Cells.Find(skuHeader),
                groupCell = Sheet.Cells.Find(groupHeader),
                nameCell = Sheet.Cells.Find(nameHeader),
                oldSkuCell = Sheet.Cells.Find(oldSkuHeader)
            };

            if (cells.Any(x => x == null))
            {
                throw new ArgumentException($"Шаблон { Name } не является прайс-листом");
            }
        }
    }
}