From 3c7e24ecfe34291e551046bf5c8f1d95ea37af7e Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Tue, 20 Dec 2022 08:30:58 +0300 Subject: [PATCH] Rename Position to Product --- src/PriceListTools/AbstractTool.cs | 18 ++++++------ src/PriceListTools/ExportTool.cs | 9 ++++-- src/PriceListTools/Position.cs | 42 --------------------------- src/PriceListTools/Product.cs | 35 ++++++++++++++++++++++ src/PriceListTools/SourcePriceList.cs | 11 +++++-- src/RhSolutions.csproj | 2 +- 6 files changed, 59 insertions(+), 58 deletions(-) delete mode 100644 src/PriceListTools/Position.cs create mode 100644 src/PriceListTools/Product.cs diff --git a/src/PriceListTools/AbstractTool.cs b/src/PriceListTools/AbstractTool.cs index dc2129a..3ea907b 100644 --- a/src/PriceListTools/AbstractTool.cs +++ b/src/PriceListTools/AbstractTool.cs @@ -43,13 +43,13 @@ namespace RhSolutions.PriceListTools } } - protected void FillPositionAmountToColumns(KeyValuePair positionAmount, params int[] columns) + protected void FillPositionAmountToColumns(KeyValuePair positionAmount, params int[] columns) { Range worksheetCells = TargetFile.Sheet.Cells; Range skuColumn = TargetFile.SkuCell.EntireColumn; Range oldSkuColumn = TargetFile.OldSkuCell.EntireColumn; - int? row = GetPositionRow(skuColumn, positionAmount.Key.Sku, positionAmount.Key.Group); + int? row = GetPositionRow(skuColumn, positionAmount.Key.ProductSku, positionAmount.Key.ProductLine); if (row != null) { @@ -65,7 +65,7 @@ namespace RhSolutions.PriceListTools if (TargetFile.OldSkuCell != null) { - row = GetPositionRow(oldSkuColumn, positionAmount.Key.Sku, positionAmount.Key.Group); + row = GetPositionRow(oldSkuColumn, positionAmount.Key.ProductSku, positionAmount.Key.ProductLine); if (row != null) { @@ -80,8 +80,8 @@ namespace RhSolutions.PriceListTools } } - string sku = positionAmount.Key.Sku.Substring(1, 6); - row = GetPositionRow(skuColumn, sku, positionAmount.Key.Group); + string sku = positionAmount.Key.ProductSku.Substring(1, 6); + row = GetPositionRow(skuColumn, sku, positionAmount.Key.ProductLine); if (row != null) { @@ -99,7 +99,7 @@ namespace RhSolutions.PriceListTools ResultBar.IncrementNotFound(); } - protected void FillMissing(KeyValuePair positionAmount, params int[] columns) + protected void FillMissing(KeyValuePair positionAmount, params int[] columns) { Range worksheetCells = TargetFile.Sheet.Cells; Range worksheetRows = TargetFile.Sheet.Rows; @@ -121,18 +121,18 @@ namespace RhSolutions.PriceListTools previous.Copy(current); current.ClearContents(); - worksheetCells[row, groupColumn].Value2 = positionAmount.Key.Group; + worksheetCells[row, groupColumn].Value2 = positionAmount.Key.ProductLine; worksheetCells[row, nameColumn].Value2 = positionAmount.Key.Name; if (TargetFile.OldSkuCell != null) { worksheetCells[row, skuColumn].Value2 = "Не найден"; - worksheetCells[row, TargetFile.OldSkuCell.Column].Value2 = positionAmount.Key.Sku; + worksheetCells[row, TargetFile.OldSkuCell.Column].Value2 = positionAmount.Key.ProductSku; } else { - worksheetCells[row, skuColumn].Value2 = positionAmount.Key.Sku; + worksheetCells[row, skuColumn].Value2 = positionAmount.Key.ProductSku; } foreach (int column in columns) diff --git a/src/PriceListTools/ExportTool.cs b/src/PriceListTools/ExportTool.cs index 3fe1ccd..4956faf 100644 --- a/src/PriceListTools/ExportTool.cs +++ b/src/PriceListTools/ExportTool.cs @@ -7,7 +7,7 @@ namespace RhSolutions.PriceListTools { internal class ExportTool : AbstractTool { - private Dictionary PositionAmount; + private Dictionary PositionAmount; private readonly Range Selection; public ExportTool() @@ -40,7 +40,7 @@ namespace RhSolutions.PriceListTools private void GetSelected() { object[,] cells = Selection.Value2; - PositionAmount = new Dictionary(); + PositionAmount = new Dictionary(); int rowsCount = Selection.Rows.Count; @@ -78,7 +78,10 @@ namespace RhSolutions.PriceListTools continue; } - Position position = new Position(null, sku, null); + Product position = new Product + { + ProductSku = sku + }; if (PositionAmount.ContainsKey(position)) { diff --git a/src/PriceListTools/Position.cs b/src/PriceListTools/Position.cs deleted file mode 100644 index 8ae5863..0000000 --- a/src/PriceListTools/Position.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Linq; - -namespace RhSolutions.PriceListTools -{ - public class Position - { - public string Group { get; private set; } - public string Sku { get; private set; } - public string Name { get; private set; } - - public Position(string group, string sku, string name) - { - Group = group; - Sku = sku; - Name = name; - } - - public override bool Equals(object obj) - { - if (obj as Position == null) - return false; - - Position other = obj as Position; - - return Group == other.Group && - Sku == other.Sku && - Name == other.Name; - } - - public override int GetHashCode() - { - string[] properties = new[] - { - Group, - Sku, - Name - }; - - return string.Concat(properties.Where(p => p != null)).GetHashCode(); - } - } -} \ No newline at end of file diff --git a/src/PriceListTools/Product.cs b/src/PriceListTools/Product.cs new file mode 100644 index 0000000..e631293 --- /dev/null +++ b/src/PriceListTools/Product.cs @@ -0,0 +1,35 @@ +using System.Linq; + +namespace RhSolutions.PriceListTools +{ + public class Product + { + public string ProductLine { get; set; } + public string ProductSku { get; set; } + public string Name { get; set; } + + public override bool Equals(object obj) + { + if (obj as Product == null) + return false; + + Product other = obj as Product; + + return ProductLine == other.ProductLine && + ProductSku == other.ProductSku && + Name == other.Name; + } + + public override int GetHashCode() + { + string[] properties = new[] + { + ProductLine, + ProductSku, + Name + }; + + return string.Concat(properties.Where(p => p != null)).GetHashCode(); + } + } +} \ No newline at end of file diff --git a/src/PriceListTools/SourcePriceList.cs b/src/PriceListTools/SourcePriceList.cs index 2196d39..7c0001e 100644 --- a/src/PriceListTools/SourcePriceList.cs +++ b/src/PriceListTools/SourcePriceList.cs @@ -9,7 +9,7 @@ namespace RhSolutions.PriceListTools { internal class SourcePriceList : AbstractPriceList { - public Dictionary PositionAmount { get; private set; } + public Dictionary PositionAmount { get; private set; } public SourcePriceList(Workbook workbook) { @@ -73,7 +73,7 @@ namespace RhSolutions.PriceListTools private void CreatePositionsDict() { - PositionAmount = new Dictionary(); + PositionAmount = new Dictionary(); for (int row = AmountCell.Row + 1; row <= Sheet.Cells[Sheet.Rows.Count, AmountCell.Column].End[XlDirection.xlUp].Row; row++) { @@ -91,7 +91,12 @@ namespace RhSolutions.PriceListTools if (!sku.ToString().IsRehauSku()) continue; - Position p = new Position(group.ToString(), sku.ToString(), name.ToString()); + Product p = new Product + { + ProductSku = sku.ToString(), + ProductLine = group.ToString(), + Name = name.ToString() + }; if (PositionAmount.ContainsKey(p)) { diff --git a/src/RhSolutions.csproj b/src/RhSolutions.csproj index a5e4612..2005e5d 100644 --- a/src/RhSolutions.csproj +++ b/src/RhSolutions.csproj @@ -87,7 +87,7 @@ - +