Add Measure field to reading-writing
This commit is contained in:
parent
13996f0381
commit
f0ec240f35
@ -15,7 +15,8 @@ public class RhAddInConfiguration : ApplicationSettingsBase, IAddInConfiguration
|
||||
["OldSku"] = OldSkuHeader,
|
||||
["Sku"] = SkuHeader,
|
||||
["ProductLine"] = ProductLineHeader,
|
||||
["Name"] = NameHeader
|
||||
["Name"] = NameHeader,
|
||||
["Measure"] = MeasureHeader
|
||||
};
|
||||
}
|
||||
|
||||
@ -70,6 +71,16 @@ public class RhAddInConfiguration : ApplicationSettingsBase, IAddInConfiguration
|
||||
}
|
||||
}
|
||||
|
||||
[UserScopedSetting]
|
||||
[DefaultSettingValue("Ед. изм.")]
|
||||
public string MeasureHeader
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)this[nameof(MeasureHeader)];
|
||||
}
|
||||
}
|
||||
|
||||
[UserScopedSetting]
|
||||
public string PriceListPath
|
||||
{
|
||||
|
@ -52,6 +52,26 @@ public class RhDxfWriter : IExcelWriter
|
||||
insertion.Attributes.AttributeWithTag($"ProductSku{row}").Value = pArray[i * 27 + row].ProductSku;
|
||||
insertion.Attributes.AttributeWithTag($"Rh{row}").Value = "«РЕХАУ»";
|
||||
insertion.Attributes.AttributeWithTag($"Amount{row}").Value = productDict[pArray[i * 27 + row]].ToString();
|
||||
|
||||
string measure = string.Empty;
|
||||
switch (pArray[i * 27 + row].ProductMeasure)
|
||||
{
|
||||
case Measure.Kg:
|
||||
measure = "кг";
|
||||
break;
|
||||
case Measure.M:
|
||||
measure = "м";
|
||||
break;
|
||||
case Measure.M2:
|
||||
measure = "м2";
|
||||
break;
|
||||
case Measure.P:
|
||||
measure = "шт";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
insertion.Attributes.AttributeWithTag($"Measure{row}").Value = measure;
|
||||
}
|
||||
insertion.Attributes.AttributeWithTag("Sheet").Value = (i + 1).ToString();
|
||||
|
||||
@ -427,6 +447,13 @@ public class RhDxfWriter : IExcelWriter
|
||||
WidthFactor = 0.85,
|
||||
Height = 250
|
||||
});
|
||||
block.AttributeDefinitions.Add(new AttributeDefinition($"Measure{i}")
|
||||
{
|
||||
Position = new Vector3(32000, y, 0),
|
||||
Alignment = TextAlignment.MiddleCenter,
|
||||
WidthFactor = 0.85,
|
||||
Height = 250
|
||||
});
|
||||
block.AttributeDefinitions.Add(new AttributeDefinition($"Amount{i}")
|
||||
{
|
||||
Position = new Vector3(34000, y, 0),
|
||||
|
@ -92,8 +92,9 @@ public class RhExcelReader : IExcelReader, IDisposable
|
||||
|
||||
Range AmountCell = worksheet.Cells.Find(headers["Amount"]),
|
||||
SkuCell = worksheet.Cells.Find(headers["Sku"]),
|
||||
ProductLineCelll = worksheet.Cells.Find(headers["ProductLine"]),
|
||||
NameCell = worksheet.Cells.Find(headers["Name"]);
|
||||
ProductLineCell = worksheet.Cells.Find(headers["ProductLine"]),
|
||||
NameCell = worksheet.Cells.Find(headers["Name"]),
|
||||
MeasureCell = worksheet.Cells.Find(headers["Measure"]);
|
||||
var lastRowIndex = worksheet.Cells[worksheet.Rows.Count, AmountCell.Column]
|
||||
.End[XlDirection.xlUp].Row;
|
||||
|
||||
@ -105,11 +106,32 @@ public class RhExcelReader : IExcelReader, IDisposable
|
||||
|
||||
if (amount != null && amount.Value != 0)
|
||||
{
|
||||
object programLine = worksheet.Cells[row, ProductLineCelll.Column].Value2;
|
||||
object productLine = worksheet.Cells[row, ProductLineCell.Column].Value2;
|
||||
object name = worksheet.Cells[row, NameCell.Column].Value2;
|
||||
object sku = worksheet.Cells[row, SkuCell.Column].Value2;
|
||||
object measure = worksheet.Cells[row, MeasureCell.Column].Value2;
|
||||
Measure productMeasure;
|
||||
|
||||
if (programLine == null || name == null || sku == null)
|
||||
switch (measure.ToString())
|
||||
{
|
||||
case "м":
|
||||
productMeasure = Measure.M;
|
||||
break;
|
||||
case "шт":
|
||||
productMeasure = Measure.P;
|
||||
break;
|
||||
case "м2":
|
||||
productMeasure = Measure.M2;
|
||||
break;
|
||||
case "кг":
|
||||
productMeasure = Measure.Kg;
|
||||
break;
|
||||
default:
|
||||
productMeasure = Measure.P;
|
||||
break;
|
||||
}
|
||||
|
||||
if (productLine == null || name == null || sku == null)
|
||||
continue;
|
||||
|
||||
if (!ProductSku.TryParse(sku.ToString(), out _))
|
||||
@ -118,8 +140,9 @@ public class RhExcelReader : IExcelReader, IDisposable
|
||||
Product p = new()
|
||||
{
|
||||
ProductSku = sku.ToString(),
|
||||
ProductLine = programLine.ToString(),
|
||||
Name = name.ToString()
|
||||
ProductLine = productLine.ToString(),
|
||||
Name = name.ToString(),
|
||||
ProductMeasure = productMeasure
|
||||
};
|
||||
|
||||
if (readResult.ContainsKey(p))
|
||||
|
Loading…
Reference in New Issue
Block a user