Price list validation optimization
This commit is contained in:
parent
1f5aebe62a
commit
47c3b19a17
@ -14,22 +14,32 @@ public static class WorksheetExtensions
|
|||||||
|
|
||||||
public static bool IsValidSource(this Worksheet worksheet)
|
public static bool IsValidSource(this Worksheet worksheet)
|
||||||
{
|
{
|
||||||
Range amountCell;
|
Range headerRow;
|
||||||
Range skuCell;
|
|
||||||
Range programLineCell;
|
|
||||||
Range nameCell;
|
|
||||||
Range measureCell;
|
|
||||||
|
|
||||||
Range[] cells = new[]
|
string[] fields = pricelistParameters.Values
|
||||||
|
.Where(v => v != "Прежний материал")
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
var value = worksheet.Cells.Find(fields[0]);
|
||||||
|
|
||||||
|
if (value == null)
|
||||||
{
|
{
|
||||||
amountCell = worksheet.Cells.Find(pricelistParameters["Amount"]),
|
return false;
|
||||||
skuCell = worksheet.Cells.Find(pricelistParameters["Sku"]),
|
}
|
||||||
programLineCell = worksheet.Cells.Find(pricelistParameters["ProductLine"]),
|
else
|
||||||
nameCell = worksheet.Cells.Find(pricelistParameters["Name"]),
|
{
|
||||||
measureCell = worksheet.Cells.Find(pricelistParameters["Measure"])
|
headerRow = value.EntireRow;
|
||||||
};
|
}
|
||||||
|
|
||||||
return cells.All(x => x != null);
|
for (int i = 1; i < fields.Length; i++)
|
||||||
|
{
|
||||||
|
if (headerRow.Find(fields[i]) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddValue(this Range range, double value)
|
public static void AddValue(this Range range, double value)
|
||||||
|
Loading…
Reference in New Issue
Block a user