Small fixes and additions in Helpers
This commit is contained in:
@ -123,11 +123,17 @@ namespace Elwig.Helpers {
|
||||
}
|
||||
|
||||
public async Task<int> NextDId(int year) {
|
||||
return await Deliveries.Where(d => d.Year == year).Select(d => d.DId).MaxAsync() + 1;
|
||||
int c = 0;
|
||||
(await Deliveries.Where(d => d.Year == year).Select(d => d.DId).ToListAsync())
|
||||
.ForEach(a => { if (a <= c + 10) c = a; });
|
||||
return c + 1;
|
||||
}
|
||||
|
||||
public async Task<int> NextDPNr(int year, int did) {
|
||||
return await DeliveryParts.Where(p => p.Year == year && p.DId == did).Select(d => d.DPNr).MaxAsync() + 1;
|
||||
int c = 0;
|
||||
(await DeliveryParts.Where(p => p.Year == year && p.DId == did).Select(d => d.DPNr).ToListAsync())
|
||||
.ForEach(a => { if (a <= c + 10) c = a; });
|
||||
return c + 1;
|
||||
}
|
||||
|
||||
public async Task<WineQualLevel> GetWineQualityLevel(double kmw) {
|
||||
|
@ -145,7 +145,7 @@ namespace Elwig.Helpers {
|
||||
selItem = source.Cast<object>().FirstOrDefault(i => selectedId.Equals(getId(i)));
|
||||
if (source != null && selItem == null) {
|
||||
if ((def == RenewSourceDefault.IfOnly && source.Cast<object>().Count() == 1) || def == RenewSourceDefault.First) {
|
||||
selItem = source.Cast<object>().First();
|
||||
selItem = source.Cast<object>().FirstOrDefault();
|
||||
}
|
||||
}
|
||||
if (handler != null && selItem != null) listBox.SelectionChanged -= handler;
|
||||
|
@ -12,6 +12,7 @@ using Elwig.Dialogs;
|
||||
namespace Elwig.Helpers {
|
||||
public static partial class Utils {
|
||||
|
||||
public static int CurrentYear => DateTime.Now.Year;
|
||||
public static int CurrentNextSeason => DateTime.Now.Year - (DateTime.Now.Month <= 3 ? 1 : 0);
|
||||
public static int CurrentLastSeason => DateTime.Now.Year - (DateTime.Now.Month <= 7 ? 1 : 0);
|
||||
public static DateTime Today => (DateTime.Now.Hour >= 3) ? DateTime.Today : DateTime.Today.AddDays(-1);
|
||||
|
Reference in New Issue
Block a user