Compare commits
2 Commits
75322da405
...
fd7a15bc5a
| Author | SHA1 | Date | |
|---|---|---|---|
| fd7a15bc5a | |||
| 5cee928978 |
+1
-1
@@ -108,7 +108,7 @@ namespace Elwig {
|
|||||||
|
|
||||||
protected void OnPrintingReadyChanged(EventArgs evt) {
|
protected void OnPrintingReadyChanged(EventArgs evt) {
|
||||||
foreach (Window w in Windows) {
|
foreach (Window w in Windows) {
|
||||||
foreach (var b in Utils.FindAllChildren<Button>(w).Where(b => "Print".Equals(b.Tag))) {
|
foreach (var b in ControlUtils.FindAllChildren<Button>(w).Where(b => "Print".Equals(b.Tag))) {
|
||||||
b.IsEnabled = IsPrintingReady;
|
b.IsEnabled = IsPrintingReady;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,213 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Controls.Primitives;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
namespace Elwig.Helpers {
|
||||||
|
public class ControlUtils {
|
||||||
|
|
||||||
|
private static void SetControlBrush(Control input, Brush brush) {
|
||||||
|
if (input is ComboBox cb) {
|
||||||
|
var border = GetComboBoxBorder(cb);
|
||||||
|
if (border != null) border.BorderBrush = brush;
|
||||||
|
} else if (input is Xceed.Wpf.Toolkit.CheckComboBox ccb) {
|
||||||
|
var border = GetComboBoxBorder(ccb);
|
||||||
|
if (border != null) border.BorderBrush = brush;
|
||||||
|
} else {
|
||||||
|
input.BorderBrush = brush;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetInputChanged(Control input) {
|
||||||
|
SetControlBrush(input, Brushes.Orange);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetInputInvalid(Control input) {
|
||||||
|
SetControlBrush(input, Brushes.Red);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ClearInputState(Control input) {
|
||||||
|
if (input is ComboBox cb) {
|
||||||
|
GetComboBoxBorder(cb)?.ClearValue(Border.BorderBrushProperty);
|
||||||
|
} else if (input is Xceed.Wpf.Toolkit.CheckComboBox ccb) {
|
||||||
|
GetComboBoxBorder(ccb)?.ClearValue(Border.BorderBrushProperty);
|
||||||
|
} else {
|
||||||
|
input.ClearValue(Control.BorderBrushProperty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Border? GetComboBoxBorder(ComboBox cb) {
|
||||||
|
var toggleButton = cb.Template.FindName("toggleButton", cb) as ToggleButton;
|
||||||
|
return toggleButton?.Template.FindName("templateRoot", toggleButton) as Border;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Border? GetComboBoxBorder(Xceed.Wpf.Toolkit.CheckComboBox ccb) {
|
||||||
|
var toggleButton = ccb.Template.FindName("toggleButton", ccb) as ToggleButton;
|
||||||
|
return toggleButton?.Template.FindName("templateRoot", toggleButton) as Border;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<T> FindAllChildren<T>(DependencyObject depObj) where T : DependencyObject {
|
||||||
|
if (depObj == null)
|
||||||
|
yield return (T)Enumerable.Empty<T>();
|
||||||
|
foreach (var child in LogicalTreeHelper.GetChildren(depObj)) {
|
||||||
|
if (child == null) {
|
||||||
|
continue;
|
||||||
|
} else if (child is T t) {
|
||||||
|
yield return t;
|
||||||
|
} else if (child is DependencyObject childDepOpj) {
|
||||||
|
foreach (T childOfChild in FindAllChildren<T>(childDepOpj)) {
|
||||||
|
yield return childOfChild;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<T> FindAllChildren<T>(DependencyObject depObj, IEnumerable<DependencyObject> exempt) where T : DependencyObject {
|
||||||
|
return FindAllChildren<T>(depObj).Where(c => !exempt.Contains(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T? FindNextSibling<T>(Control me) where T : DependencyObject {
|
||||||
|
var found = false;
|
||||||
|
foreach (var child in LogicalTreeHelper.GetChildren(me.Parent)) {
|
||||||
|
if (found && child is T c) {
|
||||||
|
return c;
|
||||||
|
} else if (child == me) {
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum RenewSourceDefault {
|
||||||
|
None,
|
||||||
|
IfOnly,
|
||||||
|
First
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RenewItemsSource(Selector selector, IEnumerable? source, Func<object?, object?> getId, SelectionChangedEventHandler? handler = null, RenewSourceDefault def = RenewSourceDefault.None) {
|
||||||
|
if (selector.ItemsSource == source)
|
||||||
|
return;
|
||||||
|
var selectedId = getId(selector.SelectedItem);
|
||||||
|
if (handler != null) selector.SelectionChanged -= handler;
|
||||||
|
selector.ItemsSource = source;
|
||||||
|
if (selectedId != null && source != null)
|
||||||
|
selector.SelectedItem = source.Cast<object>().FirstOrDefault(i => selectedId.Equals(getId(i)));
|
||||||
|
if (source != null && selector.SelectedItem == null) {
|
||||||
|
if ((def == RenewSourceDefault.IfOnly && source.Cast<object>().Count() == 1) || def == RenewSourceDefault.First) {
|
||||||
|
selector.SelectedItem = source.Cast<object>().First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (handler != null) selector.SelectionChanged += handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RenewItemsSource(Xceed.Wpf.Toolkit.Primitives.Selector selector, IEnumerable? source, Func<object?, object?> getId, Xceed.Wpf.Toolkit.Primitives.ItemSelectionChangedEventHandler? handler = null, RenewSourceDefault def = RenewSourceDefault.None) {
|
||||||
|
if (selector.ItemsSource == source)
|
||||||
|
return;
|
||||||
|
var selectedIds = selector.SelectedItems.Cast<object>().Select(i => getId(i)).ToList();
|
||||||
|
if (handler != null) selector.ItemSelectionChanged -= handler;
|
||||||
|
selector.ItemsSource = source;
|
||||||
|
if (source != null) {
|
||||||
|
foreach (var i in source.Cast<object>().Where(i => selectedIds.Contains(getId(i))))
|
||||||
|
selector.SelectedItems.Add(i);
|
||||||
|
}
|
||||||
|
if (source != null && selector.SelectedItem == null) {
|
||||||
|
if ((def == RenewSourceDefault.IfOnly && source.Cast<object>().Count() == 1) || def == RenewSourceDefault.First) {
|
||||||
|
selector.SelectedItem = source.Cast<object>().First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (handler != null) selector.ItemSelectionChanged += handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RenewItemsSource(DataGrid dataGrid, IEnumerable? source, Func<object?, object?> getId, SelectionChangedEventHandler? handler = null, RenewSourceDefault def = RenewSourceDefault.None, bool keepSort = true) {
|
||||||
|
if (dataGrid.ItemsSource == source)
|
||||||
|
return;
|
||||||
|
var column = dataGrid.CurrentCell.Column;
|
||||||
|
var sortColumns = dataGrid.Columns.Select(c => c.SortDirection).ToList();
|
||||||
|
var sort = dataGrid.Items.SortDescriptions.ToList();
|
||||||
|
var selectedId = getId(dataGrid.SelectedItem);
|
||||||
|
if (handler != null) dataGrid.SelectionChanged -= handler;
|
||||||
|
dataGrid.ItemsSource = source;
|
||||||
|
if (keepSort) {
|
||||||
|
for (int i = 0; i < dataGrid.Columns.Count; i++)
|
||||||
|
dataGrid.Columns[i].SortDirection = sortColumns[i];
|
||||||
|
foreach (var s in sort)
|
||||||
|
dataGrid.Items.SortDescriptions.Add(s);
|
||||||
|
}
|
||||||
|
if (selectedId != null && source != null)
|
||||||
|
dataGrid.SelectedItem = source.Cast<object>().FirstOrDefault(i => selectedId.Equals(getId(i)));
|
||||||
|
if (dataGrid.SelectedItem != null && column != null)
|
||||||
|
dataGrid.CurrentCell = new(dataGrid.SelectedItem, column);
|
||||||
|
if (source != null && dataGrid.SelectedItem == null) {
|
||||||
|
if ((def == RenewSourceDefault.IfOnly && source.Cast<object>().Count() == 1) || def == RenewSourceDefault.First) {
|
||||||
|
dataGrid.SelectedItem = source.Cast<object>().First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (handler != null) dataGrid.SelectionChanged += handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RenewItemsSource(ListBox listBox, IEnumerable? source, Func<object?, object?> getId, SelectionChangedEventHandler? handler = null, RenewSourceDefault def = RenewSourceDefault.None) {
|
||||||
|
if (listBox.ItemsSource == source)
|
||||||
|
return;
|
||||||
|
var selectedId = getId(listBox.SelectedItem);
|
||||||
|
if (handler != null) listBox.SelectionChanged -= handler;
|
||||||
|
listBox.ItemsSource = source;
|
||||||
|
if (selectedId != null && source != null)
|
||||||
|
listBox.SelectedItem = source.Cast<object>().FirstOrDefault(i => selectedId.Equals(getId(i)));
|
||||||
|
if (source != null && listBox.SelectedItem == null) {
|
||||||
|
if ((def == RenewSourceDefault.IfOnly && source.Cast<object>().Count() == 1) || def == RenewSourceDefault.First) {
|
||||||
|
listBox.SelectedItem = source.Cast<object>().First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (handler != null) listBox.SelectionChanged += handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static object? GetItemFromSource(IEnumerable source, Func<object?, object?> getId, object? id) {
|
||||||
|
if (source == null)
|
||||||
|
return null;
|
||||||
|
var items = source.Cast<object>();
|
||||||
|
var item = items.Where(i => getId(i)?.Equals(id) ?? false).FirstOrDefault();
|
||||||
|
if (item == null && items.Any(i => i is NullItem))
|
||||||
|
return items.Where(i => i is NullItem).First();
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static object? GetItemFromSource(IEnumerable source, object? item, Func<object?, object?> getId) {
|
||||||
|
return GetItemFromSource(source, getId, getId(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SelectComboBoxItem(ComboBox cb, Func<object?, object?> getId, object? id) {
|
||||||
|
cb.SelectedItem = GetItemFromSource(cb.ItemsSource, getId, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SelectComboBoxItem(ComboBox cb, object? item, Func<object?, object?> getId) {
|
||||||
|
SelectComboBoxItem(cb, getId, getId(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<object?> GetItemsFromSource(IEnumerable source, Func<object?, object?> getId, IEnumerable<object?> ids) {
|
||||||
|
if (source == null)
|
||||||
|
return Array.Empty<object>();
|
||||||
|
return source.Cast<object>().Where(i => ids.Any(c => c?.Equals(getId(i)) ?? false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<object?> GetItemsFromSource(IEnumerable source, IEnumerable<object?>? items, Func<object?, object?> getId) {
|
||||||
|
if (items == null)
|
||||||
|
return Array.Empty<object>();
|
||||||
|
return GetItemsFromSource(source, getId, items.Select(i => getId(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SelectCheckComboBoxItems(Xceed.Wpf.Toolkit.CheckComboBox ccb, Func<object?, object?> getId, IEnumerable<object?>? ids) {
|
||||||
|
ccb.SelectedItems.Clear();
|
||||||
|
if (ids == null) return;
|
||||||
|
foreach (var id in ids)
|
||||||
|
ccb.SelectedItems.Add(GetItemFromSource(ccb.ItemsSource, getId, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SelectCheckComboBoxItems(Xceed.Wpf.Toolkit.CheckComboBox ccb, IEnumerable<object>? items, Func<object?, object?> getId) {
|
||||||
|
SelectCheckComboBoxItems(ccb, getId, items?.Select(i => getId(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,15 +2,11 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Windows.Controls.Primitives;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.IO.Ports;
|
using System.IO.Ports;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
namespace Elwig.Helpers {
|
namespace Elwig.Helpers {
|
||||||
public static partial class Utils {
|
public static partial class Utils {
|
||||||
@@ -65,119 +61,6 @@ namespace Elwig.Helpers {
|
|||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetControlBrush(Control input, Brush brush) {
|
|
||||||
if (input is ComboBox cb) {
|
|
||||||
var border = GetComboBoxBorder(cb);
|
|
||||||
if (border != null) border.BorderBrush = brush;
|
|
||||||
} else if (input is Xceed.Wpf.Toolkit.CheckComboBox ccb) {
|
|
||||||
var border = GetComboBoxBorder(ccb);
|
|
||||||
if (border != null) border.BorderBrush = brush;
|
|
||||||
} else {
|
|
||||||
input.BorderBrush = brush;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SetInputChanged(Control input) {
|
|
||||||
SetControlBrush(input, Brushes.Orange);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SetInputInvalid(Control input) {
|
|
||||||
SetControlBrush(input, Brushes.Red);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ClearInputState(Control input) {
|
|
||||||
if (input is ComboBox cb) {
|
|
||||||
GetComboBoxBorder(cb)?.ClearValue(Border.BorderBrushProperty);
|
|
||||||
} else if (input is Xceed.Wpf.Toolkit.CheckComboBox ccb) {
|
|
||||||
GetComboBoxBorder(ccb)?.ClearValue(Border.BorderBrushProperty);
|
|
||||||
} else {
|
|
||||||
input.ClearValue(Control.BorderBrushProperty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Border? GetComboBoxBorder(ComboBox cb) {
|
|
||||||
var toggleButton = cb.Template.FindName("toggleButton", cb) as ToggleButton;
|
|
||||||
return toggleButton?.Template.FindName("templateRoot", toggleButton) as Border;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Border? GetComboBoxBorder(Xceed.Wpf.Toolkit.CheckComboBox ccb) {
|
|
||||||
var toggleButton = ccb.Template.FindName("toggleButton", ccb) as ToggleButton;
|
|
||||||
return toggleButton?.Template.FindName("templateRoot", toggleButton) as Border;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEnumerable<T> FindAllChildren<T>(DependencyObject depObj) where T : DependencyObject {
|
|
||||||
if (depObj == null)
|
|
||||||
yield return (T)Enumerable.Empty<T>();
|
|
||||||
foreach (var child in LogicalTreeHelper.GetChildren(depObj)) {
|
|
||||||
if (child == null) {
|
|
||||||
continue;
|
|
||||||
} else if (child is T t) {
|
|
||||||
yield return t;
|
|
||||||
} else if (child is DependencyObject childDepOpj) {
|
|
||||||
foreach (T childOfChild in FindAllChildren<T>(childDepOpj)) {
|
|
||||||
yield return childOfChild;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEnumerable<T> FindAllChildren<T>(DependencyObject depObj, IEnumerable<DependencyObject> exempt) where T : DependencyObject {
|
|
||||||
return FindAllChildren<T>(depObj).Where(c => !exempt.Contains(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T? FindNextSibling<T>(Control me) where T : DependencyObject {
|
|
||||||
var found = false;
|
|
||||||
foreach (var child in LogicalTreeHelper.GetChildren(me.Parent)) {
|
|
||||||
if (found && child is T c) {
|
|
||||||
return c;
|
|
||||||
} else if (child == me) {
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void RenewItemsSource(Selector selector, IEnumerable? source, Func<object?, object?> getId) {
|
|
||||||
var selectedId = getId(selector.SelectedItem);
|
|
||||||
selector.ItemsSource = source;
|
|
||||||
if (selectedId != null && source != null)
|
|
||||||
selector.SelectedItem = source.Cast<object>().FirstOrDefault(i => selectedId.Equals(getId(i)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void RenewItemsSource(Xceed.Wpf.Toolkit.Primitives.Selector selector, IEnumerable? source, Func<object?, object?> getId) {
|
|
||||||
var selectedIds = selector.SelectedItems.Cast<object>().Select(i => getId(i)).ToList();
|
|
||||||
selector.ItemsSource = source;
|
|
||||||
if (source != null) {
|
|
||||||
foreach (var i in source.Cast<object>().Where(i => selectedIds.Contains(getId(i))))
|
|
||||||
selector.SelectedItems.Add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void RenewItemsSource(DataGrid dataGrid, IEnumerable? source, Func<object?, object?> getId, bool keepSort = true) {
|
|
||||||
var column = dataGrid.CurrentCell.Column;
|
|
||||||
var sortColumns = dataGrid.Columns.Select(c => c.SortDirection).ToList();
|
|
||||||
var sort = dataGrid.Items.SortDescriptions.ToList();
|
|
||||||
var selectedId = getId(dataGrid.SelectedItem);
|
|
||||||
dataGrid.ItemsSource = source;
|
|
||||||
if (keepSort) {
|
|
||||||
for (int i = 0; i < dataGrid.Columns.Count; i++)
|
|
||||||
dataGrid.Columns[i].SortDirection = sortColumns[i];
|
|
||||||
foreach (var s in sort)
|
|
||||||
dataGrid.Items.SortDescriptions.Add(s);
|
|
||||||
}
|
|
||||||
if (selectedId != null && source != null)
|
|
||||||
dataGrid.SelectedItem = source.Cast<object>().FirstOrDefault(i => selectedId.Equals(getId(i)));
|
|
||||||
if (dataGrid.SelectedItem != null && column != null)
|
|
||||||
dataGrid.CurrentCell = new(dataGrid.SelectedItem, column);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void RenewItemsSource(ListBox listBox, IEnumerable? source, Func<object?, object?> getId) {
|
|
||||||
var selectedId = getId(listBox.SelectedItem);
|
|
||||||
listBox.ItemsSource = source;
|
|
||||||
if (selectedId != null && source != null)
|
|
||||||
listBox.SelectedItem = source.Cast<object>().FirstOrDefault(i => selectedId.Equals(getId(i)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int Modulo(string a, int b) {
|
public static int Modulo(string a, int b) {
|
||||||
if (a.Length == 0 || !a.All(char.IsAsciiDigit)) {
|
if (a.Length == 0 || !a.All(char.IsAsciiDigit)) {
|
||||||
throw new ArgumentException("First argument has to be a decimal string");
|
throw new ArgumentException("First argument has to be a decimal string");
|
||||||
@@ -251,50 +134,5 @@ namespace Elwig.Helpers {
|
|||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static object? GetItemFromSource(IEnumerable source, Func<object?, object?> getId, object? id) {
|
|
||||||
if (source == null)
|
|
||||||
return null;
|
|
||||||
var items = source.Cast<object>();
|
|
||||||
var item = items.Where(i => getId(i)?.Equals(id) ?? false).FirstOrDefault();
|
|
||||||
if (item == null && items.Any(i => i is NullItem))
|
|
||||||
return items.Where(i => i is NullItem).First();
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static object? GetItemFromSource(IEnumerable source, object? item, Func<object?, object?> getId) {
|
|
||||||
return GetItemFromSource(source, getId, getId(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SelectComboBoxItem(ComboBox cb, Func<object?, object?> getId, object? id) {
|
|
||||||
cb.SelectedItem = GetItemFromSource(cb.ItemsSource, getId, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SelectComboBoxItem(ComboBox cb, object? item, Func<object?, object?> getId) {
|
|
||||||
SelectComboBoxItem(cb, getId, getId(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEnumerable<object?> GetItemsFromSource(IEnumerable source, Func<object?, object?> getId, IEnumerable<object?> ids) {
|
|
||||||
if (source == null)
|
|
||||||
return Array.Empty<object>();
|
|
||||||
return source.Cast<object>().Where(i => ids.Any(c => c?.Equals(getId(i)) ?? false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEnumerable<object?> GetItemsFromSource(IEnumerable source, IEnumerable<object?>? items, Func<object?, object?> getId) {
|
|
||||||
if (items == null)
|
|
||||||
return Array.Empty<object>();
|
|
||||||
return GetItemsFromSource(source, getId, items.Select(i => getId(i)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SelectCheckComboBoxItems(Xceed.Wpf.Toolkit.CheckComboBox ccb, Func<object?, object?> getId, IEnumerable<object?>? ids) {
|
|
||||||
ccb.SelectedItems.Clear();
|
|
||||||
if (ids == null) return;
|
|
||||||
foreach (var id in ids)
|
|
||||||
ccb.SelectedItems.Add(GetItemFromSource(ccb.ItemsSource, getId, id));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SelectCheckComboBoxItems(Xceed.Wpf.Toolkit.CheckComboBox ccb, IEnumerable<object>? items, Func<object?, object?> getId) {
|
|
||||||
SelectCheckComboBoxItems(ccb, getId, items?.Select(i => getId(i)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,13 +63,13 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void OnLoaded(object sender, RoutedEventArgs evt) {
|
private void OnLoaded(object sender, RoutedEventArgs evt) {
|
||||||
TextBoxInputs = Utils.FindAllChildren<TextBox>(this, ExemptInputs).ToArray();
|
TextBoxInputs = ControlUtils.FindAllChildren<TextBox>(this, ExemptInputs).ToArray();
|
||||||
ComboBoxInputs = Utils.FindAllChildren<ComboBox>(this, ExemptInputs).ToArray();
|
ComboBoxInputs = ControlUtils.FindAllChildren<ComboBox>(this, ExemptInputs).ToArray();
|
||||||
CheckBoxInputs = Utils.FindAllChildren<CheckBox>(this, ExemptInputs).ToArray();
|
CheckBoxInputs = ControlUtils.FindAllChildren<CheckBox>(this, ExemptInputs).ToArray();
|
||||||
CheckComboBoxInputs = Utils.FindAllChildren<CheckComboBox>(this, ExemptInputs).ToArray();
|
CheckComboBoxInputs = ControlUtils.FindAllChildren<CheckComboBox>(this, ExemptInputs).ToArray();
|
||||||
RadioButtonInputs = Utils.FindAllChildren<RadioButton>(this, ExemptInputs).ToArray();
|
RadioButtonInputs = ControlUtils.FindAllChildren<RadioButton>(this, ExemptInputs).ToArray();
|
||||||
PlzInputs = TextBoxInputs.Where(tb => "PLZ".Equals(tb.Tag)).ToArray();
|
PlzInputs = TextBoxInputs.Where(tb => "PLZ".Equals(tb.Tag)).ToArray();
|
||||||
PlzOrtInputs = PlzInputs.Select(tb => Utils.FindNextSibling<ComboBox>(tb) ?? throw new MissingMemberException()).ToArray();
|
PlzOrtInputs = PlzInputs.Select(tb => ControlUtils.FindNextSibling<ComboBox>(tb) ?? throw new MissingMemberException()).ToArray();
|
||||||
foreach (var tb in TextBoxInputs)
|
foreach (var tb in TextBoxInputs)
|
||||||
Valid[tb] = true;
|
Valid[tb] = true;
|
||||||
foreach (var cb in ComboBoxInputs)
|
foreach (var cb in ComboBoxInputs)
|
||||||
@@ -104,24 +104,24 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
protected void ClearInputStates() {
|
protected void ClearInputStates() {
|
||||||
foreach (var tb in TextBoxInputs)
|
foreach (var tb in TextBoxInputs)
|
||||||
Utils.ClearInputState(tb);
|
ControlUtils.ClearInputState(tb);
|
||||||
foreach (var cb in ComboBoxInputs)
|
foreach (var cb in ComboBoxInputs)
|
||||||
Utils.ClearInputState(cb);
|
ControlUtils.ClearInputState(cb);
|
||||||
foreach (var ccb in CheckComboBoxInputs)
|
foreach (var ccb in CheckComboBoxInputs)
|
||||||
Utils.ClearInputState(ccb);
|
ControlUtils.ClearInputState(ccb);
|
||||||
foreach (var cb in CheckBoxInputs)
|
foreach (var cb in CheckBoxInputs)
|
||||||
Utils.ClearInputState(cb);
|
ControlUtils.ClearInputState(cb);
|
||||||
foreach (var rb in RadioButtonInputs)
|
foreach (var rb in RadioButtonInputs)
|
||||||
Utils.ClearInputState(rb);
|
ControlUtils.ClearInputState(rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ValidateRequiredInputs() {
|
protected void ValidateRequiredInputs() {
|
||||||
foreach (var input in RequiredInputs) {
|
foreach (var input in RequiredInputs) {
|
||||||
if (input is TextBox tb && tb.Text.Length == 0) {
|
if (input is TextBox tb && tb.Text.Length == 0) {
|
||||||
Utils.SetInputInvalid(input);
|
ControlUtils.SetInputInvalid(input);
|
||||||
Valid[input] = false;
|
Valid[input] = false;
|
||||||
} else if (input is ComboBox cb && cb.SelectedItem == null && cb.ItemsSource != null) {
|
} else if (input is ComboBox cb && cb.SelectedItem == null && cb.ItemsSource != null) {
|
||||||
Utils.SetInputInvalid(input);
|
ControlUtils.SetInputInvalid(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ namespace Elwig.Windows {
|
|||||||
OriginalValues.Remove(input);
|
OriginalValues.Remove(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ClearInputs() {
|
protected void ClearInputs(bool validate = true) {
|
||||||
foreach (var tb in TextBoxInputs)
|
foreach (var tb in TextBoxInputs)
|
||||||
tb.Text = "";
|
tb.Text = "";
|
||||||
foreach (var cb in ComboBoxInputs)
|
foreach (var cb in ComboBoxInputs)
|
||||||
@@ -192,7 +192,7 @@ namespace Elwig.Windows {
|
|||||||
cb.IsChecked = false;
|
cb.IsChecked = false;
|
||||||
foreach (var rb in RadioButtonInputs)
|
foreach (var rb in RadioButtonInputs)
|
||||||
rb.IsChecked = false;
|
rb.IsChecked = false;
|
||||||
ValidateRequiredInputs();
|
if (validate) ValidateRequiredInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool IsValid => Valid.All(kv => kv.Value);
|
protected bool IsValid => Valid.All(kv => kv.Value);
|
||||||
@@ -230,7 +230,7 @@ namespace Elwig.Windows {
|
|||||||
var plzInputValid = GetInputValid(plzInput);
|
var plzInputValid = GetInputValid(plzInput);
|
||||||
var item = ortInput.SelectedItem;
|
var item = ortInput.SelectedItem;
|
||||||
var list = plzInputValid && plzInput.Text.Length == 4 ? Context.Postleitzahlen.Find(int.Parse(plzInput.Text))?.Orte.ToList() : null;
|
var list = plzInputValid && plzInput.Text.Length == 4 ? Context.Postleitzahlen.Find(int.Parse(plzInput.Text))?.Orte.ToList() : null;
|
||||||
Utils.RenewItemsSource(ortInput, list, i => (i as AT_PlzDest)?.Id);
|
ControlUtils.RenewItemsSource(ortInput, list, i => (i as AT_PlzDest)?.Id);
|
||||||
if (list != null && ortInput.SelectedItem == null && list.Count == 1)
|
if (list != null && ortInput.SelectedItem == null && list.Count == 1)
|
||||||
ortInput.SelectedItem = list[0];
|
ortInput.SelectedItem = list[0];
|
||||||
UpdateComboBox(ortInput);
|
UpdateComboBox(ortInput);
|
||||||
@@ -264,12 +264,12 @@ namespace Elwig.Windows {
|
|||||||
ValidateInput(input, res.IsValid);
|
ValidateInput(input, res.IsValid);
|
||||||
if (res.IsValid) {
|
if (res.IsValid) {
|
||||||
if (InputHasChanged(input)) {
|
if (InputHasChanged(input)) {
|
||||||
Utils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
} else {
|
} else {
|
||||||
Utils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Utils.SetInputInvalid(input);
|
ControlUtils.SetInputInvalid(input);
|
||||||
}
|
}
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
return res.IsValid;
|
return res.IsValid;
|
||||||
@@ -292,11 +292,11 @@ namespace Elwig.Windows {
|
|||||||
protected void CheckBox_Changed(object sender, RoutedEventArgs evt) {
|
protected void CheckBox_Changed(object sender, RoutedEventArgs evt) {
|
||||||
var input = (CheckBox)sender;
|
var input = (CheckBox)sender;
|
||||||
if (SenderIsRequired(input) && input.IsChecked != true) {
|
if (SenderIsRequired(input) && input.IsChecked != true) {
|
||||||
Utils.SetInputInvalid(input);
|
ControlUtils.SetInputInvalid(input);
|
||||||
} else if (InputHasChanged(input)) {
|
} else if (InputHasChanged(input)) {
|
||||||
Utils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
} else {
|
} else {
|
||||||
Utils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
}
|
}
|
||||||
@@ -304,11 +304,11 @@ namespace Elwig.Windows {
|
|||||||
protected void RadioButton_Changed(object sender, RoutedEventArgs evt) {
|
protected void RadioButton_Changed(object sender, RoutedEventArgs evt) {
|
||||||
var input = (RadioButton)sender;
|
var input = (RadioButton)sender;
|
||||||
if (SenderIsRequired(input) && input.IsChecked != true) {
|
if (SenderIsRequired(input) && input.IsChecked != true) {
|
||||||
Utils.SetInputInvalid(input);
|
ControlUtils.SetInputInvalid(input);
|
||||||
} else if (InputHasChanged(input)) {
|
} else if (InputHasChanged(input)) {
|
||||||
Utils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
} else {
|
} else {
|
||||||
Utils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
}
|
}
|
||||||
@@ -317,13 +317,13 @@ namespace Elwig.Windows {
|
|||||||
var input = (TextBox)sender;
|
var input = (TextBox)sender;
|
||||||
if (SenderIsRequired(input) && input.Text.Length == 0) {
|
if (SenderIsRequired(input) && input.Text.Length == 0) {
|
||||||
ValidateInput(input, false);
|
ValidateInput(input, false);
|
||||||
Utils.SetInputInvalid(input);
|
ControlUtils.SetInputInvalid(input);
|
||||||
} else {
|
} else {
|
||||||
ValidateInput(input, true);
|
ValidateInput(input, true);
|
||||||
if (InputHasChanged(input)) {
|
if (InputHasChanged(input)) {
|
||||||
Utils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
} else {
|
} else {
|
||||||
Utils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
@@ -339,13 +339,13 @@ namespace Elwig.Windows {
|
|||||||
if (valid) {
|
if (valid) {
|
||||||
ValidateInput(input, true);
|
ValidateInput(input, true);
|
||||||
if (InputHasChanged(input)) {
|
if (InputHasChanged(input)) {
|
||||||
Utils.SetInputChanged(input);
|
ControlUtils.SetInputChanged(input);
|
||||||
} else {
|
} else {
|
||||||
Utils.ClearInputState(input);
|
ControlUtils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ValidateInput(input, false);
|
ValidateInput(input, false);
|
||||||
Utils.SetInputInvalid(input);
|
ControlUtils.SetInputInvalid(input);
|
||||||
}
|
}
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace Elwig.Windows {
|
|||||||
private async Task RefreshAreaCommitmentListQuery() {
|
private async Task RefreshAreaCommitmentListQuery() {
|
||||||
List<AreaCom> areaComs = await Context.AreaCommitments.Where(a => a.MgNr == Member.MgNr).OrderBy(a => a.FbNr).ToListAsync();
|
List<AreaCom> areaComs = await Context.AreaCommitments.Where(a => a.MgNr == Member.MgNr).OrderBy(a => a.FbNr).ToListAsync();
|
||||||
|
|
||||||
Utils.RenewItemsSource(AreaCommitmentList, areaComs, i => (i as AreaCom)?.FbNr);
|
ControlUtils.RenewItemsSource(AreaCommitmentList, areaComs, i => (i as AreaCom)?.FbNr);
|
||||||
if (areaComs.Count == 1)
|
if (areaComs.Count == 1)
|
||||||
AreaCommitmentList.SelectedIndex = 0;
|
AreaCommitmentList.SelectedIndex = 0;
|
||||||
|
|
||||||
@@ -102,10 +102,10 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
protected override async Task RenewContext() {
|
protected override async Task RenewContext() {
|
||||||
await base.RenewContext();
|
await base.RenewContext();
|
||||||
Utils.RenewItemsSource(KgInput, await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync(), i => (i as AT_Kg)?.KgNr);
|
ControlUtils.RenewItemsSource(KgInput, await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync(), i => (i as AT_Kg)?.KgNr);
|
||||||
Utils.RenewItemsSource(WineVarietyInput, await Context.WineVarieties.OrderBy(v => v.Name).ToListAsync(), i => (i as WineVar)?.SortId);
|
ControlUtils.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);
|
ControlUtils.RenewItemsSource(AttributesInput, await Context.WineAttributes.OrderBy(a => a.Name).ToListAsync(), i => (i as WineAttr)?.AttrId);
|
||||||
Utils.RenewItemsSource(WineCultivationInput, await Context.WineCultivations.OrderBy(c => c.Name).ToListAsync(), i => (i as WineCult)?.CultId);
|
ControlUtils.RenewItemsSource(WineCultivationInput, await Context.WineCultivations.OrderBy(c => c.Name).ToListAsync(), i => (i as WineCult)?.CultId);
|
||||||
await RefreshAreaCommitmentList();
|
await RefreshAreaCommitmentList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,7 +301,7 @@ namespace Elwig.Windows {
|
|||||||
if (curr_kg != null) {
|
if (curr_kg != null) {
|
||||||
var rdList = await Context.WbRde.Where(r => r.KgNr == curr_kg.KgNr).OrderBy(r => r.Name).Cast<object>().ToListAsync();
|
var rdList = await Context.WbRde.Where(r => r.KgNr == curr_kg.KgNr).OrderBy(r => r.Name).Cast<object>().ToListAsync();
|
||||||
rdList.Insert(0, new NullItem());
|
rdList.Insert(0, new NullItem());
|
||||||
Utils.RenewItemsSource(RdInput, rdList, i => (i as WbRd)?.RdNr);
|
ControlUtils.RenewItemsSource(RdInput, rdList, i => (i as WbRd)?.RdNr);
|
||||||
}
|
}
|
||||||
ComboBox_SelectionChanged(sender, evt);
|
ComboBox_SelectionChanged(sender, evt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ namespace Elwig.Windows {
|
|||||||
if (LockContext || !Context.HasBackendChanged) return;
|
if (LockContext || !Context.HasBackendChanged) return;
|
||||||
Context.Dispose();
|
Context.Dispose();
|
||||||
Context = new();
|
Context = new();
|
||||||
RenewContext();
|
RenewContext().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLoaded(object sender, RoutedEventArgs evt) {
|
private void OnLoaded(object sender, RoutedEventArgs evt) {
|
||||||
RenewContext();
|
RenewContext().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClosed(EventArgs evt) {
|
protected override void OnClosed(EventArgs evt) {
|
||||||
|
|||||||
@@ -104,19 +104,29 @@
|
|||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
|
||||||
<Button x:Name="NewMemberButton" Content="Neu"
|
<Button x:Name="NewDeliveryButton" Content="Neu" IsEnabled="False" Visibility="Hidden"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"/>
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"
|
||||||
<Button x:Name="EditMemberButton" Content="Bearbeiten" IsEnabled="False"
|
Click="NewDeliveryButton_Click"/>
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1" Grid.Row="2"/>
|
<Button x:Name="AbwertenButton" Content="Abwerten" IsEnabled="False"
|
||||||
<Button x:Name="DeleteMemberButton" Content="Löschen" IsEnabled="False"
|
ToolTip="Ausgewählte Teillieferung vollständig oder teilweise abwerten"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2" Grid.Row="2"/>
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"
|
||||||
|
Click="AbwertenButton_Click"/>
|
||||||
|
<Button x:Name="EditDeliveryButton" Content="Bearbeiten" IsEnabled="False"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1" Grid.Row="2"
|
||||||
|
Click="EditDeliveryButton_Click"/>
|
||||||
|
<Button x:Name="DeleteDeliveryButton" Content="Löschen" IsEnabled="False"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2" Grid.Row="2"
|
||||||
|
Click="DeleteDeliveryButton_Click"/>
|
||||||
|
|
||||||
<Button x:Name="SaveButton" Content="Speichern" IsEnabled="False" Visibility="Hidden"
|
<Button x:Name="SaveButton" Content="Speichern" IsEnabled="False" Visibility="Hidden"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0"/>
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"
|
||||||
|
Click="SaveButton_Click"/>
|
||||||
<Button x:Name="ResetButton" Content="Zurücksetzen" IsEnabled="False" Visibility="Hidden"
|
<Button x:Name="ResetButton" Content="Zurücksetzen" IsEnabled="False" Visibility="Hidden"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1"/>
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1" Grid.Row="2"
|
||||||
|
Click="ResetButton_Click"/>
|
||||||
<Button x:Name="CancelButton" Content="Abbrechen" IsEnabled="False" Visibility="Hidden" IsCancel="True"
|
<Button x:Name="CancelButton" Content="Abbrechen" IsEnabled="False" Visibility="Hidden" IsCancel="True"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2"/>
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2" Grid.Row="2"
|
||||||
|
Click="CancelButton_Click"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<GroupBox Header="Mitglied" Grid.Column="1" Grid.Row="1" Margin="5,5,5,5">
|
<GroupBox Header="Mitglied" Grid.Column="1" Grid.Row="1" Margin="5,5,5,5">
|
||||||
@@ -212,7 +222,7 @@
|
|||||||
ItemTemplate="{StaticResource WineQualityLevelTemplate}"
|
ItemTemplate="{StaticResource WineQualityLevelTemplate}"
|
||||||
SelectionChanged="WineQualityLevelInput_SelectionChanged"/>
|
SelectionChanged="WineQualityLevelInput_SelectionChanged"/>
|
||||||
|
|
||||||
<CheckBox x:Name="AbgewertetInput" Content="Abgewertet"
|
<CheckBox x:Name="AbgewertetInput" Content="Abgewertet" IsEnabled="False"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,75,10,10" Grid.Column="1"/>
|
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,75,10,10" Grid.Column="1"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
@@ -231,7 +241,7 @@
|
|||||||
<Label Content="kg" Margin="0,4,3,0" HorizontalAlignment="Right" FontSize="10"/>
|
<Label Content="kg" Margin="0,4,3,0" HorizontalAlignment="Right" FontSize="10"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<CheckBox x:Name="ManualWeighingInput" Content="Handwiegung"
|
<CheckBox x:Name="ManualWeighingInput" Content="Handwiegung" IsEnabled="False"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,45,10,10" Grid.Column="0" Grid.ColumnSpan="2"/>
|
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,45,10,10" Grid.Column="0" Grid.ColumnSpan="2"/>
|
||||||
|
|
||||||
<CheckBox x:Name="GerebeltGewogenInput" Content="Gerebelt gewogen"
|
<CheckBox x:Name="GerebeltGewogenInput" Content="Gerebelt gewogen"
|
||||||
@@ -308,9 +318,12 @@
|
|||||||
</ListBox>
|
</ListBox>
|
||||||
|
|
||||||
<Button x:Name="ExtractDeliveryPartButton" Content="Herausheben" IsEnabled="False"
|
<Button x:Name="ExtractDeliveryPartButton" Content="Herausheben" IsEnabled="False"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,2.5,5" Grid.Column="0" Grid.Row="2"/>
|
ToolTip="Ausgewählte Teillieferung aus aktueller Lieferung entfernen und entweder anderer oder neuer Lieferung zuordnen"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,2.5,5" Grid.Column="0" Grid.Row="2"
|
||||||
|
Click="ExtractDeliveryPartButton_Click"/>
|
||||||
<Button x:Name="DeleteDeliveryPartButton" Content="Löschen" IsEnabled="False"
|
<Button x:Name="DeleteDeliveryPartButton" Content="Löschen" IsEnabled="False"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,10,5,5" Grid.Column="1" Grid.Row="2"/>
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,10,5,5" Grid.Column="1" Grid.Row="2"
|
||||||
|
Click="DeleteDeliveryPartButton_Click"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
|
|||||||
@@ -15,22 +15,21 @@ namespace Elwig.Windows {
|
|||||||
public partial class DeliveryAdminWindow : AdministrationWindow {
|
public partial class DeliveryAdminWindow : AdministrationWindow {
|
||||||
|
|
||||||
private bool IsUpdatingGradation = false;
|
private bool IsUpdatingGradation = false;
|
||||||
private bool IsRefreshingInputs = false;
|
|
||||||
private readonly bool IsReceipt = false;
|
private readonly bool IsReceipt = false;
|
||||||
private readonly Member? Member = null;
|
private Member? Member = null;
|
||||||
private readonly DispatcherTimer Timer;
|
private readonly DispatcherTimer Timer;
|
||||||
private List<string> TextFilter = new();
|
private List<string> TextFilter = new();
|
||||||
private readonly RoutedCommand CtrlF = new();
|
private readonly RoutedCommand CtrlF = new();
|
||||||
|
|
||||||
public DeliveryAdminWindow() {
|
public DeliveryAdminWindow(bool receipt = false) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
CtrlF.InputGestures.Add(new KeyGesture(Key.F, ModifierKeys.Control));
|
CtrlF.InputGestures.Add(new KeyGesture(Key.F, ModifierKeys.Control));
|
||||||
CommandBindings.Add(new CommandBinding(CtrlF, FocusSearchInput));
|
CommandBindings.Add(new CommandBinding(CtrlF, FocusSearchInput));
|
||||||
RequiredInputs = new Control[] {
|
RequiredInputs = new Control[] {
|
||||||
MgNrInput, MemberInput,
|
MgNrInput, MemberInput,
|
||||||
|
LsNrInput, DateInput, BranchInput,
|
||||||
SortIdInput, WineVarietyInput,
|
SortIdInput, WineVarietyInput,
|
||||||
GradationOeInput, GradationKmwInput,
|
GradationOeInput, GradationKmwInput, WineQualityLevelInput,
|
||||||
WineQualityLevelInput,
|
|
||||||
WineOriginInput, WineKgInput,
|
WineOriginInput, WineKgInput,
|
||||||
WeightInput
|
WeightInput
|
||||||
};
|
};
|
||||||
@@ -38,8 +37,8 @@ namespace Elwig.Windows {
|
|||||||
SearchInput, TodayOnlyInput, SeasonOnlyInput,
|
SearchInput, TodayOnlyInput, SeasonOnlyInput,
|
||||||
DeliveryList, DeliveryPartList,
|
DeliveryList, DeliveryPartList,
|
||||||
MemberAddressField,
|
MemberAddressField,
|
||||||
LsNrInput, DateInput, TimeInput, BranchInput,
|
|
||||||
};
|
};
|
||||||
|
IsReceipt = receipt;
|
||||||
|
|
||||||
Timer = new DispatcherTimer();
|
Timer = new DispatcherTimer();
|
||||||
Timer.Tick += new EventHandler(OnSecondPassed);
|
Timer.Tick += new EventHandler(OnSecondPassed);
|
||||||
@@ -47,12 +46,23 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
InitializeDelayTimer(SearchInput, SearchInput_TextChanged);
|
InitializeDelayTimer(SearchInput, SearchInput_TextChanged);
|
||||||
SearchInput.TextChanged -= SearchInput_TextChanged;
|
SearchInput.TextChanged -= SearchInput_TextChanged;
|
||||||
}
|
|
||||||
|
|
||||||
public DeliveryAdminWindow(bool receipt) : this() {
|
if (IsReceipt) {
|
||||||
IsReceipt = receipt;
|
Title = "Übernahme - Elwig";
|
||||||
Title = "Übernahme - Elwig";
|
TodayOnlyInput.IsChecked = true;
|
||||||
TodayOnlyInput.IsChecked = true;
|
var n = App.Scales.Count();
|
||||||
|
if (n < 1) WeighingAButton.Visibility = Visibility.Hidden;
|
||||||
|
if (n < 2) WeighingBButton.Visibility = Visibility.Hidden;
|
||||||
|
if (n < 3) WeighingCButton.Visibility = Visibility.Hidden;
|
||||||
|
if (n < 4) WeighingDButton.Visibility = Visibility.Hidden;
|
||||||
|
if (n == 1) WeighingAButton.Content = "Wiegen";
|
||||||
|
} else {
|
||||||
|
WeighingManualButton.Visibility = Visibility.Hidden;
|
||||||
|
WeighingAButton.Visibility = Visibility.Hidden;
|
||||||
|
WeighingBButton.Visibility = Visibility.Hidden;
|
||||||
|
WeighingCButton.Visibility = Visibility.Hidden;
|
||||||
|
WeighingDButton.Visibility = Visibility.Hidden;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeliveryAdminWindow(int mgnr) : this() {
|
public DeliveryAdminWindow(int mgnr) : this() {
|
||||||
@@ -75,10 +85,12 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateButtons() {
|
protected override void UpdateButtons() {
|
||||||
|
if (!IsEditing && !IsCreating) return;
|
||||||
|
bool ch = HasChanged, v = IsValid;
|
||||||
|
ResetButton.IsEnabled = (ch);
|
||||||
|
SaveButton.IsEnabled = (v && ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task RefreshDeliveryList() {
|
private async Task RefreshDeliveryList() {
|
||||||
await RefreshDeliveryListQuery();
|
await RefreshDeliveryListQuery();
|
||||||
}
|
}
|
||||||
@@ -98,56 +110,48 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
List<Delivery> deliveries = await deliveryQuery.OrderByDescending(d => d.DateString).ThenByDescending(d => d.TimeString).ToListAsync();
|
List<Delivery> deliveries = await deliveryQuery.OrderByDescending(d => d.DateString).ThenByDescending(d => d.TimeString).ToListAsync();
|
||||||
if (TextFilter.Count > 0) {
|
if (TextFilter.Count > 0) {
|
||||||
deliveries = deliveries
|
var dict = deliveries
|
||||||
.ToDictionary(d => d, d => d.SearchScore(TextFilter))
|
.ToDictionary(d => d, d => d.SearchScore(TextFilter))
|
||||||
.OrderByDescending(a => a.Value)
|
.OrderByDescending(a => a.Value)
|
||||||
.ThenBy(a => a.Key.DateTime)
|
.ThenBy(a => a.Key.DateTime);
|
||||||
.Where(a => a.Value > 0)
|
var threshold = dict.Select(a => a.Value).Max() * 3 / 4;
|
||||||
|
deliveries = dict
|
||||||
|
.Where(a => a.Value > threshold)
|
||||||
.Select(a => a.Key)
|
.Select(a => a.Key)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.RenewItemsSource(DeliveryList, deliveries, d => ((d as Delivery)?.Year, (d as Delivery)?.DId), !updateSort);
|
ControlUtils.RenewItemsSource(DeliveryList, deliveries, d => ((d as Delivery)?.Year, (d as Delivery)?.DId), DeliveryList_SelectionChanged, ControlUtils.RenewSourceDefault.IfOnly, !updateSort);
|
||||||
if (deliveries.Count == 1)
|
|
||||||
DeliveryList.SelectedIndex = 0;
|
|
||||||
|
|
||||||
RefreshInputs();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RefreshDeliveryPartList(bool updateSort = false) {
|
|
||||||
if (DeliveryList.SelectedItem is not Delivery d) {
|
|
||||||
DeliveryPartList.ItemsSource = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils.RenewItemsSource(DeliveryPartList, d.Parts.OrderBy(p => p.DPNr), i => ((i as DeliveryPart)?.Year, (i as DeliveryPart)?.DId, (i as DeliveryPart)?.DPNr));
|
|
||||||
if (d.Parts.Count == 1)
|
|
||||||
DeliveryPartList.SelectedIndex = 0;
|
|
||||||
|
|
||||||
RefreshInputs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task RenewContext() {
|
protected override async Task RenewContext() {
|
||||||
await base.RenewContext();
|
await base.RenewContext();
|
||||||
|
|
||||||
|
if (Member != null) {
|
||||||
|
if (Context.Members.Find(Member.MgNr) is not Member m) {
|
||||||
|
Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Member = m;
|
||||||
|
Title = $"Lieferungen - {Member.AdministrativeName} - Elwig";
|
||||||
|
}
|
||||||
|
|
||||||
await RefreshDeliveryList();
|
await RefreshDeliveryList();
|
||||||
RefreshDeliveryPartList();
|
|
||||||
var d = DeliveryList.SelectedItem as Delivery;
|
var d = DeliveryList.SelectedItem as Delivery;
|
||||||
var y = (d?.Year ?? Utils.CurrentLastSeason);
|
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);
|
ControlUtils.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);
|
ControlUtils.RenewItemsSource(BranchInput, await Context.Branches.OrderBy(b => b.Name).ToListAsync(), i => (i as Branch)?.ZwstId);
|
||||||
Utils.SelectComboBoxItem(BranchInput, i => (i as Branch)?.ZwstId, App.ZwstId);
|
ControlUtils.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);
|
ControlUtils.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);
|
ControlUtils.RenewItemsSource(WineQualityLevelInput, await Context.WineQualityLevels.ToListAsync(), i => (i as WineQualLevel)?.QualId);
|
||||||
Utils.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.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);
|
ControlUtils.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());
|
||||||
Utils.RenewItemsSource(WineKgInput, kgList, i => (i as AT_Kg)?.KgNr);
|
ControlUtils.RenewItemsSource(WineKgInput, kgList, i => (i as AT_Kg)?.KgNr);
|
||||||
if (WineKgInput.SelectedItem == null) WineKgInput.SelectedIndex = 0;
|
|
||||||
UpdateWineQualityLevels();
|
|
||||||
UpdateRdInput();
|
UpdateRdInput();
|
||||||
await UpdateLsNr();
|
|
||||||
|
if (IsCreating) await UpdateLsNr();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FocusSearchInput(object sender, RoutedEventArgs evt) {
|
private void FocusSearchInput(object sender, RoutedEventArgs evt) {
|
||||||
@@ -157,46 +161,49 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshInputs() {
|
private void RefreshDeliveryParts() {
|
||||||
IsRefreshingInputs = true;
|
|
||||||
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);
|
ControlUtils.RenewItemsSource(ModifiersInput, Context.Modifiers.Where(m => m.Year == d.Year).OrderBy(m => m.Name).ToList(), i => (i as Modifier)?.ModId);
|
||||||
FillInputs(d);
|
ControlUtils.RenewItemsSource(DeliveryPartList, d.Parts.OrderBy(p => p.DPNr).ToList(), i => ((i as DeliveryPart)?.Year, (i as DeliveryPart)?.DId, (i as DeliveryPart)?.DPNr), DeliveryPartList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
|
||||||
} else {
|
} else {
|
||||||
Utils.RenewItemsSource(ModifiersInput, Context.Modifiers.Where(m => m.Year == Utils.CurrentLastSeason).OrderBy(m => m.Name).ToList(), i => (i as Modifier)?.ModId);
|
ControlUtils.RenewItemsSource(ModifiersInput, Context.Modifiers.Where(m => m.Year == Utils.CurrentLastSeason).OrderBy(m => m.Name).ToList(), i => (i as Modifier)?.ModId);
|
||||||
ClearOriginalValues();
|
DeliveryPartList.ItemsSource = null;
|
||||||
ClearInputs();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshInputs(bool validate = false) {
|
||||||
|
ClearInputStates();
|
||||||
|
if (DeliveryPartList.SelectedItem is DeliveryPart p) {
|
||||||
|
FillInputs(p);
|
||||||
|
} else {
|
||||||
|
ClearOriginalValues();
|
||||||
|
ClearInputs(validate);
|
||||||
}
|
}
|
||||||
IsRefreshingInputs = false;
|
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillInputs(Delivery d) {
|
private void FillInputs(DeliveryPart p) {
|
||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
|
|
||||||
|
var d = p.Delivery;
|
||||||
MgNrInput.Text = d.MgNr.ToString();
|
MgNrInput.Text = d.MgNr.ToString();
|
||||||
|
ControlUtils.SelectComboBoxItem(BranchInput, i => (i as Branch)?.ZwstId, d.ZwstId);
|
||||||
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, (i as DeliveryPart)?.DPNr));
|
|
||||||
if (DeliveryPartList.SelectedItem == null && DeliveryPartList.ItemsSource != null) {
|
|
||||||
DeliveryPartList.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
var p = DeliveryPartList.SelectedItem as DeliveryPart;
|
|
||||||
SortIdInput.Text = p?.SortId ?? "";
|
SortIdInput.Text = p?.SortId ?? "";
|
||||||
Utils.SelectCheckComboBoxItems(AttributesInput, p?.Attributes, i => (i as WineAttr)?.AttrId);
|
ControlUtils.SelectCheckComboBoxItems(AttributesInput, p?.Attributes, i => (i as WineAttr)?.AttrId);
|
||||||
GradationKmwInput.Text = (p != null) ? $"{p.Kmw:N1}" : "";
|
GradationKmwInput.Text = (p != null) ? $"{p.Kmw:N1}" : "";
|
||||||
Utils.SelectComboBoxItem(WineQualityLevelInput, q => (q as WineQualLevel)?.QualId, p?.QualId);
|
ControlUtils.SelectComboBoxItem(WineQualityLevelInput, q => (q as WineQualLevel)?.QualId, p?.QualId);
|
||||||
Utils.SelectComboBoxItem(WineKgInput, k => (k as AT_Kg)?.KgNr, p?.KgNr);
|
ControlUtils.SelectComboBoxItem(WineKgInput, k => (k as AT_Kg)?.KgNr, p?.KgNr);
|
||||||
Utils.SelectComboBoxItem(WineRdInput, r => (r as WbRd)?.RdNr, p?.RdNr);
|
ControlUtils.SelectComboBoxItem(WineRdInput, r => (r as WbRd)?.RdNr, p?.RdNr);
|
||||||
Utils.SelectComboBoxItem(WineOriginInput, r => (r as WineOrigin)?.HkId, p?.HkId);
|
ControlUtils.SelectComboBoxItem(WineOriginInput, r => (r as WineOrigin)?.HkId, p?.HkId);
|
||||||
WeightInput.Text = p?.Weight.ToString() ?? "";
|
WeightInput.Text = p?.Weight.ToString() ?? "";
|
||||||
ManualWeighingInput.IsChecked = p?.ManualWeighing ?? false;
|
ManualWeighingInput.IsChecked = p?.ManualWeighing ?? false;
|
||||||
GerebeltGewogenInput.IsChecked = p?.IsGerebelt ?? false;
|
GerebeltGewogenInput.IsChecked = p?.IsGerebelt ?? false;
|
||||||
Utils.SelectCheckComboBoxItems(ModifiersInput, p?.Modifiers, i => (i as Modifier)?.ModId);
|
ControlUtils.SelectCheckComboBoxItems(ModifiersInput, p?.Modifiers, i => (i as Modifier)?.ModId);
|
||||||
PartCommentInput.Text = p?.Comment ?? "";
|
PartCommentInput.Text = p?.Comment ?? "";
|
||||||
TemperatureInput.Text = p?.Temperature?.ToString() ?? "";
|
TemperatureInput.Text = p?.Temperature?.ToString() ?? "";
|
||||||
AcidInput.Text = p?.Acid?.ToString() ?? "";
|
AcidInput.Text = p?.Acid?.ToString() ?? "";
|
||||||
@@ -223,11 +230,27 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DeliveryList_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
private void DeliveryList_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||||
RefreshInputs();
|
RefreshDeliveryParts();
|
||||||
|
if (DeliveryList.SelectedItem != null) {
|
||||||
|
DeleteDeliveryButton.IsEnabled = true;
|
||||||
|
} else {
|
||||||
|
DeleteDeliveryButton.IsEnabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeliveryPartList_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
private void DeliveryPartList_SelectionChanged(object? sender, SelectionChangedEventArgs? evt) {
|
||||||
if (!IsRefreshingInputs) RefreshInputs();
|
RefreshInputs();
|
||||||
|
if (DeliveryPartList.SelectedItem != null) {
|
||||||
|
AbwertenButton.IsEnabled = true;
|
||||||
|
EditDeliveryButton.IsEnabled = true;
|
||||||
|
ExtractDeliveryPartButton.IsEnabled = true;
|
||||||
|
DeleteDeliveryPartButton.IsEnabled = true;
|
||||||
|
} else {
|
||||||
|
AbwertenButton.IsEnabled = false;
|
||||||
|
EditDeliveryButton.IsEnabled = false;
|
||||||
|
ExtractDeliveryPartButton.IsEnabled = false;
|
||||||
|
DeleteDeliveryPartButton.IsEnabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MgNrInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
private void MgNrInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
@@ -253,6 +276,144 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void NewDeliveryButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AbwertenButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EditDeliveryButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
if (DeliveryPartList.SelectedItem == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
IsEditing = true;
|
||||||
|
DeliveryList.IsEnabled = false;
|
||||||
|
DeliveryPartList.IsEnabled = false;
|
||||||
|
|
||||||
|
HideNewEditDeleteButtons();
|
||||||
|
ShowSaveResetCancelButtons();
|
||||||
|
UnlockInputs();
|
||||||
|
LockSearchInputs();
|
||||||
|
|
||||||
|
AbwertenButton.IsEnabled = false;
|
||||||
|
ExtractDeliveryPartButton.IsEnabled = false;
|
||||||
|
DeleteDeliveryPartButton.IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeleteDeliveryButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
if (IsEditing) {
|
||||||
|
RefreshInputs();
|
||||||
|
} else if (IsCreating) {
|
||||||
|
ClearInputs();
|
||||||
|
//InitInputs(); TODO
|
||||||
|
}
|
||||||
|
UpdateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CancelButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
IsEditing = false;
|
||||||
|
IsCreating = false;
|
||||||
|
DeliveryList.IsEnabled = true;
|
||||||
|
DeliveryPartList.IsEnabled = true;
|
||||||
|
|
||||||
|
HideSaveResetCancelButtons();
|
||||||
|
ShowNewEditDeleteButtons();
|
||||||
|
RefreshInputs();
|
||||||
|
ClearInputStates();
|
||||||
|
LockInputs();
|
||||||
|
UnlockSearchInputs();
|
||||||
|
|
||||||
|
AbwertenButton.IsEnabled = DeliveryPartList.SelectedItem != null;
|
||||||
|
ExtractDeliveryPartButton.IsEnabled = DeliveryPartList.SelectedItem != null;
|
||||||
|
DeleteDeliveryPartButton.IsEnabled = DeliveryPartList.SelectedItem != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExtractDeliveryPartButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeleteDeliveryPartButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ShowSaveResetCancelButtons() {
|
||||||
|
SaveButton.IsEnabled = false;
|
||||||
|
ResetButton.IsEnabled = false;
|
||||||
|
CancelButton.IsEnabled = true;
|
||||||
|
SaveButton.Visibility = Visibility.Visible;
|
||||||
|
ResetButton.Visibility = Visibility.Visible;
|
||||||
|
CancelButton.Visibility = Visibility.Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HideSaveResetCancelButtons() {
|
||||||
|
SaveButton.IsEnabled = false;
|
||||||
|
ResetButton.IsEnabled = false;
|
||||||
|
CancelButton.IsEnabled = false;
|
||||||
|
SaveButton.Visibility = Visibility.Hidden;
|
||||||
|
ResetButton.Visibility = Visibility.Hidden;
|
||||||
|
CancelButton.Visibility = Visibility.Hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowNewEditDeleteButtons() {
|
||||||
|
NewDeliveryButton.IsEnabled = IsReceipt;
|
||||||
|
AbwertenButton.IsEnabled = DeliveryPartList.SelectedItem != null;
|
||||||
|
EditDeliveryButton.IsEnabled = DeliveryPartList.SelectedItem != null;
|
||||||
|
DeleteDeliveryButton.IsEnabled = DeliveryList.SelectedItem != null;
|
||||||
|
NewDeliveryButton.Visibility = IsReceipt ? Visibility.Visible : Visibility.Hidden;
|
||||||
|
AbwertenButton.Visibility = !IsReceipt ? Visibility.Visible : Visibility.Hidden;
|
||||||
|
EditDeliveryButton.Visibility = Visibility.Visible;
|
||||||
|
DeleteDeliveryButton.Visibility = Visibility.Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HideNewEditDeleteButtons() {
|
||||||
|
NewDeliveryButton.IsEnabled = false;
|
||||||
|
AbwertenButton.IsEnabled = false;
|
||||||
|
EditDeliveryButton.IsEnabled = false;
|
||||||
|
DeleteDeliveryButton.IsEnabled = false;
|
||||||
|
NewDeliveryButton.Visibility = Visibility.Hidden;
|
||||||
|
AbwertenButton.Visibility = Visibility.Hidden;
|
||||||
|
EditDeliveryButton.Visibility = Visibility.Hidden;
|
||||||
|
DeleteDeliveryButton.Visibility = Visibility.Hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LockSearchInputs() {
|
||||||
|
SearchInput.IsEnabled = false;
|
||||||
|
TodayOnlyInput.IsEnabled = false;
|
||||||
|
SeasonOnlyInput.IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UnlockSearchInputs() {
|
||||||
|
SearchInput.IsEnabled = true;
|
||||||
|
TodayOnlyInput.IsEnabled = true;
|
||||||
|
SeasonOnlyInput.IsEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
new protected void UnlockInputs() {
|
||||||
|
base.UnlockInputs();
|
||||||
|
if (WineQualityLevelInput.SelectedItem != null && WineKgInput.SelectedItem != null)
|
||||||
|
WineOriginInput.IsEnabled = false;
|
||||||
|
if (WineKgInput.SelectedItem == null)
|
||||||
|
WineRdInput.IsEnabled = false;
|
||||||
|
WeightInput.IsReadOnly = true;
|
||||||
|
AbgewertetInput.IsEnabled = false;
|
||||||
|
ManualWeighingInput.IsEnabled = false;
|
||||||
|
LsNrInput.IsReadOnly = true;
|
||||||
|
DateInput.IsReadOnly = true;
|
||||||
|
TimeInput.IsReadOnly = true;
|
||||||
|
BranchInput.IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task UpdateLsNr() {
|
private async Task UpdateLsNr() {
|
||||||
var branch = (Branch)BranchInput.SelectedItem;
|
var branch = (Branch)BranchInput.SelectedItem;
|
||||||
var date = DateOnly.ParseExact(DateInput.Text, "dd.MM.yyyy");
|
var date = DateOnly.ParseExact(DateInput.Text, "dd.MM.yyyy");
|
||||||
@@ -261,7 +422,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DateInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
private void DateInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
UpdateLsNr().GetAwaiter().GetResult();
|
if (IsCreating) UpdateLsNr().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateWineVariety(bool valid) {
|
private void UpdateWineVariety(bool valid) {
|
||||||
@@ -288,8 +449,8 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void WineVarietyInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
private void WineVarietyInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||||
var s = WineVarietyInput.SelectedItem as WineVar;
|
if (WineVarietyInput.SelectedItem is WineVar s)
|
||||||
if (s != null) SortIdInput.Text = s.SortId;
|
SortIdInput.Text = s.SortId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateWineQualityLevels() {
|
private void UpdateWineQualityLevels() {
|
||||||
@@ -382,7 +543,7 @@ namespace Elwig.Windows {
|
|||||||
if (WineKgInput.SelectedItem is AT_Kg kg) {
|
if (WineKgInput.SelectedItem is AT_Kg kg) {
|
||||||
var list = Context.WbRde.Where(r => r.KgNr == kg.KgNr).OrderBy(r => r.Name).Cast<object>().ToList();
|
var list = Context.WbRde.Where(r => r.KgNr == kg.KgNr).OrderBy(r => r.Name).Cast<object>().ToList();
|
||||||
list.Insert(0, new NullItem());
|
list.Insert(0, new NullItem());
|
||||||
Utils.RenewItemsSource(WineRdInput, list, i => ((i as WbRd)?.KgNr, (i as WbRd)?.RdNr));
|
ControlUtils.RenewItemsSource(WineRdInput, list, i => ((i as WbRd)?.KgNr, (i as WbRd)?.RdNr));
|
||||||
if (WineRdInput.SelectedItem == null) WineRdInput.SelectedIndex = 0;
|
if (WineRdInput.SelectedItem == null) WineRdInput.SelectedIndex = 0;
|
||||||
WineRdInput.IsEnabled = (IsEditing || IsCreating) && list.Count > 1;
|
WineRdInput.IsEnabled = (IsEditing || IsCreating) && list.Count > 1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -89,17 +89,12 @@ namespace Elwig.Windows {
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.RenewItemsSource(MemberList, members, i => (i as Member)?.MgNr, !updateSort);
|
ControlUtils.RenewItemsSource(MemberList, members, i => (i as Member)?.MgNr, MemberList_SelectionChanged, ControlUtils.RenewSourceDefault.IfOnly, !updateSort);
|
||||||
if (members.Count == 1)
|
|
||||||
MemberList.SelectedIndex = 0;
|
|
||||||
|
|
||||||
RefreshInputs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshInputs(bool validate = false) {
|
private void RefreshInputs(bool validate = false) {
|
||||||
ClearInputStates();
|
ClearInputStates();
|
||||||
Member m = (Member)MemberList.SelectedItem;
|
if (MemberList.SelectedItem is Member m) {
|
||||||
if (m != null) {
|
|
||||||
EditMemberButton.IsEnabled = true;
|
EditMemberButton.IsEnabled = true;
|
||||||
DeleteMemberButton.IsEnabled = true;
|
DeleteMemberButton.IsEnabled = true;
|
||||||
AreaCommitmentButton.IsEnabled = true;
|
AreaCommitmentButton.IsEnabled = true;
|
||||||
@@ -111,9 +106,8 @@ namespace Elwig.Windows {
|
|||||||
AreaCommitmentButton.IsEnabled = false;
|
AreaCommitmentButton.IsEnabled = false;
|
||||||
DeliveryButton.IsEnabled = false;
|
DeliveryButton.IsEnabled = false;
|
||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
ClearInputs();
|
ClearInputs(validate);
|
||||||
}
|
}
|
||||||
if (!validate) ClearInputStates();
|
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,8 +124,8 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
protected override async Task RenewContext() {
|
protected override async Task RenewContext() {
|
||||||
await base.RenewContext();
|
await base.RenewContext();
|
||||||
Utils.RenewItemsSource(BranchInput, await Context.Branches.OrderBy(b => b.Name).ToListAsync(), i => (i as Branch)?.ZwstId);
|
ControlUtils.RenewItemsSource(BranchInput, await Context.Branches.OrderBy(b => b.Name).ToListAsync(), i => (i as Branch)?.ZwstId);
|
||||||
Utils.RenewItemsSource(DefaultKgInput, await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync(), i => (i as AT_Kg)?.KgNr);
|
ControlUtils.RenewItemsSource(DefaultKgInput, await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync(), i => (i as AT_Kg)?.KgNr);
|
||||||
await RefreshMemberList();
|
await RefreshMemberList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user