2022-01-27 09:59:33 +03:00
|
|
|
|
using Microsoft.Office.Interop.Excel;
|
|
|
|
|
using System;
|
2022-02-01 20:32:29 +03:00
|
|
|
|
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
|
|
|
|
{
|
2022-02-12 16:53:34 +03:00
|
|
|
|
public Range OldSkuCell { get; private set; }
|
2022-02-01 20:32:29 +03:00
|
|
|
|
|
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
|
|
|
|
|
2022-02-01 20:32:29 +03:00
|
|
|
|
Range[] cells = new[]
|
|
|
|
|
{
|
2022-02-12 16:53:34 +03:00
|
|
|
|
AmountCell = Sheet.Cells.Find(PriceListHeaders.Amount),
|
|
|
|
|
SkuCell = Sheet.Cells.Find(PriceListHeaders.Sku),
|
|
|
|
|
GroupCell = Sheet.Cells.Find(PriceListHeaders.Group),
|
|
|
|
|
NameCell = Sheet.Cells.Find(PriceListHeaders.Name)
|
2022-02-01 20:32:29 +03:00
|
|
|
|
};
|
2022-01-27 09:59:33 +03:00
|
|
|
|
|
2022-02-12 16:53:34 +03:00
|
|
|
|
OldSkuCell = Sheet.Cells.Find(PriceListHeaders.OldSku);
|
2022-02-04 09:17:12 +03:00
|
|
|
|
|
2022-02-01 20:32:29 +03:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|