Funktionen Version 5.7
This commit is contained in:
parent
6aa3944ee9
commit
97bf74721a
@ -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)
|
||||
{
|
||||
|
||||
@ -99,6 +99,7 @@
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||
<Button Name="buttonImportFromSEC" Margin="2" Content="{x:Static p:Resources.textImportFromSEC}" Width="120" VerticalAlignment="Center" Click="buttonImportFromSEC_Click" Background="Transparent" />
|
||||
<Button Name="buttonImportFromExcel" Margin="2" Content="{x:Static p:Resources.textImportFromExcel}" Width="120" VerticalAlignment="Center" Click="ButtonImportFromExcel_Click" Background="Transparent" />
|
||||
<TextBlock Margin="20, 0, 0, 0" Name="textBlockNumPoCEntries" FontWeight="Bold" Text="{Binding PortOfCallLast30Days.Count}" VerticalAlignment="Center"/>
|
||||
<Label Name="labelPoCEntryCount" Content="{x:Static p:Resources.textEntries}" />
|
||||
</StackPanel>
|
||||
|
||||
@ -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<PortOfCallLast30Days> importPoC30 = new List<PortOfCallLast30Days>();
|
||||
|
||||
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
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
9
ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs
generated
9
ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs
generated
@ -3413,6 +3413,15 @@ namespace ENI2.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} port entries imported.
|
||||
/// </summary>
|
||||
public static string textPoC30Imported {
|
||||
get {
|
||||
return ResourceManager.GetString("textPoC30Imported", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Pollution category.
|
||||
/// </summary>
|
||||
|
||||
@ -1432,7 +1432,7 @@
|
||||
<data name="textCopyToHAZD" xml:space="preserve">
|
||||
<value>Copy to HAZD</value>
|
||||
</data>
|
||||
<data name="textCopyToBKRD">
|
||||
<data name="textCopyToBKRD" xml:space="preserve">
|
||||
<value>Copy to BKRD</value>
|
||||
</data>
|
||||
<data name="hand_red_card" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
@ -1699,4 +1699,7 @@
|
||||
<data name="textShowData" xml:space="preserve">
|
||||
<value>Show data</value>
|
||||
</data>
|
||||
<data name="textPoC30Imported" xml:space="preserve">
|
||||
<value>{0} port entries imported</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -68,6 +68,9 @@
|
||||
<Setter Property="Background" Value="LightGray"></Setter>
|
||||
<Setter Property="Foreground" Value="Gray"></Setter>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding UnsentATAATD}" Value="true">
|
||||
<Setter Property="Foreground" Value="Red"></Setter>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
|
||||
Binary file not shown.
@ -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();
|
||||
}
|
||||
|
||||
@ -261,6 +261,11 @@ namespace bsmd.database
|
||||
/// </summary>
|
||||
public DateTime? ATD { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Helper display prop to highlight cores with unsent ATA/ATD
|
||||
/// </summary>
|
||||
public bool? UnsentATAATD { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Validation flag (set from STAT, GrossTonnage < 500)
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user