Fix Original/Default input detection in DeliveryAdminWindow
This commit is contained in:
@ -25,6 +25,10 @@ namespace Elwig.Helpers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetInputNotDefault(Control input) {
|
||||||
|
SetControlBrush(input, Brushes.Gold);
|
||||||
|
}
|
||||||
|
|
||||||
public static void SetInputChanged(Control input) {
|
public static void SetInputChanged(Control input) {
|
||||||
SetControlBrush(input, Brushes.Orange);
|
SetControlBrush(input, Brushes.Orange);
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ namespace Elwig.Windows {
|
|||||||
private RadioButton[] RadioButtonInputs;
|
private RadioButton[] RadioButtonInputs;
|
||||||
private readonly Dictionary<Control, bool> Valid;
|
private readonly Dictionary<Control, bool> Valid;
|
||||||
private readonly Dictionary<Control, object?> OriginalValues;
|
private readonly Dictionary<Control, object?> OriginalValues;
|
||||||
|
private readonly Dictionary<Control, object?> DefaultValues;
|
||||||
|
|
||||||
public AdministrationWindow() : base() {
|
public AdministrationWindow() : base() {
|
||||||
IsEditing = false;
|
IsEditing = false;
|
||||||
@ -58,6 +59,7 @@ namespace Elwig.Windows {
|
|||||||
RadioButtonInputs = Array.Empty<RadioButton>();
|
RadioButtonInputs = Array.Empty<RadioButton>();
|
||||||
Valid = new();
|
Valid = new();
|
||||||
OriginalValues = new();
|
OriginalValues = new();
|
||||||
|
DefaultValues = new();
|
||||||
Closing += OnClosing;
|
Closing += OnClosing;
|
||||||
Loaded += OnLoaded;
|
Loaded += OnLoaded;
|
||||||
}
|
}
|
||||||
@ -101,6 +103,12 @@ namespace Elwig.Windows {
|
|||||||
return (sender is Control c) && RequiredInputs.Contains(c);
|
return (sender is Control c) && RequiredInputs.Contains(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void FinishInputFilling() {
|
||||||
|
FillOriginalValues();
|
||||||
|
ValidateDefaultValues();
|
||||||
|
ValidateRequiredInputs();
|
||||||
|
}
|
||||||
|
|
||||||
protected void ClearInputStates() {
|
protected void ClearInputStates() {
|
||||||
foreach (var tb in TextBoxInputs)
|
foreach (var tb in TextBoxInputs)
|
||||||
ControlUtils.ClearInputState(tb);
|
ControlUtils.ClearInputState(tb);
|
||||||
@ -121,10 +129,25 @@ namespace Elwig.Windows {
|
|||||||
Valid[input] = false;
|
Valid[input] = false;
|
||||||
} else if (input is ComboBox cb && cb.SelectedItem == null && cb.ItemsSource != null) {
|
} else if (input is ComboBox cb && cb.SelectedItem == null && cb.ItemsSource != null) {
|
||||||
ControlUtils.SetInputInvalid(input);
|
ControlUtils.SetInputInvalid(input);
|
||||||
|
} else if (input is CheckComboBox ccb && ccb.SelectedItem == null && ccb.ItemsSource != null) {
|
||||||
|
ControlUtils.SetInputInvalid(input);
|
||||||
|
} else if (input is CheckBox ckb && ckb.IsChecked != true) {
|
||||||
|
ControlUtils.SetInputInvalid(input);
|
||||||
|
Valid[input] = false;
|
||||||
|
} else if (input is RadioButton rb && rb.IsChecked != true) {
|
||||||
|
ControlUtils.SetInputInvalid(input);
|
||||||
|
Valid[input] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void ValidateDefaultValues() {
|
||||||
|
foreach (var input in DefaultValues.Keys) {
|
||||||
|
if (InputIsNotDefault(input))
|
||||||
|
ControlUtils.SetInputNotDefault(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void LockInputs() {
|
protected void LockInputs() {
|
||||||
foreach (var tb in TextBoxInputs) {
|
foreach (var tb in TextBoxInputs) {
|
||||||
tb.IsReadOnly = true;
|
tb.IsReadOnly = true;
|
||||||
@ -159,6 +182,10 @@ namespace Elwig.Windows {
|
|||||||
OriginalValues.Clear();
|
OriginalValues.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void ClearDefaultValues() {
|
||||||
|
DefaultValues.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
protected void FillOriginalValues() {
|
protected void FillOriginalValues() {
|
||||||
foreach (var tb in TextBoxInputs)
|
foreach (var tb in TextBoxInputs)
|
||||||
OriginalValues[tb] = tb.Text;
|
OriginalValues[tb] = tb.Text;
|
||||||
@ -174,10 +201,34 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
protected void SetOriginalValue(Control input, object? value) {
|
protected void SetOriginalValue(Control input, object? value) {
|
||||||
OriginalValues[input] = value;
|
OriginalValues[input] = value;
|
||||||
|
if (InputHasChanged(input)) {
|
||||||
|
ControlUtils.SetInputChanged(input);
|
||||||
|
} else {
|
||||||
|
ControlUtils.ClearInputState(input);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void UnsetOriginalValue(Control input) {
|
protected void UnsetOriginalValue(Control input) {
|
||||||
OriginalValues.Remove(input);
|
OriginalValues.Remove(input);
|
||||||
|
ControlUtils.ClearInputState(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void SetDefaultValue(Control input, object? value) {
|
||||||
|
DefaultValues[input] = value;
|
||||||
|
if (!InputHasChanged(input)) {
|
||||||
|
if (InputIsNotDefault(input)) {
|
||||||
|
ControlUtils.SetInputNotDefault(input);
|
||||||
|
} else {
|
||||||
|
ControlUtils.ClearInputState(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void UnsetDefaultValue(Control input) {
|
||||||
|
DefaultValues.Remove(input);
|
||||||
|
if (!InputHasChanged(input)) {
|
||||||
|
ControlUtils.ClearInputState(input);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ClearInputs(bool validate = true) {
|
protected void ClearInputs(bool validate = true) {
|
||||||
@ -218,6 +269,24 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected bool InputIsNotDefault(Control input) {
|
||||||
|
if (!DefaultValues.ContainsKey(input)) {
|
||||||
|
return false;
|
||||||
|
} else if (input is TextBox tb) {
|
||||||
|
return DefaultValues[tb]?.ToString() != tb.Text;
|
||||||
|
} else if (input is ComboBox sb) {
|
||||||
|
return DefaultValues[sb] != sb.SelectedItem;
|
||||||
|
} else if (input is CheckComboBox ccb) {
|
||||||
|
return !ccb.SelectedItems.Cast<object>().ToArray().SequenceEqual(((object[]?)DefaultValues[ccb]) ?? Array.Empty<object>());
|
||||||
|
} else if (input is CheckBox cb) {
|
||||||
|
return (DefaultValues[cb] != null) != (cb.IsChecked ?? false);
|
||||||
|
} else if (input is RadioButton rb) {
|
||||||
|
return (DefaultValues[rb] != null) != (rb.IsChecked ?? false);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected bool HasChanged =>
|
protected bool HasChanged =>
|
||||||
!IsValid ||
|
!IsValid ||
|
||||||
TextBoxInputs.Any(InputHasChanged) ||
|
TextBoxInputs.Any(InputHasChanged) ||
|
||||||
@ -269,6 +338,8 @@ namespace Elwig.Windows {
|
|||||||
if (res.IsValid) {
|
if (res.IsValid) {
|
||||||
if (InputHasChanged(input)) {
|
if (InputHasChanged(input)) {
|
||||||
ControlUtils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
|
} else if (InputIsNotDefault(input)) {
|
||||||
|
ControlUtils.SetInputNotDefault(input);
|
||||||
} else {
|
} else {
|
||||||
ControlUtils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
@ -299,6 +370,8 @@ namespace Elwig.Windows {
|
|||||||
ControlUtils.SetInputInvalid(input);
|
ControlUtils.SetInputInvalid(input);
|
||||||
} else if (InputHasChanged(input)) {
|
} else if (InputHasChanged(input)) {
|
||||||
ControlUtils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
|
} else if (InputIsNotDefault(input)) {
|
||||||
|
ControlUtils.SetInputNotDefault(input);
|
||||||
} else {
|
} else {
|
||||||
ControlUtils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
@ -311,6 +384,8 @@ namespace Elwig.Windows {
|
|||||||
ControlUtils.SetInputInvalid(input);
|
ControlUtils.SetInputInvalid(input);
|
||||||
} else if (InputHasChanged(input)) {
|
} else if (InputHasChanged(input)) {
|
||||||
ControlUtils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
|
} else if (InputIsNotDefault(input)) {
|
||||||
|
ControlUtils.SetInputNotDefault(input);
|
||||||
} else {
|
} else {
|
||||||
ControlUtils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
@ -326,6 +401,8 @@ namespace Elwig.Windows {
|
|||||||
ValidateInput(input, true);
|
ValidateInput(input, true);
|
||||||
if (InputHasChanged(input)) {
|
if (InputHasChanged(input)) {
|
||||||
ControlUtils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
|
} else if (InputIsNotDefault(input)) {
|
||||||
|
ControlUtils.SetInputNotDefault(input);
|
||||||
} else {
|
} else {
|
||||||
ControlUtils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
@ -344,6 +421,8 @@ namespace Elwig.Windows {
|
|||||||
ValidateInput(input, true);
|
ValidateInput(input, true);
|
||||||
if (InputHasChanged(input)) {
|
if (InputHasChanged(input)) {
|
||||||
ControlUtils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
|
} else if (InputIsNotDefault(input)) {
|
||||||
|
ControlUtils.SetInputNotDefault(input);
|
||||||
} else {
|
} else {
|
||||||
ControlUtils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
|
@ -80,14 +80,13 @@ namespace Elwig.Windows {
|
|||||||
AreaComTypeInput.SelectedItem = a.AreaComType;
|
AreaComTypeInput.SelectedItem = a.AreaComType;
|
||||||
WineCultivationInput.SelectedItem = a.WineCult;
|
WineCultivationInput.SelectedItem = a.WineCult;
|
||||||
|
|
||||||
FillOriginalValues();
|
FinishInputFilling();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void InitInputs() {
|
private async void InitInputs() {
|
||||||
FbNrInput.Text = (await Context.NextFbNr()).ToString();
|
FbNrInput.Text = (await Context.NextFbNr()).ToString();
|
||||||
MgNrInput.Text = Member.MgNr.ToString();
|
MgNrInput.Text = Member.MgNr.ToString();
|
||||||
FillOriginalValues();
|
FinishInputFilling();
|
||||||
ValidateRequiredInputs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task RenewContext() {
|
protected override async Task RenewContext() {
|
||||||
|
@ -192,7 +192,8 @@
|
|||||||
DisplayMemberPath="Name" TextSearch.TextPath="Name"/>
|
DisplayMemberPath="Name" TextSearch.TextPath="Name"/>
|
||||||
|
|
||||||
<Label Content="Anmerkung:" Margin="10,100,0,10"/>
|
<Label Content="Anmerkung:" Margin="10,100,0,10"/>
|
||||||
<TextBox x:Name="CommentInput" Grid.Column="1" Margin="0,100,10,10"/>
|
<TextBox x:Name="CommentInput" Grid.Column="1" Margin="0,100,10,10"
|
||||||
|
TextChanged="TextBox_TextChanged"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
@ -261,10 +262,12 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<CheckBox x:Name="ManualWeighingInput" Content="Handwiegung" IsEnabled="False"
|
<CheckBox x:Name="ManualWeighingInput" Content="Handwiegung" IsEnabled="False"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,45,10,10" Grid.Column="0" Grid.ColumnSpan="2"/>
|
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,45,10,10" Grid.Column="0" Grid.ColumnSpan="2"
|
||||||
|
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
||||||
|
|
||||||
<CheckBox x:Name="GerebeltGewogenInput" Content="Gerebelt gewogen"
|
<CheckBox x:Name="GerebeltGewogenInput" Content="Gerebelt gewogen"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,75,10,10" Grid.Column="0" Grid.ColumnSpan="2"/>
|
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,75,10,10" Grid.Column="0" Grid.ColumnSpan="2"
|
||||||
|
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
||||||
|
|
||||||
<Button x:Name="WeighingManualButton" Content="Handwiegung" Width="120"
|
<Button x:Name="WeighingManualButton" Content="Handwiegung" Width="120"
|
||||||
Click="WeighingManualButton_Click"
|
Click="WeighingManualButton_Click"
|
||||||
@ -299,7 +302,8 @@
|
|||||||
ItemSelectionChanged="ModifiersInput_SelectionChanged"/>
|
ItemSelectionChanged="ModifiersInput_SelectionChanged"/>
|
||||||
|
|
||||||
<Label Content="Anmerkung:" Margin="10,40,0,10"/>
|
<Label Content="Anmerkung:" Margin="10,40,0,10"/>
|
||||||
<TextBox x:Name="PartCommentInput" Grid.Column="1" Margin="0,40,10,10" Grid.ColumnSpan="2"/>
|
<TextBox x:Name="PartCommentInput" Grid.Column="1" Margin="0,40,10,10" Grid.ColumnSpan="2"
|
||||||
|
TextChanged="TextBox_TextChanged"/>
|
||||||
|
|
||||||
<Label Content="Temperatur:" Margin="10,70,0,10"/>
|
<Label Content="Temperatur:" Margin="10,70,0,10"/>
|
||||||
<Grid Grid.Column="1" Height="25" Margin="0,70,10,10" VerticalAlignment="Top">
|
<Grid Grid.Column="1" Height="25" Margin="0,70,10,10" VerticalAlignment="Top">
|
||||||
@ -314,9 +318,11 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<CheckBox x:Name="LesewagenInput" Content="Lesewagen" Margin="10,75,0,0" Grid.Column="2"
|
<CheckBox x:Name="LesewagenInput" Content="Lesewagen" Margin="10,75,0,0" Grid.Column="2"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||||
|
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
||||||
<CheckBox x:Name="HandPickedInput" Content="Handlese" Margin="10,105,0,0" Grid.Column="2" IsThreeState="True"
|
<CheckBox x:Name="HandPickedInput" Content="Handlese" Margin="10,105,0,0" Grid.Column="2" IsThreeState="True"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Left"/>
|
VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||||
|
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
|
@ -74,6 +74,10 @@ namespace Elwig.Windows {
|
|||||||
WeighingCButton.Visibility = Visibility.Hidden;
|
WeighingCButton.Visibility = Visibility.Hidden;
|
||||||
WeighingDButton.Visibility = Visibility.Hidden;
|
WeighingDButton.Visibility = Visibility.Hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (App.Client.Client == ClientParameters.Type.Matzen) {
|
||||||
|
SetDefaultValue(GerebeltGewogenInput, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeliveryAdminWindow(int mgnr) : this() {
|
public DeliveryAdminWindow(int mgnr) : this() {
|
||||||
@ -120,11 +124,13 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private void InitialInputs() {
|
private void InitialInputs() {
|
||||||
HandPickedInput.IsChecked = null;
|
HandPickedInput.IsChecked = null;
|
||||||
|
SetDefaultValue(HandPickedInput, null);
|
||||||
if (App.Client.Client == ClientParameters.Type.Matzen) {
|
if (App.Client.Client == ClientParameters.Type.Matzen) {
|
||||||
GerebeltGewogenInput.IsChecked = true;
|
GerebeltGewogenInput.IsChecked = true;
|
||||||
GerebeltGewogenInput.IsEnabled = false;
|
GerebeltGewogenInput.IsEnabled = false;
|
||||||
} else {
|
} else {
|
||||||
GerebeltGewogenInput.IsChecked = false;
|
GerebeltGewogenInput.IsChecked = false;
|
||||||
|
UnsetDefaultValue(GerebeltGewogenInput);
|
||||||
GerebeltGewogenInput.IsEnabled = true;
|
GerebeltGewogenInput.IsEnabled = true;
|
||||||
}
|
}
|
||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
@ -372,7 +378,7 @@ namespace Elwig.Windows {
|
|||||||
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync(), i => (i as Member)?.MgNr);
|
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync(), i => (i as Member)?.MgNr);
|
||||||
ControlUtils.RenewItemsSource(BranchInput, await Context.Branches.OrderBy(b => b.Name).ToListAsync(), i => (i as Branch)?.ZwstId);
|
ControlUtils.RenewItemsSource(BranchInput, await Context.Branches.OrderBy(b => b.Name).ToListAsync(), i => (i as Branch)?.ZwstId);
|
||||||
ControlUtils.RenewItemsSource(WineVarietyInput, await Context.WineVarieties.OrderBy(v => v.Name).ToListAsync(), i => (i as WineVar)?.SortId);
|
ControlUtils.RenewItemsSource(WineVarietyInput, await Context.WineVarieties.OrderBy(v => v.Name).ToListAsync(), i => (i as WineVar)?.SortId);
|
||||||
ControlUtils.RenewItemsSource(AttributesInput, await Context.WineAttributes.OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
|
ControlUtils.RenewItemsSource(AttributesInput, await Context.WineAttributes.Where(a => IsCreating || a.IsActive).OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
|
||||||
ControlUtils.RenewItemsSource(WineQualityLevelInput, await Context.WineQualityLevels.ToListAsync(), i => (i as WineQualLevel)?.QualId);
|
ControlUtils.RenewItemsSource(WineQualityLevelInput, await Context.WineQualityLevels.ToListAsync(), i => (i as WineQualLevel)?.QualId);
|
||||||
ControlUtils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Year == y).OrderBy(m => m.Ordering).ToListAsync(), i => (i as Modifier)?.ModId);
|
ControlUtils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Year == y).OrderBy(m => m.Ordering).ToListAsync(), i => (i as Modifier)?.ModId);
|
||||||
ControlUtils.RenewItemsSource(WineOriginInput, (await Context.WineOrigins.ToListAsync()).OrderByDescending(o => o.SortKey).ThenBy(o => o.HkId), i => (i as WineOrigin)?.HkId);
|
ControlUtils.RenewItemsSource(WineOriginInput, (await Context.WineOrigins.ToListAsync()).OrderByDescending(o => o.SortKey).ThenBy(o => o.HkId), i => (i as WineOrigin)?.HkId);
|
||||||
@ -433,12 +439,12 @@ namespace Elwig.Windows {
|
|||||||
TemperatureInput.Text = "";
|
TemperatureInput.Text = "";
|
||||||
AcidInput.Text = "";
|
AcidInput.Text = "";
|
||||||
|
|
||||||
FillOriginalValues();
|
FinishInputFilling();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillInputs(DeliveryPart p) {
|
private void FillInputs(DeliveryPart p) {
|
||||||
ClearOriginalValues();
|
|
||||||
FillInputs(p.Delivery);
|
FillInputs(p.Delivery);
|
||||||
|
ClearOriginalValues();
|
||||||
|
|
||||||
SortIdInput.Text = p?.SortId ?? "";
|
SortIdInput.Text = p?.SortId ?? "";
|
||||||
ControlUtils.SelectCheckComboBoxItems(AttributesInput, p?.Attributes, i => (i as WineAttr)?.AttrId);
|
ControlUtils.SelectCheckComboBoxItems(AttributesInput, p?.Attributes, i => (i as WineAttr)?.AttrId);
|
||||||
@ -457,7 +463,7 @@ namespace Elwig.Windows {
|
|||||||
LesewagenInput.IsChecked = p?.IsLesewagen ?? false;
|
LesewagenInput.IsChecked = p?.IsLesewagen ?? false;
|
||||||
HandPickedInput.IsChecked = p?.IsHandPicked;
|
HandPickedInput.IsChecked = p?.IsHandPicked;
|
||||||
|
|
||||||
FillOriginalValues();
|
FinishInputFilling();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<DeliveryPart> UpdateDeliveryPart(Delivery? d, DeliveryPart? p) {
|
private async Task<DeliveryPart> UpdateDeliveryPart(Delivery? d, DeliveryPart? p) {
|
||||||
@ -698,10 +704,10 @@ namespace Elwig.Windows {
|
|||||||
if (m != null) MgNrInput.Text = m.MgNr.ToString();
|
if (m != null) MgNrInput.Text = m.MgNr.ToString();
|
||||||
MemberAddressField.Text = m?.FullAddress;
|
MemberAddressField.Text = m?.FullAddress;
|
||||||
if (m == null) {
|
if (m == null) {
|
||||||
UnsetOriginalValue(WineKgInput);
|
UnsetDefaultValue(WineKgInput);
|
||||||
WineKgInput.SelectedIndex = 0;
|
WineKgInput.SelectedIndex = 0;
|
||||||
} else {
|
} else {
|
||||||
SetOriginalValue(WineKgInput, m.DefaultKg);
|
SetDefaultValue(WineKgInput, m.DefaultKg);
|
||||||
WineKgInput.SelectedItem = m.DefaultKg;
|
WineKgInput.SelectedItem = m.DefaultKg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -732,6 +738,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void CancelCreatingButton_Click(object sender, RoutedEventArgs evt) {
|
private void CancelCreatingButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
ControlUtils.RenewItemsSource(AttributesInput, Context.WineAttributes.OrderBy(a => a.Name).ToList(), i => (i as WineAttr)?.AttrId);
|
||||||
if (DeliveryList.SelectedItem is not Delivery d) {
|
if (DeliveryList.SelectedItem is not Delivery d) {
|
||||||
// switch away from creating mode
|
// switch away from creating mode
|
||||||
IsCreating = false;
|
IsCreating = false;
|
||||||
@ -753,6 +760,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void NewDeliveryButton_Click(object? sender, RoutedEventArgs? evt) {
|
private void NewDeliveryButton_Click(object? sender, RoutedEventArgs? evt) {
|
||||||
|
ControlUtils.RenewItemsSource(AttributesInput, Context.WineAttributes.Where(a => a.IsActive).OrderBy(a => a.Name).ToList(), i => (i as WineAttr)?.AttrId);
|
||||||
IsCreating = true;
|
IsCreating = true;
|
||||||
DeliveryList.IsEnabled = false;
|
DeliveryList.IsEnabled = false;
|
||||||
DeliveryPartList.IsEnabled = false;
|
DeliveryPartList.IsEnabled = false;
|
||||||
@ -824,7 +832,7 @@ namespace Elwig.Windows {
|
|||||||
ShowNewEditDeleteButtons();
|
ShowNewEditDeleteButtons();
|
||||||
LockInputs();
|
LockInputs();
|
||||||
UnlockSearchInputs();
|
UnlockSearchInputs();
|
||||||
FillOriginalValues();
|
FinishInputFilling();
|
||||||
await RefreshDeliveryList();
|
await RefreshDeliveryList();
|
||||||
RefreshDeliveryParts();
|
RefreshDeliveryParts();
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
@ -853,7 +861,6 @@ namespace Elwig.Windows {
|
|||||||
HideSaveResetCancelButtons();
|
HideSaveResetCancelButtons();
|
||||||
ShowNewEditDeleteButtons();
|
ShowNewEditDeleteButtons();
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
ClearInputStates();
|
|
||||||
LockInputs();
|
LockInputs();
|
||||||
UnlockSearchInputs();
|
UnlockSearchInputs();
|
||||||
|
|
||||||
@ -1028,14 +1035,14 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private void UpdateWineQualityLevels() {
|
private void UpdateWineQualityLevels() {
|
||||||
if (!GetInputValid(GradationKmwInput)) {
|
if (!GetInputValid(GradationKmwInput)) {
|
||||||
UnsetOriginalValue(WineQualityLevelInput);
|
UnsetDefaultValue(WineQualityLevelInput);
|
||||||
WineQualityLevelInput.ItemsSource = Context.WineQualityLevels.Where(q => q.QualId == "WEI").ToList();
|
WineQualityLevelInput.ItemsSource = Context.WineQualityLevels.Where(q => q.QualId == "WEI").ToList();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var kmw = double.Parse(GradationKmwInput.Text);
|
var kmw = double.Parse(GradationKmwInput.Text);
|
||||||
WineQualityLevelInput.ItemsSource = Context.WineQualityLevels.Where(q => q.MinKmw == null || q.MinKmw <= kmw).ToList();
|
WineQualityLevelInput.ItemsSource = Context.WineQualityLevels.Where(q => q.MinKmw == null || q.MinKmw <= kmw).ToList();
|
||||||
var qual = Context.GetWineQualityLevel(kmw).GetAwaiter().GetResult();
|
var qual = Context.GetWineQualityLevel(kmw).GetAwaiter().GetResult();
|
||||||
SetOriginalValue(WineQualityLevelInput, qual);
|
SetDefaultValue(WineQualityLevelInput, qual);
|
||||||
if (WineQualityLevelInput.SelectedItem == null || (WineQualityLevelInput.SelectedItem is WineQualLevel selected && !selected.IsPredicate)) {
|
if (WineQualityLevelInput.SelectedItem == null || (WineQualityLevelInput.SelectedItem is WineQualLevel selected && !selected.IsPredicate)) {
|
||||||
WineQualityLevelInput.SelectedItem = qual;
|
WineQualityLevelInput.SelectedItem = qual;
|
||||||
}
|
}
|
||||||
@ -1099,11 +1106,13 @@ namespace Elwig.Windows {
|
|||||||
var kg = (WineKgInput.SelectedItem as AT_Kg)?.WbKg;
|
var kg = (WineKgInput.SelectedItem as AT_Kg)?.WbKg;
|
||||||
if (qual == null || kg == null) {
|
if (qual == null || kg == null) {
|
||||||
WineOriginInput.IsEnabled = (IsEditing || IsCreating);
|
WineOriginInput.IsEnabled = (IsEditing || IsCreating);
|
||||||
|
UnsetDefaultValue(WineOriginInput);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WineOriginInput.IsEnabled = false;
|
WineOriginInput.IsEnabled = false;
|
||||||
var o = kg.Origin;
|
var o = kg.Origin;
|
||||||
while (o != null && o.Level > qual.OriginLevel) o = o.Parent;
|
while (o != null && o.Level > qual.OriginLevel) o = o.Parent;
|
||||||
|
SetDefaultValue(WineOriginInput, o);
|
||||||
WineOriginInput.SelectedItem = o;
|
WineOriginInput.SelectedItem = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,8 +119,7 @@ namespace Elwig.Windows {
|
|||||||
BranchInput.SelectedItem = Context.Branches.First();
|
BranchInput.SelectedItem = Context.Branches.First();
|
||||||
ActiveInput.IsChecked = true;
|
ActiveInput.IsChecked = true;
|
||||||
ContactPostalInput.IsChecked = true;
|
ContactPostalInput.IsChecked = true;
|
||||||
FillOriginalValues();
|
FinishInputFilling();
|
||||||
ValidateRequiredInputs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task RenewContext() {
|
protected override async Task RenewContext() {
|
||||||
@ -213,7 +212,7 @@ namespace Elwig.Windows {
|
|||||||
LockInputs();
|
LockInputs();
|
||||||
UpdatePhoneNrInputVisibility();
|
UpdatePhoneNrInputVisibility();
|
||||||
UnlockSearchInputs();
|
UnlockSearchInputs();
|
||||||
FillOriginalValues();
|
FinishInputFilling();
|
||||||
await RefreshMemberList();
|
await RefreshMemberList();
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
SearchInput.Text = "";
|
SearchInput.Text = "";
|
||||||
@ -237,7 +236,6 @@ namespace Elwig.Windows {
|
|||||||
HideSaveResetCancelButtons();
|
HideSaveResetCancelButtons();
|
||||||
ShowNewEditDeleteButtons();
|
ShowNewEditDeleteButtons();
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
ClearInputStates();
|
|
||||||
LockInputs();
|
LockInputs();
|
||||||
UpdatePhoneNrInputVisibility();
|
UpdatePhoneNrInputVisibility();
|
||||||
UnlockSearchInputs();
|
UnlockSearchInputs();
|
||||||
@ -513,7 +511,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
Menu_Member_SendEmail.IsEnabled = m.Email != null;
|
Menu_Member_SendEmail.IsEnabled = m.Email != null;
|
||||||
|
|
||||||
FillOriginalValues();
|
FinishInputFilling();
|
||||||
}
|
}
|
||||||
|
|
||||||
new protected void ClearInputs(bool validate = false) {
|
new protected void ClearInputs(bool validate = false) {
|
||||||
|
Reference in New Issue
Block a user