Moved display selection to pw change, fixed bug in BRKD, increased version

This commit is contained in:
Daniel Schick 2025-03-04 07:46:11 +01:00
parent afb33fd249
commit d97692ff94
9 changed files with 86 additions and 40 deletions

View File

@ -36,8 +36,8 @@
<MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>7.2.7.2</ApplicationVersion>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>7.2.7.3</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>

View File

@ -4,8 +4,9 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:p="clr-namespace:ENI2.Properties"
mc:Ignorable="d"
Title="Change password" Height="215" Width="400" Loaded="EditWindowBase_Loaded" Background="AliceBlue">
Title="Change password" Height="243" Width="400" Loaded="EditWindowBase_Loaded" Background="AliceBlue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
@ -13,6 +14,7 @@
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".4*" />
@ -20,14 +22,16 @@
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="Name" />
<Label Grid.Row="1" Grid.Column="0" Content="Old password" />
<Label Grid.Row="2" Grid.Column="0" Content="New password" />
<Label Grid.Row="3" Grid.Column="0" Content="Repeat new password" />
<Label Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textOldPassword}" />
<Label Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textNewPassword}" />
<Label Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textRepeatNewPassword}" />
<TextBlock Grid.Row="0" Grid.Column="1" x:Name="textBlockName" VerticalAlignment="Center" FontWeight="DemiBold"/>
<PasswordBox Grid.Row="1" Grid.Column="1" x:Name="textBoxOldPassword" Margin="2" VerticalContentAlignment="Center" />
<PasswordBox Grid.Row="2" Grid.Column="1" x:Name="textBoxNew1Password" Margin="2" VerticalContentAlignment="Center" />
<PasswordBox Grid.Row="3" Grid.Column="1" x:Name="textBoxNew2Password" Margin="2" VerticalContentAlignment="Center" />
<Button Grid.Row="4" Grid.Column="1" Content="Change" Name="buttonChangePassword" Margin="2" Width="80" HorizontalAlignment="Left" Click="buttonChangePassword_Click"/>
<Label Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textDefaultDisplay}" />
<ComboBox x:Name="comboBoxDefaultDisplay" Grid.Column="1" Grid.Row="4" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" IsEditable="False" />
<Button Grid.Row="5" Grid.Column="1" Content="Change" Name="buttonChangePassword" Margin="2" Width="80" HorizontalAlignment="Left" Click="buttonChangePassword_Click"/>
</Grid>
</enictrl:EditWindowBase>

View File

@ -4,6 +4,7 @@
using bsmd.database;
using ENI2.Controls;
using System;
using System.Windows;
using System.Windows.Controls;
@ -36,43 +37,48 @@ namespace ENI2.EditControls
{
bool success = false;
string message = "";
if(!textBoxOldPassword.Password.IsNullOrEmpty())
if (!textBoxOldPassword.Password.IsNullOrEmpty() || !textBoxNew1Password.Password.IsNullOrEmpty() || !textBoxNew2Password.Password.IsNullOrEmpty())
{
if(CurrentUser.GetHash(textBoxOldPassword.Password).Equals(CurrentUser.PasswordHash))
if (!textBoxOldPassword.Password.IsNullOrEmpty())
{
if(textBoxNew1Password.Password.IsNullOrEmpty() ||
textBoxNew2Password.Password.IsNullOrEmpty() ||
!textBoxNew1Password.Password.Equals(textBoxNew2Password.Password))
if (CurrentUser.GetHash(textBoxOldPassword.Password).Equals(CurrentUser.PasswordHash))
{
message = "New passwords are empty or do not match";
}
else
{
if (textBoxOldPassword.Password.Equals(textBoxNew1Password.Password))
if (textBoxNew1Password.Password.IsNullOrEmpty() ||
textBoxNew2Password.Password.IsNullOrEmpty() ||
!textBoxNew1Password.Password.Equals(textBoxNew2Password.Password))
{
message = "Old and new password are the same";
message = "New passwords are empty or do not match";
}
else
{
CurrentUser.SetPassword(textBoxNew1Password.Password);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(CurrentUser);
success = true;
if (textBoxOldPassword.Password.Equals(textBoxNew1Password.Password))
{
message = "Old and new password are the same";
}
else
{
CurrentUser.SetPassword(textBoxNew1Password.Password);
success = true;
}
}
}
else
{
message = "Old password is not correct";
}
}
else
{
message = "Old password is not correct";
message = "Old password empty";
}
if (!success)
MessageBox.Show(message, "Changing password failed", MessageBoxButton.OK, MessageBoxImage.Error);
else
MessageBox.Show("Password successfully changed.", "Password changed", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
message = "Old password empty";
}
if (!success)
MessageBox.Show(message, "Changing password failed", MessageBoxButton.OK, MessageBoxImage.Error);
else
MessageBox.Show("Password successfully changed.", "Password changed", MessageBoxButton.OK, MessageBoxImage.Information);
// user may have changed combobox default display value so we are saving anyway here
this.CurrentUser.ShipcallDisplayMode = (ReportingParty.ShipcallDisplayModeEnum)Enum.Parse(typeof(ReportingParty.ShipcallDisplayModeEnum), (string)this.comboBoxDefaultDisplay.SelectedValue);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(CurrentUser);
}
private void EditWindowBase_Loaded(object sender, RoutedEventArgs e)
@ -82,6 +88,8 @@ namespace ENI2.EditControls
this.OkVisible = false;
var cancelButton = (Button)Template.FindName("buttonCancel", this);
cancelButton.Content = "Close";
this.comboBoxDefaultDisplay.ItemsSource = Util.EnumHelper.GetAllValuesAndDescription(typeof(ReportingParty.ShipcallDisplayModeEnum));
this.comboBoxDefaultDisplay.SelectedValue = this.CurrentUser.ShipcallDisplayMode;
}
#endregion

View File

@ -48,7 +48,7 @@
<Label Name="labelAdmin" Grid.Row="7" Grid.Column="2" Content="{x:Static p:Resources.textAdministrator}" HorizontalContentAlignment="Right" />
<Label Name="labelArchived" Grid.Row="8" Grid.Column="0" Content="{x:Static p:Resources.textArchived}" HorizontalContentAlignment="Right" />
<Label Name="labelEditor" Grid.Row="8" Grid.Column="2" Content="{x:Static p:Resources.textEditor}" HorizontalContentAlignment="Right" />
<Label Name="labelDefaultDisplay" Grid.Row="9" Grid.Column="0" Content="{x:Static p:Resources.textDefaultDisplay}" HorizontalContentAlignment="Right" />
<Label Name="labelCreated" Grid.Row="10" Grid.Column="0" Content="{x:Static p:Resources.textCreated}" HorizontalContentAlignment="Right" />
<Label Name="labelChanged" Grid.Row="10" Grid.Column="2" Content="{x:Static p:Resources.textChanged}" HorizontalContentAlignment="Right" />
@ -69,7 +69,6 @@
<CheckBox Grid.Row="7" Grid.Column="3" VerticalAlignment="Center" Name="checkBoxAdministrator" Margin="2" />
<CheckBox Grid.Row="8" Grid.Column="3" VerticalAlignment="Center" Name="checkBoxEditor" Margin="2" />
<CheckBox Grid.Row="8" Grid.Column="1" VerticalAlignment="Center" Name="checkBoxArchived" Margin="2" />
<ComboBox x:Name="comboBoxDefaultDisplay" Grid.Column="1" Grid.Row="9" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" />
<Label Grid.Row="10" Grid.Column="1" Name="dateTimePickerCreated" FontStyle="Italic" />
<Label Grid.Row="10" Grid.Column="3" Name="dateTimePickerChanged" FontStyle="Italic" />

View File

@ -25,7 +25,7 @@ namespace ENI2.EditControls
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;
@ -42,7 +42,7 @@ namespace ENI2.EditControls
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() : "";
@ -65,7 +65,6 @@ namespace ENI2.EditControls
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())
{

View File

@ -4188,6 +4188,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to New password.
/// </summary>
public static string textNewPassword {
get {
return ResourceManager.GetString("textNewPassword", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Create new id.
/// </summary>
@ -4323,6 +4332,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Old password.
/// </summary>
public static string textOldPassword {
get {
return ResourceManager.GetString("textOldPassword", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to This only works if the grid is empty!.
/// </summary>
@ -4989,6 +5007,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Repeat new password.
/// </summary>
public static string textRepeatNewPassword {
get {
return ResourceManager.GetString("textRepeatNewPassword", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Reporting party.
/// </summary>

View File

@ -2218,4 +2218,13 @@
<data name="textTab53" xml:space="preserve">
<value>4 Tanker</value>
</data>
<data name="textNewPassword" xml:space="preserve">
<value>New password</value>
</data>
<data name="textOldPassword" xml:space="preserve">
<value>Old password</value>
</data>
<data name="textRepeatNewPassword" xml:space="preserve">
<value>Repeat new password</value>
</data>
</root>

View File

@ -51,7 +51,7 @@
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textAnchored}" Name="label_IsAnchored" Margin="0,0,10,0" />
<CheckBox Grid.Column="1" Grid.Row="3" IsThreeState="True" VerticalContentAlignment="Center" Name="checkBox_IsAnchored" IsChecked="{Binding IsAnchored}"/>
<Label HorizontalContentAlignment="Right" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textAreMatterToReport}" Name="label_AreMatterToReport" Margin="0,0,10,0"/>
<CheckBox Grid.Column="1" Grid.Row="4" IsThreeState="True" VerticalContentAlignment="Center" Name="checkBox_AreMatterToReport" IsChecked="{Binding IsAnchored}"/>
<CheckBox Grid.Column="1" Grid.Row="4" IsThreeState="True" VerticalContentAlignment="Center" Name="checkBox_AreMatterToReport" IsChecked="{Binding AreMatterToReport}"/>
<Label HorizontalContentAlignment="Right" Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textMatterToReport}" Name="label_MatterToReport" Margin="0,0,10,0"/>
<TextBox Name="textBoxMatterToReport" Grid.Row="5" Grid.Column="1" MaxLength="1024" Text="{Binding MatterToReport, Converter={util:TrimStringConverter}}" Margin="2" VerticalContentAlignment="Center"/>

View File

@ -69,7 +69,7 @@ namespace ENI2.SheetDisplayControls
// 4.3
this.dataGridBKRD.Initialize();
this.dataGridBKRD.ItemsSource = this._brkaMessage.Elements;
this.dataGridBKRD.ItemsSource = this._brkdMessage.Elements;
this.dataGridBKRD.AddingNewItem += DataGridBKRD_AddingNewItem;
this.dataGridBKRD.EditRequested += DataGridBKRD_EditRequested;
this.dataGridBKRD.DeleteRequested += DataGridBKRD_DeleteRequested;