commit
215d68ea95
@ -36,22 +36,5 @@ namespace RehauSku.Interface
|
|||||||
else return null;
|
else return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SaveWorkbookAs()
|
|
||||||
{
|
|
||||||
Workbook workbook = AddIn.Excel.ActiveWorkbook;
|
|
||||||
|
|
||||||
using (SaveFileDialog dialog = new SaveFileDialog())
|
|
||||||
{
|
|
||||||
dialog.FileName = workbook.Name;
|
|
||||||
dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm";
|
|
||||||
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
string fileName = dialog.FileName;
|
|
||||||
workbook.SaveAs(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,13 +45,17 @@ namespace RehauSku.PriceListTools
|
|||||||
|
|
||||||
protected void FillPositionAmountToColumns(KeyValuePair<Position, double> positionAmount, params int[] columns)
|
protected void FillPositionAmountToColumns(KeyValuePair<Position, double> positionAmount, params int[] columns)
|
||||||
{
|
{
|
||||||
int? row = GetPositionRow(TargetFile.SkuCell.EntireColumn, positionAmount.Key.Sku, positionAmount.Key.Group);
|
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);
|
||||||
|
|
||||||
if (row != null)
|
if (row != null)
|
||||||
{
|
{
|
||||||
foreach (int column in columns)
|
foreach (int column in columns)
|
||||||
{
|
{
|
||||||
Range cell = TargetFile.Sheet.Cells[row, column];
|
Range cell = worksheetCells[row, column];
|
||||||
cell.AddValue(positionAmount.Value);
|
cell.AddValue(positionAmount.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,13 +65,13 @@ namespace RehauSku.PriceListTools
|
|||||||
|
|
||||||
if (TargetFile.OldSkuCell != null)
|
if (TargetFile.OldSkuCell != null)
|
||||||
{
|
{
|
||||||
row = GetPositionRow(TargetFile.OldSkuCell.EntireColumn, positionAmount.Key.Sku, positionAmount.Key.Group);
|
row = GetPositionRow(oldSkuColumn, positionAmount.Key.Sku, positionAmount.Key.Group);
|
||||||
|
|
||||||
if (row != null)
|
if (row != null)
|
||||||
{
|
{
|
||||||
foreach (int column in columns)
|
foreach (int column in columns)
|
||||||
{
|
{
|
||||||
Range cell = TargetFile.Sheet.Cells[row, column];
|
Range cell = worksheetCells[row, column];
|
||||||
cell.AddValue(positionAmount.Value);
|
cell.AddValue(positionAmount.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,13 +81,13 @@ namespace RehauSku.PriceListTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
string sku = positionAmount.Key.Sku.Substring(1, 6);
|
string sku = positionAmount.Key.Sku.Substring(1, 6);
|
||||||
row = GetPositionRow(TargetFile.SkuCell.EntireColumn, sku, positionAmount.Key.Group);
|
row = GetPositionRow(skuColumn, sku, positionAmount.Key.Group);
|
||||||
|
|
||||||
if (row != null)
|
if (row != null)
|
||||||
{
|
{
|
||||||
foreach (int column in columns)
|
foreach (int column in columns)
|
||||||
{
|
{
|
||||||
Range cell = TargetFile.Sheet.Cells[row, column];
|
Range cell = worksheetCells[row, column];
|
||||||
cell.AddValue(positionAmount.Value);
|
cell.AddValue(positionAmount.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,37 +101,43 @@ namespace RehauSku.PriceListTools
|
|||||||
|
|
||||||
protected 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]
|
Range worksheetCells = TargetFile.Sheet.Cells;
|
||||||
|
Range worksheetRows = TargetFile.Sheet.Rows;
|
||||||
|
int skuColumn = TargetFile.SkuCell.Column;
|
||||||
|
int groupColumn = TargetFile.GroupCell.Column;
|
||||||
|
int nameColumn = TargetFile.NameCell.Column;
|
||||||
|
|
||||||
|
int row = worksheetCells[worksheetRows.Count, skuColumn]
|
||||||
.End[XlDirection.xlUp]
|
.End[XlDirection.xlUp]
|
||||||
.Row + 1;
|
.Row + 1;
|
||||||
|
|
||||||
TargetFile.Sheet.Rows[row]
|
worksheetRows[row]
|
||||||
.EntireRow
|
.EntireRow
|
||||||
.Insert(XlInsertShiftDirection.xlShiftDown, XlInsertFormatOrigin.xlFormatFromLeftOrAbove);
|
.Insert(XlInsertShiftDirection.xlShiftDown, XlInsertFormatOrigin.xlFormatFromLeftOrAbove);
|
||||||
|
|
||||||
Range previous = TargetFile.Sheet.Rows[row - 1];
|
Range previous = worksheetRows[row - 1];
|
||||||
Range current = TargetFile.Sheet.Rows[row];
|
Range current = worksheetRows[row];
|
||||||
|
|
||||||
previous.Copy(current);
|
previous.Copy(current);
|
||||||
current.ClearContents();
|
current.ClearContents();
|
||||||
|
|
||||||
TargetFile.Sheet.Cells[row, TargetFile.GroupCell.Column].Value2 = positionAmount.Key.Group;
|
worksheetCells[row, groupColumn].Value2 = positionAmount.Key.Group;
|
||||||
TargetFile.Sheet.Cells[row, TargetFile.NameCell.Column].Value2 = positionAmount.Key.Name;
|
worksheetCells[row, nameColumn].Value2 = positionAmount.Key.Name;
|
||||||
|
|
||||||
if (TargetFile.OldSkuCell != null)
|
if (TargetFile.OldSkuCell != null)
|
||||||
{
|
{
|
||||||
TargetFile.Sheet.Cells[row, TargetFile.SkuCell.Column].Value2 = "Не найден";
|
worksheetCells[row, skuColumn].Value2 = "Не найден";
|
||||||
TargetFile.Sheet.Cells[row, TargetFile.OldSkuCell.Column].Value2 = positionAmount.Key.Sku;
|
worksheetCells[row, TargetFile.OldSkuCell.Column].Value2 = positionAmount.Key.Sku;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TargetFile.Sheet.Cells[row, TargetFile.SkuCell.Column].Value2 = positionAmount.Key.Sku;
|
worksheetCells[row, skuColumn].Value2 = positionAmount.Key.Sku;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (int column in columns)
|
foreach (int column in columns)
|
||||||
{
|
{
|
||||||
Range cell = TargetFile.Sheet.Cells[row, column];
|
Range cell = worksheetCells[row, column];
|
||||||
cell.AddValue(positionAmount.Value);
|
cell.AddValue(positionAmount.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,13 +152,18 @@ namespace RehauSku.PriceListTools
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int firstFoundRow = found.Row;
|
int firstFoundRow = found.Row;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(group))
|
||||||
|
{
|
||||||
|
return found.Row;
|
||||||
|
}
|
||||||
|
|
||||||
while (true)
|
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))
|
if (group.Equals(foundGroupValue))
|
||||||
{
|
{
|
||||||
return found.Row;
|
return found.Row;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using RehauSku.Interface;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Dialog = RehauSku.Interface.Dialog;
|
using Dialog = RehauSku.Interface.Dialog;
|
||||||
|
|
||||||
namespace RehauSku.PriceListTools
|
namespace RehauSku.PriceListTools
|
||||||
@ -26,7 +27,7 @@ namespace RehauSku.PriceListTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillTarget()
|
public override async 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();
|
||||||
@ -51,7 +52,7 @@ namespace RehauSku.PriceListTools
|
|||||||
FilterByAmount();
|
FilterByAmount();
|
||||||
ResultBar.Update();
|
ResultBar.Update();
|
||||||
|
|
||||||
Interface.Dialog.SaveWorkbookAs();
|
await Task.Delay(new TimeSpan(0, 0, 5));
|
||||||
ExcelApp.StatusBar = false;
|
ExcelApp.StatusBar = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using RehauSku.Interface;
|
using RehauSku.Interface;
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace RehauSku.PriceListTools
|
namespace RehauSku.PriceListTools
|
||||||
{
|
{
|
||||||
@ -11,7 +13,7 @@ namespace RehauSku.PriceListTools
|
|||||||
Current = new SourcePriceList(ExcelApp.ActiveWorkbook);
|
Current = new SourcePriceList(ExcelApp.ActiveWorkbook);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillTarget()
|
public override async void FillTarget()
|
||||||
{
|
{
|
||||||
ProgressBar = new ProgressBar("Заполняю строки...", Current.PositionAmount.Count);
|
ProgressBar = new ProgressBar("Заполняю строки...", Current.PositionAmount.Count);
|
||||||
ResultBar = new ResultBar();
|
ResultBar = new ResultBar();
|
||||||
@ -25,7 +27,7 @@ namespace RehauSku.PriceListTools
|
|||||||
FilterByAmount();
|
FilterByAmount();
|
||||||
ResultBar.Update();
|
ResultBar.Update();
|
||||||
|
|
||||||
Dialog.SaveWorkbookAs();
|
await Task.Delay(new TimeSpan(0, 0, 5));
|
||||||
ExcelApp.StatusBar = false;
|
ExcelApp.StatusBar = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using RehauSku.Interface;
|
using RehauSku.Interface;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace RehauSku.PriceListTools
|
namespace RehauSku.PriceListTools
|
||||||
{
|
{
|
||||||
@ -21,11 +22,11 @@ namespace RehauSku.PriceListTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillTarget()
|
public override async void FillTarget()
|
||||||
{
|
{
|
||||||
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);
|
||||||
@ -35,13 +36,13 @@ namespace RehauSku.PriceListTools
|
|||||||
FilterByAmount();
|
FilterByAmount();
|
||||||
ResultBar.Update();
|
ResultBar.Update();
|
||||||
|
|
||||||
Interface.Dialog.SaveWorkbookAs();
|
await Task.Delay(new TimeSpan(0, 0, 5));
|
||||||
ExcelApp.StatusBar = false;
|
ExcelApp.StatusBar = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetSelected()
|
private void GetSelected()
|
||||||
{
|
{
|
||||||
object[,] cells = Selection.Value2;
|
object[,] cells = Selection.Value2;
|
||||||
PositionAmount = new Dictionary<Position, double>();
|
PositionAmount = new Dictionary<Position, double>();
|
||||||
|
|
||||||
int rowsCount = Selection.Rows.Count;
|
int rowsCount = Selection.Rows.Count;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace RehauSku.PriceListTools
|
namespace RehauSku.PriceListTools
|
||||||
{
|
{
|
||||||
@ -24,7 +25,7 @@ namespace RehauSku.PriceListTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillTarget()
|
public override async 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();
|
||||||
@ -41,7 +42,7 @@ namespace RehauSku.PriceListTools
|
|||||||
FilterByAmount();
|
FilterByAmount();
|
||||||
ResultBar.Update();
|
ResultBar.Update();
|
||||||
|
|
||||||
Dialog.SaveWorkbookAs();
|
await Task.Delay(new TimeSpan(0, 0, 5));
|
||||||
ExcelApp.StatusBar = false;
|
ExcelApp.StatusBar = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace RehauSku.PriceListTools
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace RehauSku.PriceListTools
|
||||||
{
|
{
|
||||||
public class Position
|
public class Position
|
||||||
{
|
{
|
||||||
@ -12,5 +14,29 @@
|
|||||||
Sku = sku;
|
Sku = sku;
|
||||||
Name = name;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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.4")]
|
[assembly: AssemblyVersion("1.0.4.2")]
|
||||||
[assembly: AssemblyFileVersion("1.0.4")]
|
[assembly: AssemblyFileVersion("1.0.4.2")]
|
||||||
|
Loading…
Reference in New Issue
Block a user