Rename Position to Product

This commit is contained in:
Sergey Chebotar 2022-12-20 08:30:58 +03:00
parent 598ffe0d3c
commit 3c7e24ecfe
6 changed files with 59 additions and 58 deletions

View File

@ -43,13 +43,13 @@ namespace RhSolutions.PriceListTools
}
}
protected void FillPositionAmountToColumns(KeyValuePair<Position, double> positionAmount, params int[] columns)
protected void FillPositionAmountToColumns(KeyValuePair<Product, double> 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<Position, double> positionAmount, params int[] columns)
protected void FillMissing(KeyValuePair<Product, double> 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)

View File

@ -7,7 +7,7 @@ namespace RhSolutions.PriceListTools
{
internal class ExportTool : AbstractTool
{
private Dictionary<Position, double> PositionAmount;
private Dictionary<Product, double> PositionAmount;
private readonly Range Selection;
public ExportTool()
@ -40,7 +40,7 @@ namespace RhSolutions.PriceListTools
private void GetSelected()
{
object[,] cells = Selection.Value2;
PositionAmount = new Dictionary<Position, double>();
PositionAmount = new Dictionary<Product, double>();
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))
{

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}

View File

@ -9,7 +9,7 @@ namespace RhSolutions.PriceListTools
{
internal class SourcePriceList : AbstractPriceList
{
public Dictionary<Position, double> PositionAmount { get; private set; }
public Dictionary<Product, double> PositionAmount { get; private set; }
public SourcePriceList(Workbook workbook)
{
@ -73,7 +73,7 @@ namespace RhSolutions.PriceListTools
private void CreatePositionsDict()
{
PositionAmount = new Dictionary<Position, double>();
PositionAmount = new Dictionary<Product, double>();
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))
{

View File

@ -87,7 +87,7 @@
<Compile Include="Interface\ResultBar.cs" />
<Compile Include="PriceListTools\CombineTool.cs" />
<Compile Include="PriceListTools\ConvertTool.cs" />
<Compile Include="PriceListTools\Position.cs" />
<Compile Include="PriceListTools\Product.cs" />
<Compile Include="PriceListTools\AbstractTool.cs" />
<Compile Include="PriceListTools\MergeTool.cs" />
<Compile Include="PriceListTools\AbstractPriceList.cs" />