aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Chebotar <s.chebotar@gmail.com>2023-04-20 07:18:16 +0300
committerSergey Chebotar <s.chebotar@gmail.com>2023-04-20 07:18:16 +0300
commitf0ec240f351c64cfdf8aa7bac5b4fd110a579d72 (patch)
treec3e99c27d52f72555bb6948fc3460f373701dff5
parent13996f03816f658d1c1f034964f7381a991d8bde (diff)
Add Measure field to reading-writing
-rw-r--r--RhSolutions.AddIn/Services/RhAddInConfiguration.cs13
-rw-r--r--RhSolutions.AddIn/Services/RhDxfWriter.cs27
-rw-r--r--RhSolutions.AddIn/Services/RhExcelReader.cs35
3 files changed, 68 insertions, 7 deletions
diff --git a/RhSolutions.AddIn/Services/RhAddInConfiguration.cs b/RhSolutions.AddIn/Services/RhAddInConfiguration.cs
index 620f9b7..e9e393b 100644
--- a/RhSolutions.AddIn/Services/RhAddInConfiguration.cs
+++ b/RhSolutions.AddIn/Services/RhAddInConfiguration.cs
@@ -15,7 +15,8 @@ public class RhAddInConfiguration : ApplicationSettingsBase, IAddInConfiguration
["OldSku"] = OldSkuHeader,
["Sku"] = SkuHeader,
["ProductLine"] = ProductLineHeader,
- ["Name"] = NameHeader
+ ["Name"] = NameHeader,
+ ["Measure"] = MeasureHeader
};
}
@@ -71,6 +72,16 @@ public class RhAddInConfiguration : ApplicationSettingsBase, IAddInConfiguration
}
[UserScopedSetting]
+ [DefaultSettingValue("Ед. изм.")]
+ public string MeasureHeader
+ {
+ get
+ {
+ return (string)this[nameof(MeasureHeader)];
+ }
+ }
+
+ [UserScopedSetting]
public string PriceListPath
{
get
diff --git a/RhSolutions.AddIn/Services/RhDxfWriter.cs b/RhSolutions.AddIn/Services/RhDxfWriter.cs
index d5ea96b..43aa55c 100644
--- a/RhSolutions.AddIn/Services/RhDxfWriter.cs
+++ b/RhSolutions.AddIn/Services/RhDxfWriter.cs
@@ -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),
diff --git a/RhSolutions.AddIn/Services/RhExcelReader.cs b/RhSolutions.AddIn/Services/RhExcelReader.cs
index 3face65..fd3163a 100644
--- a/RhSolutions.AddIn/Services/RhExcelReader.cs
+++ b/RhSolutions.AddIn/Services/RhExcelReader.cs
@@ -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))