RhSolutions-AddIn/src/PriceListTools/TargetPriceList.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2022-01-27 09:59:33 +03:00
using Microsoft.Office.Interop.Excel;
using System;
using System.Linq;
2022-01-27 09:59:33 +03:00
namespace RehauSku.PriceListTools
{
2022-02-02 18:05:49 +03:00
internal class TargetPriceList : AbstractPriceList
2022-01-27 09:59:33 +03:00
{
private const string oldSkuHeader = "Прежний материал";
public Range oldSkuCell { get; private set; }
2022-02-02 18:05:49 +03:00
public TargetPriceList(Workbook workbook)
2022-01-27 09:59:33 +03:00
{
2022-02-08 16:46:53 +03:00
if (workbook == null)
{
throw new ArgumentException("Невозможно открыть книгу шаблонного файла. " +
"Возможно открыт файл с именем, совпадающим с именем шаблонного файла.");
}
2022-01-27 09:59:33 +03:00
Sheet = workbook.ActiveSheet;
2022-01-27 17:34:03 +03:00
Name = workbook.FullName;
2022-01-27 09:59:33 +03:00
Range[] cells = new[]
{
amountCell = Sheet.Cells.Find(amountHeader),
skuCell = Sheet.Cells.Find(skuHeader),
groupCell = Sheet.Cells.Find(groupHeader),
2022-02-04 09:17:12 +03:00
nameCell = Sheet.Cells.Find(nameHeader)
};
2022-01-27 09:59:33 +03:00
2022-02-04 09:17:12 +03:00
oldSkuCell = Sheet.Cells.Find(oldSkuHeader);
if (cells.Any(x => x == null))
2022-01-27 09:59:33 +03:00
{
2022-01-27 17:34:03 +03:00
throw new ArgumentException($"Шаблон { Name } не является прайс-листом");
2022-01-27 09:59:33 +03:00
}
}
}
}