diff --git a/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs b/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs
index 31f2df4a..23315ba9 100644
--- a/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs
@@ -79,16 +79,24 @@ namespace ENI2.Controls
public string LocodeValue
{
get { return (string)GetValue(LocodeValueProperty); }
- set { SetValue(LocodeValueProperty, value); }
+ set { SetValue(LocodeValueProperty, value); }
}
+ private static object LocodeValue_CoerceValue(DependencyObject dobj, object Value)
+ {
+ //called whenever dependency property value is reevaluated. The return value is the
+ //latest value set to the dependency property
+ // MessageBox.Show(string.Format("CoerceValue is fired : Value {0}", Value));
+ return Value;
+ }
+
+
public RuleEngine.LocodeMode LocodeSource { get; set; }
#region static methods
public static readonly DependencyProperty LocodeValueProperty = DependencyProperty.Register("LocodeValue", typeof(string), typeof(LocodeControl),
- new UIPropertyMetadata(LocodeValueChangedHandler));
-
+ new UIPropertyMetadata(null, LocodeValueChangedHandler, LocodeValue_CoerceValue));
public static void LocodeValueChangedHandler(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
@@ -209,6 +217,7 @@ namespace ENI2.Controls
this.LocodeValue = this.SelectedItem;
}
}
+ this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocodeList"));
}
#endregion
diff --git a/ENI-2/ENI2/ENI2/DetailBaseControl.cs b/ENI-2/ENI2/ENI2/DetailBaseControl.cs
index 1732693b..a3633167 100644
--- a/ENI-2/ENI2/ENI2/DetailBaseControl.cs
+++ b/ENI-2/ENI2/ENI2/DetailBaseControl.cs
@@ -76,6 +76,11 @@ namespace ENI2
///
public event Action RequestDisable;
+ ///
+ /// Damit kann aus einer Anmeldung heraus die Kopier-Logik ausgelöst werden
+ ///
+ public event Action RequestCopy;
+
///
/// Eine in der Detailansicht enthaltene Meldeklasse hat sich geändert
///
@@ -165,6 +170,11 @@ namespace ENI2
this.RequestDisable?.Invoke();
}
+ protected virtual void OnRequestCopy()
+ {
+ this.RequestCopy?.Invoke();
+ }
+
protected virtual void OnControlCacheReset(string messageGroupName)
{
this.ResetControlCache?.Invoke(messageGroupName);
diff --git a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs
index 207e8b7c..8efd70de 100644
--- a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs
@@ -50,6 +50,8 @@ namespace ENI2
internal event DatabaseEntityWatchdog.DatabaseEntityChangedHandler HighlightReset;
+ internal event Action OpenNewCoreRequested;
+
public bool HasUnsavedChanges
{
get { return (this.buttonSave.Visibility == Visibility.Visible); } // schwach aber es wird's tun
@@ -159,6 +161,7 @@ namespace ENI2
detailControl.ResetControlCache += DetailControl_ResetControlCache;
detailControl.RequestValidate += DetailControl_RequestValidate;
detailControl.RequestDisable += DetailControl_RequestDisable;
+ detailControl.RequestCopy += DetailControl_RequestCopy;
detailControl.RequestSendValidation += DetailControl_RequestSendValidation;
detailControl.Initialize();
@@ -192,7 +195,52 @@ namespace ENI2
detailView.Children.Add(controlCache[mg.MessageGroupName]);
}
- }
+ }
+
+ private void DetailControl_RequestCopy()
+ {
+ CopyDeclarationDialog cdd = new CopyDeclarationDialog();
+ MessageCore newCore = new MessageCore();
+ cdd.NewCore = newCore;
+ cdd.OldCore = this.Core;
+
+ cdd.IsModal = false;
+ cdd.Closed += (senderDialog, closeArgs) =>
+ {
+ CopyDeclarationDialog closedDialog = senderDialog as CopyDeclarationDialog;
+ if (closedDialog.IsOK)
+ {
+ if (!closedDialog.NewCore.IsDK && closedDialog.NewCore.VisitId.IsNullOrEmpty() && closedDialog.NewCore.TransitId.IsNullOrEmpty())
+ {
+ // deutsche Häfen fordern eine Visit-Id an, für DK erfolgt hier nur die Anlage eines Datensatzes
+ closedDialog.NewCore.BSMDStatusInternal = MessageCore.BSMDStatus.TOSEND;
+ }
+
+ if (closedDialog.NewCore.PoC.Equals("ZZNOK"))
+ closedDialog.NewCore.IsTransit = true;
+
+ closedDialog.NewCore.Incoming = true;
+ closedDialog.NewCore.DefaultReportingPartyId = this.LockedBy.Id;
+ DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(newCore);
+
+ // Meldeklassen für neuen Anlauf erzeugen
+ List newMessages = new List();
+ foreach (Message oldMessage in this._messages)
+ {
+ Message newMessage = oldMessage.Clone() as Message;
+ newMessage.MessageCore = newCore;
+ newMessage.MessageCoreId = newCore.Id;
+ DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(newMessage);
+ newMessage.SaveElements();
+ }
+ //
+
+
+ this.OnOpenNewCoreRequested(newCore);
+ }
+ };
+ cdd.Show();
+ }
private void DetailControl_RequestDisable()
{
@@ -604,6 +652,11 @@ namespace ENI2
this.HighlightReset?.Invoke(this.Core);
}
+ protected virtual void OnOpenNewCoreRequested(MessageCore newCore)
+ {
+ this.OpenNewCoreRequested?.Invoke(newCore);
+ }
+
private DependencyObject GetContainerForMessageGroupName(string messageGroupName)
{
if (controlCache.ContainsKey(messageGroupName))
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml
index ccb12adc..91421d0f 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml
@@ -79,7 +79,7 @@
-
+
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
index 983a3dd2..5553abec 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
@@ -532,7 +532,7 @@ namespace ENI2.DetailViewControls
private void buttonCopy_Click(object sender, RoutedEventArgs e)
{
-
+ this.OnRequestCopy();
}
private void buttonSendPDF_Click(object sender, RoutedEventArgs e)
diff --git a/ENI-2/ENI2/ENI2/ENI2.csproj b/ENI-2/ENI2/ENI2/ENI2.csproj
index 32186dff..11102102 100644
--- a/ENI-2/ENI2/ENI2/ENI2.csproj
+++ b/ENI-2/ENI2/ENI2/ENI2.csproj
@@ -35,8 +35,8 @@
3.5.1.0
true
publish.html
- 1
- 5.0.1.%2a
+ 0
+ 5.0.3.%2a
false
true
true
@@ -237,6 +237,9 @@
AboutDialog.xaml
+
+ CopyDeclarationDialog.xaml
+
CoreStatusInfoDialog.xaml
@@ -445,6 +448,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -673,6 +680,9 @@
+
+
+
Always
diff --git a/ENI-2/ENI2/ENI2/EditControls/CopyDeclarationDialog.xaml b/ENI-2/ENI2/ENI2/EditControls/CopyDeclarationDialog.xaml
new file mode 100644
index 00000000..dafc35bd
--- /dev/null
+++ b/ENI-2/ENI2/ENI2/EditControls/CopyDeclarationDialog.xaml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ENI-2/ENI2/ENI2/EditControls/CopyDeclarationDialog.xaml.cs b/ENI-2/ENI2/ENI2/EditControls/CopyDeclarationDialog.xaml.cs
new file mode 100644
index 00000000..d142f538
--- /dev/null
+++ b/ENI-2/ENI2/ENI2/EditControls/CopyDeclarationDialog.xaml.cs
@@ -0,0 +1,155 @@
+// Copyright (c) 2017 schick Informatik
+// Description: Dialog, um aus einer alten Anmeldung eine neue zu machen
+//
+
+
+using ENI2.Controls;
+using bsmd.database;
+using System.Collections.Generic;
+using System;
+using bsmd.ExcelReadService;
+using System.ComponentModel;
+
+namespace ENI2.EditControls
+{
+ ///
+ /// Interaction logic for CopyDeclarationDialog.xaml
+ ///
+ public partial class CopyDeclarationDialog : EditWindowBase
+ {
+ private bool _isOK = false;
+
+ public CopyDeclarationDialog()
+ {
+ InitializeComponent();
+ Loaded += CopyDeclarationDialog_Loaded;
+ }
+
+ private void CopyDeclarationDialog_Loaded(object sender, System.Windows.RoutedEventArgs e)
+ {
+ this.OKClicked += VisitIdDialog_OKClicked;
+ List> comboDataSource = new List>()
+ {
+ new KeyValuePair( Message.NSWProvider.DBH, "DBH live" ),
+ new KeyValuePair( Message.NSWProvider.DBH_TEST, "DBH Testsystem" ),
+ new KeyValuePair( Message.NSWProvider.DUDR, "HIS-Nord live" ),
+ new KeyValuePair( Message.NSWProvider.DUDR_TEST, "HIS-Nord Testsystem" )
+ };
+
+ this.comboBoxInitialHIS.ItemsSource = comboDataSource;
+ this.comboBoxInitialHIS.SelectedIndex = 2;
+
+ this.EnableOK(false);
+ this.locodePoC.PropertyChanged += LocodePoC_PropertyChanged;
+
+ if (!this.OldCore.IMO.IsNullOrEmpty()) this.doubleUpDownIMO.Value = Double.Parse(this.OldCore.IMO);
+ if (!this.OldCore.ENI.IsNullOrEmpty()) this.doubleUpDownENI.Value = Double.Parse(this.OldCore.ENI);
+ if (!this.OldCore.PoC.IsNullOrEmpty()) this.locodePoC.LocodeValue = this.OldCore.PoC;
+ if (this.OldCore.ETA.HasValue) this.datePickerETA.SelectedDate = this.OldCore.ETA;
+
+ }
+
+ #region Properties
+
+ public MessageCore OldCore { get; set; }
+
+ public MessageCore NewCore { get; set; }
+
+ public bool IsOK { get { return this._isOK; } }
+
+ #endregion
+
+ #region completion logic
+
+ private void CheckComplete()
+ {
+ bool isComplete = true;
+
+ isComplete &= this.datePickerETA.SelectedDate.HasValue; // ETA
+
+ bool imo_OR_eni = ((doubleUpDownIMO.Value.HasValue) && (doubleUpDownIMO.Value >= 1000000) && (doubleUpDownIMO.Value <= 9999999)) ||
+ ((doubleUpDownENI.Value.HasValue) && (doubleUpDownENI.Value >= 100000) && (doubleUpDownENI.Value <= 99999999));
+
+ isComplete &= imo_OR_eni;
+
+ string locode = this.locodePoC.LocodeValue;
+ bool validLocode = (locode != null) && (locode.Length == 5) && (locode.StartsWith("DE") || locode.StartsWith("DK") || locode.Equals("ZZNOK"));
+
+ isComplete &= validLocode;
+
+ isComplete &= (comboBoxInitialHIS.SelectedValue != null);
+
+ this.EnableOK(isComplete);
+
+ }
+
+ #endregion
+
+ #region event handler
+
+ private void LocodePoC_PropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ this.CheckComplete();
+ }
+
+ private void doubleUpDownIMO_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs