2022-01-27 09:59:33 +03:00
|
|
|
|
using Microsoft.Office.Interop.Excel;
|
|
|
|
|
using System;
|
2023-01-13 07:52:16 +03:00
|
|
|
|
using System.IO;
|
2022-02-01 20:32:29 +03:00
|
|
|
|
using System.Linq;
|
2023-02-08 15:59:30 +03:00
|
|
|
|
using Range = Microsoft.Office.Interop.Excel.Range;
|
2022-01-27 09:59:33 +03:00
|
|
|
|
|
2022-12-20 12:27:47 +03:00
|
|
|
|
namespace RhSolutions.Models
|
2022-01-27 09:59:33 +03:00
|
|
|
|
{
|
2022-12-20 11:53:55 +03:00
|
|
|
|
internal class TargetPriceList : PriceListBase
|
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;
|
2023-01-13 07:52:16 +03:00
|
|
|
|
Name = Path.GetFileNameWithoutExtension(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-12-20 12:27:47 +03:00
|
|
|
|
throw new ArgumentException($"Шаблон {Name} не является прайс-листом");
|
2022-01-27 09:59:33 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|