diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs
index 9b198dfb..d6ee6d5d 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs
@@ -24,9 +24,9 @@ namespace ENI2.DetailViewControls
{
private Message _bpolMessage;
private Message _crewMessage;
- private Message _crewdMessage;
+ //private Message _crewdMessage;
private Message _pasMessage;
- private Message _pasdMessage;
+ //private Message _pasdMessage;
private Message _secMessage;
private BPOL _bpol;
private SEC _sec;
@@ -54,8 +54,8 @@ namespace ENI2.DetailViewControls
if (aMessage.MessageNotificationClass == Message.NotificationClass.BPOL) { this._bpolMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.CREW) { this._crewMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.PAS) { this._pasMessage = aMessage; this.ControlMessages.Add(aMessage); }
- if (aMessage.MessageNotificationClass == Message.NotificationClass.CREWD) { this._crewdMessage = aMessage; this.ControlMessages.Add(aMessage); }
- if (aMessage.MessageNotificationClass == Message.NotificationClass.PASD) { this._pasdMessage = aMessage; this.ControlMessages.Add(aMessage); }
+ //if (aMessage.MessageNotificationClass == Message.NotificationClass.CREWD) { this._crewdMessage = aMessage; this.ControlMessages.Add(aMessage); }
+ //if (aMessage.MessageNotificationClass == Message.NotificationClass.PASD) { this._pasdMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.SEC)
{
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml
index 7c4a319b..2a1fafce 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml
@@ -99,6 +99,7 @@
+
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml.cs
index 67b9b065..0fbe3188 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml.cs
@@ -3,12 +3,18 @@
//
using System;
+using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
+using Microsoft.Win32;
+using System.IO;
+
using ENI2.EditControls;
using ENI2.Util;
using bsmd.database;
-using System.Collections.Generic;
+
+using bsmd.ExcelReadService;
+using ExcelDataReader;
namespace ENI2.DetailViewControls
{
@@ -210,6 +216,8 @@ namespace ENI2.DetailViewControls
#endregion
+ #region load/button event handler
+
private void MaritimeHealthDeclarationDetailControl_Loaded(object sender, RoutedEventArgs e)
{
@@ -268,6 +276,82 @@ namespace ENI2.DetailViewControls
}
}
+ private void ButtonImportFromExcel_Click(object sender, RoutedEventArgs e)
+ {
+ OpenFileDialog ofd = new OpenFileDialog
+ {
+ Filter = "Excel Files|*.xls;*.xlsx"
+ };
+ if (ofd.ShowDialog() ?? false)
+ {
+ FileStream stream;
+ try
+ {
+ stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ using (var reader = ExcelReaderFactory.CreateReader(stream))
+ {
+ List importPoC30 = new List();
+
+ try
+ {
+ do
+ {
+ while (reader.Read())
+ {
+ if (reader.FieldCount < 2)
+ {
+ throw new InvalidDataException("Sheet must have at least 2 Columns of data");
+ }
+ PortOfCallLast30Days poc30 = new PortOfCallLast30Days();
+ if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
+ if (!reader.IsDBNull(0)) poc30.PortOfCallLast30DaysLocode = reader.GetString(0);
+ if (!reader.IsDBNull(1)) poc30.PortOfCallLast30DaysDateOfDeparture = reader.GetDateTime(1);
+ // if (DateTime.TryParse(reader.GetString(1), out DateTime dateOfDep))
+ // poc30.PortOfCallLast30DaysDateOfDeparture = dateOfDep;
+ if (!reader.IsDBNull(2) && !reader.GetString(2).IsNullOrEmpty()) poc30.PortOfCallLast30DaysCrewMembersJoined = true;
+
+ for (int colIndex = 2; (colIndex < reader.FieldCount) && !reader.IsDBNull(colIndex); colIndex++)
+ {
+ string crewName = reader.GetString(colIndex);
+ if (crewName.IsNullOrEmpty()) break;
+ PortOfCallLast30DaysCrewJoinedShip poc30Crew = new PortOfCallLast30DaysCrewJoinedShip();
+ poc30Crew.PortOfCallLast30DaysCrewJoinedShipName = crewName;
+ poc30Crew.PortOfCallLast30Days = poc30;
+ poc30.CrewJoinedShip.Add(poc30Crew);
+ }
+
+ poc30.MDH = this._mdh;
+ this._mdh.PortOfCallLast30Days.Add(poc30);
+ importPoC30.Add(poc30);
+ }
+ } while (reader.NextResult());
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+
+ if (importPoC30.Count > 0)
+ {
+ this.dataGridPortOfCallLast30Days.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ MessageBox.Show(String.Format(Properties.Resources.textPoC30Imported, importPoC30.Count), Properties.Resources.textCaptionInformation,
+ MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ }
+
+ stream.Close();
+ }
+ }
+
+ #endregion
#region SanitaryMeasures Grid
@@ -520,6 +604,6 @@ namespace ENI2.DetailViewControls
}
#endregion
-
+
}
}
diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs
index 42fd7a22..ea3ac85a 100644
--- a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs
+++ b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs
@@ -3413,6 +3413,15 @@ namespace ENI2.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to {0} port entries imported.
+ ///
+ public static string textPoC30Imported {
+ get {
+ return ResourceManager.GetString("textPoC30Imported", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Pollution category.
///
diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.resx b/ENI-2/ENI2/ENI2/Properties/Resources.resx
index 08698c38..3b6b23f4 100644
--- a/ENI-2/ENI2/ENI2/Properties/Resources.resx
+++ b/ENI-2/ENI2/ENI2/Properties/Resources.resx
@@ -1432,7 +1432,7 @@
Copy to HAZD
-
+
Copy to BKRD
@@ -1699,4 +1699,7 @@
Show data
+
+ {0} port entries imported
+
\ No newline at end of file
diff --git a/ENI-2/ENI2/ENI2/SucheControl.xaml b/ENI-2/ENI2/ENI2/SucheControl.xaml
index 6e803368..2f9050ef 100644
--- a/ENI-2/ENI2/ENI2/SucheControl.xaml
+++ b/ENI-2/ENI2/ENI2/SucheControl.xaml
@@ -68,6 +68,9 @@
+
+
+
diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx
index cb0afd2d..1cc6b60b 100644
Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ
diff --git a/nsw/Source/bsmd.database/DBManager.cs b/nsw/Source/bsmd.database/DBManager.cs
index 0211f6f4..cb183cb6 100644
--- a/nsw/Source/bsmd.database/DBManager.cs
+++ b/nsw/Source/bsmd.database/DBManager.cs
@@ -1316,12 +1316,18 @@ namespace bsmd.database
if (core == null) return;
using (SqlCommand cmd = new SqlCommand())
{
- cmd.CommandText = "SELECT ATA.ATAPortOfCall FROM ATA JOIN MessageHeader ON ATA.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
+ cmd.CommandText = "SELECT MessageHeader.BSMDStatus, ATA.ATAPortOfCall FROM ATA JOIN MessageHeader ON ATA.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
cmd.Parameters.AddWithValue("@ID", core.Id);
SqlDataReader reader = this.PerformCommand(cmd);
if (reader.Read())
{
- if (!reader.IsDBNull(0)) core.ATA = reader.GetDateTime(0);
+ Message.BSMDStatus status = Message.BSMDStatus.UNDEFINED;
+ if (!reader.IsDBNull(0)) status = (Message.BSMDStatus)Enum.ToObject(typeof(Message.BSMDStatus), reader.GetByte(0));
+ if (!reader.IsDBNull(1))
+ {
+ core.ATA = reader.GetDateTime(1);
+ core.UnsentATAATD |= (status == Message.BSMDStatus.SAVED) || (status == Message.BSMDStatus.EXCEL) || (status == Message.BSMDStatus.UPDATED);
+ }
}
reader.Close();
}
@@ -1332,12 +1338,18 @@ namespace bsmd.database
if (core == null) return;
using (SqlCommand cmd = new SqlCommand())
{
- cmd.CommandText = "SELECT ATD.ATDPortOfCall FROM ATD JOIN MessageHeader ON ATD.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
+ cmd.CommandText = "SELECT MessageHeader.BSMDStatus, ATD.ATDPortOfCall FROM ATD JOIN MessageHeader ON ATD.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
cmd.Parameters.AddWithValue("@ID", core.Id);
SqlDataReader reader = this.PerformCommand(cmd);
if (reader.Read())
{
- if (!reader.IsDBNull(0)) core.ATD = reader.GetDateTime(0);
+ Message.BSMDStatus status = Message.BSMDStatus.UNDEFINED;
+ if (!reader.IsDBNull(0)) status = (Message.BSMDStatus)Enum.ToObject(typeof(Message.BSMDStatus), reader.GetByte(0));
+ if (!reader.IsDBNull(1))
+ {
+ core.ATD = reader.GetDateTime(1);
+ core.UnsentATAATD |= (status == Message.BSMDStatus.SAVED) || (status == Message.BSMDStatus.EXCEL) || (status == Message.BSMDStatus.UPDATED);
+ }
}
reader.Close();
}
diff --git a/nsw/Source/bsmd.database/MessageCore.cs b/nsw/Source/bsmd.database/MessageCore.cs
index 5f109574..5af0e493 100644
--- a/nsw/Source/bsmd.database/MessageCore.cs
+++ b/nsw/Source/bsmd.database/MessageCore.cs
@@ -261,6 +261,11 @@ namespace bsmd.database
///
public DateTime? ATD { get; set; }
+ ///
+ /// Helper display prop to highlight cores with unsent ATA/ATD
+ ///
+ public bool? UnsentATAATD { get; set; }
+
///
/// Validation flag (set from STAT, GrossTonnage < 500)
///