Fix DB cnx
This commit is contained in:
@ -28,22 +28,22 @@ namespace Elwig.Models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Column("time")]
|
[Column("time")]
|
||||||
public string TimeString { get; set; }
|
public string? TimeString { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public TimeOnly Time {
|
public TimeOnly? Time {
|
||||||
get {
|
get {
|
||||||
return TimeOnly.ParseExact(TimeString, "HH:mm:ss");
|
return (TimeString == null) ? null : TimeOnly.ParseExact(TimeString, "HH:mm:ss");
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
TimeString = value.ToString("HH:mm:ss");
|
TimeString = value?.ToString("HH:mm:ss");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public DateTime DateTime {
|
public DateTime DateTime {
|
||||||
get {
|
get {
|
||||||
return Date.ToDateTime(Time);
|
return Date.ToDateTime(Time ?? TimeOnly.MinValue);
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
Date = DateOnly.FromDateTime(value);
|
Date = DateOnly.FromDateTime(value);
|
||||||
@ -86,7 +86,7 @@ namespace Elwig.Models {
|
|||||||
|
|
||||||
public int SearchScore(IEnumerable<string> keywords) {
|
public int SearchScore(IEnumerable<string> keywords) {
|
||||||
var list = new string?[] {
|
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,
|
MgNr.ToString(), Member.FamilyName, Member.MiddleName, Member.GivenName, Member.BillingAddress?.Name,
|
||||||
Comment
|
Comment
|
||||||
}.ToList();
|
}.ToList();
|
||||||
|
@ -12,5 +12,8 @@ namespace Elwig.Models {
|
|||||||
|
|
||||||
[Column("max_kg_per_ha")]
|
[Column("max_kg_per_ha")]
|
||||||
public int MaxKgPerHa { get; set; }
|
public int MaxKgPerHa { get; set; }
|
||||||
|
|
||||||
|
[Column("active")]
|
||||||
|
public bool IsActive { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,13 +121,15 @@ namespace Elwig.Windows {
|
|||||||
await base.RenewContext();
|
await base.RenewContext();
|
||||||
await RefreshDeliveryList();
|
await RefreshDeliveryList();
|
||||||
RefreshDeliveryPartList();
|
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(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);
|
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);
|
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(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(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(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);
|
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();
|
var kgList = await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).Cast<object>().ToListAsync();
|
||||||
kgList.Insert(0, new NullItem());
|
kgList.Insert(0, new NullItem());
|
||||||
@ -149,8 +151,10 @@ namespace Elwig.Windows {
|
|||||||
IsRefreshingInputs = true;
|
IsRefreshingInputs = true;
|
||||||
ClearInputStates();
|
ClearInputStates();
|
||||||
if (DeliveryList.SelectedItem is Delivery d) {
|
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);
|
FillInputs(d);
|
||||||
} else {
|
} else {
|
||||||
|
Utils.RenewItemsSource(ModifiersInput, Context.Modifiers.Where(m => m.Year == Utils.CurrentLastSeason).OrderBy(m => m.Name).ToList(), i => (i as Modifier)?.ModId);
|
||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
ClearInputs();
|
ClearInputs();
|
||||||
}
|
}
|
||||||
@ -164,7 +168,7 @@ namespace Elwig.Windows {
|
|||||||
MgNrInput.Text = d.MgNr.ToString();
|
MgNrInput.Text = d.MgNr.ToString();
|
||||||
LsNrInput.Text = d.LsNr;
|
LsNrInput.Text = d.LsNr;
|
||||||
DateInput.Text = d.Date.ToString("dd.MM.yyyy");
|
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 ?? "";
|
CommentInput.Text = d.Comment ?? "";
|
||||||
Utils.RenewItemsSource(DeliveryPartList, d.Parts, i => ((i as DeliveryPart)?.Year, (i as DeliveryPart)?.DId));
|
Utils.RenewItemsSource(DeliveryPartList, d.Parts, i => ((i as DeliveryPart)?.Year, (i as DeliveryPart)?.DId));
|
||||||
if (DeliveryPartList.SelectedItem == null && DeliveryPartList.ItemsSource != null) {
|
if (DeliveryPartList.SelectedItem == null && DeliveryPartList.ItemsSource != null) {
|
||||||
|
Reference in New Issue
Block a user