2022-02-01 20:32:29 +03:00
|
|
|
|
using ExcelDna.Integration.CustomUI;
|
|
|
|
|
using RehauSku.PriceListTools;
|
2022-01-09 10:37:25 +03:00
|
|
|
|
using System;
|
2022-02-01 20:32:29 +03:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Windows.Forms;
|
2021-12-05 16:55:36 +03:00
|
|
|
|
|
2022-02-02 09:46:47 +03:00
|
|
|
|
namespace RehauSku.Interface
|
2021-12-05 16:55:36 +03:00
|
|
|
|
{
|
|
|
|
|
[ComVisible(true)]
|
|
|
|
|
public class RibbonController : ExcelRibbon
|
|
|
|
|
{
|
|
|
|
|
public override string GetCustomUI(string RibbonID)
|
|
|
|
|
{
|
|
|
|
|
return @"
|
|
|
|
|
<customUI xmlns='http://schemas.microsoft.com/office/2006/01/customui'>
|
|
|
|
|
<ribbon>
|
|
|
|
|
<tabs>
|
2021-12-09 14:08:26 +03:00
|
|
|
|
<tab id='rau' label='REHAU'>
|
|
|
|
|
<group id='priceList' label='Прайс-лист'>
|
2022-01-07 19:04:07 +03:00
|
|
|
|
<button id='exportToPrice' label='Экспорт в новый файл' size='normal' imageMso='PivotExportToExcel' onAction='OnExportPressed'/>
|
2022-01-28 14:38:05 +03:00
|
|
|
|
<button id='convertPrice' label='Актуализировать' size='normal' imageMso='FileUpdate' onAction='OnConvertPressed'/>
|
2022-01-07 19:04:07 +03:00
|
|
|
|
<menu id='conjoinMenu' label='Объединить' imageMso='Copy'>
|
|
|
|
|
<button id='mergeFiles' label='Сложить' onAction='OnMergePressed'/>
|
|
|
|
|
<button id='combineFiles' label='По колонкам' onAction='OnCombinePressed'/>
|
|
|
|
|
</menu>
|
2021-12-09 14:08:26 +03:00
|
|
|
|
</group>
|
|
|
|
|
<group id='rausettings' label='Настройки'>
|
2022-01-28 09:08:35 +03:00
|
|
|
|
<button id='setPriceList' label='Указать путь к шаблону' size='large' imageMso='CurrentViewSettings' onAction='OnSetPricePressed'/>
|
2021-12-09 14:08:26 +03:00
|
|
|
|
</group>
|
2021-12-05 16:55:36 +03:00
|
|
|
|
</tab>
|
|
|
|
|
</tabs>
|
|
|
|
|
</ribbon>
|
|
|
|
|
</customUI>";
|
|
|
|
|
}
|
2021-12-07 08:28:21 +03:00
|
|
|
|
|
2021-12-24 16:22:03 +03:00
|
|
|
|
public void OnMergePressed(IRibbonControl control)
|
|
|
|
|
{
|
2022-01-27 17:34:03 +03:00
|
|
|
|
MergeTool mergeTool = new MergeTool();
|
|
|
|
|
string[] files = Dialog.GetMultiplyFiles();
|
|
|
|
|
|
|
|
|
|
if (files.Length != 0)
|
2021-12-24 16:22:03 +03:00
|
|
|
|
{
|
2022-02-02 18:05:49 +03:00
|
|
|
|
mergeTool.SourceFiles = SourcePriceList.GetSourceLists(files);
|
2022-01-27 17:34:03 +03:00
|
|
|
|
mergeTool.OpenNewPrice();
|
|
|
|
|
mergeTool.FillTarget();
|
2022-01-07 19:04:07 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnCombinePressed(IRibbonControl control)
|
|
|
|
|
{
|
2022-01-27 17:34:03 +03:00
|
|
|
|
CombineTool combineTool = new CombineTool();
|
|
|
|
|
string[] files = Dialog.GetMultiplyFiles();
|
|
|
|
|
|
|
|
|
|
if (files.Length != 0)
|
2022-01-07 19:04:07 +03:00
|
|
|
|
{
|
2022-02-02 18:05:49 +03:00
|
|
|
|
combineTool.SourceFiles = SourcePriceList.GetSourceLists(files);
|
2022-01-27 17:34:03 +03:00
|
|
|
|
combineTool.OpenNewPrice();
|
|
|
|
|
combineTool.FillTarget();
|
2021-12-24 16:22:03 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-17 09:07:34 +03:00
|
|
|
|
public void OnExportPressed(IRibbonControl control)
|
2021-12-07 08:28:21 +03:00
|
|
|
|
{
|
2022-01-09 10:37:25 +03:00
|
|
|
|
try
|
2021-12-07 08:28:21 +03:00
|
|
|
|
{
|
2022-01-27 17:34:03 +03:00
|
|
|
|
ExportTool exportTool = new ExportTool();
|
|
|
|
|
exportTool.TryGetSelection();
|
|
|
|
|
exportTool.OpenNewPrice();
|
|
|
|
|
exportTool.FillTarget();
|
2021-12-07 08:28:21 +03:00
|
|
|
|
}
|
2022-01-27 17:34:03 +03:00
|
|
|
|
|
2022-01-09 10:37:25 +03:00
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.Message,
|
|
|
|
|
"Ошибка",
|
|
|
|
|
MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Information);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-12-07 08:28:21 +03:00
|
|
|
|
}
|
2021-12-24 16:22:03 +03:00
|
|
|
|
|
2022-01-28 09:08:35 +03:00
|
|
|
|
public void OnConvertPressed(IRibbonControl control)
|
|
|
|
|
{
|
|
|
|
|
ConvertTool convertTool = new ConvertTool();
|
|
|
|
|
|
|
|
|
|
convertTool.GetCurrent();
|
|
|
|
|
convertTool.OpenNewPrice();
|
|
|
|
|
convertTool.FillTarget();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-24 17:42:20 +03:00
|
|
|
|
public void OnSetPricePressed(IRibbonControl control)
|
2021-12-17 09:07:34 +03:00
|
|
|
|
{
|
2021-12-24 17:42:20 +03:00
|
|
|
|
string path = Dialog.GetFilePath();
|
|
|
|
|
RegistryUtil.PriceListPath = path;
|
2021-12-17 09:07:34 +03:00
|
|
|
|
}
|
2021-12-05 16:55:36 +03:00
|
|
|
|
}
|
|
|
|
|
}
|