113 lines
5.6 KiB
C#
113 lines
5.6 KiB
C#
// Copyright (c) 2017 schick Informatik
|
|
// Description: PAS Bearbeitungsdialog
|
|
//
|
|
|
|
using System;
|
|
using System.Windows;
|
|
|
|
using bsmd.database;
|
|
using ENI2.Controls;
|
|
using ENI2.Util;
|
|
|
|
namespace ENI2.EditControls
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for EditPasDialog.xaml
|
|
/// </summary>
|
|
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.GenderDict;
|
|
this.comboBoxGender.SelectedValue = this.PAS.PassengerGender?.ToString();
|
|
this.textBoxPlaceOfBirth.Text = this.PAS.PassengerPlaceOfBirth;
|
|
this.comboBoxNationality.ItemsSource = bsmd.database.CREW.NationalityDict;
|
|
this.comboBoxNationality.SelectedValue = this.PAS.PassengerNationality;
|
|
if (this.PAS.PassengerDateOfBirth > CREW.CLAMPMAXDATE)
|
|
{
|
|
this.datePickerDateOfBirth.SelectedDate = CREW.CLAMPMAXDATE;
|
|
}
|
|
else if (this.PAS.PassengerDateOfBirth < CREW.CLAMPMINDATE)
|
|
{
|
|
this.datePickerDateOfBirth.SelectedDate = CREW.CLAMPMINDATE;
|
|
}
|
|
else
|
|
{
|
|
this.datePickerDateOfBirth.SelectedDate = this.PAS.PassengerDateOfBirth;
|
|
}
|
|
this.comboBoxIdDocType.ItemsSource = GlobalStructures.IDDocTypeDict;
|
|
this.comboBoxIdDocType.SelectedValue = this.PAS.PassengerIdentityDocumentType?.ToString();
|
|
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;
|
|
|
|
if (this.PAS.PassengerIdentityDocumentExpiryDate > CREW.CLAMPMAXDATE)
|
|
{
|
|
this.datePickerExpiryDate.SelectedDate = CREW.CLAMPMAXDATE;
|
|
}
|
|
else if (this.PAS.PassengerIdentityDocumentExpiryDate < CREW.CLAMPMINDATE)
|
|
{
|
|
this.datePickerExpiryDate.SelectedDate = CREW.CLAMPMINDATE;
|
|
}
|
|
else
|
|
{
|
|
this.datePickerExpiryDate.SelectedDate = this.PAS.PassengerIdentityDocumentExpiryDate;
|
|
}
|
|
|
|
// XXX : TODO
|
|
//this.comboBoxCountryOfBirth.ItemsSource = bsmd.database.CREW.NationalityDict;
|
|
//this.comboBoxCountryOfBirth.SelectedValue = this.PAS.PassengerCountryOfBirth;
|
|
//this.textBoxEmergencyCare.Text = this.PAS.EmergencyCare;
|
|
//this.textBoxEmergencyContactNumber.Text = this.PAS.EmergencyContactNumber;
|
|
|
|
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?)byte.Parse((string)this.comboBoxGender.SelectedValue);
|
|
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?) byte.Parse((string)this.comboBoxIdDocType.SelectedValue);
|
|
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;
|
|
// XXX : TODO
|
|
// this.PAS.PassengerCountryOfBirth = (this.comboBoxCountryOfBirth.SelectedValue == null) ? "" : (string)this.comboBoxCountryOfBirth.SelectedValue;
|
|
//this.PAS.EmergencyCare = this.textBoxEmergencyCare.Text.Trim();
|
|
//this.PAS.EmergencyContactNumber = this.textBoxEmergencyContactNumber.Text.Trim();
|
|
}
|
|
|
|
private void EditPasDialog_OKClicked()
|
|
{
|
|
this.CopyValuesToEntity();
|
|
}
|
|
}
|
|
}
|