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

@ -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}";