ControlUtils: Cleanup SelectItem() method and use accordingly

This commit is contained in:
2024-03-18 17:55:27 +01:00
parent 51e345f1fd
commit 2f3524db9d
20 changed files with 181 additions and 194 deletions

View File

@ -198,15 +198,15 @@ namespace Elwig.Windows {
protected void FillOriginalValues() {
foreach (var tb in TextBoxInputs)
OriginalValues[tb] = Utils.GetEntityIdentifier(tb.Text);
OriginalValues[tb] = ControlUtils.GetInputHashCode(tb);
foreach (var cb in ComboBoxInputs)
OriginalValues[cb] = Utils.GetEntityIdentifier(cb.SelectedItem);
OriginalValues[cb] = ControlUtils.GetInputHashCode(cb);
foreach (var ccb in CheckComboBoxInputs)
OriginalValues[ccb] = Utils.GetEntityIdentifier(ccb.SelectedItems);
OriginalValues[ccb] = ControlUtils.GetInputHashCode(ccb);
foreach (var cb in CheckBoxInputs)
OriginalValues[cb] = Utils.GetEntityIdentifier(cb.IsChecked);
OriginalValues[cb] = ControlUtils.GetInputHashCode(cb);
foreach (var rb in RadioButtonInputs)
OriginalValues[rb] = Utils.GetEntityIdentifier(rb.IsChecked);
OriginalValues[rb] = ControlUtils.GetInputHashCode(rb);
}
protected void SetOriginalValue(Control input, object? value) {
@ -232,7 +232,7 @@ namespace Elwig.Windows {
protected void SetDefaultValue(Control input, object? value) {
if (input is UnitTextBox utbx) input = utbx.TextBox;
DefaultValues[input] = value != null ? Utils.GetEntityIdentifier(value) : null;
DefaultValues[input] = Utils.GetEntityIdentifier(value);
if (!InputHasChanged(input)) {
if (InputIsNotDefault(input)) {
ControlUtils.SetInputNotDefault(input);
@ -278,39 +278,21 @@ namespace Elwig.Windows {
protected bool InputHasChanged(Control input) {
if (input is UnitTextBox utbx) input = utbx.TextBox;
if (!OriginalValues.ContainsKey(input)) {
if (!OriginalValues.TryGetValue(input, out int? original)) {
return false;
} else if (input is TextBox tb) {
return OriginalValues[tb] != Utils.GetEntityIdentifier(tb.Text);
} else if (input is ComboBox sb) {
return OriginalValues[sb] != Utils.GetEntityIdentifier(sb.SelectedItem);
} else if (input is CheckComboBox ccb) {
return OriginalValues[ccb] != Utils.GetEntityIdentifier(ccb.SelectedItems);
} else if (input is CheckBox cb) {
return OriginalValues[cb] != Utils.GetEntityIdentifier(cb.IsChecked);
} else if (input is RadioButton rb) {
return OriginalValues[rb] != Utils.GetEntityIdentifier(rb.IsChecked);
} else {
return false;
var current = ControlUtils.GetInputHashCode(input);
return original != current;
}
}
protected bool InputIsNotDefault(Control input) {
if (input is UnitTextBox utbx) input = utbx.TextBox;
if (!DefaultValues.ContainsKey(input)) {
if (!DefaultValues.TryGetValue(input, out int? defaultValue)) {
return false;
} else if (input is TextBox tb) {
return DefaultValues[tb] != Utils.GetEntityIdentifier(tb.Text);
} else if (input is ComboBox sb) {
return DefaultValues[sb] != Utils.GetEntityIdentifier(sb.SelectedItem);
} else if (input is CheckComboBox ccb) {
return DefaultValues[ccb] != Utils.GetEntityIdentifier(ccb.SelectedItems);
} else if (input is CheckBox cb) {
return DefaultValues[cb] != Utils.GetEntityIdentifier(cb.IsChecked);
} else if (input is RadioButton rb) {
return DefaultValues[rb] != Utils.GetEntityIdentifier(rb.IsChecked);
} else {
return false;
var current = ControlUtils.GetInputHashCode(input);
return defaultValue != current;
}
}
@ -343,7 +325,7 @@ namespace Elwig.Windows {
.ToListAsync();
}
ControlUtils.RenewItemsSource(ortInput, list, i => (i as AT_PlzDest)?.Id);
ControlUtils.RenewItemsSource(ortInput, list);
if (list != null && ortInput.SelectedItem == null && list.Count == 1)
ortInput.SelectedItem = list[0];
UpdateComboBox(ortInput);

View File

@ -61,7 +61,7 @@ namespace Elwig.Windows {
.ToList();
}
ControlUtils.RenewItemsSource(AreaCommitmentList, areaComs, i => (i as AreaCom)?.FbNr,
ControlUtils.RenewItemsSource(AreaCommitmentList, areaComs,
AreaCommitmentList_SelectionChanged, filter.Count > 0 ? ControlUtils.RenewSourceDefault.IfOnly : ControlUtils.RenewSourceDefault.None, !updateSort);
RefreshInputs();
@ -153,18 +153,18 @@ namespace Elwig.Windows {
YearFromInput.Text = a.YearFrom.ToString();
YearToInput.Text = a.YearTo.ToString();
ControlUtils.SelectComboBoxItem(KgInput, k => (k as AT_Kg)?.KgNr, a.KgNr);
ControlUtils.SelectItemWithPk(KgInput, a.KgNr);
if (a.RdNr != null) {
ControlUtils.SelectComboBoxItem(RdInput, r => (r as WbRd)?.RdNr, a.RdNr);
ControlUtils.SelectItemWithPk(RdInput, a.KgNr, a.RdNr);
} else {
RdInput.SelectedIndex = 0;
}
GstNrInput.Text = a.GstNr;
AreaInput.Text = a.Area.ToString();
ControlUtils.SelectComboBoxItem(AreaComTypeInput, t => (t as AreaComType)?.VtrgId, a.VtrgId);
ControlUtils.SelectItemWithPk(AreaComTypeInput, a.VtrgId);
if (a.CultId != null) {
ControlUtils.SelectComboBoxItem(WineCultivationInput, c => (c as WineCult)?.CultId, a.CultId);
ControlUtils.SelectItemWithPk(WineCultivationInput, a.CultId);
} else {
WineCultivationInput.SelectedIndex = 0;
}
@ -196,17 +196,17 @@ namespace Elwig.Windows {
.Include(k => k.AtKg.WbKg!.Rds)
.Select(k => k.AtKg)
.OrderBy(k => k.Name)
.ToListAsync(), i => (i as AT_Kg)?.KgNr);
.ToListAsync());
ControlUtils.RenewItemsSource(AreaComTypeInput, await ctx.AreaCommitmentTypes
.Include(c => c.WineVar)
.Include(c => c.WineAttr)
.OrderBy(v => v.VtrgId)
.ToListAsync(), i => (i as AreaComType)?.VtrgId);
.ToListAsync());
var cultList = await ctx.WineCultivations
.OrderBy(c => c.Name)
.Cast<object>().ToListAsync();
cultList.Insert(0, new NullItem());
ControlUtils.RenewItemsSource(WineCultivationInput, cultList, i => (i as WineCult)?.CultId, null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(WineCultivationInput, cultList, null, ControlUtils.RenewSourceDefault.First);
await RefreshAreaCommitmentList();
}
@ -312,7 +312,7 @@ namespace Elwig.Windows {
await RefreshAreaCommitmentList();
RefreshInputs();
SearchInput.Text = "";
AreaCommitmentList.SelectedItem = AreaCommitmentList.ItemsSource.Cast<AreaCom>().Where(a => a.FbNr == fbnr).FirstOrDefault();
ControlUtils.SelectItem(AreaCommitmentList, AreaCommitmentList.ItemsSource.Cast<AreaCom>().Where(a => a.FbNr == fbnr).FirstOrDefault());
}
private void AreaCommitmentResetButton_Click(object sender, RoutedEventArgs evt) {
@ -418,10 +418,10 @@ namespace Elwig.Windows {
if (KgInput.SelectedItem is AT_Kg kg) {
var rdList = kg.WbKg!.Rds.OrderBy(r => r.Name).Cast<object>().ToList();
rdList.Insert(0, new NullItem());
ControlUtils.RenewItemsSource(RdInput, rdList, i => (i as WbRd)?.RdNr, null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(RdInput, rdList, null, ControlUtils.RenewSourceDefault.First);
} else {
var rdList = new object[] { new NullItem() };
ControlUtils.RenewItemsSource(RdInput, rdList, i => (i as WbRd)?.RdNr, null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(RdInput, rdList, null, ControlUtils.RenewSourceDefault.First);
}
ComboBox_SelectionChanged(sender, evt);
}

View File

@ -26,12 +26,12 @@ namespace Elwig.Windows {
.ToListAsync());
_acts = _actList.ToDictionary(v => v.VtrgId, v => (string?)v.VtrgId);
_actIds = _actList.ToDictionary(v => v, v => v.VtrgId);
ControlUtils.RenewItemsSource(AreaCommitmentTypeList, _actList, a => (a as AreaComType)?.VtrgId);
ControlUtils.RenewItemsSource(AreaCommitmentTypeList, _actList);
AreaCommitmentTypeList_SelectionChanged(null, null);
}
private async Task AreaCommitmentTypesFinishEditing(AppDbContext ctx) {
ControlUtils.RenewItemsSource(AreaCommitmentTypeList, await ctx.AreaCommitmentTypes.OrderBy(v => v.SortId).ToListAsync(), v => (v as AreaComType)?.VtrgId);
ControlUtils.RenewItemsSource(AreaCommitmentTypeList, await ctx.AreaCommitmentTypes.OrderBy(v => v.SortId).ToListAsync());
_actList = null;
_acts = null;
_actIds = null;
@ -73,8 +73,8 @@ namespace Elwig.Windows {
_actUpdate = true;
if (AreaCommitmentTypeList.SelectedItem is AreaComType type) {
AreaCommitmentTypeIdInput.Text = $"{type.SortId}{type.AttrId}";
ControlUtils.SelectComboBoxItem(AreaCommitmentTypeWineVariantInput, s => (s as WineVar)?.SortId, type.SortId);
ControlUtils.SelectComboBoxItem(AreaCommitmentTypeWineAttributeInput, a => (a as WineAttr)?.AttrId, type.AttrId);
ControlUtils.SelectItemWithPk(AreaCommitmentTypeWineVariantInput, type.SortId);
ControlUtils.SelectItemWithPk(AreaCommitmentTypeWineAttributeInput, type.AttrId);
AreaCommitmentTypeMinKgPerHaInput.Text = $"{type.MinKgPerHa}";
AreaCommitmentTypePenaltyPerKgInput.Text = $"{type.PenaltyPerKg}";
AreaCommitmentTypePenaltyInput.Text = $"{type.PenaltyAmount}";

View File

@ -25,7 +25,7 @@ namespace Elwig.Windows {
.ToListAsync());
_branches = _branchList.ToDictionary(b => b.ZwstId, b => (string?)b.ZwstId);
_branchIds = _branchList.ToDictionary(b => b, b => b.ZwstId);
ControlUtils.RenewItemsSource(BranchList, _branchList, b => (b as Branch)?.ZwstId);
ControlUtils.RenewItemsSource(BranchList, _branchList);
BranchList_SelectionChanged(null, null);
}
@ -33,7 +33,7 @@ namespace Elwig.Windows {
ControlUtils.RenewItemsSource(BranchList, await ctx.Branches
.OrderBy(b => b.Name)
.Include(b => b.PostalDest!.AtPlz)
.ToListAsync(), b => (b as Branch)?.ZwstId);
.ToListAsync());
_branchList = null;
_branches = null;
_branchIds = null;
@ -85,7 +85,7 @@ namespace Elwig.Windows {
BranchIdInput.Text = branch.ZwstId;
BranchNameInput.Text = branch.Name;
BranchPlzInput.Text = branch.PostalDest?.AtPlz?.Plz.ToString() ?? "";
ControlUtils.SelectComboBoxItem(BranchOrtInput, o => (o as AT_PlzDest)?.Okz, branch.PostalDest?.AtPlz?.Okz);
ControlUtils.SelectItem(BranchOrtInput, branch.PostalDest?.AtPlz);
BranchAddressInput.Text = branch.Address;
BranchPhoneNrInput.Text = branch.PhoneNr;
BranchFaxNrInput.Text = branch.FaxNr;

View File

@ -25,13 +25,13 @@ namespace Elwig.Windows {
_modList = new(await ctx.Modifiers.Where(m => m.Year == year).OrderBy(m => m.Ordering).ToListAsync());
_mods = _modList.ToDictionary(m => m.ModId, m => (string?)m.ModId);
_modIds = _modList.ToDictionary(m => m, m => m.ModId);
ControlUtils.RenewItemsSource(SeasonModifierList, _modList, m => (m as Modifier)?.ModId);
ControlUtils.RenewItemsSource(SeasonModifierList, _modList);
SeasonModifierList_SelectionChanged(null, null);
}
private async Task ModifiersFinishEditing(AppDbContext ctx) {
var year = (SeasonList.SelectedItem as Season)?.Year;
ControlUtils.RenewItemsSource(SeasonModifierList, await ctx.Modifiers.Where(m => m.Year == year).OrderBy(m => m.Ordering).ToListAsync(), m => (m as Modifier)?.ModId);
ControlUtils.RenewItemsSource(SeasonModifierList, await ctx.Modifiers.Where(m => m.Year == year).OrderBy(m => m.Ordering).ToListAsync());
_modList = null;
_mods = null;
_modIds = null;

View File

@ -13,12 +13,12 @@ namespace Elwig.Windows {
private bool _seasonUpdate = false;
private async Task SeasonsInitEditing(AppDbContext ctx) {
ControlUtils.RenewItemsSource(SeasonList, await ctx.Seasons.OrderByDescending(s => s.Year).ToListAsync(), s => (s as Season)?.Year);
ControlUtils.RenewItemsSource(SeasonList, await ctx.Seasons.OrderByDescending(s => s.Year).ToListAsync());
SeasonList_SelectionChanged(null, null);
}
private async Task SeasonsFinishEditing(AppDbContext ctx) {
ControlUtils.RenewItemsSource(SeasonList, await ctx.Seasons.OrderByDescending(s => s.Year).Include(s => s.Modifiers).ToListAsync(), s => (s as Season)?.Year);
ControlUtils.RenewItemsSource(SeasonList, await ctx.Seasons.OrderByDescending(s => s.Year).Include(s => s.Modifiers).ToListAsync());
_seasonChanged = false;
}

View File

@ -22,12 +22,12 @@ namespace Elwig.Windows {
_attrList = new(await ctx.WineAttributes.OrderBy(a => a.Name).ToListAsync());
_attrs = _attrList.ToDictionary(a => a.AttrId, a => (string?)a.AttrId);
_attrIds = _attrList.ToDictionary(a => a, a => a.AttrId);
ControlUtils.RenewItemsSource(WineAttributeList, _attrList, a => (a as WineAttr)?.AttrId);
ControlUtils.RenewItemsSource(WineAttributeList, _attrList);
WineAttributeList_SelectionChanged(null, null);
}
private async Task WineAttributesFinishEditing(AppDbContext ctx) {
ControlUtils.RenewItemsSource(WineAttributeList, await ctx.WineAttributes.OrderBy(a => a.Name).ToListAsync(), a => (a as WineAttr)?.AttrId);
ControlUtils.RenewItemsSource(WineAttributeList, await ctx.WineAttributes.OrderBy(a => a.Name).ToListAsync());
_attrList = null;
_attrs = null;
_attrIds = null;

View File

@ -22,12 +22,12 @@ namespace Elwig.Windows {
_cultList = new(await ctx.WineCultivations.OrderBy(c => c.Name).ToListAsync());
_cults = _cultList.ToDictionary(c => c.CultId, c => (string?)c.CultId);
_cultIds = _cultList.ToDictionary(c => c, c => c.CultId);
ControlUtils.RenewItemsSource(WineCultivationList, _cultList, c => (c as WineCult)?.CultId);
ControlUtils.RenewItemsSource(WineCultivationList, _cultList);
WineCultivationList_SelectionChanged(null, null);
}
private async Task WineCultivationsFinishEditing(AppDbContext ctx) {
ControlUtils.RenewItemsSource(WineCultivationList, await ctx.WineCultivations.OrderBy(c => c.Name).ToListAsync(), c => (c as WineCult)?.CultId);
ControlUtils.RenewItemsSource(WineCultivationList, await ctx.WineCultivations.OrderBy(c => c.Name).ToListAsync());
_cultList = null;
_cults = null;
_cultIds = null;

View File

@ -137,33 +137,33 @@ namespace Elwig.Windows {
FillInputs(App.Client);
ControlUtils.RenewItemsSource(SeasonList, await ctx.Seasons
.OrderByDescending(s => s.Year)
.ToListAsync(), s => (s as Season)?.Year, null, ControlUtils.RenewSourceDefault.First);
.ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
var year = (SeasonList.SelectedItem as Season)?.Year;
ControlUtils.RenewItemsSource(BranchList, await ctx.Branches
.OrderBy(b => b.Name)
.Include(b => b.PostalDest!.AtPlz)
.ToListAsync(), b => (b as Branch)?.ZwstId, null, ControlUtils.RenewSourceDefault.First);
.ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(WineAttributeList, await ctx.WineAttributes
.OrderBy(a => a.Name)
.ToListAsync(), a => (a as WineAttr)?.AttrId, null, ControlUtils.RenewSourceDefault.First);
.ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(AreaCommitmentTypeWineVariantInput, await ctx.WineVarieties
.OrderBy(s => s.Name)
.ToListAsync(), s => (s as WineVar)?.SortId);
.ToListAsync());
var attrList = await ctx.WineAttributes.OrderBy(a => a.Name).Cast<object>().ToListAsync();
attrList.Insert(0, new NullItem(""));
ControlUtils.RenewItemsSource(AreaCommitmentTypeWineAttributeInput, attrList, a => (a as WineAttr)?.AttrId);
ControlUtils.RenewItemsSource(AreaCommitmentTypeWineAttributeInput, attrList);
ControlUtils.RenewItemsSource(AreaCommitmentTypeList, await ctx.AreaCommitmentTypes
.OrderBy(t => t.VtrgId)
.Include(t => t.WineVar)
.Include(t => t.WineAttr)
.ToListAsync(), t => (t as AreaComType)?.VtrgId, null, ControlUtils.RenewSourceDefault.First);
.ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(WineCultivationList, await ctx.WineCultivations
.OrderBy(c => c.Name)
.ToListAsync(), c=> (c as WineCult)?.CultId, null, ControlUtils.RenewSourceDefault.First);
.ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(SeasonModifierList, await ctx.Modifiers
.Where(m => m.Year == year)
.OrderBy(m => m.Ordering)
.ToListAsync(), m => (m as Modifier)?.ModId, null, ControlUtils.RenewSourceDefault.First);
.ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
}
protected override void UpdateButtons() {

View File

@ -139,9 +139,9 @@ namespace Elwig.Windows {
});
FillingInputs = true;
ControlUtils.RenewItemsSource(VaributeInput, Vaributes, v => (v as Varibute)?.Listing);
ControlUtils.RenewItemsSource(VaributeInput, Vaributes);
FillingInputs = false;
ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.VaributeStringChange, GraphList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(GraphList, GraphEntries, GraphList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
RefreshInputs();
}
@ -194,7 +194,7 @@ namespace Elwig.Windows {
GebundenFlatBonus.Text = "";
}
ControlUtils.SelectCheckComboBoxItems(VaributeInput, SelectedGraphEntry?.Vaributes ?? [], i => (i as Varibute)?.Listing);
ControlUtils.SelectItems(VaributeInput, SelectedGraphEntry?.Vaributes ?? []);
InitPlot();
OechslePricePlot.IsEnabled = true;

View File

@ -396,10 +396,10 @@
<CheckBox x:Name="LesewagenInput" Content="Lesewagen" Margin="10,75,0,0" Grid.Column="2"
VerticalAlignment="Top" HorizontalAlignment="Left"
Checked="LesewagenInput_Changed" Unchecked="LesewagenInput_Changed"/>
Checked="LesewagenInput_Changed" Unchecked="LesewagenInput_Changed" Click="HandPickedInput_Changed"/>
<CheckBox x:Name="HandPickedInput" Content="Handlese" Margin="10,105,0,0" Grid.Column="2" IsThreeState="True"
VerticalAlignment="Top" HorizontalAlignment="Left"
Checked="HandPickedInput_Changed" Unchecked="HandPickedInput_Changed"/>
Checked="HandPickedInput_Changed" Unchecked="HandPickedInput_Changed" Click="HandPickedInput_Changed"/>
</Grid>
</GroupBox>

View File

@ -288,7 +288,7 @@ namespace Elwig.Windows {
}
private void InitInputs() {
ControlUtils.SelectComboBoxItem(BranchInput, i => (i as Branch)?.ZwstId, App.ZwstId);
ControlUtils.SelectItemWithPk(BranchInput, App.ZwstId);
OnSecondPassed(null, null);
UpdateLsNr().GetAwaiter().GetResult();
InitialInputs();
@ -646,7 +646,7 @@ namespace Elwig.Windows {
}
deliveries.ForEach(d => { d.PartFilter = predicate; });
ControlUtils.RenewItemsSource(DeliveryList, deliveries, d => ((d as Delivery)?.Year, (d as Delivery)?.DId),
ControlUtils.RenewItemsSource(DeliveryList, deliveries,
DeliveryList_SelectionChanged, filter.Count > 0 ? ControlUtils.RenewSourceDefault.IfOnly : ControlUtils.RenewSourceDefault.None, !updateSort);
await RefreshDeliveryParts();
@ -795,21 +795,21 @@ namespace Elwig.Windows {
await RefreshDeliveryList();
var d = DeliveryList.SelectedItem as Delivery;
var y = d?.Year ?? Utils.CurrentLastSeason;
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.Where(m => m.IsActive || !IsCreating).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(WineVarietyInput, await Context.WineVarieties.OrderBy(v => v.Name).ToListAsync(), i => (i as WineVar)?.SortId);
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.Where(m => m.IsActive || !IsCreating).OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync());
ControlUtils.RenewItemsSource(BranchInput, await Context.Branches.OrderBy(b => b.Name).ToListAsync());
ControlUtils.RenewItemsSource(WineVarietyInput, await Context.WineVarieties.OrderBy(v => v.Name).ToListAsync());
var attrList = await Context.WineAttributes.Where(a => !IsCreating || a.IsActive).OrderBy(a => a.Name).Cast<object>().ToListAsync();
attrList.Insert(0, new NullItem(""));
ControlUtils.RenewItemsSource(AttributeInput, attrList, i => (i as WineAttr)?.AttrId, null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(AttributeInput, attrList, null, ControlUtils.RenewSourceDefault.First);
var cultList = await Context.WineCultivations.OrderBy(a => a.Name).Cast<object>().ToListAsync();
cultList.Insert(0, new NullItem(""));
ControlUtils.RenewItemsSource(CultivationInput, cultList, i => (i as WineCult)?.CultId, null, ControlUtils.RenewSourceDefault.First);
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(WineOriginInput, (await Context.WineOrigins.ToListAsync()).OrderByDescending(o => o.SortKey).ThenBy(o => o.HkId), i => (i as WineOrigin)?.HkId);
ControlUtils.RenewItemsSource(CultivationInput, cultList, null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(WineQualityLevelInput, await Context.WineQualityLevels.ToListAsync());
ControlUtils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Year == y).OrderBy(m => m.Ordering).ToListAsync());
ControlUtils.RenewItemsSource(WineOriginInput, (await Context.WineOrigins.ToListAsync()).OrderByDescending(o => o.SortKey).ThenBy(o => o.HkId));
var kgList = await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).Cast<object>().ToListAsync();
kgList.Insert(0, new NullItem());
ControlUtils.RenewItemsSource(WineKgInput, kgList, i => (i as AT_Kg)?.KgNr);
ControlUtils.RenewItemsSource(WineKgInput, kgList);
UpdateRdInput();
if (IsCreating) await UpdateLsNr();
@ -826,10 +826,10 @@ namespace Elwig.Windows {
private async Task RefreshDeliveryParts() {
if (DeliveryList.SelectedItem is Delivery d) {
ControlUtils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Year == d.Year).OrderBy(m => m.Ordering).ToListAsync(), i => (i as Modifier)?.ModId);
ControlUtils.RenewItemsSource(DeliveryPartList, d.FilteredParts.OrderBy(p => p.DPNr).ToList(), i => ((i as DeliveryPart)?.Year, (i as DeliveryPart)?.DId, (i as DeliveryPart)?.DPNr), DeliveryPartList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Year == d.Year).OrderBy(m => m.Ordering).ToListAsync());
ControlUtils.RenewItemsSource(DeliveryPartList, d.FilteredParts.OrderBy(p => p.DPNr).ToList(), DeliveryPartList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
} else {
ControlUtils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Year == Utils.CurrentLastSeason).OrderBy(m => m.Ordering).ToListAsync(), i => (i as Modifier)?.ModId);
ControlUtils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Year == Utils.CurrentLastSeason).OrderBy(m => m.Ordering).ToListAsync());
DeliveryPartList.ItemsSource = null;
}
}
@ -854,7 +854,7 @@ namespace Elwig.Windows {
ClearDefaultValues();
MgNrInput.Text = d.MgNr.ToString();
ControlUtils.SelectComboBoxItem(BranchInput, i => (i as Branch)?.ZwstId, d.ZwstId);
ControlUtils.SelectItemWithPk(BranchInput, d.ZwstId);
LsNrInput.Text = d.LsNr;
DateInput.Text = d.Date.ToString("dd.MM.yyyy");
TimeInput.Text = d.Time?.ToString("HH:mm") ?? "";
@ -877,17 +877,17 @@ namespace Elwig.Windows {
ClearDefaultValues();
SortIdInput.Text = p?.SortId ?? "";
ControlUtils.SelectComboBoxItem(AttributeInput, p?.Attribute, i => (i as WineAttr)?.AttrId);
ControlUtils.SelectComboBoxItem(CultivationInput, p?.Cultivation, i => (i as WineCult)?.CultId);
ControlUtils.SelectItemWithPk(AttributeInput, p?.AttrId);
ControlUtils.SelectItemWithPk(CultivationInput, p?.CultId);
GradationKmwInput.Text = (p != null) ? $"{p.Kmw:N1}" : "";
ControlUtils.SelectComboBoxItem(WineQualityLevelInput, q => (q as WineQualLevel)?.QualId, p?.QualId);
ControlUtils.SelectComboBoxItem(WineKgInput, k => (k as AT_Kg)?.KgNr, p?.KgNr);
ControlUtils.SelectComboBoxItem(WineRdInput, r => (r as WbRd)?.RdNr, p?.RdNr);
ControlUtils.SelectComboBoxItem(WineOriginInput, r => (r as WineOrigin)?.HkId, p?.HkId);
ControlUtils.SelectItemWithPk(WineQualityLevelInput, p?.QualId);
ControlUtils.SelectItemWithPk(WineKgInput, p?.KgNr);
ControlUtils.SelectItemWithPk(WineRdInput, p?.KgNr, p?.RdNr);
ControlUtils.SelectItemWithPk(WineOriginInput, p?.HkId);
WeightInput.Text = (p != null) ? $"{p.Weight:N0}" : "";
ManualWeighingInput.IsChecked = p?.IsManualWeighing ?? false;
GerebeltGewogenInput.IsChecked = p?.IsNetWeight ?? false;
ControlUtils.SelectCheckComboBoxItems(ModifiersInput, p?.Modifiers, i => (i as Modifier)?.ModId);
ControlUtils.SelectItems(ModifiersInput, p?.Modifiers);
PartCommentInput.Text = p?.Comment ?? "";
TemperatureInput.Text = (p != null && p.Temperature != null) ? $"{p.Temperature:N1}" : "";
AcidInput.Text = (p != null && p.Acid != null) ? $"{p.Acid:N1}" : "";
@ -1118,12 +1118,12 @@ namespace Elwig.Windows {
private void MgNrInput_TextChanged(object sender, TextChangedEventArgs evt) {
var valid = InputTextChanged((TextBox)sender, Validator.CheckMgNr);
MemberInput.SelectedItem = valid ? Context.Members.Find(int.Parse(MgNrInput.Text)) : null;
ControlUtils.SelectItemWithPk(MemberInput, valid ? int.Parse(MgNrInput.Text) : null);
}
private void MgNrInput_LostFocus(object sender, RoutedEventArgs evt) {
var valid = InputLostFocus((TextBox)sender, Validator.CheckMgNr);
MemberInput.SelectedItem = valid ? Context.Members.Find(int.Parse(MgNrInput.Text)) : null;
ControlUtils.SelectItemWithPk(MemberInput, valid ? int.Parse(MgNrInput.Text) : null);
}
private void MemberInput_SelectionChanged(object? sender, SelectionChangedEventArgs? evt) {
@ -1134,8 +1134,8 @@ namespace Elwig.Windows {
UnsetDefaultValue(WineKgInput);
WineKgInput.SelectedIndex = 0;
} else {
SetDefaultValue(WineKgInput, m.DefaultKg);
WineKgInput.SelectedItem = m.DefaultKg;
ControlUtils.SelectItemWithPk(WineKgInput, m.DefaultKgNr);
SetDefaultValue(WineKgInput);
}
}
@ -1155,7 +1155,7 @@ namespace Elwig.Windows {
await RefreshDeliveryList();
await RefreshDeliveryParts();
NewDeliveryPartButton.Cursor = null;
DeliveryList.SelectedItem = p?.Delivery;
ControlUtils.SelectItem(DeliveryList, p?.Delivery);
DeliveryPartList.SelectedItem = null;
RefreshInputs();
InitialInputs();
@ -1201,8 +1201,8 @@ namespace Elwig.Windows {
var attrList = await Context.WineAttributes.OrderBy(a => a.Name).Cast<object>().ToListAsync();
attrList.Insert(0, new NullItem(""));
ControlUtils.RenewItemsSource(AttributeInput, attrList, i => (i as WineAttr)?.AttrId, null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.Where(m => m.IsActive || !IsReceipt).OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync(), i => (i as Member)?.MgNr);
ControlUtils.RenewItemsSource(AttributeInput, attrList, null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.Where(m => m.IsActive || !IsReceipt).OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync());
if (DeliveryList.SelectedItem is not Delivery d) {
// switch away from creating mode
IsCreating = false;
@ -1220,7 +1220,7 @@ namespace Elwig.Windows {
} else {
// switch to last delivery part
DeliveryPartList.IsEnabled = true;
DeliveryPartList.SelectedItem = d.FilteredParts.Last();
ControlUtils.SelectItem(DeliveryPartList, d.FilteredParts.Last());
}
}
@ -1229,8 +1229,8 @@ namespace Elwig.Windows {
SearchInput.Text = "";
var attrList = await Context.WineAttributes.Where(a => a.IsActive).OrderBy(a => a.Name).Cast<object>().ToListAsync();
attrList.Insert(0, new NullItem(""));
ControlUtils.RenewItemsSource(AttributeInput, attrList, i => (i as WineAttr)?.AttrId, null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.Where(m => m.IsActive || !IsReceipt).OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync(), i => (i as Member)?.MgNr);
ControlUtils.RenewItemsSource(AttributeInput, attrList, null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.Where(m => m.IsActive || !IsReceipt).OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync());
IsCreating = true;
DeliveryList.IsEnabled = false;
DeliveryPartList.IsEnabled = false;
@ -1253,8 +1253,8 @@ namespace Elwig.Windows {
Mouse.OverrideCursor = Cursors.AppStarting;
ClearOriginalValues();
if (res >= p.Weight) {
ControlUtils.SelectComboBoxItem(WineQualityLevelInput, q => (q as WineQualLevel)?.QualId, "WEI");
ControlUtils.SelectComboBoxItem(WineOriginInput, o => (o as WineOrigin)?.HkId, "OEST");
ControlUtils.SelectItemWithPk(WineQualityLevelInput, "WEI");
ControlUtils.SelectItemWithPk(WineOriginInput, "OEST");
p.QualId = "WEI";
p.HkId = "OEST";
entry1 = Context.Update(p);
@ -1449,7 +1449,7 @@ namespace Elwig.Windows {
Mouse.OverrideCursor = null;
await RefreshDeliveryList();
DeliveryList.SelectedItem = d;
ControlUtils.SelectItem(DeliveryList, d);
} catch (Exception exc) {
if (entry != null) {
entry.State = EntityState.Detached;
@ -1612,10 +1612,10 @@ namespace Elwig.Windows {
private void UpdateWineVariety(bool valid) {
if (valid) {
var text = SortIdInput.Text;
WineVarietyInput.SelectedItem = Context.WineVarieties.Find(text[0..2]);
ControlUtils.SelectItemWithPk(WineVarietyInput, text[0..2]);
if (text.Length >= 3) {
ControlUtils.SelectComboBoxItem(AttributeInput, Context.WineAttributes.Find(text[2..]), a => (a as WineAttr)?.AttrId);
ControlUtils.SelectComboBoxItem(CultivationInput, Context.WineCultivations.Find(text[2..]), i => (i as WineCult)?.CultId);
ControlUtils.SelectItemWithPk(AttributeInput, text[2..]);
ControlUtils.SelectItemWithPk(CultivationInput, text[2..]);
SortIdInput.Text = text[0..2];
}
} else {
@ -1649,7 +1649,7 @@ namespace Elwig.Windows {
var qual = Context.GetWineQualityLevel(kmw).GetAwaiter().GetResult();
SetDefaultValue(WineQualityLevelInput, qual);
if (WineQualityLevelInput.SelectedItem == null || (WineQualityLevelInput.SelectedItem is WineQualLevel selected && !selected.IsPredicate)) {
WineQualityLevelInput.SelectedItem = qual;
ControlUtils.SelectItem(WineQualityLevelInput, qual);
}
}
@ -1744,7 +1744,7 @@ namespace Elwig.Windows {
var o = kg.Origin;
while (o != null && o.Level > qual.OriginLevel) o = o.Parent;
SetDefaultValue(WineOriginInput, o);
WineOriginInput.SelectedItem = o;
ControlUtils.SelectItem(WineOriginInput, o);
}
private void WineQualityLevelInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
@ -1756,7 +1756,7 @@ namespace Elwig.Windows {
if (WineKgInput.SelectedItem is AT_Kg kg) {
var list = Context.WbRde.Where(r => r.KgNr == kg.KgNr).OrderBy(r => r.Name).Cast<object>().ToList();
list.Insert(0, new NullItem());
ControlUtils.RenewItemsSource(WineRdInput, list, i => ((i as WbRd)?.KgNr, (i as WbRd)?.RdNr));
ControlUtils.RenewItemsSource(WineRdInput, list);
if (WineRdInput.SelectedItem == null) WineRdInput.SelectedIndex = 0;
WineRdInput.IsEnabled = (IsEditing || IsCreating) && list.Count > 1;
} else {

View File

@ -142,7 +142,7 @@ namespace Elwig.Windows {
ControlUtils.RenewItemsSource(MemberBranchInput, await ctx.Branches
.Where(b => b.Members.Any())
.OrderBy(b => b.Name)
.ToListAsync(), b => (b as Branch)?.ZwstId, MemberInput_SelectionChanged);
.ToListAsync(), MemberInput_SelectionChanged);
if (MemberBranchInput.SelectedItems.Count == 0) {
MemberBranchInput.ItemSelectionChanged -= MemberInput_SelectionChanged;
MemberBranchInput.SelectAll();
@ -151,7 +151,7 @@ namespace Elwig.Windows {
ControlUtils.RenewItemsSource(MemberKgInput, await ctx.Katastralgemeinden
.Where(k => k.WbKg!.Members.Any())
.OrderBy(k => k.Name)
.ToListAsync(), k => (k as AT_Kg)?.KgNr, MemberInput_SelectionChanged);
.ToListAsync(), MemberInput_SelectionChanged);
if (MemberKgInput.SelectedItems.Count == 0) {
MemberKgInput.ItemSelectionChanged -= MemberInput_SelectionChanged;
MemberKgInput.SelectAll();
@ -159,7 +159,7 @@ namespace Elwig.Windows {
}
ControlUtils.RenewItemsSource(MemberAreaComInput, await ctx.AreaCommitmentTypes
.OrderBy(a => a.VtrgId)
.ToListAsync(), a => (a as AreaComType)?.VtrgId, MemberInput_SelectionChanged);
.ToListAsync(), MemberInput_SelectionChanged);
if (MemberAreaComInput.SelectedItems.Count == 0) {
MemberAreaComInput.ItemSelectionChanged -= MemberInput_SelectionChanged;
MemberAreaComInput.SelectAll();
@ -169,7 +169,7 @@ namespace Elwig.Windows {
.Where(m => m.IsActive)
.OrderBy(m => m.FamilyName)
.ThenBy(m => m.GivenName)
.ToListAsync(), m => (m as Member)?.MgNr, MemberInput_SelectionChanged);
.ToListAsync(), MemberInput_SelectionChanged);
if (MemberCustomInput.SelectedItems.Count == 0) {
MemberCustomInput.ItemSelectionChanged -= MemberInput_SelectionChanged;
MemberCustomInput.SelectAll();

View File

@ -90,8 +90,7 @@ namespace Elwig.Windows {
FocusMember(mgnr);
});
} else {
MemberList.SelectedItem = item;
MemberList.ScrollIntoView(MemberList.SelectedItem);
ControlUtils.SelectItem(MemberList, item);
}
}
@ -218,7 +217,7 @@ namespace Elwig.Windows {
.ToList();
}
ControlUtils.RenewItemsSource(MemberList, members, i => (i as Member)?.MgNr,
ControlUtils.RenewItemsSource(MemberList, members,
MemberList_SelectionChanged, TextFilter.Count > 0 ? ControlUtils.RenewSourceDefault.IfOnly : ControlUtils.RenewSourceDefault.None, !updateSort);
}
@ -268,8 +267,8 @@ namespace Elwig.Windows {
protected override async Task OnRenewContext() {
await base.OnRenewContext();
using var ctx = new AppDbContext();
ControlUtils.RenewItemsSource(BranchInput, await ctx.Branches.OrderBy(b => b.Name).ToListAsync(), i => (i as Branch)?.ZwstId);
ControlUtils.RenewItemsSource(DefaultKgInput, await ctx.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync(), i => (i as AT_Kg)?.KgNr);
ControlUtils.RenewItemsSource(BranchInput, await ctx.Branches.OrderBy(b => b.Name).ToListAsync());
ControlUtils.RenewItemsSource(DefaultKgInput, await ctx.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync());
await RefreshMemberList();
StatusMembers.Text = $"Mitglieder: {await ctx.Members.CountAsync(m => m.IsActive):N0} ({await ctx.Members.CountAsync():N0})";
StatusBusinessShares.Text = $"Geschäftsanteile: {await ctx.Members.Where(m => m.IsActive).SumAsync(m => m.BusinessShares):N0} ({await ctx.Members.SumAsync(m => m.BusinessShares):N0})";
@ -686,7 +685,7 @@ namespace Elwig.Windows {
AT_PlzDest? p = m.PostalDest.AtPlz;
if (p != null) {
PlzInput.Text = p.Plz.ToString();
ControlUtils.SelectComboBoxItem(OrtInput, o => (o as AT_PlzDest)?.Okz, p.Okz);
ControlUtils.SelectItem(OrtInput, p);
} else {
PlzInput.Text = null;
OrtInput.SelectedItem = null;
@ -728,7 +727,7 @@ namespace Elwig.Windows {
AT_PlzDest? b = billingAddr.PostalDest.AtPlz;
if (b != null) {
BillingPlzInput.Text = b.Plz.ToString();
ControlUtils.SelectComboBoxItem(BillingOrtInput, o => (o as AT_PlzDest)?.Okz, b.Okz);
ControlUtils.SelectItem(BillingOrtInput, b);
}
} else {
BillingNameInput.Text = "";
@ -741,8 +740,8 @@ namespace Elwig.Windows {
ExitDateInput.Text = (m.ExitDateString != null) ? string.Join(".", m.ExitDateString.Split("-").Reverse()) : null;
BusinessSharesInput.Text = m.BusinessShares.ToString();
AccountingNrInput.Text = m.AccountingNr;
ControlUtils.SelectComboBoxItem(BranchInput, b => (b as Branch)?.ZwstId, m.ZwstId);
ControlUtils.SelectComboBoxItem(DefaultKgInput, k => (k as AT_Kg)?.KgNr, m.DefaultKgNr);
ControlUtils.SelectItemWithPk(BranchInput, m.ZwstId);
ControlUtils.SelectItemWithPk(DefaultKgInput, m.DefaultKgNr);
CommentInput.Text = m.Comment;
ActiveInput.IsChecked = m.IsActive;
VollLieferantInput.IsChecked = m.IsVollLieferant;

View File

@ -28,7 +28,7 @@ namespace Elwig.Windows {
.ToListAsync())
.OrderByDescending(o => o.SortKey)
.ThenBy(o => o.HkId);
ControlUtils.RenewItemsSource(WineOrigins, origins, i => (i as WineOrigin)?.HkId, WineOrigins_SelectionChanged);
ControlUtils.RenewItemsSource(WineOrigins, origins, WineOrigins_SelectionChanged);
if (WineOrigins.SelectedItem == null) {
var hkid = await ctx.WbKgs
.GroupBy(k => k.AtKg.Gem.WbGem!.HkId)
@ -36,14 +36,14 @@ namespace Elwig.Windows {
.OrderByDescending(g => g.Count())
.Select(g => g.Key)
.FirstOrDefaultAsync();
ControlUtils.SelectListBoxItem(WineOrigins, o => (o as WineOrigin)?.HkId, hkid);
ControlUtils.SelectItemWithPk(WineOrigins, hkid);
}
var gls = await ctx.WbGls
.OrderBy(g => g.GlNr)
.Include("Kgs.Rds")
.AsSplitQuery()
.ToListAsync();
ControlUtils.RenewItemsSource(WbGls, gls, g => (g as WbGl)?.GlNr, WbGls_SelectionChanged, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(WbGls, gls, WbGls_SelectionChanged, ControlUtils.RenewSourceDefault.First);
}
UpdateWbGems();
UpdateWbKgs();
@ -55,7 +55,7 @@ namespace Elwig.Windows {
WbGemsHeader.Content = "Gemeinden" + (WineOrigins.SelectedItem is WineOrigin o ? $" ({o.Name})" : "");
var origin = (WineOrigins.SelectedItem as WineOrigin);
var gems = origin?.Gems.Select(g => g.AtGem).OrderBy(g => g.Name).ToList();
ControlUtils.RenewItemsSource(WbGems, gems, g => (g as AT_Gem)?.Gkz, WbGems_SelectionChanged);
ControlUtils.RenewItemsSource(WbGems, gems, WbGems_SelectionChanged);
UpdateWbKgs();
}
@ -72,7 +72,7 @@ namespace Elwig.Windows {
kgs = null;
}
var kgList = kgs?.OrderBy(k => k.WbKg?.Gl == null).ThenBy(k => k.WbKg?.GlNr).ThenBy(k => k.Name).ToList();
ControlUtils.RenewItemsSource(WbKgs, kgList, k => (k as AT_Kg)?.KgNr, WbKgs_SelectionChanged);
ControlUtils.RenewItemsSource(WbKgs, kgList, WbKgs_SelectionChanged);
}
private void UpdateWbGlKgs() {
@ -80,7 +80,7 @@ namespace Elwig.Windows {
if (WbGls.SelectedItem is WbGl g) {
WbGlKgsHeader.Content += $" ({g.Name})";
var kgs = g.Kgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToList();
ControlUtils.RenewItemsSource(WbGlKgs, kgs, k => (k as AT_Kg)?.KgNr, WbGlKgs_SelectionChanged);
ControlUtils.RenewItemsSource(WbGlKgs, kgs, WbGlKgs_SelectionChanged);
} else {
WbGlKgs.ItemsSource = null;
}
@ -122,7 +122,7 @@ namespace Elwig.Windows {
if (WbGlKgs.SelectedItem is AT_Kg k) {
WbRdsHeader.Content += $" ({k.Name})";
var rds = k.WbKg?.Rds.OrderBy(r => r.Name).ToList();
ControlUtils.RenewItemsSource(WbRds, rds, k => (k as AT_Kg)?.KgNr);
ControlUtils.RenewItemsSource(WbRds, rds);
} else {
WbRds.ItemsSource = null;
}
@ -145,9 +145,9 @@ namespace Elwig.Windows {
UpdateWbRds();
if (!isUpdating && WbGlKgs.SelectedItem is AT_Kg k) {
isUpdating = true;
ControlUtils.SelectListBoxItem(WineOrigins, o => (o as WineOrigin)?.HkId, k.Gem.WbGem?.HkId);
ControlUtils.SelectListBoxItem(WbGems, g => (g as AT_Gem)?.Gkz, k.Gkz);
ControlUtils.SelectListBoxItem(WbKgs, k => (k as AT_Kg)?.KgNr, k.KgNr);
ControlUtils.SelectItemWithPk(WineOrigins, k.Gem.WbGem?.HkId);
ControlUtils.SelectItemWithPk(WbGems, k.Gkz);
ControlUtils.SelectItemWithPk(WbKgs, k.KgNr);
isUpdating = false;
}
await UpdateStatusBar();
@ -157,8 +157,8 @@ namespace Elwig.Windows {
UpdateButtons();
if (!isUpdating && WbKgs.SelectedItem is AT_Kg k && k.WbKg != null && ((WbGls.SelectedItem as WbGl)?.GlNr == k.WbKg?.GlNr || WbGls.SelectedItem == null)) {
isUpdating = true;
ControlUtils.SelectListBoxItem(WbGls, g => (g as WbGl)?.GlNr, k.WbKg?.GlNr);
ControlUtils.SelectListBoxItem(WbGlKgs, k => (k as AT_Kg)?.KgNr, k.KgNr);
ControlUtils.SelectItemWithPk(WbGls, k.WbKg?.GlNr);
ControlUtils.SelectItemWithPk(WbGlKgs, k.KgNr);
isUpdating = false;
}
}
@ -194,7 +194,7 @@ namespace Elwig.Windows {
await ctx.SaveChangesAsync();
}
await App.HintContextChange();
ControlUtils.SelectListBoxItem(WbGlKgs, kg => (kg as AT_Kg)?.KgNr, k.KgNr);
ControlUtils.SelectItemWithPk(WbGlKgs, k.KgNr);
} catch (Exception exc) {
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
@ -214,7 +214,7 @@ namespace Elwig.Windows {
await ctx.SaveChangesAsync();
}
await App.HintContextChange();
ControlUtils.SelectListBoxItem(WbKgs, kg => (kg as AT_Kg)?.KgNr, k.KgNr);
ControlUtils.SelectItemWithPk(WbKgs, k.KgNr);
} catch (Exception exc) {
await HintContextChange();
var str = "Der Eintrag konnte nicht aus der Datenbank gelöscht werden!\n\n" + exc.Message;
@ -226,8 +226,8 @@ namespace Elwig.Windows {
public void FocusKgNr(int kgnr) {
using var ctx = new AppDbContext();
var kg = ctx.Katastralgemeinden.Find(kgnr);
ControlUtils.SelectListBoxItem(WbGls, kg?.WbKg?.Gl, g => (g as WbGl)?.GlNr);
ControlUtils.SelectListBoxItem(WbGlKgs, kg, k => (k as AT_Kg)?.KgNr);
ControlUtils.SelectItemWithPk(WbGls, kg?.WbKg?.GlNr);
ControlUtils.SelectItemWithPk(WbGlKgs, kg?.KgNr);
WbGlKgs.Focus();
WbGlKgs.ScrollIntoView(kg?.WbKg?.Gl);
}

View File

@ -42,7 +42,7 @@ namespace Elwig.Windows {
.Where(v => v.Year == Year)
.OrderBy(v => v.AvNr)
.Include(v => v.Season.Currency)
.ToListAsync(), v => (v as PaymentVar)?.AvNr);
.ToListAsync());
await Update();
}
@ -207,7 +207,7 @@ namespace Elwig.Windows {
await ctx.SaveChangesAsync();
await App.HintContextChange();
ControlUtils.SelectListBoxItem(PaymentVariantList, v, v => (v as PaymentVar)?.AvNr);
ControlUtils.SelectItem(PaymentVariantList, v);
} catch (Exception exc) {
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
@ -232,7 +232,7 @@ namespace Elwig.Windows {
await ctx.SaveChangesAsync();
await App.HintContextChange();
ControlUtils.SelectListBoxItem(PaymentVariantList, n, v => (v as PaymentVar)?.AvNr);
ControlUtils.SelectItem(PaymentVariantList, n);
} catch (Exception exc) {
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;