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)
|
||||
{
|
||||
Range amountCell;
|
||||
Range skuCell;
|
||||
Range programLineCell;
|
||||
Range nameCell;
|
||||
Range measureCell;
|
||||
Range headerRow;
|
||||
|
||||
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"]),
|
||||
skuCell = worksheet.Cells.Find(pricelistParameters["Sku"]),
|
||||
programLineCell = worksheet.Cells.Find(pricelistParameters["ProductLine"]),
|
||||
nameCell = worksheet.Cells.Find(pricelistParameters["Name"]),
|
||||
measureCell = worksheet.Cells.Find(pricelistParameters["Measure"])
|
||||
};
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user