aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Chebotar <s.chebotar@gmail.com>2022-02-08 17:26:05 +0300
committerSergey Chebotar <s.chebotar@gmail.com>2022-02-08 17:26:05 +0300
commitacaea679201b5b05af705ef3f6af632ec5bddc81 (patch)
tree06889b658d8620fbf6736e2b4879463b3a7bd35b
parent0b5bea215529e6d8aa2b76197cf3fe8a49a9e2b7 (diff)
Throw exception if template target file is open
-rw-r--r--src/PriceListTools/AbstractTool.cs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/PriceListTools/AbstractTool.cs b/src/PriceListTools/AbstractTool.cs
index f959fb5..d312315 100644
--- a/src/PriceListTools/AbstractTool.cs
+++ b/src/PriceListTools/AbstractTool.cs
@@ -3,6 +3,7 @@ using Microsoft.Office.Interop.Excel;
using RehauSku.Interface;
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Windows.Forms;
using Application = Microsoft.Office.Interop.Excel.Application;
using ProgressBar = RehauSku.Interface.ProgressBar;
@@ -18,6 +19,19 @@ namespace RehauSku.PriceListTools
public void OpenNewPrice()
{
+ if (ExcelApp.Workbooks
+ .Cast<Workbook>()
+ .FirstOrDefault(w => w.FullName == RegistryUtil.PriceListPath) != null)
+ {
+ MessageBox.Show
+ ("Шаблонный файл редактируется в другом месте",
+ "Ошибка открытия шаблонного прайс-листа",
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+
+ throw new ArgumentException("Шаблонный файл редактируется в другом месте");
+ }
+
Workbook wb = ExcelApp.Workbooks.Open(RegistryUtil.PriceListPath, null, true);
try