159 lines
6.3 KiB
C#
159 lines
6.3 KiB
C#
// Copyright (c) 2017 schick Informatik
|
|
// Description: LADG Bearbeitungsdialog
|
|
//
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Collections.Generic;
|
|
|
|
using bsmd.database;
|
|
using ENI2.Controls;
|
|
|
|
|
|
namespace ENI2.EditControls
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for EditLADGDialog.xaml
|
|
/// </summary>
|
|
public partial class EditLADGDialog : EditWindowBase
|
|
{
|
|
private static readonly string[] handlingTypeList =
|
|
{
|
|
Properties.Resources.textLoading,
|
|
Properties.Resources.textDischarge,
|
|
Properties.Resources.textTransit
|
|
};
|
|
|
|
private static readonly string[] handlinTypeListDE =
|
|
{
|
|
Properties.Resources.textLoading,
|
|
Properties.Resources.textDischarge
|
|
};
|
|
|
|
private static List<KeyValuePair<string, string>> _nstList = null;
|
|
|
|
public EditLADGDialog()
|
|
{
|
|
InitializeComponent();
|
|
Loaded += EditLADGDialog_Loaded;
|
|
if (_nstList == null)
|
|
_nstList = LocalizedLookup.GetNST2007List();
|
|
}
|
|
|
|
public LADG LADG { get; set; }
|
|
|
|
public MessageCore Core { get; set; }
|
|
|
|
#region event handler
|
|
|
|
private void EditLADGDialog_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
this.OKClicked += EditLADGDialog_OKClicked;
|
|
|
|
if (this.Core.IsDK)
|
|
this.comboBoxHandlingType.ItemsSource = handlingTypeList;
|
|
else
|
|
this.comboBoxHandlingType.ItemsSource = handlinTypeListDE;
|
|
|
|
//this.comboBoxHandlingType.KeyUp += ComboBox_KeyUp;
|
|
if (this.LADG.CargoHandlingType.HasValue)
|
|
this.comboBoxHandlingType.SelectedIndex = this.LADG.CargoHandlingType.Value;
|
|
|
|
this.comboBoxLACodes.ItemsSource = LADG.LACodes;
|
|
this.comboBoxLACodes.SelectedValue = this.LADG.CargoLACode;
|
|
|
|
this.integerUpDownNumberOfItems.Value = this.LADG.CargoNumberOfItems;
|
|
this.doubleUpDownGrossQuantity.Value = this.LADG.CargoGrossQuantity_TNE;
|
|
this.locodeControl_PortOfLoading.LocodeValue = this.LADG.PortOfLoading;
|
|
this.locodeControl_PortOfDischarge.LocodeValue = this.LADG.PortOfDischarge;
|
|
this.comboBoxLACodes.SelectedValue = this.LADG.CargoLACode;
|
|
|
|
this.comboBoxNSTCode.ItemsSource = LADG.CargoCodesNST;
|
|
this.comboBoxNSTCode.SelectedValue = this.LADG.CargoCodeNST;
|
|
this.comboBoxNSTCode.SelectionChanged += ComboBoxNSTCode_SelectionChanged;
|
|
this.comboBoxNST3Code.ItemsSource = LADG.CargoCodesNST3;
|
|
this.ComboBoxNSTCode_SelectionChanged(null, null);
|
|
|
|
this.comboBoxNST3Code.SelectedValue = this.LADG.CargoCodeNST_3;
|
|
|
|
this.AddVisible = true;
|
|
|
|
}
|
|
|
|
|
|
public void CopyValuesToEntity()
|
|
{
|
|
this.LADG.CargoHandlingType = (this.comboBoxHandlingType.SelectedIndex < 0) ? null : (byte?)this.comboBoxHandlingType.SelectedIndex;
|
|
this.LADG.CargoNumberOfItems = this.integerUpDownNumberOfItems.Value;
|
|
this.LADG.CargoGrossQuantity_TNE = this.doubleUpDownGrossQuantity.Value;
|
|
this.LADG.PortOfLoading = this.locodeControl_PortOfLoading.LocodeValue;
|
|
this.LADG.PortOfDischarge = this.locodeControl_PortOfDischarge.LocodeValue;
|
|
this.LADG.CargoLACode = (this.comboBoxLACodes.SelectedValue == null) ? null : ((int?)this.comboBoxLACodes.SelectedValue);
|
|
this.LADG.CargoCodeNST = (string)this.comboBoxNSTCode.SelectedValue;
|
|
this.LADG.CargoCodeNST_3 = (string)this.comboBoxNST3Code.SelectedValue;
|
|
}
|
|
|
|
private void ComboBoxNSTCode_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
|
{
|
|
if (this.comboBoxNSTCode.SelectedItem == null) return;
|
|
// filter ItemsSource von NST3
|
|
KeyValuePair<string, string> selectedItem = (KeyValuePair < string, string> ) this.comboBoxNSTCode.SelectedItem;
|
|
string key = selectedItem.Key;
|
|
if (key.Length == 1) key = "0" + key;
|
|
List<KeyValuePair<string, string>> filteredItemsSource = new List<KeyValuePair<string, string>>();
|
|
foreach(KeyValuePair<string, string> aPair in LADG.CargoCodesNST3)
|
|
{
|
|
if (aPair.Value.StartsWith(key))
|
|
filteredItemsSource.Add(aPair);
|
|
}
|
|
this.comboBoxNST3Code.ItemsSource = filteredItemsSource;
|
|
}
|
|
|
|
private void EditLADGDialog_OKClicked()
|
|
{
|
|
this.CopyValuesToEntity();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region NST2007 list search/select event handler
|
|
|
|
private void textBoxSearchNSTList_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
|
{
|
|
if (textBoxSearchNSTList.Text.IsNullOrEmpty() || (textBoxSearchNSTList.Text.Length == 1))
|
|
{
|
|
this.listBoxNST2007.ItemsSource = null;
|
|
// this.comboBoxSelectNST2007ListItem.ItemsSource = null;
|
|
}
|
|
else
|
|
{
|
|
var result = _nstList.Where(kvp => kvp.Key.Contains(textBoxSearchNSTList.Text, StringComparison.OrdinalIgnoreCase));
|
|
this.listBoxNST2007.ItemsSource = result;
|
|
//this.comboBoxSelectNST2007ListItem.ItemsSource = result;
|
|
}
|
|
}
|
|
|
|
private void buttonSetTemplate_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if(this.listBoxNST2007.SelectedItem != null)
|
|
{
|
|
KeyValuePair<string, string> selectedTemplate = (KeyValuePair<string, string>) this.listBoxNST2007.SelectedItem;
|
|
if(selectedTemplate.Value.Length == 3)
|
|
{
|
|
this.comboBoxNSTCode.SelectedValue = selectedTemplate.Value.Substring(0, 2);
|
|
this.comboBoxNST3Code.SelectedValue = selectedTemplate.Value.Substring(2, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void listBoxNST2007_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
{
|
|
this.buttonSetTemplate_Click(null, null);
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|