114 lines
3.6 KiB
C#
114 lines
3.6 KiB
C#
// Copyright (c) 2025- schick Informatik
|
|
// Description: Display control of formsheet Tab 12. ATA ATD
|
|
//
|
|
|
|
using bsmd.database;
|
|
using System;
|
|
using System.Windows;
|
|
|
|
namespace ENI2.SheetDisplayControls
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for ATAControl.xaml
|
|
/// </summary>
|
|
public partial class ATAControl : DetailBaseControl
|
|
{
|
|
#region Fields
|
|
|
|
ATA _ata;
|
|
ATD _atd;
|
|
bool startupComplete = false;
|
|
|
|
#endregion
|
|
|
|
#region Fields
|
|
|
|
public ATAControl()
|
|
{
|
|
InitializeComponent();
|
|
Loaded += ATAControl_Loaded;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region public overrides
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
foreach (Message aMessage in this.Messages)
|
|
{
|
|
if (aMessage.MessageNotificationClass == Message.NotificationClass.ATA)
|
|
{
|
|
this.ControlMessages.Add(aMessage);
|
|
if (aMessage.Elements.Count > 0)
|
|
_ata = aMessage.Elements[0] as ATA;
|
|
if (_ata == null)
|
|
{
|
|
_ata = new ATA();
|
|
_ata.MessageCore = this.Core;
|
|
_ata.MessageHeader = aMessage;
|
|
aMessage.Elements.Add(_ata);
|
|
}
|
|
this.dateTimePickerATA.DataContext = _ata;
|
|
}
|
|
|
|
if (aMessage.MessageNotificationClass == Message.NotificationClass.ATD)
|
|
{
|
|
this.ControlMessages.Add(aMessage);
|
|
if (aMessage.Elements.Count > 0)
|
|
_atd = aMessage.Elements[0] as ATD;
|
|
if (_atd == null)
|
|
{
|
|
_atd = new ATD();
|
|
_atd.MessageCore = this.Core;
|
|
_atd.MessageHeader = aMessage;
|
|
aMessage.Elements.Add(_atd);
|
|
}
|
|
this.dateTimePickerATD.DataContext = _atd;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void SetEnabled(bool enabled)
|
|
{
|
|
base.SetEnabled(enabled);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region event handler
|
|
private void ATAControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
this.RegisterDateTimePickerChange(this.dateTimePickerATA, Message.NotificationClass.ATA);
|
|
this.RegisterDateTimePickerChange(this.dateTimePickerATD, Message.NotificationClass.ATD);
|
|
startupComplete = true;
|
|
}
|
|
|
|
private void dateTimePickerATD_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
|
|
{
|
|
if (startupComplete && this.dateTimePickerATD.Value.HasValue)
|
|
{
|
|
DateTime setTime = this.dateTimePickerATD.Value.Value;
|
|
if ((setTime > DateTime.Now.AddDays(14)) || (setTime < DateTime.Now.AddDays(-14)))
|
|
MessageBox.Show("ATD value may be invalid", "Date implausible", MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
}
|
|
}
|
|
|
|
private void dateTimePickerATA_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
|
|
{
|
|
if (startupComplete && this.dateTimePickerATA.Value.HasValue)
|
|
{
|
|
DateTime setTime = this.dateTimePickerATA.Value.Value;
|
|
if ((setTime > DateTime.Now.AddDays(14)) || (setTime < DateTime.Now.AddDays(-14)))
|
|
MessageBox.Show("ATA value may be invalid", "Date implausible", MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|