aboutsummaryrefslogtreecommitdiff
path: root/Source/PriceListTools
diff options
context:
space:
mode:
Diffstat (limited to 'Source/PriceListTools')
-rw-r--r--Source/PriceListTools/ExportTool.cs22
-rw-r--r--Source/PriceListTools/MergeTool.cs43
2 files changed, 58 insertions, 7 deletions
diff --git a/Source/PriceListTools/ExportTool.cs b/Source/PriceListTools/ExportTool.cs
index 02def5b..0a28bf3 100644
--- a/Source/PriceListTools/ExportTool.cs
+++ b/Source/PriceListTools/ExportTool.cs
@@ -74,12 +74,30 @@ namespace RehauSku.PriceListTools
public void ExportToNewFile()
{
+ if (SkuAmount.Count < 1)
+ {
+ return;
+ }
+
string exportFile = PriceListUtil.CreateNewExportFile();
Workbook wb = ExcelApp.Workbooks.Open(exportFile);
- PriceList priceList = new PriceList(wb);
- if (priceList.IsValid())
+ try
+ {
+ PriceList priceList = new PriceList(wb);
priceList.Fill(SkuAmount);
+ }
+
+ catch(Exception ex)
+ {
+ System.Windows.Forms.MessageBox.Show
+ ($"{RegistryUtil.PriceListPath} не является файлом прайслиста \n\n {ex.Message}",
+ "Неверный файл прайс-листа!",
+ System.Windows.Forms.MessageBoxButtons.OK,
+ System.Windows.Forms.MessageBoxIcon.Error);
+
+ wb.Close();
+ }
}
public void Dispose()
diff --git a/Source/PriceListTools/MergeTool.cs b/Source/PriceListTools/MergeTool.cs
index 21da41d..6b0644d 100644
--- a/Source/PriceListTools/MergeTool.cs
+++ b/Source/PriceListTools/MergeTool.cs
@@ -22,23 +22,56 @@ namespace RehauSku.PriceListTools
foreach (string file in files)
{
Workbook wb = ExcelApp.Workbooks.Open(file);
- PriceList priceList = new PriceList(wb);
- if (priceList.IsValid())
+ try
+ {
+ PriceList priceList = new PriceList(wb);
SkuAmount.AddValues(priceList);
+ }
- wb.Close();
+ catch (Exception ex)
+ {
+ System.Windows.Forms.MessageBox.Show
+ ( $"{wb.Name} не является файлом прайслиста \n\n {ex.Message}",
+ "Неверный файл прайс-листа!",
+ System.Windows.Forms.MessageBoxButtons.OK,
+ System.Windows.Forms.MessageBoxIcon.Error);
+ }
+
+ finally
+ {
+ wb.Close();
+ }
}
ExcelApp.ScreenUpdating = true;
}
public void ExportToNewFile(string exportFile)
{
+ if (SkuAmount.Count < 1)
+ {
+ return;
+ }
+
Workbook wb = ExcelApp.Workbooks.Open(exportFile);
- PriceList priceList = new PriceList(wb);
+ PriceList priceList;
- if (priceList.IsValid())
+ try
+ {
+ priceList = new PriceList(wb);
priceList.Fill(SkuAmount);
+ }
+
+ catch (Exception ex)
+ {
+ System.Windows.Forms.MessageBox.Show
+ ($"{RegistryUtil.PriceListPath} не является файлом прайслиста \n\n {ex.Message}",
+ "Неверный файл прайс-листа!",
+ System.Windows.Forms.MessageBoxButtons.OK,
+ System.Windows.Forms.MessageBoxIcon.Error);
+
+ wb.Close();
+ }
}
public void Dispose()