Models: Remove DeliveryPartAttr
This commit is contained in:
@ -280,7 +280,7 @@ namespace Elwig.Windows {
|
||||
if (ctrl == MgNrInput || ctrl == MemberInput) {
|
||||
SortIdInput.Focus();
|
||||
SortIdInput.SelectAll();
|
||||
} else if (ctrl == SortIdInput || ctrl == WineVarietyInput || ctrl == AttributesInput) {
|
||||
} else if (ctrl == SortIdInput || ctrl == WineVarietyInput || ctrl == AttributeInput) {
|
||||
GradationOeInput.Focus();
|
||||
GradationOeInput.SelectAll();
|
||||
} else if (ctrl == GradationKmwInput || ctrl == GradationOeInput || ctrl == WineQualityLevelInput) {
|
||||
@ -486,12 +486,8 @@ namespace Elwig.Windows {
|
||||
if (filterNotVar.Count > 0) dpq = dpq.Where(p => !filterNotVar.Contains(p.SortId));
|
||||
if (filterQual.Count > 0) dpq = dpq.Where(p => filterQual.Contains(p.QualId));
|
||||
if (filterZwst.Count > 0) dpq = dpq.Where(p => filterZwst.Contains(p.Delivery.ZwstId));
|
||||
if (filterAttr.Count > 0)
|
||||
foreach (var a in filterAttr)
|
||||
dpq = dpq.Where(p => p.PartAttributes.Select(a => a.Attr.AttrId).Contains(a));
|
||||
if (filterNotAttr.Count > 0)
|
||||
foreach (var a in filterNotAttr)
|
||||
dpq = dpq.Where(p => !p.PartAttributes.Select(a => a.Attr.AttrId).Contains(a));
|
||||
if (filterAttr.Count > 0) dpq = dpq.Where(p => p.AttrId != null && filterAttr.Contains(p.AttrId));
|
||||
if (filterNotAttr.Count > 0) dpq = dpq.Where(p => p.AttrId == null || !filterAttr.Contains(p.AttrId));
|
||||
if (filterKmwGt > 0) dpq = dpq.Where(p => p.Kmw >= filterKmwGt);
|
||||
if (filterKmwLt > 0) dpq = dpq.Where(p => p.Kmw < filterKmwLt);
|
||||
if (filterOeGt > 0) dpq = dpq.Where(p => p.Kmw * (4.54 + 0.022 * p.Kmw) >= filterOeGt);
|
||||
@ -570,7 +566,7 @@ namespace Elwig.Windows {
|
||||
if (n > 0 && (n <= 200 || TodayOnlyInput.IsChecked == true)) {
|
||||
var parts = await deliveryParts.ToListAsync();
|
||||
var groups = parts
|
||||
.GroupBy(p => string.Join("/", p.Attributes.Select(a => a.Name)))
|
||||
.GroupBy(p => p.Attribute?.Name)
|
||||
.Select(g => (g.Key, g.Sum(p => p.Weight), g.Min(p => p.Kmw), Utils.AggregateDeliveryPartsKmw(g), g.Max(p => p.Kmw)))
|
||||
.OrderByDescending(g => g.Item2)
|
||||
.ToList();
|
||||
@ -636,7 +632,9 @@ namespace Elwig.Windows {
|
||||
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.Where(m => m.IsActive || !IsCreating).OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync(), i => (i as Member)?.MgNr);
|
||||
ControlUtils.RenewItemsSource(BranchInput, await Context.Branches.OrderBy(b => b.Name).ToListAsync(), i => (i as Branch)?.ZwstId);
|
||||
ControlUtils.RenewItemsSource(WineVarietyInput, await Context.WineVarieties.OrderBy(v => v.Name).ToListAsync(), i => (i as WineVar)?.SortId);
|
||||
ControlUtils.RenewItemsSource(AttributesInput, await Context.WineAttributes.Where(a => !IsCreating || a.IsActive).OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
|
||||
var attrList = await Context.WineAttributes.Where(a => !IsCreating || a.IsActive).OrderBy(a => a.Name).Cast<object>().ToListAsync();
|
||||
attrList.Insert(0, new NullItem(""));
|
||||
ControlUtils.RenewItemsSource(AttributeInput, attrList, i => (i as WineAttr)?.AttrId, null, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(WineQualityLevelInput, await Context.WineQualityLevels.ToListAsync(), i => (i as WineQualLevel)?.QualId);
|
||||
ControlUtils.RenewItemsSource(ModifiersInput, await Context.Modifiers.Where(m => m.Year == y).OrderBy(m => m.Ordering).ToListAsync(), i => (i as Modifier)?.ModId);
|
||||
ControlUtils.RenewItemsSource(WineOriginInput, (await Context.WineOrigins.ToListAsync()).OrderByDescending(o => o.SortKey).ThenBy(o => o.HkId), i => (i as WineOrigin)?.HkId);
|
||||
@ -710,7 +708,7 @@ namespace Elwig.Windows {
|
||||
ClearDefaultValues();
|
||||
|
||||
SortIdInput.Text = p?.SortId ?? "";
|
||||
ControlUtils.SelectCheckComboBoxItems(AttributesInput, p?.Attributes, i => (i as WineAttr)?.AttrId);
|
||||
ControlUtils.SelectComboBoxItem(AttributeInput, p?.Attribute, i => (i as WineAttr)?.AttrId);
|
||||
GradationKmwInput.Text = (p != null) ? $"{p.Kmw:N1}" : "";
|
||||
ControlUtils.SelectComboBoxItem(WineQualityLevelInput, q => (q as WineQualLevel)?.QualId, p?.QualId);
|
||||
ControlUtils.SelectComboBoxItem(WineKgInput, k => (k as AT_Kg)?.KgNr, p?.KgNr);
|
||||
@ -774,6 +772,7 @@ namespace Elwig.Windows {
|
||||
d.Comment = (CommentInput.Text == "") ? null : CommentInput.Text;
|
||||
|
||||
p.SortId = (WineVarietyInput.SelectedItem as WineVar)?.SortId;
|
||||
p.AttrId = (AttributeInput.SelectedItem as WineAttr)?.AttrId;
|
||||
p.Kmw = double.Parse(GradationKmwInput.Text);
|
||||
p.QualId = (WineQualityLevelInput.SelectedItem as WineQualLevel)?.QualId;
|
||||
p.HkId = (WineOriginInput.SelectedItem as WineOrigin)?.HkId;
|
||||
@ -805,7 +804,6 @@ namespace Elwig.Windows {
|
||||
pEntry = partNew ? await Context.AddAsync(p) : Context.Update(p);
|
||||
}
|
||||
|
||||
await Context.UpdateDeliveryPartAttributes(p, AttributesInput.SelectedItems.Cast<WineAttr>());
|
||||
await Context.UpdateDeliveryPartModifiers(p, ModifiersInput.SelectedItems.Cast<Modifier>());
|
||||
|
||||
if (originalMgNr != null && originalMgNr.Value != d.MgNr) {
|
||||
@ -1013,7 +1011,9 @@ namespace Elwig.Windows {
|
||||
if (r != MessageBoxResult.Yes) return;
|
||||
}
|
||||
|
||||
ControlUtils.RenewItemsSource(AttributesInput, await Context.WineAttributes.OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
|
||||
var attrList = await Context.WineAttributes.OrderBy(a => a.Name).Cast<object>().ToListAsync();
|
||||
attrList.Insert(0, new NullItem(""));
|
||||
ControlUtils.RenewItemsSource(AttributeInput, attrList, i => (i as WineAttr)?.AttrId, null, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.Where(m => m.IsActive || !IsReceipt).OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync(), i => (i as Member)?.MgNr);
|
||||
if (DeliveryList.SelectedItem is not Delivery d) {
|
||||
// switch away from creating mode
|
||||
@ -1039,7 +1039,9 @@ namespace Elwig.Windows {
|
||||
private async void NewDeliveryButton_Click(object? sender, RoutedEventArgs? evt) {
|
||||
TodayOnlyInput.IsChecked = true;
|
||||
SearchInput.Text = "";
|
||||
ControlUtils.RenewItemsSource(AttributesInput, await Context.WineAttributes.Where(a => a.IsActive).OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
|
||||
var attrList = await Context.WineAttributes.Where(a => a.IsActive).OrderBy(a => a.Name).Cast<object>().ToListAsync();
|
||||
attrList.Insert(0, new NullItem(""));
|
||||
ControlUtils.RenewItemsSource(AttributeInput, attrList, i => (i as WineAttr)?.AttrId, null, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(MemberInput, await Context.Members.Where(m => m.IsActive || !IsReceipt).OrderBy(m => m.FamilyName).ThenBy(m => m.GivenName).ToListAsync(), i => (i as Member)?.MgNr);
|
||||
IsCreating = true;
|
||||
DeliveryList.IsEnabled = false;
|
||||
@ -1084,7 +1086,6 @@ namespace Elwig.Windows {
|
||||
p2.HkId = "OEST";
|
||||
entry2 = await Context.AddAsync(p2);
|
||||
|
||||
await Context.UpdateDeliveryPartAttributes(p2, p.Attributes);
|
||||
await Context.UpdateDeliveryPartModifiers(p2, p.Modifiers);
|
||||
}
|
||||
await Context.SaveChangesAsync();
|
||||
@ -1425,13 +1426,12 @@ namespace Elwig.Windows {
|
||||
var text = SortIdInput.Text;
|
||||
WineVarietyInput.SelectedItem = Context.WineVarieties.Find(text[0..2]);
|
||||
if (text.Length >= 3) {
|
||||
AttributesInput.UnSelectAll();
|
||||
AttributesInput.SelectedItems.Add(Context.WineAttributes.Find(text[2..]));
|
||||
ControlUtils.SelectComboBoxItem(AttributeInput, Context.WineAttributes.Find(text[2..]), a => (a as WineAttr)?.AttrId);
|
||||
SortIdInput.Text = text[0..2];
|
||||
}
|
||||
} else {
|
||||
WineVarietyInput.SelectedItem = null;
|
||||
AttributesInput.UnSelectAll();
|
||||
AttributeInput.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1508,7 +1508,7 @@ namespace Elwig.Windows {
|
||||
GradationKmwInput.Text += ",0";
|
||||
}
|
||||
|
||||
private void AttributesInput_SelectionChanged(object sender, ItemSelectionChangedEventArgs evt) {
|
||||
private void AttributeInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user