[#34] DeliveryAdminWindow: Show cultivation beside attribute

This commit is contained in:
2024-02-23 12:54:09 +01:00
parent 7b1a3b4f8b
commit 190ef82872
2 changed files with 40 additions and 17 deletions

View File

@ -107,6 +107,7 @@
<Bold>Saison</Bold>: z.B. 2020, &gt;2015, 2017-2019, &lt;2005, 2019-, ...<LineBreak/>
<Bold>Zweigstelle</Bold>: z.B. musterort, ...<LineBreak/>
<Bold>Attribut</Bold>: z.B. kabinett, !kabinett (alle außer kabinett), ...<LineBreak/>
<Bold>Bewirtschaftung</Bold>: z.B. bio, !kip (alle außer KIP), ...<LineBreak/>
<Bold>Datum</Bold>: z.B. 1.9., 15.9.-10.10., -15.10.2020, ...<LineBreak/>
<Bold>Uhrzeit</Bold>: z.B. 06:00-08:00, 18:00-, ...<LineBreak/>
<Bold>Freitext</Bold>: z.B. Lieferscheinnummern, Anmerkung, "quw" (sucht nach dem Text "quw")
@ -415,7 +416,8 @@
<TextBlock Text="{Binding Kmw, StringFormat='{}{0:0.0}°'}" Width="40" TextAlignment="Right" Padding="0,0,10,0"/>
<TextBlock Text="{Binding QualId}" Width="30"/>
<TextBlock Text="{Binding Weight, StringFormat='{}{0:N0} kg'}" Width="60" TextAlignment="Right" Padding="0,0,10,0"/>
<TextBlock Text="{Binding Attribute.Name}" Width="100"/>
<TextBlock Text="{Binding Attribute.Name}" Width="60"/>
<TextBlock Text="{Binding Cultivation.Name}" Width="50"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>

View File

@ -118,7 +118,7 @@ namespace Elwig.Windows {
NewDeliveryButton_Click(null, null);
if ((Context.Seasons.Find(Utils.CurrentYear)) == null) {
MessageBox.Show("Die Saison für das aktuelle Jahr wurde noch nicht erstellt. Neue Lieferungen können nicht abgespeichert werden.",
"Saison noch nicht erstellt", MessageBoxButton.OK, MessageBoxImage.Error);
"Saison noch nicht erstellt", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
}
@ -335,6 +335,8 @@ namespace Elwig.Windows {
var filterZwst = new List<string>();
var filterAttr = new List<string>();
var filterNotAttr = new List<string>();
var filterCult = new List<string>();
var filterNotCult = new List<string>();
var filterDate = new List<(string?, string?)>();
var filterTime = new List<(string?, string?)>();
int filterYearGt = 0, filterYearLt = 0;
@ -347,7 +349,8 @@ namespace Elwig.Windows {
var qual = await Context.WineQualityLevels.Where(q => !q.IsPredicate).ToDictionaryAsync(q => q.QualId, q => q);
var mgnr = await Context.Members.ToDictionaryAsync(m => m.MgNr.ToString(), m => m);
var zwst = await Context.Branches.ToDictionaryAsync(b => b.Name.ToLower().Split(" ")[0], b => b);
var attr = await Context.WineAttributes.ToDictionaryAsync(a => a.Name.ToLower().Split(" ")[0], a => a);
var attr = await Context.WineAttributes.ToDictionaryAsync(a => a.Name.ToLower().Split(' ')[0], a => a);
var cult = await Context.WineCultivations.ToDictionaryAsync(c => c.Name.ToLower().Split(' ')[0], c => c);
for (int i = 0; i < filter.Count; i++) {
var e = filter[i];
@ -399,6 +402,16 @@ namespace Elwig.Windows {
filterNotAttr.Add(a.AttrId);
filter.RemoveAt(i--);
filterNames.Add($"ohne Attribut {a.Name}");
} else if (cult.ContainsKey(e.ToLower())) {
var c = cult[e.ToLower()];
filterCult.Add(c.CultId);
filter.RemoveAt(i--);
filterNames.Add($"Bewirtschaftung {c.Name}");
} else if (e[0] == '!' && cult.ContainsKey(e[1..].ToLower())) {
var c = cult[e[1..].ToLower()];
filterNotCult.Add(c.CultId);
filter.RemoveAt(i--);
filterNames.Add($"ohne Bewirtschaftung {c.Name}");
} else if (zwst.ContainsKey(e.ToLower())) {
var b = zwst[e.ToLower()];
filterZwst.Add(b.ZwstId);
@ -523,6 +536,8 @@ namespace Elwig.Windows {
if (filterZwst.Count > 0) prd = prd.And(p => filterZwst.Contains(p.Delivery.ZwstId));
if (filterAttr.Count > 0) prd = prd.And(p => p.AttrId != null && filterAttr.Contains(p.AttrId));
if (filterNotAttr.Count > 0) prd = prd.And(p => p.AttrId == null || !filterNotAttr.Contains(p.AttrId));
if (filterCult.Count > 0) prd = prd.And(p => p.CultId != null && filterCult.Contains(p.CultId));
if (filterNotCult.Count > 0) prd = prd.And(p => p.CultId == null || !filterNotCult.Contains(p.CultId));
if (filterKmwGt > 0) prd = prd.And(p => p.Kmw >= filterKmwGt);
if (filterKmwLt > 0) prd = prd.And(p => p.Kmw < filterKmwLt);
if (filterOeGt > 0) prd = prd.And(p => p.Kmw * (4.54 + 0.022 * p.Kmw) >= filterOeGt);
@ -646,9 +661,10 @@ namespace Elwig.Windows {
AddGradationToolTipRow(1, "Gradation", null, kmwMin, kmwAvg, kmwMax);
var attrGroups = await deliveryParts
.GroupBy(p => p.Attribute.Name)
.GroupBy(p => new { Attr = p.Attribute.Name, Cult = p.Cultivation.Name })
.Select(g => new {
Attr = g.Key,
g.Key.Attr,
g.Key.Cult,
Weight = g.Sum(p => p.Weight),
Min = g.Min(p => p.Kmw),
Avg = g.Sum(p => p.Kmw * p.Weight) / g.Sum(p => p.Weight),
@ -671,11 +687,13 @@ namespace Elwig.Windows {
.ToListAsync();
var groups = await deliveryParts
.GroupBy(p => new {
p.Attribute.Name,
Attr = p.Attribute.Name,
Cult = p.Cultivation.Name,
p.SortId,
})
.Select(g => new {
Attr = g.Key.Name,
g.Key.Attr,
g.Key.Cult,
g.Key.SortId,
Weight = g.Sum(p => p.Weight),
Min = g.Min(p => p.Kmw),
@ -690,25 +708,28 @@ namespace Elwig.Windows {
int rowNum = 1;
foreach (var attrG in attrGroups) {
rowNum++;
AddWeightToolTipRow(rowNum++, attrG.Attr, null, attrG.Weight, attrG.Weight, weight);
foreach (var g in groups.Where(g => g.Attr == attrG.Attr).OrderByDescending(g => g.Weight).ThenBy(g => g.SortId)) {
var name = attrG.Attr == null && attrG.Cult == null ? null : attrG.Attr + (attrG.Attr != null && attrG.Cult != null ? " / " : "") + attrG.Cult;
AddWeightToolTipRow(rowNum++, name, null, attrG.Weight, attrG.Weight, weight);
foreach (var g in groups.Where(g => g.Attr == attrG.Attr && g.Cult == attrG.Cult).OrderByDescending(g => g.Weight).ThenBy(g => g.SortId)) {
AddWeightToolTipRow(rowNum++, null, g.SortId, g.Weight, attrG.Weight, weight);
}
}
rowNum = 2;
foreach (var attrG in attrGroups) {
rowNum++;
AddGradationToolTipRow(rowNum++, attrG.Attr, null, attrG.Min, attrG.Avg, attrG.Max);
foreach (var g in groups.Where(g => g.Attr == attrG.Attr).OrderByDescending(g => g.Avg).ThenBy(g => g.SortId)) {
var name = attrG.Attr == null && attrG.Cult == null ? null : attrG.Attr + (attrG.Attr != null && attrG.Cult != null ? " / " : "") + attrG.Cult;
AddGradationToolTipRow(rowNum++, name, null, attrG.Min, attrG.Avg, attrG.Max);
foreach (var g in groups.Where(g => g.Attr == attrG.Attr && g.Cult == attrG.Cult).OrderByDescending(g => g.Avg).ThenBy(g => g.SortId)) {
AddGradationToolTipRow(rowNum++, null, g.SortId, g.Min, g.Avg, g.Max);
}
}
if (attrGroups.Count == 1) {
var g = attrGroups.First().Attr;
if (g != null) {
StatusWeight.Text += $" [{g}]";
StatusGradation.Text += $" [{g}]";
var g = attrGroups.First();
var name = g.Attr == null && g.Cult == null ? null : g.Attr + (g.Attr != null && g.Cult != null ? " / " : "") + g.Cult;
if (name != null) {
StatusWeight.Text += $" [{name}]";
StatusGradation.Text += $" [{name}]";
}
if (sortGroups.Count > 1 && sortGroups.Count <= 4) {
StatusWeight.Text += $" = {string.Join(" + ", sortGroups.Select(g => $"{g.Weight:N0} kg ({(double)g.Weight / weight:0%})" + (g.SortId == null ? "" : $" [{g.SortId}]")))}";
@ -716,8 +737,8 @@ namespace Elwig.Windows {
}
} else if (attrGroups.Count <= 4) {
StatusWeight.Text += $" = {string.Join(" + ", attrGroups.Select(g => $"{g.Weight:N0} kg ({(double)g.Weight / weight:0%})" + (g.Attr == null ? "" : $" [{g.Attr}]")))}";
StatusGradation.Text += $" = {string.Join(" + ", attrGroups.Select(g => $"{g.Min:N1}/{g.Avg:N1}/{g.Max:N1}" + (g.Attr == null ? "" : $" [{g.Attr}]")))}";
StatusWeight.Text += $" = {string.Join(" + ", attrGroups.Select(g => $"{g.Weight:N0} kg ({(double)g.Weight / weight:0%})" + (g.Attr == null && g.Cult == null ? "" : $" [{g.Attr}{(g.Attr != null && g.Cult != null ? " / " : "")}{g.Cult}]")))}";
StatusGradation.Text += $" = {string.Join(" + ", attrGroups.Select(g => $"{g.Min:N1}/{g.Avg:N1}/{g.Max:N1}" + (g.Attr == null && g.Cult == null ? "" : $" [{g.Attr}{(g.Attr != null && g.Cult != null ? " / " : "")}{g.Cult}]")))}";
}
} else {
StatusGradation.Text = "Gradation: -";