git_bsmd/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs

726 lines
33 KiB
C#

// Copyright (c) 2017 schick Informatik
// Description: Haupt-Übersichtsansicht eines Anlaufs / Auftrags (Core)
//
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Timers;
using bsmd.database;
using ENI2.EditControls;
using System.Windows.Media.Imaging;
using System.Collections.Generic;
using System.Windows.Media;
namespace ENI2.DetailViewControls
{
/// <summary>
/// Interaction logic for OverViewDetailControl.xaml
/// </summary>
public partial class OverViewDetailControl : DetailBaseControl
{
private Message _message = null;
private Message _ataMessage;
private Message _atdMessage;
private Message _noanodMessage;
private Timer _checkStatusTimer;
private DateTime _startStatusCheck;
private object _collectionLock = new object();
public OverViewDetailControl()
{
InitializeComponent();
this.Loaded += OverViewDetailControl_Loaded;
}
private void OverViewDetailControl_Loaded(object sender, RoutedEventArgs e)
{
// die Controls nach Änderungen monitoren
// diese Einträge gehen auf core
this.RegisterTextboxChange(this.textBoxTicketNo, Message.NotificationClass.ATA);
this.RegisterTextboxChange(this.textBoxDisplayId, Message.NotificationClass.ATA);
this.RegisterTextboxChange(this.textBoxIMO, Message.NotificationClass.ATA);
this.RegisterTextboxChange(this.textBoxENI, Message.NotificationClass.ATA);
this.RegisterLocodeChange(this.locodePoC, Message.NotificationClass.ATA);
this.RegisterDateTimePickerChange(this.dateTimePickerATA, Message.NotificationClass.ATA);
this.RegisterDateTimePickerChange(this.dateTimePickerATD, Message.NotificationClass.ATD);
this.RegisterDateTimePickerChange(this.dateTimePickerETA, Message.NotificationClass.NOA_NOD);
this.RegisterDateTimePickerChange(this.dateTimePickerETD, Message.NotificationClass.NOA_NOD);
}
#region Initialize
public override void Initialize()
{
base.Initialize();
Message.NotificationClass notificationClass = this.Core.IsTransit ? Message.NotificationClass.TRANSIT : Message.NotificationClass.VISIT;
if (this.Messages == null) return;
if (this.Core == null) return;
if(DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsAdmin)
{
this.textBoxENI.IsReadOnly = false;
this.textBoxIMO.IsReadOnly = false;
this.locodePoC.IsEnabled = true;
this.textBoxDisplayId.IsReadOnly = false;
}
this.textBoxENI.DataContext = this.Core;
this.textBoxIMO.DataContext = this.Core;
this.locodePoC.DataContext = this.Core;
this.textBoxTicketNo.DataContext = this.Core;
this.labelBSMDStatusInternal.DataContext = this.Core;
this.labelCreated.Content = this.Core.Created?.ToString();
this.comboBoxInitialHis.ItemsSource = Util.EnumHelper.GetAllValuesAndDescription(typeof(Message.NSWProvider));
this.comboBoxInitialHis.DataContext = this.Core;
Binding vtBinding = new Binding();
vtBinding.Source = this.Core;
vtBinding.Path = this.Core.IsTransit ? new PropertyPath("TransitId") : new PropertyPath("VisitId");
vtBinding.Mode = BindingMode.TwoWay;
vtBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
BindingOperations.SetBinding(textBoxDisplayId, TextBox.TextProperty, vtBinding);
if (this.Core.Cancelled ?? false) this.ShowCancelledLabel();
#region Context-Menu Meldeklassen
// wenn man das mal aufwendig "schön" machen will (die Items enabled abh. vom Zustand der Meldeklasse) sollte man
// Command Bindings verwenden. Hier ist das erklärt: https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/commanding-overview#code-snippet-2
this.dataGridMessages.ContextMenu = new ContextMenu();
MenuItem sendItem = new MenuItem();
sendItem.Header = Properties.Resources.textSendToNSW;
sendItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/mail_forward.png")) };
//sendItem.Command =
sendItem.Click += new RoutedEventHandler(this.contextSendMessage);
this.dataGridMessages.ContextMenu.Items.Add(sendItem);
MenuItem resetItem = new MenuItem();
resetItem.Header = Properties.Resources.textReset;
resetItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/mail_delete.png")) };
resetItem.Click += new RoutedEventHandler(this.contextResetMessage);
this.dataGridMessages.ContextMenu.Items.Add(resetItem);
MenuItem systemErrorItem = new MenuItem();
systemErrorItem.Header = Properties.Resources.textSystemErrors;
systemErrorItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/hand_red_card.png")) };
systemErrorItem.Click += new RoutedEventHandler(this.buttonSystemErrors_Click);
this.dataGridMessages.ContextMenu.Items.Add(systemErrorItem);
MenuItem errorItem = new MenuItem();
errorItem.Header = Properties.Resources.textErrors;
errorItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/error.png")) };
errorItem.Click += new RoutedEventHandler(this.buttonErrors_Click);
this.dataGridMessages.ContextMenu.Items.Add(errorItem);
MenuItem vioItem = new MenuItem();
vioItem.Header = Properties.Resources.textViolations;
vioItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/sign_warning.png")) };
vioItem.Click += new RoutedEventHandler(this.buttonWarnings_Click);
this.dataGridMessages.ContextMenu.Items.Add(vioItem);
MenuItem pdfItem = new MenuItem();
pdfItem.Header = Properties.Resources.textCreatePDF;
pdfItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/document_pdf.png")) };
pdfItem.Click += new RoutedEventHandler(this.buttonCreatePDF_Click);
this.dataGridMessages.ContextMenu.Items.Add(pdfItem);
#endregion
#region lokale Meldeklassen
foreach (Message aMessage in this.Messages)
{
if (aMessage.MessageNotificationClass == notificationClass)
_message = aMessage;
if (aMessage.MessageNotificationClass == Message.NotificationClass.ATA)
this._ataMessage = aMessage;
if (aMessage.MessageNotificationClass == Message.NotificationClass.ATD)
this._atdMessage = aMessage;
if (aMessage.MessageNotificationClass == Message.NotificationClass.NOA_NOD)
this._noanodMessage = aMessage;
}
#endregion
#region init ATA
// ganz hakelig ich weiß dafür kapiert das gleich jeder
if (this._ataMessage == null)
{
this._ataMessage = this.Core.CreateMessage(Message.NotificationClass.ATA);
this.Messages.Add(this._ataMessage);
this._ataMessage.ENINotificationIconString = "../Resources/arrow_down_right_red.png";
this._ataMessage.ENINotificationDetailGroup = Properties.Resources.textArrivalNotification;
this._ataMessage.ENINotificationDetailIndex = 4;
}
ATA ata = null;
if (this._ataMessage.Elements.Count > 0)
ata = this._ataMessage.Elements[0] as ATA;
if (ata == null)
{
ata = new ATA();
ata.MessageCore = this.Core;
ata.MessageHeader = this._ataMessage;
_ataMessage.Elements.Add(ata);
}
this.dateTimePickerATA.DataContext = ata;
this.ControlMessages.Add(this._ataMessage);
#endregion
#region init ATD
if (this._atdMessage == null)
{
this._atdMessage = this.Core.CreateMessage(Message.NotificationClass.ATD);
this.Messages.Add(this._atdMessage);
this._atdMessage.ENINotificationIconString = "../Resources/arrow_up_right_green.png";
this._atdMessage.ENINotificationDetailGroup = Properties.Resources.textDepartureNotification;
this._atdMessage.ENINotificationDetailIndex = 10;
}
ATD atd = null;
if (this._atdMessage.Elements.Count > 0)
atd = this._atdMessage.Elements[0] as ATD;
if (atd == null)
{
atd = new ATD();
atd.MessageCore = this.Core;
atd.MessageHeader = this._atdMessage;
_atdMessage.Elements.Add(atd);
}
this.dateTimePickerATD.DataContext = atd;
this.ControlMessages.Add(this._atdMessage);
#endregion
#region init NOA_NOD
if (this._noanodMessage == null)
{
this._noanodMessage = this.Core.CreateMessage(Message.NotificationClass.NOA_NOD);
this.Messages.Add(this._noanodMessage);
_noanodMessage.ENINotificationIconString = "../Resources/eye_blue.png";
_noanodMessage.ENINotificationDetailGroup = Properties.Resources.textPortCall;
_noanodMessage.ENINotificationDetailIndex = 1;
}
NOA_NOD noa_nod = null;
if (this._noanodMessage.Elements.Count > 0)
noa_nod = this._noanodMessage.Elements[0] as NOA_NOD;
if (noa_nod == null)
{
noa_nod = new NOA_NOD();
noa_nod.MessageCore = this.Core;
noa_nod.MessageHeader = this._noanodMessage;
_noanodMessage.Elements.Add(noa_nod);
}
this.dateTimePickerETD.DataContext = noa_nod;
this.dateTimePickerETA.DataContext = noa_nod;
this.ControlMessages.Add(this._noanodMessage);
#endregion
#region Meldeklassen einrichten und Icons / Gruppen / Index zuordnen
foreach (Message aMessage in this.Messages)
{
switch (aMessage.MessageNotificationClass)
{
case Message.NotificationClass.VISIT:
case Message.NotificationClass.TRANSIT:
aMessage.ENINotificationDetailGroup = Properties.Resources.textOverview;
aMessage.ENINotificationIconString = "../Resources/documents.png";
aMessage.ENINotificationDetailIndex = 0;
break;
case Message.NotificationClass.NOA_NOD:
case Message.NotificationClass.AGNT:
aMessage.ENINotificationIconString = "../Resources/eye_blue.png";
aMessage.ENINotificationDetailGroup = Properties.Resources.textPortCall;
aMessage.ENINotificationDetailIndex = 1;
break;
case Message.NotificationClass.NAME:
case Message.NotificationClass.INFO:
case Message.NotificationClass.SERV:
case Message.NotificationClass.LADG:
aMessage.ENINotificationIconString = "../Resources/anchor.png";
aMessage.ENINotificationDetailGroup = Properties.Resources.textPortNotification;
aMessage.ENINotificationDetailIndex = 2;
break;
case Message.NotificationClass.WAS:
aMessage.ENINotificationIconString = "../Resources/garbage.png";
aMessage.ENINotificationDetailGroup = Properties.Resources.textWaste;
aMessage.ENINotificationDetailIndex = 3;
break;
case Message.NotificationClass.ATA:
case Message.NotificationClass.POBA:
case Message.NotificationClass.TIEFA:
case Message.NotificationClass.BKRA:
aMessage.ENINotificationIconString = "../Resources/arrow_down_right_red.png";
aMessage.ENINotificationDetailGroup = Properties.Resources.textArrivalNotification;
aMessage.ENINotificationDetailIndex = 4;
break;
case Message.NotificationClass.SEC:
aMessage.ENINotificationIconString = "../Resources/shield_yellow.png";
aMessage.ENINotificationDetailGroup = Properties.Resources.textSecurity;
aMessage.ENINotificationDetailIndex = 5;
break;
case Message.NotificationClass.PRE72H:
aMessage.ENINotificationIconString = "../Resources/alarmclock.png";
aMessage.ENINotificationDetailGroup = Properties.Resources.textPSC72h;
aMessage.ENINotificationDetailIndex = 6;
break;
case Message.NotificationClass.MDH:
aMessage.ENINotificationIconString = "../Resources/medical_bag.png";
aMessage.ENINotificationDetailGroup = Properties.Resources.textMDH;
aMessage.ENINotificationDetailIndex = 7;
break;
case Message.NotificationClass.ATD:
case Message.NotificationClass.TIEFD:
case Message.NotificationClass.BKRD:
case Message.NotificationClass.POBD:
aMessage.ENINotificationIconString = "../Resources/arrow_up_right_green.png";
aMessage.ENINotificationDetailGroup = Properties.Resources.textDepartureNotification;
aMessage.ENINotificationDetailIndex = 8;
break;
case Message.NotificationClass.STAT:
aMessage.ENINotificationIconString = "../Resources/containership.png";
aMessage.ENINotificationDetailGroup = Properties.Resources.textShipData;
aMessage.ENINotificationDetailIndex = 9;
break;
case Message.NotificationClass.BPOL:
case Message.NotificationClass.CREW:
case Message.NotificationClass.PAS:
aMessage.ENINotificationIconString = "../Resources/policeman_german.png";
aMessage.ENINotificationDetailGroup = Properties.Resources.textBorderPolice;
aMessage.ENINotificationDetailIndex = 10;
break;
case Message.NotificationClass.HAZA:
aMessage.ENINotificationIconString = "../Resources/sign_warning_radiation.png";
aMessage.ENINotificationDetailGroup = Properties.Resources.textDGArrival;
aMessage.ENINotificationDetailIndex = 11;
break;
case Message.NotificationClass.HAZD:
aMessage.ENINotificationIconString = "../Resources/sign_warning_radiation.png";
aMessage.ENINotificationDetailGroup = Properties.Resources.textDGDeparture;
aMessage.ENINotificationDetailIndex = 12;
break;
case Message.NotificationClass.TOWA:
case Message.NotificationClass.TOWD:
aMessage.ENINotificationIconString = "../Resources/ship2.png";
aMessage.ENINotificationDetailGroup = Properties.Resources.textTowage;
aMessage.ENINotificationDetailIndex = 13;
break;
default:
aMessage.ENINotificationDetailGroup = "unspecified";
break;
}
}
#endregion
#region Meldeklassen nach ihrem Vorkommen in den Detailansichten sortieren (SH, 12.5.17)
this.Messages.Sort((a, b) =>
{
if (a.ENINotificationDetailIndex == b.ENINotificationDetailIndex)
return a.MessageNotificationClassDisplay.CompareTo(b.MessageNotificationClassDisplay);
return a.ENINotificationDetailIndex.CompareTo(b.ENINotificationDetailIndex);
});
if (_message != null)
{
// kann das eigentlich passieren??!
}
#endregion
BindingOperations.EnableCollectionSynchronization(this.Messages, _collectionLock);
this.dataGridMessages.ItemsSource = this.Messages;
base.Initialize(); // wenn Meldeklassen erst bei der Init. erzeugt werden, fehlen die Handler, die hier erneut festgelegt werden
this._initialized = true;
}
#endregion
#region public methods
public void ShowLockedBy(ReportingParty reportingParty)
{
if (reportingParty != null)
{
this.stackPanelLock.Visibility = Visibility.Visible;
this.textBlockLockUserName.Text = reportingParty.FirstName + " " + reportingParty.LastName;
}
else
{
MessageBox.Show("Reporting party empty, cannot show locked by!", "Notification", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
public void UpdateCore()
{
this.UnregisterTextboxChange(this.textBoxDisplayId);
this.textBoxDisplayId.DataContext = null;
this.textBoxDisplayId.DataContext = this.Core;
this.textBoxDisplayId.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
this.RegisterTextboxChange(this.textBoxDisplayId, Message.NotificationClass.ATA);
this.labelBSMDStatusInternal.DataContext = null;
this.labelBSMDStatusInternal.DataContext = this.Core;
this.labelBSMDStatusInternal.GetBindingExpression(Label.ContentProperty)?.UpdateTarget();
//MessageBox.Show(string.Format("Visit/Transit ID updated: {0}", this.Core.DisplayId));
ShowIdDialog sid = new ShowIdDialog();
sid.DisplayId = this.Core.DisplayId;
sid.Show();
this.Core.IsDirty = false; // ist ja schon gespeichert..
}
#endregion
#region private methods
private void jumpToMessage(Message message)
{
this.OnJumpToListElementRequest(message.ENINotificationDetailIndex);
}
private void ShowCancelledLabel()
{
this.labelCancelled.Content = Properties.Resources.textCancelled;
this.labelCancelled.Background = Brushes.Yellow;
}
#endregion
#region mouse event handler
private void dataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (sender != null)
{
DataGrid grid = sender as DataGrid;
if ((grid != null) && (grid.SelectedItems != null) && (grid.SelectedItems.Count == 1))
{
DataGridRow dgr = grid.ItemContainerGenerator.ContainerFromItem(grid.SelectedItem) as DataGridRow;
Message selectedMessage = grid.SelectedItem as Message;
this.jumpToMessage(selectedMessage);
}
}
}
private void dataGrid_PreviewKeyDown(object sender, KeyEventArgs e)
{
if ((e.Key == Key.Return) || (e.Key == Key.Enter))
{
Message selectedMessage = this.dataGridMessages.SelectedItem as Message;
this.jumpToMessage(selectedMessage);
}
else
{
base.OnPreviewKeyDown(e);
}
}
#endregion
#region Command button event handler
private void contextSendMessage(object sender, RoutedEventArgs e)
{
MessageBoxResult result = MessageBox.Show(Properties.Resources.textConfirmSend, Properties.Resources.textConfirm, MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
bool somethingsNotSaved = false;
foreach (Message selectedMessage in this.dataGridMessages.SelectedItems)
{
if (selectedMessage.IsDirty) somethingsNotSaved = true;
}
if(somethingsNotSaved)
{
if (MessageBox.Show(Properties.Resources.textUnsavedChangesSendAnyWay, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
return;
}
foreach (Message selectedMessage in this.dataGridMessages.SelectedItems)
{
if (selectedMessage.Reset) selectedMessage.Reset = false; // "nochmal" Versenden ist möglich
selectedMessage.InternalStatus = Message.BSMDStatus.TOSEND;
string userName = "?";
if (App.UserId.HasValue && DBManager.Instance.GetReportingPartyDict().ContainsKey(App.UserId.Value))
{
userName = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].Logon;
}
selectedMessage.ChangedBy = string.Format("{0} at {1} (Send)", userName, DateTime.Now);
selectedMessage.StatusInfo = string.Format(Properties.Resources.textMessageSentAt, DateTime.Now);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(selectedMessage);
}
// komplette Anmeldung auf "zu versenden" stellen
this.Core.BSMDStatusInternal = MessageCore.BSMDStatus.TOSEND;
this.Core.DefaultReportingPartyId = App.UserId;
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(this.Core);
this.OnRequestSendValidation();
this.dataGridMessages.Items.Refresh();
}
}
private void contextResetMessage(object sender, RoutedEventArgs e)
{
MessageBoxResult result = MessageBox.Show(Properties.Resources.textConfirmReset, Properties.Resources.textConfirm, MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
foreach (Message selectedMessage in this.dataGridMessages.SelectedItems)
{
selectedMessage.Reset = true;
selectedMessage.InternalStatus = Message.BSMDStatus.TOSEND;
selectedMessage.StatusInfo = string.Format(Properties.Resources.textMessageResetAt, DateTime.Now);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(selectedMessage);
}
// komplette Anmeldung auf "zu versenden" stellen
this.Core.BSMDStatusInternal = MessageCore.BSMDStatus.TOSEND;
this.Core.DefaultReportingPartyId = App.UserId;
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(this.Core);
this.dataGridMessages.Items.Refresh();
}
}
private void buttonStorno_Click(object sender, RoutedEventArgs e)
{
if (this.Core.Cancelled ?? false)
{
MessageBox.Show(Properties.Resources.textAlreadyCancelled);
}
else
{
MessageBoxResult result = MessageBox.Show(Properties.Resources.textConfirmCancel, Properties.Resources.textConfirm, MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
this.Core.Cancelled = true;
this.Core.BSMDStatusInternal = MessageCore.BSMDStatus.TOSEND;
this.Core.DefaultReportingPartyId = App.UserId;
this.ShowCancelledLabel();
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(this.Core);
this.OnRequestDisable();
}
}
}
private void buttonCopy_Click(object sender, RoutedEventArgs e)
{
this.OnRequestCopy();
}
private void buttonSendPDF_Click(object sender, RoutedEventArgs e)
{
}
private void buttonQueryHIS_Click(object sender, RoutedEventArgs e)
{
this._startStatusCheck = DateTime.Now;
this.Core.QueryNSWStatus = true;
this.Core.StatusCheckErrorCode = string.Empty;
this.Core.StatusCheckErrorMessage = string.Empty;
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(this.Core);
this.busyIndicator.IsBusy = true;
// Hintergrund-Thread starten, der gelegentlich auf das Ergebnis prüft..
if (_checkStatusTimer == null)
{
_checkStatusTimer = new Timer(3000);
_checkStatusTimer.Elapsed += _checkStatusTimer_Elapsed;
_checkStatusTimer.AutoReset = true;
}
_checkStatusTimer.Start();
}
#endregion
#region event handler
private void _checkStatusTimer_Elapsed(object sender, ElapsedEventArgs e)
{
bool? statusFlag = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoreQueryStatusFlag(this.Core.Id.Value);
if (statusFlag ?? true)
{
double elapsedSec = (DateTime.Now - _startStatusCheck).TotalSeconds;
if (elapsedSec < Properties.Settings.Default.RequestTimeout)
{
// not yet.. (calling ui thread async)
this.Dispatcher.BeginInvoke(new Action(() =>
{
this.labelBusyTimeElapsed.Content = string.Format(Properties.Resources.textSecondsElapsed, elapsedSec.ToString("N0"));
}));
}
else
{
this._checkStatusTimer.Stop();
this.Dispatcher.BeginInvoke(new Action(() =>
{
MessageBox.Show(Properties.Resources.textRequestTimedOut, Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Warning);
this.busyIndicator.IsBusy = false;
}));
}
}
else
{
this._checkStatusTimer.Stop();
this.Dispatcher.BeginInvoke(new Action(() =>
{
MessageCore reloadedCore = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoreById(this.Core.Id.Value);
CoreStatusInfoDialog csid = new CoreStatusInfoDialog();
csid.IsModal = false;
csid.Core = reloadedCore;
csid.Show();
this.busyIndicator.IsBusy = false;
this.OnRequestReload();
}));
}
}
private void buttonStopWaiting_Click(object sender, RoutedEventArgs e)
{
this._checkStatusTimer.Stop();
this.busyIndicator.IsBusy = false;
}
private void buttonRefresh_Click(object sender, RoutedEventArgs e)
{
// reload Core and all message classes
// container class needs to dismiss all created controls
this.Dispatcher.BeginInvoke(new Action(() =>
{
this.OnRequestReload();
}));
}
private void buttonInfoCore_Click(object sender, RoutedEventArgs e)
{
SimplePropertyViewDialog spvd = new SimplePropertyViewDialog();
spvd.IsModal = false;
spvd.DisplayObject = this.Core;
spvd.Show();
//CoreStatusInfoDialog csid = new CoreStatusInfoDialog();
//csid.IsModal = false;
//csid.Core = this.Core;
//csid.Show();
}
private void buttonErrors_Click(object sender, RoutedEventArgs e)
{
if (this.dataGridMessages.SelectedItems.Count > 0)
{
Message selectedMessage = this.dataGridMessages.SelectedItems[0] as Message;
ErrorListDialog eld = new ErrorListDialog();
eld.Errors = selectedMessage.ErrorList;
eld.ShowDialog();
}
}
private void buttonWarnings_Click(object sender, RoutedEventArgs e)
{
if (this.dataGridMessages.SelectedItems.Count > 0)
{
Message selectedMessage = this.dataGridMessages.SelectedItems[0] as Message;
ViolationListDialog vld = new ViolationListDialog();
vld.Violations = selectedMessage.ViolationList;
vld.ShowDialog();
}
}
private void buttonCreatePDF_Click(object sender, RoutedEventArgs e)
{
bool cannotCreateReport = false;
for (int i = 0; i < this.dataGridMessages.SelectedItems.Count; i++)
{
Message selectedMessage = this.dataGridMessages.SelectedItems[i] as Message;
if ((selectedMessage.InternalStatus == Message.BSMDStatus.SENT) || (selectedMessage.InternalStatus == Message.BSMDStatus.TOSEND))
{
cannotCreateReport = true;
break;
}
}
if (cannotCreateReport)
{
MessageBox.Show("Cannot create report: some messages still in status TOSEND / SENT", Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Exclamation);
return;
}
for (int i = 0; i < this.dataGridMessages.SelectedItems.Count; i++)
{
Message selectedMessage = this.dataGridMessages.SelectedItems[i] as Message;
selectedMessage.InternalStatus = Message.BSMDStatus.REPORT;
selectedMessage.ReportingPartyId = App.UserId; // wichtig damit der Richtige(!) die Mail mit dem PDF bekommt
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(selectedMessage);
}
this.Core.ReportStatus = MessageCore.ReportStatusEnum.SINGLE;
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(this.Core);
this.dataGridMessages.Items.Refresh();
}
private void buttonSystemErrors_Click(object sender, RoutedEventArgs e)
{
if (this.dataGridMessages.SelectedItems.Count > 0)
{
Message selectedMessage = this.dataGridMessages.SelectedItems[0] as Message;
SystemErrorDialog sed = new SystemErrorDialog();
sed.SystemErrors = selectedMessage.SystemErrorList;
sed.ShowDialog();
}
}
private void buttonValidate_Click(object sender, RoutedEventArgs e)
{
this.OnRequestValidate();
}
#endregion
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
#endregion
}
}