From 98b2b0adba46fd990d2c58413b833175c2f49b52 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Wed, 22 Mar 2023 10:54:52 +0100 Subject: [PATCH] das ist alles gar nicht so einfach --- ENI2/Controls/MaerskListControl.xaml.cs | 33 ++++++++++++++++--------- ENI2/ENI2.csproj | 2 +- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ENI2/Controls/MaerskListControl.xaml.cs b/ENI2/Controls/MaerskListControl.xaml.cs index 57647754..bf334d66 100644 --- a/ENI2/Controls/MaerskListControl.xaml.cs +++ b/ENI2/Controls/MaerskListControl.xaml.cs @@ -375,17 +375,18 @@ namespace ENI2.Controls List importData = new List(); bool isFirstRow = true; - int currentRow = 1; + int currentRow = 0; bool imosAreOkay = true; try { while (reader.Read()) { + currentRow++; if (isFirstRow) { - isFirstRow = false; // this must be a header row, skip + isFirstRow = false; // this must be a header row, skip continue; } @@ -435,22 +436,30 @@ namespace ENI2.Controls { if (Int32.TryParse(md.ColF, out int imo)) { - if ((imo < 1000000) && (imo > 9999999)) + if ((imo < 1000000) || (imo > 9999999)) { imosAreOkay = false; } - } - if(!imosAreOkay) + } + else { - MessageBox.Show($"Invalid IMO in row {currentRow}, aborting import", Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error); - break; - } - } - + imosAreOkay = false; + } + } + else + { + imosAreOkay = false; + } + + if (!imosAreOkay) + { + MessageBox.Show($"Invalid IMO in row {currentRow}, aborting import", Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error); + break; + } + importData.Add(md); - if (isFirstRow) isFirstRow = false; - currentRow++; + if (isFirstRow) isFirstRow = false; } } catch (Exception ex) diff --git a/ENI2/ENI2.csproj b/ENI2/ENI2.csproj index 8141c294..a44e8a83 100644 --- a/ENI2/ENI2.csproj +++ b/ENI2/ENI2.csproj @@ -36,7 +36,7 @@ 5.4.0.0 true publish.html - 5 + 8 7.10.0.%2a false true