// Copyright (c) 2017 schick Informatik // Description: Reporting party Bearbeitungsdialog // using System; using System.Windows; using bsmd.database; using ENI2.Controls; using ENI2.Util; namespace ENI2.EditControls { /// /// Interaction logic for EditReportingPartyDialog.xaml /// public partial class EditReportingPartyDialog : EditWindowBase { public EditReportingPartyDialog() { InitializeComponent(); Loaded += EditReportingPartyDialog_Loaded; } public ReportingParty ReportingParty { get; set; } private void EditReportingPartyDialog_Loaded(object sender, RoutedEventArgs e) { this.comboBoxDefaultDisplay.ItemsSource = Util.EnumHelper.GetAllValuesAndDescription(typeof(ReportingParty.ShipcallDisplayModeEnum)); this.textBoxCity.Text = this.ReportingParty.City; this.textBoxCountry.Text = this.ReportingParty.Country; this.textBoxEMail.Text = this.ReportingParty.EMail; this.textBoxFax.Text = this.ReportingParty.Fax; this.textBoxFirstName.Text = this.ReportingParty.FirstName; this.textBoxLastName.Text = this.ReportingParty.LastName; this.textBoxName.Text = this.ReportingParty.Name; this.textBoxPhone.Text = this.ReportingParty.Phone; this.textBoxPostalCode.Text = this.ReportingParty.PostalCode; this.textBoxStreetNumber.Text = this.ReportingParty.StreetAndNumber; this.textBoxUserEMail.Text = this.ReportingParty.UserEMail; this.textBoxUserLogon.Text = this.ReportingParty.Logon; this.checkBoxAdministrator.IsChecked = this.ReportingParty.IsAdmin; this.checkBoxArchived.IsChecked = this.ReportingParty.IsArchived; this.checkBoxEditor.IsChecked = this.ReportingParty.IsEditor; this.comboBoxDefaultDisplay.SelectedValue = this.ReportingParty.ShipcallDisplayMode; this.dateTimePickerChanged.Content = this.ReportingParty.Changed.HasValue ? this.ReportingParty.Changed.ToString() : ""; this.dateTimePickerCreated.Content = this.ReportingParty.Created.HasValue ? this.ReportingParty.Created.ToString() : ""; this.AddVisible = false; // hier mal nicht this.OKClicked += EditReportingPartyDialog_OKClicked; } public void CopyValuesToEntity() { this.ReportingParty.City = this.textBoxCity.Text.Trim(); this.ReportingParty.Country = this.textBoxCountry.Text.Trim(); this.ReportingParty.EMail = this.textBoxEMail.Text.Trim(); this.ReportingParty.Fax = this.textBoxFax.Text.Trim(); this.ReportingParty.FirstName = this.textBoxFirstName.Text.Trim(); this.ReportingParty.LastName = this.textBoxLastName.Text.Trim(); this.ReportingParty.Name = this.textBoxName.Text.Trim(); this.ReportingParty.Phone = this.textBoxPhone.Text.Trim(); this.ReportingParty.PostalCode = this.textBoxPostalCode.Text.Trim(); this.ReportingParty.StreetAndNumber = this.textBoxStreetNumber.Text.Trim(); this.ReportingParty.UserEMail = this.textBoxUserEMail.Text.Trim(); this.ReportingParty.Logon = this.textBoxUserLogon.Text.Trim(); this.ReportingParty.ShipcallDisplayMode = (ReportingParty.ShipcallDisplayModeEnum) Enum.Parse(typeof(ReportingParty.ShipcallDisplayModeEnum), (string) this.comboBoxDefaultDisplay.SelectedValue); if(!this.passwordBoxPassword.Password.IsNullOrEmpty()) { this.ReportingParty.SetPassword(this.passwordBoxPassword.Password); } this.ReportingParty.IsAdmin = this.checkBoxAdministrator.IsChecked ?? false; this.ReportingParty.IsArchived = this.checkBoxArchived.IsChecked ?? false; this.ReportingParty.IsEditor = this.checkBoxEditor.IsChecked ?? false; // save value DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(this.ReportingParty); } private void EditReportingPartyDialog_OKClicked() { this.CopyValuesToEntity(); } } }