Fix DB cnx

This commit is contained in:
2023-07-13 22:12:06 +02:00
parent f90319fc9f
commit 7c2a0ca1a6
3 changed files with 15 additions and 8 deletions

View File

@ -121,13 +121,15 @@ namespace Elwig.Windows {
await base.RenewContext();
await RefreshDeliveryList();
RefreshDeliveryPartList();
var d = DeliveryList.SelectedItem as Delivery;
var y = (d?.Year ?? Utils.CurrentLastSeason);
Utils.RenewItemsSource(MemberInput, await Context.Members.OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync(), i => (i as Member)?.MgNr);
Utils.RenewItemsSource(BranchInput, await Context.Branches.OrderBy(b => b.Name).ToListAsync(), i => (i as Branch)?.ZwstId);
BranchInput.SelectedItem = BranchInput.ItemsSource.Cast<Branch>().First(b => b.ZwstId == App.ZwstId);
Utils.RenewItemsSource(WineVarietyInput, await Context.WineVarieties.OrderBy(v => v.Name).ToListAsync(), i => (i as WineVar)?.SortId);
Utils.RenewItemsSource(AttributesInput, await Context.WineAttributes.OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
Utils.RenewItemsSource(WineQualityLevelInput, await Context.WineQualityLevels.ToListAsync(), i => (i as WineQualLevel)?.QualId);
Utils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Season.Year == 2022).OrderBy(m => m.Name).ToListAsync(), i => (i as Modifier)?.ModId);
Utils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Year == y).OrderBy(m => m.Name).ToListAsync(), i => (i as Modifier)?.ModId);
Utils.RenewItemsSource(WineOriginInput, (await Context.WineOrigins.ToListAsync()).OrderByDescending(o => o.SortKey).ThenBy(o => o.HkId), i => (i as WineOrigin)?.HkId);
var kgList = await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).Cast<object>().ToListAsync();
kgList.Insert(0, new NullItem());
@ -149,8 +151,10 @@ namespace Elwig.Windows {
IsRefreshingInputs = true;
ClearInputStates();
if (DeliveryList.SelectedItem is Delivery d) {
Utils.RenewItemsSource(ModifiersInput, Context.Modifiers.Where(m => m.Year == d.Year).OrderBy(m => m.Name).ToList(), i => (i as Modifier)?.ModId);
FillInputs(d);
} else {
Utils.RenewItemsSource(ModifiersInput, Context.Modifiers.Where(m => m.Year == Utils.CurrentLastSeason).OrderBy(m => m.Name).ToList(), i => (i as Modifier)?.ModId);
ClearOriginalValues();
ClearInputs();
}
@ -164,7 +168,7 @@ namespace Elwig.Windows {
MgNrInput.Text = d.MgNr.ToString();
LsNrInput.Text = d.LsNr;
DateInput.Text = d.Date.ToString("dd.MM.yyyy");
TimeInput.Text = d.Time.ToString("HH:mm");
TimeInput.Text = d.Time?.ToString("HH:mm") ?? "";
CommentInput.Text = d.Comment ?? "";
Utils.RenewItemsSource(DeliveryPartList, d.Parts, i => ((i as DeliveryPart)?.Year, (i as DeliveryPart)?.DId));
if (DeliveryPartList.SelectedItem == null && DeliveryPartList.ItemsSource != null) {