ControlUtils: Cleanup SelectItem() method and use accordingly
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user