335 lines
13 KiB
C#
335 lines
13 KiB
C#
// Copyright (c) 2017 schick Informatik
|
|
// Description: Detailansicht für BPOL, CREW(D), PAS(D)
|
|
//
|
|
|
|
using System.Collections.Generic;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using ENI2.EditControls;
|
|
|
|
using bsmd.database;
|
|
|
|
namespace ENI2.DetailViewControls
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for BorderPoliceDetailControl.xaml
|
|
/// </summary>
|
|
public partial class BorderPoliceDetailControl : DetailBaseControl
|
|
{
|
|
private Message _bpolMessage;
|
|
private Message _crewMessage;
|
|
private Message _crewdMessage;
|
|
private Message _pasMessage;
|
|
private Message _pasdMessage;
|
|
private BPOL _bpol;
|
|
|
|
public BorderPoliceDetailControl()
|
|
{
|
|
InitializeComponent();
|
|
this.Loaded += BorderPoliceDetailControl_Loaded;
|
|
}
|
|
|
|
private void BorderPoliceDetailControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
this.RegisterCheckboxChange(this.checkBoxCruiseShip, Message.NotificationClass.BPOL);
|
|
this.RegisterCheckboxChange(this.checkBoxStowaways, Message.NotificationClass.BPOL);
|
|
}
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
foreach (Message aMessage in this.Messages)
|
|
{
|
|
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); }
|
|
}
|
|
|
|
#region init BPOL
|
|
|
|
if (this._bpolMessage == null)
|
|
{
|
|
this._bpolMessage = this.Core.CreateMessage(Message.NotificationClass.BPOL);
|
|
this.Messages.Add(this._bpolMessage);
|
|
}
|
|
|
|
BPOL bpol = null;
|
|
if (this._bpolMessage.Elements.Count > 0)
|
|
bpol = this._bpolMessage.Elements[0] as BPOL;
|
|
if (bpol == null)
|
|
{
|
|
bpol = new BPOL();
|
|
bpol.MessageCore = this.Core;
|
|
bpol.MessageHeader = this._bpolMessage;
|
|
_bpolMessage.Elements.Add(bpol);
|
|
}
|
|
|
|
this.groupBoxBorderPolice.DataContext = bpol;
|
|
this._bpol = bpol;
|
|
this.dataGridPortOfItinerary.Initialize();
|
|
this.dataGridPortOfItinerary.ItemsSource = bpol.PortOfItineraries;
|
|
this.dataGridPortOfItinerary.AddingNewItem += DataGridPortOfItinerary_AddingNewItem;
|
|
this.dataGridPortOfItinerary.EditRequested += DataGridPortOfItinerary_EditRequested;
|
|
this.dataGridPortOfItinerary.DeleteRequested += DataGridPortOfItinerary_DeleteRequested;
|
|
this.dataGridPortOfItinerary.CreateRequested += DataGridPortOfItinerary_CreateRequested;
|
|
|
|
#endregion
|
|
|
|
#region init CREW
|
|
|
|
if (this._crewMessage == null)
|
|
{
|
|
this._crewMessage = this.Core.CreateMessage(Message.NotificationClass.CREW);
|
|
this.Messages.Add(this._crewMessage);
|
|
}
|
|
|
|
this.dataGridCrewList.Initialize();
|
|
this.dataGridCrewList.ItemsSource = this._crewMessage.Elements;
|
|
this.dataGridCrewList.AddingNewItem += DataGridCrewList_AddingNewItem;
|
|
this.dataGridCrewList.EditRequested += DataGridCrewList_EditRequested;
|
|
this.dataGridCrewList.DeleteRequested += DataGridCrewList_DeleteRequested;
|
|
this.dataGridCrewList.CreateRequested += DataGridCrewList_CreateRequested;
|
|
|
|
#endregion
|
|
|
|
#region init PAS
|
|
|
|
if (this._pasMessage == null)
|
|
{
|
|
this._pasMessage = this.Core.CreateMessage(Message.NotificationClass.PAS);
|
|
this.Messages.Add(this._pasMessage);
|
|
}
|
|
|
|
this.dataGridPassengerList.Initialize();
|
|
this.dataGridPassengerList.ItemsSource = this._pasMessage.Elements;
|
|
this.dataGridPassengerList.AddingNewItem += DataGridPassengerList_AddingNewItem;
|
|
this.dataGridPassengerList.EditRequested += DataGridPassengerList_EditRequested;
|
|
this.dataGridPassengerList.DeleteRequested += DataGridPassengerList_DeleteRequested;
|
|
this.dataGridPassengerList.CreateRequested += DataGridPassengerList_CreateRequested;
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
#region port of itinerary grid
|
|
|
|
private void DataGridPortOfItinerary_CreateRequested()
|
|
{
|
|
PortOfItinerary poi = new PortOfItinerary();
|
|
EditPortOfItineraryDialog epid = new EditPortOfItineraryDialog();
|
|
epid.PortOfItinerary = poi;
|
|
|
|
epid.AddClicked += () =>
|
|
{
|
|
epid.CopyValuesToEntity();
|
|
epid.PortOfItinerary.BPOL = _bpol;
|
|
this._bpol.PortOfItineraries.Add(epid.PortOfItinerary);
|
|
this.dataGridPortOfItinerary.Items.Refresh();
|
|
epid.PortOfItinerary = new PortOfItinerary();
|
|
this.SublistElementChanged(Message.NotificationClass.BPOL);
|
|
};
|
|
|
|
if (epid.ShowDialog() ?? false)
|
|
{
|
|
_bpol.PortOfItineraries.Add(epid.PortOfItinerary);
|
|
epid.PortOfItinerary.BPOL = _bpol;
|
|
this.dataGridPortOfItinerary.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.BPOL);
|
|
}
|
|
}
|
|
|
|
private void DataGridPortOfItinerary_DeleteRequested(DatabaseEntity obj)
|
|
{
|
|
PortOfItinerary poi = obj as PortOfItinerary;
|
|
if (poi != null)
|
|
{
|
|
// are you sure dialog is in base class
|
|
_bpol.PortOfItineraries.Remove(poi);
|
|
DBManager.Instance.Delete(poi);
|
|
this.dataGridPortOfItinerary.Items.Refresh();
|
|
}
|
|
}
|
|
|
|
private void DataGridPortOfItinerary_EditRequested(DatabaseEntity obj)
|
|
{
|
|
PortOfItinerary poi = obj as PortOfItinerary;
|
|
if (poi != null)
|
|
{
|
|
EditPortOfItineraryDialog epid = new EditPortOfItineraryDialog();
|
|
epid.PortOfItinerary = poi;
|
|
|
|
epid.AddClicked += () =>
|
|
{
|
|
epid.CopyValuesToEntity();
|
|
_bpol.PortOfItineraries.Add(epid.PortOfItinerary);
|
|
this.dataGridPortOfItinerary.Items.Refresh();
|
|
epid.PortOfItinerary = new PortOfItinerary();
|
|
epid.PortOfItinerary.BPOL = this._bpol;
|
|
this.SublistElementChanged(Message.NotificationClass.BPOL);
|
|
};
|
|
|
|
if (epid.ShowDialog() ?? false)
|
|
{
|
|
this.dataGridPortOfItinerary.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.BPOL);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void DataGridPortOfItinerary_AddingNewItem(object sender, AddingNewItemEventArgs e)
|
|
{
|
|
this.DataGridPortOfItinerary_CreateRequested();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region passenger grid
|
|
|
|
private void DataGridPassengerList_CreateRequested()
|
|
{
|
|
PAS pas = new PAS();
|
|
EditPASDialog epd = new EditPASDialog();
|
|
epd.PAS = pas;
|
|
|
|
epd.AddClicked += () =>
|
|
{
|
|
epd.CopyValuesToEntity();
|
|
epd.PAS.MessageHeader = this._pasMessage;
|
|
this._pasMessage.Elements.Add(epd.PAS);
|
|
this.dataGridPassengerList.Items.Refresh();
|
|
epd.PAS = new PAS();
|
|
this.SublistElementChanged(Message.NotificationClass.PAS);
|
|
};
|
|
|
|
if (epd.ShowDialog() ?? false)
|
|
{
|
|
_pasMessage.Elements.Add(epd.PAS);
|
|
epd.PAS.MessageHeader = this._pasMessage;
|
|
this.dataGridPassengerList.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.PAS);
|
|
}
|
|
}
|
|
|
|
private void DataGridPassengerList_DeleteRequested(DatabaseEntity obj)
|
|
{
|
|
PAS pas = obj as PAS;
|
|
if (pas != null)
|
|
{
|
|
// are you sure dialog is in base class
|
|
_pasMessage.Elements.Remove(pas);
|
|
DBManager.Instance.Delete(pas);
|
|
this.dataGridPassengerList.Items.Refresh();
|
|
}
|
|
}
|
|
|
|
private void DataGridPassengerList_EditRequested(DatabaseEntity obj)
|
|
{
|
|
PAS pas = obj as PAS;
|
|
if (pas != null)
|
|
{
|
|
EditPASDialog epd = new EditPASDialog();
|
|
epd.PAS = pas;
|
|
|
|
epd.AddClicked += () =>
|
|
{
|
|
epd.CopyValuesToEntity();
|
|
_pasMessage.Elements.Add(epd.PAS);
|
|
this.dataGridPassengerList.Items.Refresh();
|
|
epd.PAS = new PAS();
|
|
epd.PAS.MessageHeader = _pasMessage;
|
|
this.SublistElementChanged(Message.NotificationClass.PAS);
|
|
};
|
|
|
|
if (epd.ShowDialog() ?? false)
|
|
{
|
|
this.dataGridPassengerList.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.PAS);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void DataGridPassengerList_AddingNewItem(object sender, AddingNewItemEventArgs e)
|
|
{
|
|
this.DataGridPassengerList_CreateRequested();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region crew grid
|
|
|
|
private void DataGridCrewList_CreateRequested()
|
|
{
|
|
CREW crew = new CREW();
|
|
EditCREWDialog ecd = new EditCREWDialog();
|
|
ecd.CREW = crew;
|
|
|
|
ecd.AddClicked += () =>
|
|
{
|
|
ecd.CopyValuesToEntity();
|
|
ecd.CREW.MessageHeader = this._crewMessage;
|
|
this._crewMessage.Elements.Add(ecd.CREW);
|
|
this.dataGridCrewList.Items.Refresh();
|
|
ecd.CREW = new CREW();
|
|
this.SublistElementChanged(Message.NotificationClass.CREW);
|
|
};
|
|
|
|
if (ecd.ShowDialog() ?? false)
|
|
{
|
|
_crewMessage.Elements.Add(ecd.CREW);
|
|
ecd.CREW.MessageHeader = this._crewMessage;
|
|
this.dataGridCrewList.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.CREW);
|
|
}
|
|
}
|
|
|
|
private void DataGridCrewList_DeleteRequested(DatabaseEntity obj)
|
|
{
|
|
CREW crew = obj as CREW;
|
|
if (crew != null)
|
|
{
|
|
// are you sure dialog is in base class
|
|
_crewMessage.Elements.Remove(crew);
|
|
DBManager.Instance.Delete(crew);
|
|
this.dataGridCrewList.Items.Refresh();
|
|
}
|
|
}
|
|
|
|
private void DataGridCrewList_EditRequested(DatabaseEntity obj)
|
|
{
|
|
CREW crew = obj as CREW;
|
|
if (crew != null)
|
|
{
|
|
EditCREWDialog ecd = new EditCREWDialog();
|
|
ecd.CREW = crew;
|
|
|
|
ecd.AddClicked += () =>
|
|
{
|
|
ecd.CopyValuesToEntity();
|
|
_crewMessage.Elements.Add(ecd.CREW);
|
|
this.dataGridCrewList.Items.Refresh();
|
|
ecd.CREW = new CREW();
|
|
ecd.CREW.MessageHeader = _crewMessage;
|
|
this.SublistElementChanged(Message.NotificationClass.CREW);
|
|
};
|
|
|
|
if (ecd.ShowDialog() ?? false)
|
|
{
|
|
this.dataGridCrewList.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.CREW);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void DataGridCrewList_AddingNewItem(object sender, AddingNewItemEventArgs e)
|
|
{
|
|
this.DataGridCrewList_CreateRequested();
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|