diff --git a/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs b/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs index 4a86d304..acfc8e62 100644 --- a/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs +++ b/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs @@ -72,7 +72,7 @@ namespace ENI2.DetailViewControls this.textBoxENI.IsReadOnly = !iAmAdmin; this.textBoxIMO.IsReadOnly = !iAmAdmin; this.locodePoC.IsEnabled = iAmAdmin; - this.textBoxDisplayId.IsReadOnly = !iAmAdmin; + this.textBoxDisplayId.IsReadOnly = !iAmAdmin; this.textBoxENI.DataContext = this.Core; this.textBoxIMO.DataContext = this.Core; diff --git a/ENI2/EditControls/CompareExcelDialog.xaml.cs b/ENI2/EditControls/CompareExcelDialog.xaml.cs index 96d2ec90..36429513 100644 --- a/ENI2/EditControls/CompareExcelDialog.xaml.cs +++ b/ENI2/EditControls/CompareExcelDialog.xaml.cs @@ -3,6 +3,7 @@ // using bsmd.database; +using Microsoft.Win32; using System; using System.Diagnostics; using System.IO; @@ -174,15 +175,26 @@ namespace ENI2.EditControls private void buttonCompare_Click(object sender, RoutedEventArgs e) { Util.UIHelper.SetBusyState(); - string resultPath = Excel.ExcelComparer.Compare(_sourcePath, _targetPath, out string errorMessage); - if(!errorMessage.IsNullOrEmpty()) { - MessageBox.Show(errorMessage, "Comparison error", MessageBoxButton.OK, MessageBoxImage.Warning); - } - if(File.Exists(resultPath)) + + string defaultName = string.Format("{0}.xlsx", Guid.NewGuid().ToString()); + SaveFileDialog sfd = new SaveFileDialog { - if(new FileInfo(resultPath).Length > 0) + Filter = "Excel Files|*.xls;*.xlsx", + FileName = defaultName + }; + + if (sfd.ShowDialog() ?? false) + { + string resultPath = Excel.ExcelComparer.Compare(_sourcePath, _targetPath, sfd.FileName, out string errorMessage); + if (!errorMessage.IsNullOrEmpty()) { + MessageBox.Show(errorMessage, "Comparison error", MessageBoxButton.OK, MessageBoxImage.Warning); + } + if (File.Exists(resultPath)) { - Process.Start(resultPath); + if (new FileInfo(resultPath).Length > 0) + { + Process.Start(resultPath); + } } } diff --git a/ENI2/EditControls/CopyDeclarationDialog.xaml.cs b/ENI2/EditControls/CopyDeclarationDialog.xaml.cs index 5ad407cd..3e32da9b 100644 --- a/ENI2/EditControls/CopyDeclarationDialog.xaml.cs +++ b/ENI2/EditControls/CopyDeclarationDialog.xaml.cs @@ -23,7 +23,7 @@ namespace ENI2.EditControls { InitializeComponent(); Loaded += CopyDeclarationDialog_Loaded; - } + } #region Properties diff --git a/ENI2/EditControls/VisitIdDialog.xaml.cs b/ENI2/EditControls/VisitIdDialog.xaml.cs index 7c785d9b..ae152674 100644 --- a/ENI2/EditControls/VisitIdDialog.xaml.cs +++ b/ENI2/EditControls/VisitIdDialog.xaml.cs @@ -38,7 +38,7 @@ namespace ENI2.EditControls this.EnableOK(false); this.locodePoC.PropertyChanged += LocodePoC_PropertyChanged; - } + } private void VisitIdDialog_OKClicked() { diff --git a/ENI2/Excel/ExcelComparer.cs b/ENI2/Excel/ExcelComparer.cs index 1e9b6c0e..a78a8e4d 100644 --- a/ENI2/Excel/ExcelComparer.cs +++ b/ENI2/Excel/ExcelComparer.cs @@ -61,17 +61,16 @@ namespace ENI2.Excel return columnName; } - public static string Compare(string sourcePath, string targetPath, out string errorMessage) - { - string fileName = Path.GetTempPath() + Guid.NewGuid().ToString() + ".xlsx"; + public static string Compare(string sourcePath, string targetPath, string comparisonFileName, out string errorMessage) + { errorMessage = ""; int counter = 0; try { - File.Copy(targetPath, fileName); + File.Copy(targetPath, comparisonFileName); ExcelReader source = new ExcelReader(sourcePath, true, false); - ExcelReader comparison = new ExcelReader(fileName, false, false); + ExcelReader comparison = new ExcelReader(comparisonFileName, false, false); /* erste Variante Vergleich über Namen der Zellen @@ -182,7 +181,9 @@ namespace ENI2.Excel } } - comparison.Save(fileName); + comparison.Save(comparisonFileName); + source.Dispose(); + comparison.Dispose(); errorMessage = string.Format("{0} differences found", counter); } catch (Exception ex) @@ -190,7 +191,7 @@ namespace ENI2.Excel errorMessage = ex.Message; } - return fileName; + return comparisonFileName; } }