Exception message on wrong files
This commit is contained in:
parent
94e0c84ce1
commit
233c91c71b
@ -36,8 +36,12 @@ namespace RehauSku.PriceListTools
|
|||||||
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
System.Windows.Forms.MessageBox.Show
|
||||||
|
(ex.Message,
|
||||||
|
"Ошибка открытия шаблонного прайс-листа",
|
||||||
|
System.Windows.Forms.MessageBoxButtons.OK,
|
||||||
|
System.Windows.Forms.MessageBoxIcon.Information);
|
||||||
wb.Close();
|
wb.Close();
|
||||||
throw ex;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,10 +56,22 @@ namespace RehauSku.PriceListTools
|
|||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
Workbook wb = ExcelApp.Workbooks.Open(file);
|
Workbook wb = ExcelApp.Workbooks.Open(file);
|
||||||
|
try
|
||||||
|
{
|
||||||
PriceList priceList = new PriceList(wb);
|
PriceList priceList = new PriceList(wb);
|
||||||
sourcePriceLists.Add(priceList);
|
sourcePriceLists.Add(priceList);
|
||||||
wb.Close();
|
wb.Close();
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.Windows.Forms.MessageBox.Show
|
||||||
|
(ex.Message,
|
||||||
|
"Ошибка открытия исходного прайс-листа",
|
||||||
|
System.Windows.Forms.MessageBoxButtons.OK,
|
||||||
|
System.Windows.Forms.MessageBoxIcon.Information);
|
||||||
|
wb.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
ExcelApp.ScreenUpdating = true;
|
ExcelApp.ScreenUpdating = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,16 +75,16 @@ namespace RehauSku.PriceListTools
|
|||||||
|
|
||||||
public override void FillPriceList()
|
public override void FillPriceList()
|
||||||
{
|
{
|
||||||
if (SkuAmount.Count < 1) return;
|
if (SkuAmount.Count < 1)
|
||||||
|
return;
|
||||||
PriceList offer = NewPriceList;
|
|
||||||
offer.Sheet.Activate();
|
|
||||||
|
|
||||||
int exportedValues = 0;
|
int exportedValues = 0;
|
||||||
|
|
||||||
|
ExcelApp.ScreenUpdating = false;
|
||||||
|
|
||||||
foreach (var kvp in SkuAmount)
|
foreach (var kvp in SkuAmount)
|
||||||
{
|
{
|
||||||
Range cell = offer.Sheet.Columns[offer.skuCell.Column].Find(kvp.Key);
|
Range cell = NewPriceList.Sheet.Columns[NewPriceList.skuCell.Column].Find(kvp.Key);
|
||||||
|
|
||||||
if (cell == null)
|
if (cell == null)
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ namespace RehauSku.PriceListTools
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Range sumCell = offer.Sheet.Cells[cell.Row, offer.amountCell.Column];
|
Range sumCell = NewPriceList.Sheet.Cells[cell.Row, NewPriceList.amountCell.Column];
|
||||||
|
|
||||||
if (sumCell.Value2 == null)
|
if (sumCell.Value2 == null)
|
||||||
sumCell.Value2 = kvp.Value;
|
sumCell.Value2 = kvp.Value;
|
||||||
@ -107,7 +107,10 @@ namespace RehauSku.PriceListTools
|
|||||||
exportedValues++;
|
exportedValues++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterByAmount();
|
FilterByAmount();
|
||||||
|
ExcelApp.ScreenUpdating = true;
|
||||||
|
|
||||||
AddIn.Excel.StatusBar = $"Экспортировано {exportedValues} строк из {SkuAmount.Count}";
|
AddIn.Excel.StatusBar = $"Экспортировано {exportedValues} строк из {SkuAmount.Count}";
|
||||||
Forms.Dialog.SaveWorkbookAs();
|
Forms.Dialog.SaveWorkbookAs();
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ namespace RehauSku.PriceListTools
|
|||||||
{
|
{
|
||||||
int exportedValues = 0;
|
int exportedValues = 0;
|
||||||
|
|
||||||
|
ExcelApp.ScreenUpdating = false;
|
||||||
|
|
||||||
foreach (var sheet in sourcePriceLists)
|
foreach (var sheet in sourcePriceLists)
|
||||||
{
|
{
|
||||||
if (sheet.SkuAmount.Count == 0)
|
if (sheet.SkuAmount.Count == 0)
|
||||||
@ -42,6 +44,8 @@ namespace RehauSku.PriceListTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
FilterByAmount();
|
FilterByAmount();
|
||||||
|
ExcelApp.ScreenUpdating = true;
|
||||||
|
|
||||||
AddIn.Excel.StatusBar = $"Экспортировано {exportedValues} строк из {sourcePriceLists.Count} файлов";
|
AddIn.Excel.StatusBar = $"Экспортировано {exportedValues} строк из {sourcePriceLists.Count} файлов";
|
||||||
Forms.Dialog.SaveWorkbookAs();
|
Forms.Dialog.SaveWorkbookAs();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user