// Copyright (c) 2017 schick Informatik // Description: Dialog zum Bearbeiten von Bunker-Informationen // using System.Windows; using bsmd.database; using ENI2.Controls; namespace ENI2.EditControls { /// /// Interaction logic for EditBKRDialog.xaml /// public partial class EditBKRDialog : EditWindowBase { public EditBKRDialog() { InitializeComponent(); Loaded += EditBKRDialog_Loaded; AddClicked += () => { this.textBoxBunkerType.Focus(); }; } #region Properties public bool IsDeparture { get; set; } public BRKA BRKA { get; set; } public BRKD BRKD { get; set; } #endregion #region event handler private void EditBKRDialog_Loaded(object sender, RoutedEventArgs e) { this.Title = this.IsDeparture ? Properties.Resources.textBunkerOnDeparture : Properties.Resources.textBunkerOnArrival; // copy into fields this.textBoxBunkerType.Text = this.IsDeparture ? this.BRKD.BunkerFuelType : this.BRKA.BunkerFuelType; this.doubleUpDownBunkerQuantity.Value = this.IsDeparture ? this.BRKD.BunkerFuelQuantity_TNE : this.BRKA.BunkerFuelQuantity_TNE; this.OKClicked += EditBKRDialog_OKClicked; this.AddVisible = true; this.textBoxBunkerType.Focus(); } public void CopyValuesToEntity() { // copy back if (this.IsDeparture) { this.BRKD.BunkerFuelType = this.textBoxBunkerType.Text.Trim(); this.BRKD.BunkerFuelQuantity_TNE = this.doubleUpDownBunkerQuantity.Value; } else { this.BRKA.BunkerFuelType = this.textBoxBunkerType.Text.Trim(); this.BRKA.BunkerFuelQuantity_TNE = this.doubleUpDownBunkerQuantity.Value; } } private void EditBKRDialog_OKClicked() { this.CopyValuesToEntity(); } #endregion } }