RhSolutions-AddIn/RhSolutions.AddIn/Models/TargetPriceList.cs
2023-03-22 08:36:13 +03:00

42 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.Office.Interop.Excel;
using System;
using System.IO;
using System.Linq;
using Range = Microsoft.Office.Interop.Excel.Range;
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);
Range[] cells = new[]
{
AmountCell = Sheet.Cells.Find(PriceListHeaders.Amount),
SkuCell = Sheet.Cells.Find(PriceListHeaders.Sku),
GroupCell = Sheet.Cells.Find(PriceListHeaders.Group),
NameCell = Sheet.Cells.Find(PriceListHeaders.Name)
};
OldSkuCell = Sheet.Cells.Find(PriceListHeaders.OldSku);
if (cells.Any(x => x == null))
{
throw new ArgumentException($"Шаблон {Name} не является прайс-листом");
}
}
}
}