Merge pull request #17 from schebotar/dev

Dev
This commit is contained in:
Serghei Cebotari 2022-02-14 11:09:22 +03:00 committed by GitHub
commit 031ea7f7ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 209 additions and 196 deletions

View File

@ -4,7 +4,7 @@ namespace RehauSku
{ {
internal static class EventsUtil internal static class EventsUtil
{ {
private static Application Excel = AddIn.Excel; private static readonly Application Excel = AddIn.Excel;
public static void Initialize() public static void Initialize()
{ {
@ -22,12 +22,12 @@ namespace RehauSku
private static void RefreshConvertButton(object sh) private static void RefreshConvertButton(object sh)
{ {
Interface.RibbonController.RefreshControl("convertPrice"); Interface.RibbonController.RefreshControl("convert");
} }
private static void RefreshExportButton(object sh, Range target) private static void RefreshExportButton(object sh, Range target)
{ {
Interface.RibbonController.RefreshControl("exportToPrice"); Interface.RibbonController.RefreshControl("export");
} }
} }
} }

View File

@ -63,9 +63,15 @@ namespace RehauSku
{ {
priceListPath = value; priceListPath = value;
RootKey.SetValue("PriceListPath", value); RootKey.SetValue("PriceListPath", value);
RibbonController.RefreshControl("setPriceList");
} }
} }
public static string GetPriceListName()
{
return Path.GetFileName(priceListPath);
}
public static ResponseOrder StoreResponseOrder public static ResponseOrder StoreResponseOrder
{ {
get get

View File

@ -1,15 +1,11 @@
using Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Excel;
using RehauSku.PriceListTools;
using System.Linq; using System.Linq;
namespace RehauSku namespace RehauSku
{ {
public static class WorksheetExtensions public static class WorksheetExtensions
{ {
private static string amountHeader = "Кол-во";
private static string skuHeader = "Актуальный материал";
private static string groupHeader = "Программа";
private static string nameHeader = "Наименование";
public static bool IsRehauSource(this Worksheet worksheet) public static bool IsRehauSource(this Worksheet worksheet)
{ {
Range amountCell; Range amountCell;
@ -19,10 +15,10 @@ namespace RehauSku
Range[] cells = new[] Range[] cells = new[]
{ {
amountCell = worksheet.Cells.Find(amountHeader), amountCell = worksheet.Cells.Find(PriceListHeaders.Amount),
skuCell = worksheet.Cells.Find(skuHeader), skuCell = worksheet.Cells.Find(PriceListHeaders.Sku),
groupCell = worksheet.Cells.Find(groupHeader), groupCell = worksheet.Cells.Find(PriceListHeaders.Group),
nameCell = worksheet.Cells.Find(nameHeader) nameCell = worksheet.Cells.Find(PriceListHeaders.Name)
}; };
return cells.All(x => x != null); return cells.All(x => x != null);

View File

@ -19,7 +19,7 @@
if (percent < 100) if (percent < 100)
{ {
Excel.StatusBar = $"{Message} Выполнено {percent.ToString("#.#")} %"; Excel.StatusBar = $"{Message} Выполнено {percent:#.#} %";
} }
else else

View File

@ -2,6 +2,8 @@
using Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Excel;
using RehauSku.PriceListTools; using RehauSku.PriceListTools;
using System; using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
@ -20,15 +22,15 @@ namespace RehauSku.Interface
<tabs> <tabs>
<tab id='rau' label='REHAU'> <tab id='rau' label='REHAU'>
<group id='priceList' label='Прайс-лист'> <group id='priceList' label='Прайс-лист'>
<button id='exportToPrice' getEnabled='GetExportEnabled' label='Экспорт в новый файл' size='normal' imageMso='PivotExportToExcel' onAction='OnExportPressed'/> <button id='export' getEnabled='GetExportEnabled' label='Экспорт в новый файл' size='normal' imageMso='PivotExportToExcel' onAction='OnToolPressed'/>
<button id='convertPrice' getEnabled='GetConvertEnabled' label='Актуализировать' size='normal' imageMso='FileUpdate' onAction='OnConvertPressed'/> <button id='convert' getEnabled='GetConvertEnabled' label='Актуализировать' size='normal' imageMso='FileUpdate' onAction='OnToolPressed'/>
<menu id='conjoinMenu' label='Объединить' imageMso='Copy'> <menu id='conjoinMenu' label='Объединить' imageMso='Copy'>
<button id='mergeFiles' label='Сложить' onAction='OnMergePressed'/> <button id='merge' label='Сложить' onAction='OnToolPressed'/>
<button id='combineFiles' label='По колонкам' onAction='OnCombinePressed'/> <button id='combine' label='По колонкам' onAction='OnToolPressed'/>
</menu> </menu>
</group> </group>
<group id='rausettings' label='Настройки'> <group id='rausettings' getLabel='GetVersionLabel'>
<button id='setPriceList' label='Указать путь к шаблону' size='large' imageMso='CurrentViewSettings' onAction='OnSetPricePressed'/> <button id='setPriceList' getLabel='GetPriceListPathLabel' size='large' imageMso='TableExcelSpreadsheetInsert' onAction='OnSetPricePressed'/>
</group> </group>
</tab> </tab>
</tabs> </tabs>
@ -48,30 +50,50 @@ namespace RehauSku.Interface
ribbonUi.InvalidateControl(id); ribbonUi.InvalidateControl(id);
} }
} }
public void OnSetPricePressed(IRibbonControl control)
public void OnMergePressed(IRibbonControl control)
{ {
MergeTool mergeTool = new MergeTool(); string path = Dialog.GetFilePath();
string[] files = Dialog.GetMultiplyFiles();
if (files != null) if (!string.IsNullOrEmpty(path))
{ {
mergeTool.SourceFiles = SourcePriceList.GetSourceLists(files); RegistryUtil.PriceListPath = path;
mergeTool.OpenNewPrice();
mergeTool.FillTarget();
} }
} }
public void OnCombinePressed(IRibbonControl control) public void OnToolPressed(IRibbonControl control)
{ {
CombineTool combineTool = new CombineTool(); try
string[] files = Dialog.GetMultiplyFiles();
if (files != null)
{ {
combineTool.SourceFiles = SourcePriceList.GetSourceLists(files); AbstractTool tool;
combineTool.OpenNewPrice(); switch (control.Id)
combineTool.FillTarget(); {
case "export":
tool = new ExportTool();
break;
case "convert":
tool = new ConvertTool();
break;
case "merge":
tool = new MergeTool();
break;
case "combine":
tool = new CombineTool();
break;
default:
throw new Exception("Неизвестный инструмент");
}
tool.OpenNewPrice();
tool.FillTarget();
}
catch (Exception exception)
{
MessageBox.Show(exception.Message,
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
} }
} }
@ -87,25 +109,6 @@ namespace RehauSku.Interface
} }
} }
public void OnExportPressed(IRibbonControl control)
{
try
{
ExportTool exportTool = new ExportTool();
exportTool.OpenNewPrice();
exportTool.FillTarget();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
}
}
public bool GetExportEnabled(IRibbonControl control) public bool GetExportEnabled(IRibbonControl control)
{ {
if (AddIn.Excel.ActiveWorkbook == null) if (AddIn.Excel.ActiveWorkbook == null)
@ -118,23 +121,16 @@ namespace RehauSku.Interface
} }
} }
public void OnConvertPressed(IRibbonControl control) public string GetVersionLabel(IRibbonControl control)
{ {
ConvertTool convertTool = new ConvertTool(); string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
return $"v{version}";
convertTool.GetCurrent();
convertTool.OpenNewPrice();
convertTool.FillTarget();
} }
public void OnSetPricePressed(IRibbonControl control) public string GetPriceListPathLabel(IRibbonControl control)
{ {
string path = Dialog.GetFilePath(); string name = RegistryUtil.GetPriceListName();
return string.IsNullOrEmpty(name) ? "Нет файла шаблона!" : name;
if (!string.IsNullOrEmpty(path))
{
RegistryUtil.PriceListPath = path;
}
} }
} }
} }

View File

@ -4,15 +4,10 @@ namespace RehauSku.PriceListTools
{ {
internal abstract class AbstractPriceList internal abstract class AbstractPriceList
{ {
protected const string amountHeader = "Кол-во"; public Range AmountCell { get; protected set; }
protected const string skuHeader = "Актуальный материал"; public Range SkuCell { get; protected set; }
protected const string groupHeader = "Программа"; public Range GroupCell { get; protected set; }
protected const string nameHeader = "Наименование"; public Range NameCell { get; protected set; }
public Range amountCell { get; protected set; }
public Range skuCell { get; protected set; }
public Range groupCell { get; protected set; }
public Range nameCell { get; protected set; }
public Worksheet Sheet { get; protected set; } public Worksheet Sheet { get; protected set; }
public string Name { get; protected set; } public string Name { get; protected set; }

View File

@ -1,21 +1,20 @@
using ExcelDna.Integration; using Microsoft.Office.Interop.Excel;
using Microsoft.Office.Interop.Excel;
using RehauSku.Interface; using RehauSku.Interface;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Forms;
using Application = Microsoft.Office.Interop.Excel.Application;
using ProgressBar = RehauSku.Interface.ProgressBar; using ProgressBar = RehauSku.Interface.ProgressBar;
namespace RehauSku.PriceListTools namespace RehauSku.PriceListTools
{ {
internal abstract class AbstractTool internal abstract class AbstractTool
{ {
protected private Application ExcelApp = (Application)ExcelDnaUtil.Application; protected Application ExcelApp = AddIn.Excel;
protected private TargetPriceList TargetFile; protected TargetPriceList TargetFile { get; set; }
protected private ResultBar ResultBar { get; set; } protected ResultBar ResultBar { get; set; }
protected private ProgressBar ProgressBar { get; set; } protected ProgressBar ProgressBar { get; set; }
public abstract void FillTarget();
public void OpenNewPrice() public void OpenNewPrice()
{ {
@ -23,12 +22,6 @@ namespace RehauSku.PriceListTools
.Cast<Workbook>() .Cast<Workbook>()
.FirstOrDefault(w => w.FullName == RegistryUtil.PriceListPath) != null) .FirstOrDefault(w => w.FullName == RegistryUtil.PriceListPath) != null)
{ {
MessageBox.Show
("Шаблонный файл редактируется в другом месте",
"Ошибка открытия шаблонного прайс-листа",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
throw new ArgumentException("Шаблонный файл редактируется в другом месте"); throw new ArgumentException("Шаблонный файл редактируется в другом месте");
} }
@ -41,12 +34,6 @@ namespace RehauSku.PriceListTools
catch (Exception exception) catch (Exception exception)
{ {
MessageBox.Show
(exception.Message,
"Ошибка открытия шаблонного прайс-листа",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
if (wb != null) if (wb != null)
{ {
wb.Close(); wb.Close();
@ -56,9 +43,9 @@ namespace RehauSku.PriceListTools
} }
} }
protected private void FillPositionAmountToColumns(KeyValuePair<Position, double> positionAmount, params int[] columns) protected void FillPositionAmountToColumns(KeyValuePair<Position, double> positionAmount, params int[] columns)
{ {
int? row = GetPositionRow(positionAmount.Key.Sku, positionAmount.Key.Group, TargetFile.skuCell.Column); int? row = GetPositionRow(TargetFile.SkuCell.EntireColumn, positionAmount.Key.Sku, positionAmount.Key.Group);
if (row != null) if (row != null)
{ {
@ -69,11 +56,12 @@ namespace RehauSku.PriceListTools
} }
ResultBar.IncrementSuccess(); ResultBar.IncrementSuccess();
return;
} }
else if (TargetFile.oldSkuCell != null) if (TargetFile.OldSkuCell != null)
{ {
row = GetPositionRow(positionAmount.Key.Sku, positionAmount.Key.Group, TargetFile.oldSkuCell.Column); row = GetPositionRow(TargetFile.OldSkuCell.EntireColumn, positionAmount.Key.Sku, positionAmount.Key.Group);
if (row != null) if (row != null)
{ {
@ -84,36 +72,32 @@ namespace RehauSku.PriceListTools
} }
ResultBar.IncrementReplaced(); ResultBar.IncrementReplaced();
return;
} }
} }
else string sku = positionAmount.Key.Sku.Substring(1, 6);
row = GetPositionRow(TargetFile.SkuCell.EntireColumn, sku, positionAmount.Key.Group);
if (row != null)
{ {
string sku = positionAmount.Key.Sku.Substring(1, 6); foreach (int column in columns)
row = GetPositionRow(sku, positionAmount.Key.Group, TargetFile.skuCell.Column);
if (row != null)
{ {
foreach (int column in columns) Range cell = TargetFile.Sheet.Cells[row, column];
{ cell.AddValue(positionAmount.Value);
Range cell = TargetFile.Sheet.Cells[row, column];
cell.AddValue(positionAmount.Value);
}
ResultBar.IncrementReplaced();
} }
else ResultBar.IncrementReplaced();
{ return;
FillMissing(positionAmount, columns);
ResultBar.IncrementNotFound();
}
} }
FillMissing(positionAmount, columns);
ResultBar.IncrementNotFound();
} }
protected private void FillMissing(KeyValuePair<Position, double> positionAmount, params int[] columns) protected void FillMissing(KeyValuePair<Position, double> positionAmount, params int[] columns)
{ {
int row = TargetFile.Sheet.Cells[TargetFile.Sheet.Rows.Count, TargetFile.skuCell.Column] int row = TargetFile.Sheet.Cells[TargetFile.Sheet.Rows.Count, TargetFile.SkuCell.Column]
.End[XlDirection.xlUp] .End[XlDirection.xlUp]
.Row + 1; .Row + 1;
@ -127,18 +111,18 @@ namespace RehauSku.PriceListTools
previous.Copy(current); previous.Copy(current);
current.ClearContents(); current.ClearContents();
TargetFile.Sheet.Cells[row, TargetFile.groupCell.Column].Value2 = positionAmount.Key.Group; TargetFile.Sheet.Cells[row, TargetFile.GroupCell.Column].Value2 = positionAmount.Key.Group;
TargetFile.Sheet.Cells[row, TargetFile.nameCell.Column].Value2 = positionAmount.Key.Name; TargetFile.Sheet.Cells[row, TargetFile.NameCell.Column].Value2 = positionAmount.Key.Name;
if (TargetFile.oldSkuCell != null) if (TargetFile.OldSkuCell != null)
{ {
TargetFile.Sheet.Cells[row, TargetFile.skuCell.Column].Value2 = "Не найден"; TargetFile.Sheet.Cells[row, TargetFile.SkuCell.Column].Value2 = "Не найден";
TargetFile.Sheet.Cells[row, TargetFile.oldSkuCell.Column].Value2 = positionAmount.Key.Sku; TargetFile.Sheet.Cells[row, TargetFile.OldSkuCell.Column].Value2 = positionAmount.Key.Sku;
} }
else else
{ {
TargetFile.Sheet.Cells[row, TargetFile.skuCell.Column].Value2 = positionAmount.Key.Sku; TargetFile.Sheet.Cells[row, TargetFile.SkuCell.Column].Value2 = positionAmount.Key.Sku;
} }
foreach (int column in columns) foreach (int column in columns)
@ -148,40 +132,42 @@ namespace RehauSku.PriceListTools
} }
} }
protected private int? GetPositionRow(string sku, string group, int column) protected int? GetPositionRow(Range range, string sku, string group)
{ {
int? row = null; Range found = range.Find(sku);
Range foundCell = TargetFile.Sheet.Columns[column].Find(sku);
string foundGroupValue; string foundGroupValue;
if (foundCell == null) return null; if (found == null)
else
{ {
row = foundCell.Row; return null;
foundGroupValue = TargetFile.Sheet.Cells[foundCell.Row, TargetFile.groupCell.Column].Value2.ToString();
} }
if (string.IsNullOrEmpty(group) || group.Equals(foundGroupValue)) int firstFoundRow = found.Row;
return row;
else while (true)
while (true) {
foundGroupValue = TargetFile.Sheet.Cells[found.Row, TargetFile.GroupCell.Column].Value2.ToString();
if (string.IsNullOrEmpty(group) || group.Equals(foundGroupValue))
{ {
foundCell = TargetFile.skuCell.EntireColumn.FindNext(foundCell); return found.Row;
if (foundCell == null) return row;
foundGroupValue = TargetFile.Sheet.Cells[foundCell.Row, TargetFile.groupCell.Column].Value2.ToString();
if (group.Equals(foundGroupValue)) return foundCell.Row;
} }
found = range.FindNext(found);
if (found.Row == firstFoundRow)
{
return null;
}
}
} }
protected private void FilterByAmount() protected void FilterByAmount()
{ {
AutoFilter filter = TargetFile.Sheet.AutoFilter; AutoFilter filter = TargetFile.Sheet.AutoFilter;
int startColumn = filter.Range.Column; int startColumn = filter.Range.Column;
filter.Range.AutoFilter(TargetFile.amountCell.Column - startColumn + 1, "<>"); filter.Range.AutoFilter(TargetFile.AmountCell.Column - startColumn + 1, "<>");
TargetFile.Sheet.Range["A1"].Activate(); TargetFile.Sheet.Range["A1"].Activate();
} }
} }

View File

@ -1,32 +1,49 @@
using Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Excel;
using System.Collections.Generic;
using RehauSku.Interface; using RehauSku.Interface;
using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Dialog = RehauSku.Interface.Dialog;
namespace RehauSku.PriceListTools namespace RehauSku.PriceListTools
{ {
internal class CombineTool : AbstractTool internal class CombineTool : AbstractTool
{ {
public List<SourcePriceList> SourceFiles; private List<SourcePriceList> SourceFiles { get; set; }
public void FillTarget() public CombineTool()
{
string[] files = Dialog.GetMultiplyFiles();
if (files != null)
{
SourceFiles = SourcePriceList.GetSourceLists(files);
}
else
{
throw new Exception("Не выбраны файлы");
}
}
public override void FillTarget()
{ {
ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(file => file.PositionAmount.Count)); ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(file => file.PositionAmount.Count));
ResultBar = new ResultBar(); ResultBar = new ResultBar();
foreach (SourcePriceList source in SourceFiles) foreach (SourcePriceList source in SourceFiles)
{ {
TargetFile.Sheet.Columns[TargetFile.amountCell.Column] TargetFile.Sheet.Columns[TargetFile.AmountCell.Column]
.EntireColumn .EntireColumn
.Insert(XlInsertShiftDirection.xlShiftToRight, XlInsertFormatOrigin.xlFormatFromRightOrBelow); .Insert(XlInsertShiftDirection.xlShiftToRight, XlInsertFormatOrigin.xlFormatFromRightOrBelow);
Range newColumnHeader = TargetFile.Sheet.Cells[TargetFile.amountCell.Row, TargetFile.amountCell.Column - 1]; Range newColumnHeader = TargetFile.Sheet.Cells[TargetFile.AmountCell.Row, TargetFile.AmountCell.Column - 1];
newColumnHeader.Value2 = $"{source.Name}"; newColumnHeader.Value2 = $"{source.Name}";
newColumnHeader.WrapText = true; newColumnHeader.WrapText = true;
foreach (var kvp in source.PositionAmount) foreach (var kvp in source.PositionAmount)
{ {
FillPositionAmountToColumns(kvp, TargetFile.amountCell.Column - 1, TargetFile.amountCell.Column); FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column - 1, TargetFile.AmountCell.Column);
ProgressBar.Update(); ProgressBar.Update();
} }
} }

View File

@ -1,38 +1,24 @@
using RehauSku.Interface; using RehauSku.Interface;
using System;
namespace RehauSku.PriceListTools namespace RehauSku.PriceListTools
{ {
internal class ConvertTool : AbstractTool internal class ConvertTool : AbstractTool
{ {
private SourcePriceList Current; private SourcePriceList Current { get; set; }
public void GetCurrent() public ConvertTool()
{ {
try Current = new SourcePriceList(ExcelApp.ActiveWorkbook);
{
Current = new SourcePriceList(ExcelApp.ActiveWorkbook);
}
catch (Exception exception)
{
System.Windows.Forms.MessageBox.Show
(exception.Message,
"Ошибка распознавания",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information);
throw exception;
}
} }
public void FillTarget() public override void FillTarget()
{ {
ProgressBar = new ProgressBar("Заполняю строки...", Current.PositionAmount.Count); ProgressBar = new ProgressBar("Заполняю строки...", Current.PositionAmount.Count);
ResultBar = new ResultBar(); ResultBar = new ResultBar();
foreach (var kvp in Current.PositionAmount) foreach (var kvp in Current.PositionAmount)
{ {
FillPositionAmountToColumns(kvp, TargetFile.amountCell.Column); FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column);
ProgressBar.Update(); ProgressBar.Update();
} }

View File

@ -8,22 +8,27 @@ namespace RehauSku.PriceListTools
internal class ExportTool : AbstractTool internal class ExportTool : AbstractTool
{ {
private Dictionary<Position, double> PositionAmount; private Dictionary<Position, double> PositionAmount;
private Range Selection; private readonly Range Selection;
public ExportTool() public ExportTool()
{ {
Selection = ExcelApp.Selection; Selection = ExcelApp.Selection;
GetSelected();
if (PositionAmount.Count == 0)
{
throw new Exception("В выделенном диапазоне не найдены позиции для экспорта");
}
} }
public void FillTarget() public override void FillTarget()
{ {
GetSelected();
ProgressBar = new ProgressBar("Заполняю строки...", PositionAmount.Count); ProgressBar = new ProgressBar("Заполняю строки...", PositionAmount.Count);
ResultBar = new ResultBar(); ResultBar = new ResultBar();
foreach (var kvp in PositionAmount) foreach (var kvp in PositionAmount)
{ {
FillPositionAmountToColumns(kvp, TargetFile.amountCell.Column); FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column);
ProgressBar.Update(); ProgressBar.Update();
} }

View File

@ -1,4 +1,5 @@
using RehauSku.Interface; using RehauSku.Interface;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -6,9 +7,24 @@ namespace RehauSku.PriceListTools
{ {
internal class MergeTool : AbstractTool internal class MergeTool : AbstractTool
{ {
public List<SourcePriceList> SourceFiles; private List<SourcePriceList> SourceFiles { get; set; }
public void FillTarget() public MergeTool()
{
string[] files = Dialog.GetMultiplyFiles();
if (files != null)
{
SourceFiles = SourcePriceList.GetSourceLists(files);
}
else
{
throw new Exception("Не выбраны файлы");
}
}
public override void FillTarget()
{ {
ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(x => x.PositionAmount.Count)); ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(x => x.PositionAmount.Count));
ResultBar = new ResultBar(); ResultBar = new ResultBar();
@ -17,7 +33,7 @@ namespace RehauSku.PriceListTools
{ {
foreach (var kvp in source.PositionAmount) foreach (var kvp in source.PositionAmount)
{ {
FillPositionAmountToColumns(kvp, TargetFile.amountCell.Column); FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column);
ProgressBar.Update(); ProgressBar.Update();
} }
} }

View File

@ -0,0 +1,11 @@
namespace RehauSku.PriceListTools
{
internal static class PriceListHeaders
{
public static readonly string Amount = "Кол-во";
public static readonly string OldSku = "Прежний материал";
public static readonly string Sku = "Актуальный материал";
public static readonly string Group = "Программа";
public static readonly string Name = "Наименование";
}
}

View File

@ -7,7 +7,6 @@ using RehauSku.Interface;
namespace RehauSku.PriceListTools namespace RehauSku.PriceListTools
{ {
internal class SourcePriceList : AbstractPriceList internal class SourcePriceList : AbstractPriceList
{ {
public Dictionary<Position, double> PositionAmount { get; private set; } public Dictionary<Position, double> PositionAmount { get; private set; }
@ -24,10 +23,10 @@ namespace RehauSku.PriceListTools
Range[] cells = new[] Range[] cells = new[]
{ {
amountCell = Sheet.Cells.Find(amountHeader), AmountCell = Sheet.Cells.Find(PriceListHeaders.Amount),
skuCell = Sheet.Cells.Find(skuHeader), SkuCell = Sheet.Cells.Find(PriceListHeaders.Sku),
groupCell = Sheet.Cells.Find(groupHeader), GroupCell = Sheet.Cells.Find(PriceListHeaders.Group),
nameCell = Sheet.Cells.Find(nameHeader) NameCell = Sheet.Cells.Find(PriceListHeaders.Name)
}; };
if (cells.Any(x => x == null)) if (cells.Any(x => x == null))
@ -76,15 +75,15 @@ namespace RehauSku.PriceListTools
{ {
PositionAmount = new Dictionary<Position, double>(); PositionAmount = new Dictionary<Position, 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++)
{ {
object amount = Sheet.Cells[row, amountCell.Column].Value2; object amount = Sheet.Cells[row, AmountCell.Column].Value2;
if (amount != null && (double)amount != 0) if (amount != null && (double)amount != 0)
{ {
object group = Sheet.Cells[row, groupCell.Column].Value2; object group = Sheet.Cells[row, GroupCell.Column].Value2;
object name = Sheet.Cells[row, nameCell.Column].Value2; object name = Sheet.Cells[row, NameCell.Column].Value2;
object sku = Sheet.Cells[row, skuCell.Column].Value2; object sku = Sheet.Cells[row, SkuCell.Column].Value2;
if (group == null || name == null || sku == null) if (group == null || name == null || sku == null)
continue; continue;

View File

@ -6,8 +6,7 @@ namespace RehauSku.PriceListTools
{ {
internal class TargetPriceList : AbstractPriceList internal class TargetPriceList : AbstractPriceList
{ {
private const string oldSkuHeader = "Прежний материал"; public Range OldSkuCell { get; private set; }
public Range oldSkuCell { get; private set; }
public TargetPriceList(Workbook workbook) public TargetPriceList(Workbook workbook)
{ {
@ -22,13 +21,13 @@ namespace RehauSku.PriceListTools
Range[] cells = new[] Range[] cells = new[]
{ {
amountCell = Sheet.Cells.Find(amountHeader), AmountCell = Sheet.Cells.Find(PriceListHeaders.Amount),
skuCell = Sheet.Cells.Find(skuHeader), SkuCell = Sheet.Cells.Find(PriceListHeaders.Sku),
groupCell = Sheet.Cells.Find(groupHeader), GroupCell = Sheet.Cells.Find(PriceListHeaders.Group),
nameCell = Sheet.Cells.Find(nameHeader) NameCell = Sheet.Cells.Find(PriceListHeaders.Name)
}; };
oldSkuCell = Sheet.Cells.Find(oldSkuHeader); OldSkuCell = Sheet.Cells.Find(PriceListHeaders.OldSku);
if (cells.Any(x => x == null)) if (cells.Any(x => x == null))
{ {

View File

@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RehauSku.Assist")] [assembly: AssemblyProduct("RehauSku.Assist")]
[assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyCopyright("Copyright © 2021-2022")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.4")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.4")]

View File

@ -131,6 +131,7 @@
<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" />
<Compile Include="PriceListTools\PriceListHeaders.cs" />
<Compile Include="PriceListTools\SourcePriceList.cs" /> <Compile Include="PriceListTools\SourcePriceList.cs" />
<Compile Include="PriceListTools\TargetPriceList.cs" /> <Compile Include="PriceListTools\TargetPriceList.cs" />
<Compile Include="Interface\RibbonController.cs" /> <Compile Include="Interface\RibbonController.cs" />