Fix DB cnx
This commit is contained in:
@ -28,22 +28,22 @@ namespace Elwig.Models {
|
||||
}
|
||||
|
||||
[Column("time")]
|
||||
public string TimeString { get; set; }
|
||||
public string? TimeString { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public TimeOnly Time {
|
||||
public TimeOnly? Time {
|
||||
get {
|
||||
return TimeOnly.ParseExact(TimeString, "HH:mm:ss");
|
||||
return (TimeString == null) ? null : TimeOnly.ParseExact(TimeString, "HH:mm:ss");
|
||||
}
|
||||
set {
|
||||
TimeString = value.ToString("HH:mm:ss");
|
||||
TimeString = value?.ToString("HH:mm:ss");
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public DateTime DateTime {
|
||||
get {
|
||||
return Date.ToDateTime(Time);
|
||||
return Date.ToDateTime(Time ?? TimeOnly.MinValue);
|
||||
}
|
||||
set {
|
||||
Date = DateOnly.FromDateTime(value);
|
||||
@ -86,7 +86,7 @@ namespace Elwig.Models {
|
||||
|
||||
public int SearchScore(IEnumerable<string> keywords) {
|
||||
var list = new string?[] {
|
||||
LsNr, Year.ToString(), Date.ToString("dd.MM.yyyy"), Time.ToString("HH:ss"),
|
||||
LsNr, Year.ToString(), Date.ToString("dd.MM.yyyy"), Time?.ToString("HH:ss"),
|
||||
MgNr.ToString(), Member.FamilyName, Member.MiddleName, Member.GivenName, Member.BillingAddress?.Name,
|
||||
Comment
|
||||
}.ToList();
|
||||
|
@ -12,5 +12,8 @@ namespace Elwig.Models {
|
||||
|
||||
[Column("max_kg_per_ha")]
|
||||
public int MaxKgPerHa { get; set; }
|
||||
|
||||
[Column("active")]
|
||||
public bool IsActive { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user