109 lines
3.9 KiB
C#
109 lines
3.9 KiB
C#
// Copyright (c) 2023 schick Informatik
|
|
// Description: Terminals have all different fields so a different dialog
|
|
//
|
|
|
|
using BreCalClient.misc.Model;
|
|
using System.Windows;
|
|
|
|
namespace BreCalClient
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for EditTimesTerminalControl.xaml
|
|
/// </summary>
|
|
public partial class EditTimesTerminalControl : Window, IEditTimesControl
|
|
{
|
|
public EditTimesTerminalControl()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
#region Properties
|
|
|
|
public Times Times { get; set; } = new();
|
|
|
|
public Extensions.TypeEnum CallType { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region event handler
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
this.comboBoxBerth.ItemsSource = BreCalLists.Berths;
|
|
this.CopyToControls();
|
|
this.EnableControls();
|
|
}
|
|
|
|
private void contextMenuItemClearOperationStart_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.datePickerOperationStart.Value = null;
|
|
}
|
|
|
|
private void contextMenuItemClearOperationEnd_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.datePickerOperationEnd.Value = null;
|
|
}
|
|
|
|
private void contextMenuItemBerth_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.comboBoxBerth.SelectedIndex -= 1;
|
|
}
|
|
|
|
private void buttonOK_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.CopyToModel();
|
|
this.DialogResult = true;
|
|
this.Close();
|
|
}
|
|
|
|
private void buttonCancel_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.DialogResult = false;
|
|
this.Close();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region private methods
|
|
|
|
private void CopyToModel()
|
|
{
|
|
switch(this.comboBoxPierside.SelectedIndex)
|
|
{
|
|
case 0: this.Times.PierSide = true; break;
|
|
case 1: this.Times.PierSide= false; break;
|
|
default: this.Times.PierSide = null; break;
|
|
}
|
|
this.Times.OperationsStart = this.datePickerOperationStart.Value;
|
|
this.Times.OperationsEnd = this.datePickerOperationEnd.Value;
|
|
this.Times.BerthId = (this.comboBoxBerth.SelectedItem != null) ? ((Berth)this.comboBoxBerth.SelectedItem).Id : null;
|
|
this.Times.Remarks = this.textBoxRemarks.Text.Trim();
|
|
this.Times.BerthInfo = this.textBoxBerthRemarks.Text.Trim();
|
|
}
|
|
|
|
private void CopyToControls()
|
|
{
|
|
this.datePickerOperationStart.Value = this.Times.OperationsStart;
|
|
this.datePickerOperationEnd.Value = this.Times.OperationsEnd;
|
|
if(this.Times.PierSide == null) { this.comboBoxPierside.SelectedIndex = -1; }
|
|
else this.comboBoxPierside.SelectedIndex = (this.Times.PierSide ?? false) ? 0 : 1;
|
|
this.comboBoxBerth.SelectedValue = this.Times.BerthId;
|
|
this.textBoxRemarks.Text = this.Times.Remarks;
|
|
this.textBoxBerthRemarks.Text = this.Times.BerthInfo;
|
|
}
|
|
|
|
private void EnableControls()
|
|
{
|
|
this.datePickerOperationStart.IsEnabled = (CallType == Extensions.TypeEnum.Incoming) || (CallType == Extensions.TypeEnum.Shifting);
|
|
this.datePickerOperationEnd.IsEnabled = (CallType == Extensions.TypeEnum.Outgoing) || (CallType == Extensions.TypeEnum.Shifting);
|
|
this.comboBoxBerth.IsEnabled = (CallType == Extensions.TypeEnum.Incoming) || (CallType == Extensions.TypeEnum.Shifting);
|
|
this.comboBoxPierside.IsEnabled = (CallType == Extensions.TypeEnum.Incoming) || (CallType == Extensions.TypeEnum.Shifting);
|
|
this.textBoxBerthRemarks.IsEnabled = (CallType == Extensions.TypeEnum.Incoming) || (CallType == Extensions.TypeEnum.Shifting);
|
|
this.textBoxRemarks.IsEnabled = true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|