git_bsmd/ENI2/EditControls/EditCREWDialog.xaml.cs

85 lines
4.5 KiB
C#

// Copyright (c) 2017 schick Informatik
// Description: CREW Bearbeitungsdialog
//
using System.Windows;
using bsmd.database;
using ENI2.Controls;
using ENI2.Util;
namespace ENI2.EditControls
{
/// <summary>
/// Interaction logic for EditCREWDialog.xaml
/// </summary>
public partial class EditCREWDialog : EditWindowBase
{
public EditCREWDialog()
{
InitializeComponent();
Loaded += EditCREWDialog_Loaded;
AddClicked += () => { this.textBoxDuty.Focus(); };
}
public CREW CREW { get; set; }
private void EditCREWDialog_Loaded(object sender, RoutedEventArgs e)
{
// copy into fields
this.textBoxDuty.Text = this.CREW.CrewMemberDuty;
this.textBoxLastName.Text = this.CREW.CrewMemberLastName;
this.textBoxFirstName.Text = this.CREW.CrewMemberFirstName;
this.comboBoxGender.ItemsSource = GlobalStructures.GenderList;
//this.comboBoxGender.KeyUp += ComboBox_KeyUp;
this.comboBoxGender.SelectedIndex = this.CREW.CrewMemberGender ?? -1;
if (this.CREW.CrewMemberGender == 9)
this.comboBoxGender.SelectedIndex = 3;
this.textBoxPlaceOfBirth.Text = this.CREW.CrewMemberPlaceOfBirth;
this.comboBoxNationality.ItemsSource = bsmd.database.CREW.NationalityDict;
//this.comboBoxNationality.KeyUp += ComboBox_KeyUp;
this.comboBoxNationality.SelectedValue = this.CREW.CrewMemberNationality;
this.datePickerDateOfBirth.SelectedDate = this.CREW.CrewMemberDateOfBirth;
this.comboBoxIdDocType.ItemsSource = GlobalStructures.IDDocTypeList;
//this.comboBoxIdDocType.KeyUp += ComboBox_KeyUp;
this.comboBoxIdDocType.SelectedIndex = this.CREW.CrewMemberIdentityDocumentType ?? -1;
this.textBoxIdDocNumber.Text = this.CREW.CrewMemberIdentityDocumentId;
this.textBoxVisaNumber.Text = this.CREW.CrewMemberVisaNumber;
this.comboBoxIssuingState.ItemsSource = bsmd.database.CREW.NationalityDict;
this.comboBoxIssuingState.SelectedValue = this.CREW.CrewMemberIdentityDocumentIssuingState;
this.datePickerExpiryDate.SelectedDate = this.CREW.CrewMemberIdentityDocumentExpiryDate;
// this.comboBoxCountryOfBirth.ItemsSource = bsmd.database.CREW.NationalityDict; // XXX: TODO
// this.comboBoxCountryOfBirth.SelectedValue = this.CREW.CrewMemberCountryOfBirth;
// this.textBoxEffects.Text = this.CREW.Effects;
this.OKClicked += EditCREWDialog_OKClicked;
this.AddVisible = true;
}
public void CopyValuesToEntity()
{
// copy back
this.CREW.CrewMemberDuty = this.textBoxDuty.Text.Trim();
this.CREW.CrewMemberLastName = this.textBoxLastName.Text.Trim();
this.CREW.CrewMemberFirstName = this.textBoxFirstName.Text.Trim();
this.CREW.CrewMemberGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?) this.comboBoxGender.SelectedIndex;
if (this.CREW.CrewMemberGender == 3) this.CREW.CrewMemberGender = 9;
this.CREW.CrewMemberPlaceOfBirth = this.textBoxPlaceOfBirth.Text.Trim();
this.CREW.CrewMemberNationality = (this.comboBoxNationality.SelectedValue == null) ? "" : (string)this.comboBoxNationality.SelectedValue;
this.CREW.CrewMemberDateOfBirth = this.datePickerDateOfBirth.SelectedDate;
this.CREW.CrewMemberIdentityDocumentType = (this.comboBoxIdDocType.SelectedIndex == -1) ? null : (byte?)this.comboBoxIdDocType.SelectedIndex;
this.CREW.CrewMemberIdentityDocumentId = this.textBoxIdDocNumber.Text.Trim();
this.CREW.CrewMemberVisaNumber = this.textBoxVisaNumber.Text.Trim();
this.CREW.CrewMemberIdentityDocumentIssuingState = (this.comboBoxIssuingState.SelectedValue == null) ? "" : (string)this.comboBoxIssuingState.SelectedValue;
this.CREW.CrewMemberIdentityDocumentExpiryDate = this.datePickerExpiryDate.SelectedDate;
// this.CREW.CrewMemberCountryOfBirth = (this.comboBoxCountryOfBirth.SelectedValue == null) ? "" : (string)this.comboBoxCountryOfBirth.SelectedValue;
// this.CREW.Effects = this.textBoxEffects.Text.Trim();
}
private void EditCREWDialog_OKClicked()
{
this.CopyValuesToEntity();
}
}
}