AreaComWindow: Fix wine cultivation null crash
This commit is contained in:
@ -170,6 +170,7 @@ namespace Elwig.Windows {
|
||||
FbNrInput.Text = (await Context.NextFbNr()).ToString();
|
||||
MgNrInput.Text = Member.MgNr.ToString();
|
||||
YearFromInput.Text = DateTime.Now.Year.ToString();
|
||||
WineCultivationInput.SelectedIndex = 0;
|
||||
|
||||
SetDefaultValue(FbNrInput);
|
||||
ValidateRequiredInputs();
|
||||
@ -181,7 +182,7 @@ namespace Elwig.Windows {
|
||||
ControlUtils.RenewItemsSource(AreaComTypeInput, await Context.AreaCommitmentTypes.OrderBy(v => v.VtrgId).ToListAsync(), i => (i as AreaComType)?.VtrgId);
|
||||
var cultList = await Context.WineCultivations.OrderBy(c => c.Name).Cast<object>().ToListAsync();
|
||||
cultList.Insert(0, new NullItem());
|
||||
ControlUtils.RenewItemsSource(WineCultivationInput, cultList, i => (i as WineCult)?.CultId);
|
||||
ControlUtils.RenewItemsSource(WineCultivationInput, cultList, i => (i as WineCult)?.CultId, null, ControlUtils.RenewSourceDefault.First);
|
||||
await RefreshAreaCommitmentList();
|
||||
}
|
||||
|
||||
@ -233,7 +234,7 @@ namespace Elwig.Windows {
|
||||
a.GstNr = GstNrInput.Text;
|
||||
a.Area = int.Parse(AreaInput.Text);
|
||||
a.VtrgId = (AreaComTypeInput.SelectedItem as AreaComType)!.VtrgId;
|
||||
a.CultId = (WineCultivationInput.SelectedItem as WineCult)!.CultId;
|
||||
a.CultId = (WineCultivationInput.SelectedItem as WineCult)?.CultId;
|
||||
a.Comment = (CommentInput.Text == "") ? null : CommentInput.Text;
|
||||
|
||||
EntityEntry<AreaCom>? tr = null;
|
||||
|
Reference in New Issue
Block a user