2023-04-01 15:24:04 +03:00
|
|
|
|
using RhSolutions.AddIn;
|
|
|
|
|
using System.IO;
|
2022-01-27 09:59:33 +03:00
|
|
|
|
|
2023-03-28 10:36:36 +03:00
|
|
|
|
namespace RhSolutions.Models;
|
|
|
|
|
|
|
|
|
|
internal class TargetPriceList : PriceListBase
|
2022-01-27 09:59:33 +03:00
|
|
|
|
{
|
2023-03-28 10:36:36 +03:00
|
|
|
|
public Range OldSkuCell { get; private set; }
|
|
|
|
|
|
|
|
|
|
public TargetPriceList(Workbook workbook)
|
2022-01-27 09:59:33 +03:00
|
|
|
|
{
|
2023-03-28 10:36:36 +03:00
|
|
|
|
if (workbook == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("Невозможно открыть книгу шаблонного файла. " +
|
|
|
|
|
"Возможно открыт файл с именем, совпадающим с именем шаблонного файла.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Sheet = workbook.ActiveSheet;
|
|
|
|
|
Name = Path.GetFileNameWithoutExtension(workbook.FullName);
|
|
|
|
|
|
2023-04-01 15:24:04 +03:00
|
|
|
|
var pricelistParameters = RhSolutionsAddIn.Configuration.GetPriceListParameters();
|
|
|
|
|
|
2023-03-28 10:36:36 +03:00
|
|
|
|
Range[] cells = new[]
|
|
|
|
|
{
|
2023-04-01 15:24:04 +03:00
|
|
|
|
AmountCell = Sheet.Cells.Find(pricelistParameters["Amount"]),
|
|
|
|
|
SkuCell = Sheet.Cells.Find(pricelistParameters["Sku"]),
|
|
|
|
|
GroupCell = Sheet.Cells.Find(pricelistParameters["Group"]),
|
|
|
|
|
NameCell = Sheet.Cells.Find(pricelistParameters["Name"])
|
2023-03-28 10:36:36 +03:00
|
|
|
|
};
|
|
|
|
|
|
2023-04-01 15:24:04 +03:00
|
|
|
|
OldSkuCell = Sheet.Cells.Find(pricelistParameters["OldSku"]);
|
2022-02-01 20:32:29 +03:00
|
|
|
|
|
2023-03-28 10:36:36 +03:00
|
|
|
|
if (cells.Any(x => x == null))
|
2022-01-27 09:59:33 +03:00
|
|
|
|
{
|
2023-03-28 10:36:36 +03:00
|
|
|
|
throw new ArgumentException($"Шаблон {Name} не является прайс-листом");
|
2022-01-27 09:59:33 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|