Rename Position to Product
This commit is contained in:
parent
598ffe0d3c
commit
3c7e24ecfe
@ -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 worksheetCells = TargetFile.Sheet.Cells;
|
||||||
Range skuColumn = TargetFile.SkuCell.EntireColumn;
|
Range skuColumn = TargetFile.SkuCell.EntireColumn;
|
||||||
Range oldSkuColumn = TargetFile.OldSkuCell.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)
|
if (row != null)
|
||||||
{
|
{
|
||||||
@ -65,7 +65,7 @@ namespace RhSolutions.PriceListTools
|
|||||||
|
|
||||||
if (TargetFile.OldSkuCell != null)
|
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)
|
if (row != null)
|
||||||
{
|
{
|
||||||
@ -80,8 +80,8 @@ namespace RhSolutions.PriceListTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string sku = positionAmount.Key.Sku.Substring(1, 6);
|
string sku = positionAmount.Key.ProductSku.Substring(1, 6);
|
||||||
row = GetPositionRow(skuColumn, sku, positionAmount.Key.Group);
|
row = GetPositionRow(skuColumn, sku, positionAmount.Key.ProductLine);
|
||||||
|
|
||||||
if (row != null)
|
if (row != null)
|
||||||
{
|
{
|
||||||
@ -99,7 +99,7 @@ namespace RhSolutions.PriceListTools
|
|||||||
ResultBar.IncrementNotFound();
|
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 worksheetCells = TargetFile.Sheet.Cells;
|
||||||
Range worksheetRows = TargetFile.Sheet.Rows;
|
Range worksheetRows = TargetFile.Sheet.Rows;
|
||||||
@ -121,18 +121,18 @@ namespace RhSolutions.PriceListTools
|
|||||||
previous.Copy(current);
|
previous.Copy(current);
|
||||||
current.ClearContents();
|
current.ClearContents();
|
||||||
|
|
||||||
worksheetCells[row, groupColumn].Value2 = positionAmount.Key.Group;
|
worksheetCells[row, groupColumn].Value2 = positionAmount.Key.ProductLine;
|
||||||
worksheetCells[row, nameColumn].Value2 = positionAmount.Key.Name;
|
worksheetCells[row, nameColumn].Value2 = positionAmount.Key.Name;
|
||||||
|
|
||||||
if (TargetFile.OldSkuCell != null)
|
if (TargetFile.OldSkuCell != null)
|
||||||
{
|
{
|
||||||
worksheetCells[row, skuColumn].Value2 = "Не найден";
|
worksheetCells[row, skuColumn].Value2 = "Не найден";
|
||||||
worksheetCells[row, TargetFile.OldSkuCell.Column].Value2 = positionAmount.Key.Sku;
|
worksheetCells[row, TargetFile.OldSkuCell.Column].Value2 = positionAmount.Key.ProductSku;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
worksheetCells[row, skuColumn].Value2 = positionAmount.Key.Sku;
|
worksheetCells[row, skuColumn].Value2 = positionAmount.Key.ProductSku;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (int column in columns)
|
foreach (int column in columns)
|
||||||
|
@ -7,7 +7,7 @@ namespace RhSolutions.PriceListTools
|
|||||||
{
|
{
|
||||||
internal class ExportTool : AbstractTool
|
internal class ExportTool : AbstractTool
|
||||||
{
|
{
|
||||||
private Dictionary<Position, double> PositionAmount;
|
private Dictionary<Product, double> PositionAmount;
|
||||||
private readonly Range Selection;
|
private readonly Range Selection;
|
||||||
|
|
||||||
public ExportTool()
|
public ExportTool()
|
||||||
@ -40,7 +40,7 @@ namespace RhSolutions.PriceListTools
|
|||||||
private void GetSelected()
|
private void GetSelected()
|
||||||
{
|
{
|
||||||
object[,] cells = Selection.Value2;
|
object[,] cells = Selection.Value2;
|
||||||
PositionAmount = new Dictionary<Position, double>();
|
PositionAmount = new Dictionary<Product, double>();
|
||||||
|
|
||||||
int rowsCount = Selection.Rows.Count;
|
int rowsCount = Selection.Rows.Count;
|
||||||
|
|
||||||
@ -78,7 +78,10 @@ namespace RhSolutions.PriceListTools
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Position position = new Position(null, sku, null);
|
Product position = new Product
|
||||||
|
{
|
||||||
|
ProductSku = sku
|
||||||
|
};
|
||||||
|
|
||||||
if (PositionAmount.ContainsKey(position))
|
if (PositionAmount.ContainsKey(position))
|
||||||
{
|
{
|
||||||
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
35
src/PriceListTools/Product.cs
Normal file
35
src/PriceListTools/Product.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,7 @@ namespace RhSolutions.PriceListTools
|
|||||||
{
|
{
|
||||||
internal class SourcePriceList : AbstractPriceList
|
internal class SourcePriceList : AbstractPriceList
|
||||||
{
|
{
|
||||||
public Dictionary<Position, double> PositionAmount { get; private set; }
|
public Dictionary<Product, double> PositionAmount { get; private set; }
|
||||||
|
|
||||||
public SourcePriceList(Workbook workbook)
|
public SourcePriceList(Workbook workbook)
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ namespace RhSolutions.PriceListTools
|
|||||||
|
|
||||||
private void CreatePositionsDict()
|
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++)
|
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())
|
if (!sku.ToString().IsRehauSku())
|
||||||
continue;
|
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))
|
if (PositionAmount.ContainsKey(p))
|
||||||
{
|
{
|
||||||
|
@ -87,7 +87,7 @@
|
|||||||
<Compile Include="Interface\ResultBar.cs" />
|
<Compile Include="Interface\ResultBar.cs" />
|
||||||
<Compile Include="PriceListTools\CombineTool.cs" />
|
<Compile Include="PriceListTools\CombineTool.cs" />
|
||||||
<Compile Include="PriceListTools\ConvertTool.cs" />
|
<Compile Include="PriceListTools\ConvertTool.cs" />
|
||||||
<Compile Include="PriceListTools\Position.cs" />
|
<Compile Include="PriceListTools\Product.cs" />
|
||||||
<Compile Include="PriceListTools\AbstractTool.cs" />
|
<Compile Include="PriceListTools\AbstractTool.cs" />
|
||||||
<Compile Include="PriceListTools\MergeTool.cs" />
|
<Compile Include="PriceListTools\MergeTool.cs" />
|
||||||
<Compile Include="PriceListTools\AbstractPriceList.cs" />
|
<Compile Include="PriceListTools\AbstractPriceList.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user