// Copyright (c) 2017 schick Informatik // Description: PAS Bearbeitungsdialog // using System.Windows; using bsmd.database; using ENI2.Controls; using ENI2.Util; namespace ENI2.EditControls { /// /// Interaction logic for EditPasDialog.xaml /// public partial class EditPASDialog : EditWindowBase { public EditPASDialog() { InitializeComponent(); Loaded += EditPasDialog_Loaded; AddClicked += () => { this.textBoxLastName.Focus(); }; } public PAS PAS { get; set; } private void EditPasDialog_Loaded(object sender, RoutedEventArgs e) { // copy into fields this.textBoxLastName.Text = this.PAS.PassengerLastName; this.textBoxFirstName.Text = this.PAS.PassengerFirstName; this.comboBoxGender.ItemsSource = GlobalStructures.GenderList; //this.comboBoxGender.KeyUp += ComboBox_KeyUp; this.comboBoxGender.SelectedIndex = this.PAS.PassengerGender.HasValue ? this.PAS.PassengerGender.Value : -1; this.textBoxPlaceOfBirth.Text = this.PAS.PassengerPlaceOfBirth; this.comboBoxNationality.ItemsSource = bsmd.database.CREW.NationalityDict; //this.comboBoxNationality.KeyUp += ComboBox_KeyUp; this.comboBoxNationality.SelectedValue = this.PAS.PassengerNationality; this.datePickerDateOfBirth.SelectedDate = this.PAS.PassengerDateOfBirth; this.comboBoxIdDocType.ItemsSource = GlobalStructures.IDDocTypeList; //this.comboBoxIdDocType.KeyUp += ComboBox_KeyUp; this.comboBoxIdDocType.SelectedIndex = this.PAS.PassengerIdentityDocumentType.HasValue ? this.PAS.PassengerIdentityDocumentType.Value : -1; this.textBoxIdDocNumber.Text = this.PAS.PassengerIdentityDocumentId; this.textBoxVisaNumber.Text = this.PAS.PassengerVisaNumber; this.locodePortOfEmbarkation.LocodeValue = this.PAS.PassengerPortOfEmbarkation; this.locodePortOfDisembarkation.LocodeValue = this.PAS.PassengerPortOfDisembarkation; this.checkBoxTransitPassenger.IsChecked = this.PAS.PassengerInTransit; this.comboBoxIssuingState.ItemsSource = bsmd.database.CREW.NationalityDict; this.comboBoxIssuingState.SelectedValue = this.PAS.PassengerIdentityDocumentIssuingState; this.datePickerExpiryDate.SelectedDate = this.PAS.PassengerIdentityDocumentExpiryDate; this.OKClicked += EditPasDialog_OKClicked; this.AddVisible = true; } public void CopyValuesToEntity() { // copy back this.PAS.PassengerLastName = this.textBoxLastName.Text.Trim(); this.PAS.PassengerFirstName = this.textBoxFirstName.Text.Trim(); this.PAS.PassengerGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?)this.comboBoxGender.SelectedIndex; this.PAS.PassengerPlaceOfBirth = this.textBoxPlaceOfBirth.Text.Trim(); this.PAS.PassengerNationality = (this.comboBoxNationality.SelectedValue == null) ? "" : (string)this.comboBoxNationality.SelectedValue; this.PAS.PassengerDateOfBirth = this.datePickerDateOfBirth.SelectedDate; this.PAS.PassengerIdentityDocumentType = (this.comboBoxIdDocType.SelectedIndex == -1) ? null : (byte?)this.comboBoxIdDocType.SelectedIndex; this.PAS.PassengerIdentityDocumentId = this.textBoxIdDocNumber.Text.Trim(); this.PAS.PassengerVisaNumber = this.textBoxVisaNumber.Text.Trim(); this.PAS.PassengerPortOfEmbarkation = this.locodePortOfEmbarkation.LocodeValue; this.PAS.PassengerPortOfDisembarkation = this.locodePortOfDisembarkation.LocodeValue; this.PAS.PassengerInTransit = this.checkBoxTransitPassenger.IsChecked; this.PAS.PassengerIdentityDocumentIssuingState = (this.comboBoxIssuingState.SelectedValue == null) ? "" : (string)this.comboBoxIssuingState.SelectedValue; this.PAS.PassengerIdentityDocumentExpiryDate = this.datePickerExpiryDate.SelectedDate; } private void EditPasDialog_OKClicked() { this.CopyValuesToEntity(); } } }