diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2022-01-28 16:19:39 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2022-01-28 16:19:39 +0300 |
commit | 42c06d00e3720b8ac263d3e76c6d4fb724dca970 (patch) | |
tree | 2b3ba49fd956538e41f0cb86b5d0ba7496ed3dd6 /src/PriceListTools | |
parent | 2b3937ac2f1832ef89d28565c43464397384b571 (diff) |
Move GetSourceFiles to Source class
Diffstat (limited to 'src/PriceListTools')
-rw-r--r-- | src/PriceListTools/PriceListTool.cs | 1 | ||||
-rw-r--r-- | src/PriceListTools/Source.cs | 34 | ||||
-rw-r--r-- | src/PriceListTools/SourceUtil.cs | 41 |
3 files changed, 34 insertions, 42 deletions
diff --git a/src/PriceListTools/PriceListTool.cs b/src/PriceListTools/PriceListTool.cs index 74aec56..bf658f8 100644 --- a/src/PriceListTools/PriceListTool.cs +++ b/src/PriceListTools/PriceListTool.cs @@ -54,6 +54,7 @@ namespace RehauSku.PriceListTools protected private void FillPosition(KeyValuePair<Position, double> kvp, int[] columns) { Range foundCell = TargetFile.skuCell.EntireColumn.Find(kvp.Key.Sku); + if (foundCell == null) { Missing.Add(kvp); diff --git a/src/PriceListTools/Source.cs b/src/PriceListTools/Source.cs index 2f1e7ce..5013157 100644 --- a/src/PriceListTools/Source.cs +++ b/src/PriceListTools/Source.cs @@ -1,4 +1,5 @@ -using Microsoft.Office.Interop.Excel; +using ExcelDna.Integration; +using Microsoft.Office.Interop.Excel; using System; using System.Collections.Generic; @@ -31,6 +32,37 @@ namespace RehauSku.PriceListTools CreatePositionsDict(); } + public static List<Source> GetSourceLists(string[] files) + { + var ExcelApp = (Application)ExcelDnaUtil.Application; + + List<Source> sourceFiles = new List<Source>(); + + ExcelApp.ScreenUpdating = false; + foreach (string file in files) + { + Workbook wb = ExcelApp.Workbooks.Open(file); + try + { + Source priceList = new Source(wb); + sourceFiles.Add(priceList); + 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; + + return sourceFiles; + } + private void CreatePositionsDict() { PositionAmount = new Dictionary<Position, double>(); diff --git a/src/PriceListTools/SourceUtil.cs b/src/PriceListTools/SourceUtil.cs deleted file mode 100644 index 5c575f6..0000000 --- a/src/PriceListTools/SourceUtil.cs +++ /dev/null @@ -1,41 +0,0 @@ -using ExcelDna.Integration; -using Microsoft.Office.Interop.Excel; -using System; -using System.Collections.Generic; - -namespace RehauSku.PriceListTools -{ - internal static class SourceUtil - { - public static List<Source> GetSourceLists(string[] files) - { - var ExcelApp = (Application)ExcelDnaUtil.Application; - - List<Source> sourceFiles = new List<Source>(); - - ExcelApp.ScreenUpdating = false; - foreach (string file in files) - { - Workbook wb = ExcelApp.Workbooks.Open(file); - try - { - Source priceList = new Source(wb); - sourceFiles.Add(priceList); - 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; - - return sourceFiles; - } - } -} |