// Copyright (c) 2017 schick Informatik // Description: Waste Bearbeitungsdialog // using System.Windows; using System.Collections.Generic; using bsmd.database; using ENI2.Controls; using ENI2.Util; namespace ENI2.EditControls { /// /// Interaction logic for EditWasteDialog.xaml /// public partial class EditWasteDialog : EditWindowBase { public EditWasteDialog() { InitializeComponent(); Loaded += EditWasteDialog_Loaded; AddClicked += () => { this.comboBoxWasteCode.Focus(); }; } public Waste Waste { get; set; } private void EditWasteDialog_Loaded(object sender, RoutedEventArgs e) { Dictionary codeDict = new Dictionary(); foreach (string key in WAS.WasteCodeDict.Keys) codeDict.Add(int.Parse(key), string.Format("{0} - {1}", key, WAS.WasteCodeDict[key])); this.comboBoxWasteCode.ItemsSource = codeDict; this.comboBoxWasteCode.SelectedValue = this.Waste.WasteType; this.textBoxDescription.Text = this.Waste.WasteDescription; this.doubleUpDownAmountDisposed.Value = this.Waste.WasteDisposalAmount_MTQ; this.doubleUpDownAmountGeneratedTilNextPort.Value = this.Waste.WasteAmountGeneratedTillNextPort_MTQ; this.doubleUpDownAmountRetained.Value = this.Waste.WasteAmountRetained_MTQ; this.doubleUpDownMaxCapacity.Value = this.Waste.WasteCapacity_MTQ; this.locodePortOfDeliveryRemainingWaste.LocodeValue = this.Waste.WasteDisposalPort; OKClicked += EditWasteDialog_OKClicked; this.AddVisible = true; } public void CopyValuesToEntity() { // copy back if (this.comboBoxWasteCode.SelectedValue != null) this.Waste.WasteType = (int)this.comboBoxWasteCode.SelectedValue; else this.Waste.WasteType = null; this.Waste.WasteDescription = this.textBoxDescription.Text?.Trim(); this.Waste.WasteDisposalAmount_MTQ = this.doubleUpDownAmountDisposed.Value; this.Waste.WasteAmountGeneratedTillNextPort_MTQ = this.doubleUpDownAmountGeneratedTilNextPort.Value; this.Waste.WasteAmountRetained_MTQ = this.doubleUpDownAmountRetained.Value; this.Waste.WasteCapacity_MTQ = this.doubleUpDownMaxCapacity.Value; this.Waste.WasteDisposalPort = this.locodePortOfDeliveryRemainingWaste.LocodeValue; } private void EditWasteDialog_OKClicked() { this.CopyValuesToEntity(); } } }