git_bsmd/ENI2/EditControls/EditReportingPartyDialog.xaml.cs

85 lines
3.8 KiB
C#

// Copyright (c) 2017 schick Informatik
// Description: Reporting party Bearbeitungsdialog
//
using System.Windows;
using bsmd.database;
using ENI2.Controls;
using ENI2.Util;
namespace ENI2.EditControls
{
/// <summary>
/// Interaction logic for EditReportingPartyDialog.xaml
/// </summary>
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.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.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();
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();
}
}
}