// Copyright (c) 2017 schick Informatik // Description: Dialog zum Bearbeiten von Towage-Informationen // using System.Windows; using bsmd.database; using ENI2.Controls; namespace ENI2.EditControls { /// /// Interaction logic for EditTOWDialog.xaml /// public partial class EditTOWDialog : EditWindowBase { public EditTOWDialog() { InitializeComponent(); Loaded += EditTOWDialog_Loaded; AddClicked += () => { this.textBoxName.Focus(); }; } public bool IsDeparture { get; set; } public TOWA TOWA { get; set; } public TOWD TOWD { get; set; } private void EditTOWDialog_Loaded(object sender, RoutedEventArgs e) { this.Title = this.IsDeparture ? Properties.Resources.textTowageOnDeparture : Properties.Resources.textTowageOnArrival; this.textBoxName.Text = this.IsDeparture ? this.TOWD.TowageOnDepartureName : this.TOWA.TowageOnArrivalName; if (this.IsDeparture) { this.labelPurposeOfCall.Visibility = Visibility.Hidden; this.textBoxPurposeOfCall.Visibility = Visibility.Hidden; this.labelGrossTonnage.Visibility = Visibility.Hidden; this.integerUpDownGrossTonnage.Visibility = Visibility.Hidden; } else { this.textBoxPurposeOfCall.Text = this.TOWA.TowageOnArrivalPurposeOfCall; this.integerUpDownGrossTonnage.Value = this.TOWA.TowageOnArrivalGrossTonnage; } this.doubleUpDownDraught.Value = this.IsDeparture ? this.TOWD.TowageOnDepartureDraught_DMT : this.TOWA.TowageOnArrivalDraught_DMT; this.doubleUpDownLength.Value = this.IsDeparture ? this.TOWD.TowageOnDepartureLengthOverall_MTR : this.TOWA.TowageOnArrivalLengthOverall_MTR; this.textBoxRemarks.Text = this.IsDeparture ? this.TOWD.TowageOnDepartureRemarks : this.TOWA.TowageOnArrivalRemarks; this.comboBoxFlag.ItemsSource = bsmd.database.CREW.NationalityDict; this.comboBoxFlag.SelectedValue = this.IsDeparture ? this.TOWD.TowageOnDepartureFlag : this.TOWA.TowageOnArrivalFlag; //this.comboBoxFlag.KeyUp += ComboBox_KeyUp; this.doubleUpDownBeam.Value = this.IsDeparture ? this.TOWD.TowageOnDepartureBeam_MTR : this.TOWA.TowageOnArrivalBeam_MTR; this.textBoxOperatorName.Text = this.IsDeparture ? this.TOWD.TowageOnDepartureOperatorCompanyName : this.TOWA.TowageOnArrivalOperatorCompanyName; this.textBoxStreetNumber.Text = this.IsDeparture ? this.TOWD.TowageOnDepartureOperatorStreetNameAndNumber : this.TOWA.TowageOnArrivalOperatorStreetNameAndNumber; this.textBoxPostalCode.Text = this.IsDeparture ? this.TOWD.TowageOnDepartureOperatorPostalCode : this.TOWA.TowageOnArrivalOperatorPostalCode; this.textBoxCountry.Text = this.IsDeparture ? this.TOWD.TowageOnDepartureOperatorCountry : this.TOWA.TowageOnArrivalOperatorCountry; this.textBoxPhone.Text = this.IsDeparture ? this.TOWD.TowageOnDepartureOperatorPhone : this.TOWA.TowageOnArrivalOperatorPhone; this.textBoxEMail.Text = this.IsDeparture ? this.TOWD.TowageOnDepartureOperatorEmail : this.TOWA.TowageOnArrivalOperatorEmail; this.textBoxCity.Text = this.IsDeparture ? this.TOWD.TowageOnDepartureOperatorCity : this.TOWA.TowageOnArrivalOperatorCity; this.textBoxFax.Text = this.IsDeparture ? this.TOWD.TowageOnDepartureOperatorFax : this.TOWA.TowageOnArrivalOperatorFax; this.OKClicked += EditTOWDialog_OKClicked; this.AddVisible = true; } public void CopyValuesToEntity() { if(this.IsDeparture) { this.TOWD.TowageOnDepartureName = this.textBoxName.Text.Trim(); this.TOWD.TowageOnDepartureDraught_DMT = this.doubleUpDownDraught.Value; this.TOWD.TowageOnDepartureLengthOverall_MTR = this.doubleUpDownLength.Value; this.TOWD.TowageOnDepartureRemarks = this.textBoxRemarks.Text.Trim(); this.TOWD.TowageOnDepartureFlag = (string) this.comboBoxFlag.SelectedValue; this.TOWD.TowageOnDepartureBeam_MTR = this.doubleUpDownBeam.Value; this.TOWD.TowageOnDepartureOperatorCompanyName = this.textBoxOperatorName.Text.Trim(); this.TOWD.TowageOnDepartureOperatorStreetNameAndNumber = this.textBoxStreetNumber.Text.Trim(); this.TOWD.TowageOnDepartureOperatorPostalCode = this.textBoxPostalCode.Text.Trim(); this.TOWD.TowageOnDepartureOperatorCountry = this.textBoxCountry.Text.Trim(); this.TOWD.TowageOnDepartureOperatorPhone = this.textBoxPhone.Text.Trim(); this.TOWD.TowageOnDepartureOperatorEmail = this.textBoxEMail.Text.Trim(); this.TOWD.TowageOnDepartureOperatorCity = this.textBoxCity.Text.Trim(); this.TOWD.TowageOnDepartureOperatorFax = this.textBoxFax.Text.Trim(); } else { this.TOWA.TowageOnArrivalName = this.textBoxName.Text.Trim(); this.TOWA.TowageOnArrivalPurposeOfCall = this.textBoxPurposeOfCall.Text.Trim(); this.TOWA.TowageOnArrivalDraught_DMT = this.doubleUpDownDraught.Value; this.TOWA.TowageOnArrivalLengthOverall_MTR = this.doubleUpDownLength.Value; this.TOWA.TowageOnArrivalRemarks = this.textBoxRemarks.Text.Trim(); this.TOWA.TowageOnArrivalFlag = (string) this.comboBoxFlag.SelectedValue; this.TOWA.TowageOnArrivalGrossTonnage = this.integerUpDownGrossTonnage.Value; this.TOWA.TowageOnArrivalBeam_MTR = this.doubleUpDownBeam.Value; this.TOWA.TowageOnArrivalOperatorCompanyName = this.textBoxOperatorName.Text.Trim(); this.TOWA.TowageOnArrivalOperatorStreetNameAndNumber = this.textBoxStreetNumber.Text.Trim(); this.TOWA.TowageOnArrivalOperatorPostalCode = this.textBoxPostalCode.Text.Trim(); this.TOWA.TowageOnArrivalOperatorCountry = this.textBoxCountry.Text.Trim(); this.TOWA.TowageOnArrivalOperatorPhone = this.textBoxPhone.Text.Trim(); this.TOWA.TowageOnArrivalOperatorEmail = this.textBoxEMail.Text.Trim(); this.TOWA.TowageOnArrivalOperatorCity = this.textBoxCity.Text.Trim(); this.TOWA.TowageOnArrivalOperatorFax = this.textBoxFax.Text.Trim(); } } private void EditTOWDialog_OKClicked() { this.CopyValuesToEntity(); } } }