40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using RhSolutions.AddIn;
|
||
using System.IO;
|
||
|
||
namespace RhSolutions.Models;
|
||
|
||
internal class TargetPriceList : PriceListBase
|
||
{
|
||
public Range OldSkuCell { get; private set; }
|
||
|
||
public TargetPriceList(Workbook workbook)
|
||
{
|
||
if (workbook == null)
|
||
{
|
||
throw new ArgumentException("Невозможно открыть книгу шаблонного файла. " +
|
||
"Возможно открыт файл с именем, совпадающим с именем шаблонного файла.");
|
||
}
|
||
|
||
Sheet = workbook.ActiveSheet;
|
||
Name = Path.GetFileNameWithoutExtension(workbook.FullName);
|
||
|
||
var pricelistParameters = RhSolutionsAddIn.Configuration.GetPriceListParameters();
|
||
|
||
Range[] cells = new[]
|
||
{
|
||
AmountCell = Sheet.Cells.Find(pricelistParameters["Amount"]),
|
||
SkuCell = Sheet.Cells.Find(pricelistParameters["Sku"]),
|
||
GroupCell = Sheet.Cells.Find(pricelistParameters["Group"]),
|
||
NameCell = Sheet.Cells.Find(pricelistParameters["Name"])
|
||
};
|
||
|
||
OldSkuCell = Sheet.Cells.Find(pricelistParameters["OldSku"]);
|
||
|
||
if (cells.Any(x => x == null))
|
||
{
|
||
throw new ArgumentException($"Шаблон {Name} не является прайс-листом");
|
||
}
|
||
}
|
||
}
|
||
|