aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AddIn/EventsUtil.cs2
-rw-r--r--src/AddIn/WorksheetExtensions.cs14
-rw-r--r--src/Interface/ProgressBar.cs2
-rw-r--r--src/PriceListTools/AbstractPriceList.cs13
-rw-r--r--src/PriceListTools/AbstractTool.cs26
-rw-r--r--src/PriceListTools/CombineTool.cs6
-rw-r--r--src/PriceListTools/ConvertTool.cs2
-rw-r--r--src/PriceListTools/ExportTool.cs4
-rw-r--r--src/PriceListTools/MergeTool.cs2
-rw-r--r--src/PriceListTools/PriceListHeaders.cs11
-rw-r--r--src/PriceListTools/SourcePriceList.cs19
-rw-r--r--src/PriceListTools/TargetPriceList.cs13
-rw-r--r--src/RehauSku.Assist.csproj1
13 files changed, 58 insertions, 57 deletions
diff --git a/src/AddIn/EventsUtil.cs b/src/AddIn/EventsUtil.cs
index 102e12e..bc8d1d3 100644
--- a/src/AddIn/EventsUtil.cs
+++ b/src/AddIn/EventsUtil.cs
@@ -4,7 +4,7 @@ namespace RehauSku
{
internal static class EventsUtil
{
- private static Application Excel = AddIn.Excel;
+ private static readonly Application Excel = AddIn.Excel;
public static void Initialize()
{
diff --git a/src/AddIn/WorksheetExtensions.cs b/src/AddIn/WorksheetExtensions.cs
index cffa55c..7880b66 100644
--- a/src/AddIn/WorksheetExtensions.cs
+++ b/src/AddIn/WorksheetExtensions.cs
@@ -1,15 +1,11 @@
using Microsoft.Office.Interop.Excel;
+using RehauSku.PriceListTools;
using System.Linq;
namespace RehauSku
{
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)
{
Range amountCell;
@@ -19,10 +15,10 @@ namespace RehauSku
Range[] cells = new[]
{
- amountCell = worksheet.Cells.Find(amountHeader),
- skuCell = worksheet.Cells.Find(skuHeader),
- groupCell = worksheet.Cells.Find(groupHeader),
- nameCell = worksheet.Cells.Find(nameHeader)
+ amountCell = worksheet.Cells.Find(PriceListHeaders.Amount),
+ skuCell = worksheet.Cells.Find(PriceListHeaders.Sku),
+ groupCell = worksheet.Cells.Find(PriceListHeaders.Group),
+ nameCell = worksheet.Cells.Find(PriceListHeaders.Name)
};
return cells.All(x => x != null);
diff --git a/src/Interface/ProgressBar.cs b/src/Interface/ProgressBar.cs
index 2e68e8b..416c7d6 100644
--- a/src/Interface/ProgressBar.cs
+++ b/src/Interface/ProgressBar.cs
@@ -19,7 +19,7 @@
if (percent < 100)
{
- Excel.StatusBar = $"{Message} Выполнено {percent.ToString("#.#")} %";
+ Excel.StatusBar = $"{Message} Выполнено {percent:#.#} %";
}
else
diff --git a/src/PriceListTools/AbstractPriceList.cs b/src/PriceListTools/AbstractPriceList.cs
index 06427a0..2f89a85 100644
--- a/src/PriceListTools/AbstractPriceList.cs
+++ b/src/PriceListTools/AbstractPriceList.cs
@@ -4,15 +4,10 @@ namespace RehauSku.PriceListTools
{
internal abstract class AbstractPriceList
{
- protected const string amountHeader = "Кол-во";
- protected const string skuHeader = "Актуальный материал";
- protected const string groupHeader = "Программа";
- protected const string nameHeader = "Наименование";
-
- 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 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 string Name { get; protected set; }
diff --git a/src/PriceListTools/AbstractTool.cs b/src/PriceListTools/AbstractTool.cs
index c43d06c..256be06 100644
--- a/src/PriceListTools/AbstractTool.cs
+++ b/src/PriceListTools/AbstractTool.cs
@@ -45,7 +45,7 @@ namespace RehauSku.PriceListTools
protected void FillPositionAmountToColumns(KeyValuePair<Position, double> positionAmount, params int[] columns)
{
- int? row = GetPositionRow(TargetFile.skuCell.EntireColumn, positionAmount.Key.Sku, positionAmount.Key.Group);
+ int? row = GetPositionRow(TargetFile.SkuCell.EntireColumn, positionAmount.Key.Sku, positionAmount.Key.Group);
if (row != null)
{
@@ -59,9 +59,9 @@ namespace RehauSku.PriceListTools
return;
}
- if (TargetFile.oldSkuCell != null)
+ if (TargetFile.OldSkuCell != null)
{
- row = GetPositionRow(TargetFile.oldSkuCell.EntireColumn, positionAmount.Key.Sku, positionAmount.Key.Group);
+ row = GetPositionRow(TargetFile.OldSkuCell.EntireColumn, positionAmount.Key.Sku, positionAmount.Key.Group);
if (row != null)
{
@@ -77,7 +77,7 @@ namespace RehauSku.PriceListTools
}
string sku = positionAmount.Key.Sku.Substring(1, 6);
- row = GetPositionRow(TargetFile.skuCell.EntireColumn, sku, positionAmount.Key.Group);
+ row = GetPositionRow(TargetFile.SkuCell.EntireColumn, sku, positionAmount.Key.Group);
if (row != null)
{
@@ -97,7 +97,7 @@ namespace RehauSku.PriceListTools
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]
.Row + 1;
@@ -111,18 +111,18 @@ namespace RehauSku.PriceListTools
previous.Copy(current);
current.ClearContents();
- 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.GroupCell.Column].Value2 = positionAmount.Key.Group;
+ 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.oldSkuCell.Column].Value2 = positionAmount.Key.Sku;
+ TargetFile.Sheet.Cells[row, TargetFile.SkuCell.Column].Value2 = "Не найден";
+ TargetFile.Sheet.Cells[row, TargetFile.OldSkuCell.Column].Value2 = positionAmount.Key.Sku;
}
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)
@@ -146,7 +146,7 @@ namespace RehauSku.PriceListTools
while (true)
{
- foundGroupValue = TargetFile.Sheet.Cells[found.Row, TargetFile.groupCell.Column].Value2.ToString();
+ foundGroupValue = TargetFile.Sheet.Cells[found.Row, TargetFile.GroupCell.Column].Value2.ToString();
if (string.IsNullOrEmpty(group) || group.Equals(foundGroupValue))
{
@@ -167,7 +167,7 @@ namespace RehauSku.PriceListTools
AutoFilter filter = TargetFile.Sheet.AutoFilter;
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();
}
}
diff --git a/src/PriceListTools/CombineTool.cs b/src/PriceListTools/CombineTool.cs
index e3cb83e..eddf9e7 100644
--- a/src/PriceListTools/CombineTool.cs
+++ b/src/PriceListTools/CombineTool.cs
@@ -33,17 +33,17 @@ namespace RehauSku.PriceListTools
foreach (SourcePriceList source in SourceFiles)
{
- TargetFile.Sheet.Columns[TargetFile.amountCell.Column]
+ TargetFile.Sheet.Columns[TargetFile.AmountCell.Column]
.EntireColumn
.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.WrapText = true;
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();
}
}
diff --git a/src/PriceListTools/ConvertTool.cs b/src/PriceListTools/ConvertTool.cs
index abf7e39..1bb02f4 100644
--- a/src/PriceListTools/ConvertTool.cs
+++ b/src/PriceListTools/ConvertTool.cs
@@ -18,7 +18,7 @@ namespace RehauSku.PriceListTools
foreach (var kvp in Current.PositionAmount)
{
- FillPositionAmountToColumns(kvp, TargetFile.amountCell.Column);
+ FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column);
ProgressBar.Update();
}
diff --git a/src/PriceListTools/ExportTool.cs b/src/PriceListTools/ExportTool.cs
index acc6515..603de8b 100644
--- a/src/PriceListTools/ExportTool.cs
+++ b/src/PriceListTools/ExportTool.cs
@@ -8,7 +8,7 @@ namespace RehauSku.PriceListTools
internal class ExportTool : AbstractTool
{
private Dictionary<Position, double> PositionAmount;
- private Range Selection;
+ private readonly Range Selection;
public ExportTool()
{
@@ -28,7 +28,7 @@ namespace RehauSku.PriceListTools
foreach (var kvp in PositionAmount)
{
- FillPositionAmountToColumns(kvp, TargetFile.amountCell.Column);
+ FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column);
ProgressBar.Update();
}
diff --git a/src/PriceListTools/MergeTool.cs b/src/PriceListTools/MergeTool.cs
index 77732bf..179fb81 100644
--- a/src/PriceListTools/MergeTool.cs
+++ b/src/PriceListTools/MergeTool.cs
@@ -33,7 +33,7 @@ namespace RehauSku.PriceListTools
{
foreach (var kvp in source.PositionAmount)
{
- FillPositionAmountToColumns(kvp, TargetFile.amountCell.Column);
+ FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column);
ProgressBar.Update();
}
}
diff --git a/src/PriceListTools/PriceListHeaders.cs b/src/PriceListTools/PriceListHeaders.cs
new file mode 100644
index 0000000..74c7870
--- /dev/null
+++ b/src/PriceListTools/PriceListHeaders.cs
@@ -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 = "Наименование";
+ }
+} \ No newline at end of file
diff --git a/src/PriceListTools/SourcePriceList.cs b/src/PriceListTools/SourcePriceList.cs
index 01637f8..d03d776 100644
--- a/src/PriceListTools/SourcePriceList.cs
+++ b/src/PriceListTools/SourcePriceList.cs
@@ -7,7 +7,6 @@ using RehauSku.Interface;
namespace RehauSku.PriceListTools
{
-
internal class SourcePriceList : AbstractPriceList
{
public Dictionary<Position, double> PositionAmount { get; private set; }
@@ -24,10 +23,10 @@ namespace RehauSku.PriceListTools
Range[] cells = new[]
{
- amountCell = Sheet.Cells.Find(amountHeader),
- skuCell = Sheet.Cells.Find(skuHeader),
- groupCell = Sheet.Cells.Find(groupHeader),
- nameCell = Sheet.Cells.Find(nameHeader)
+ AmountCell = Sheet.Cells.Find(PriceListHeaders.Amount),
+ SkuCell = Sheet.Cells.Find(PriceListHeaders.Sku),
+ GroupCell = Sheet.Cells.Find(PriceListHeaders.Group),
+ NameCell = Sheet.Cells.Find(PriceListHeaders.Name)
};
if (cells.Any(x => x == null))
@@ -76,15 +75,15 @@ namespace RehauSku.PriceListTools
{
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)
{
- object group = Sheet.Cells[row, groupCell.Column].Value2;
- object name = Sheet.Cells[row, nameCell.Column].Value2;
- object sku = Sheet.Cells[row, skuCell.Column].Value2;
+ object group = Sheet.Cells[row, GroupCell.Column].Value2;
+ object name = Sheet.Cells[row, NameCell.Column].Value2;
+ object sku = Sheet.Cells[row, SkuCell.Column].Value2;
if (group == null || name == null || sku == null)
continue;
diff --git a/src/PriceListTools/TargetPriceList.cs b/src/PriceListTools/TargetPriceList.cs
index 5fb2bf9..2f23168 100644
--- a/src/PriceListTools/TargetPriceList.cs
+++ b/src/PriceListTools/TargetPriceList.cs
@@ -6,8 +6,7 @@ namespace RehauSku.PriceListTools
{
internal class TargetPriceList : AbstractPriceList
{
- private const string oldSkuHeader = "Прежний материал";
- public Range oldSkuCell { get; private set; }
+ public Range OldSkuCell { get; private set; }
public TargetPriceList(Workbook workbook)
{
@@ -22,13 +21,13 @@ namespace RehauSku.PriceListTools
Range[] cells = new[]
{
- amountCell = Sheet.Cells.Find(amountHeader),
- skuCell = Sheet.Cells.Find(skuHeader),
- groupCell = Sheet.Cells.Find(groupHeader),
- nameCell = Sheet.Cells.Find(nameHeader)
+ AmountCell = Sheet.Cells.Find(PriceListHeaders.Amount),
+ SkuCell = Sheet.Cells.Find(PriceListHeaders.Sku),
+ GroupCell = Sheet.Cells.Find(PriceListHeaders.Group),
+ NameCell = Sheet.Cells.Find(PriceListHeaders.Name)
};
- oldSkuCell = Sheet.Cells.Find(oldSkuHeader);
+ OldSkuCell = Sheet.Cells.Find(PriceListHeaders.OldSku);
if (cells.Any(x => x == null))
{
diff --git a/src/RehauSku.Assist.csproj b/src/RehauSku.Assist.csproj
index 76bd243..8a2990b 100644
--- a/src/RehauSku.Assist.csproj
+++ b/src/RehauSku.Assist.csproj
@@ -131,6 +131,7 @@
<Compile Include="PriceListTools\AbstractTool.cs" />
<Compile Include="PriceListTools\MergeTool.cs" />
<Compile Include="PriceListTools\AbstractPriceList.cs" />
+ <Compile Include="PriceListTools\PriceListHeaders.cs" />
<Compile Include="PriceListTools\SourcePriceList.cs" />
<Compile Include="PriceListTools\TargetPriceList.cs" />
<Compile Include="Interface\RibbonController.cs" />