AreaComAdminWindow: Allow users to create new reeds inline
This commit is contained in:
@ -13,10 +13,15 @@ using System.Threading;
|
|||||||
using System.Windows.Markup;
|
using System.Windows.Markup;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Elwig.Helpers.Printing;
|
using Elwig.Helpers.Printing;
|
||||||
|
using Elwig.Windows;
|
||||||
|
using Elwig.Dialogs;
|
||||||
|
|
||||||
namespace Elwig {
|
namespace Elwig {
|
||||||
public partial class App : Application {
|
public partial class App : Application {
|
||||||
|
|
||||||
|
protected static App CurrentApp;
|
||||||
|
public static int NumWindows => CurrentApp.Windows.Count;
|
||||||
|
|
||||||
public static readonly string DataPath = @"C:\ProgramData\Elwig\";
|
public static readonly string DataPath = @"C:\ProgramData\Elwig\";
|
||||||
public static readonly string ExePath = @"C:\Program Files\Elwig\";
|
public static readonly string ExePath = @"C:\Program Files\Elwig\";
|
||||||
public static readonly string TempPath = Path.Combine(Path.GetTempPath(), "Elwig");
|
public static readonly string TempPath = Path.Combine(Path.GetTempPath(), "Elwig");
|
||||||
@ -56,6 +61,7 @@ namespace Elwig {
|
|||||||
Directory.CreateDirectory(DataPath);
|
Directory.CreateDirectory(DataPath);
|
||||||
MainDispatcher = Dispatcher;
|
MainDispatcher = Dispatcher;
|
||||||
Scales = Array.Empty<IScale>();
|
Scales = Array.Empty<IScale>();
|
||||||
|
CurrentApp = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnStartup(StartupEventArgs evt) {
|
protected override void OnStartup(StartupEventArgs evt) {
|
||||||
@ -168,5 +174,49 @@ namespace Elwig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static T FocusWindow<T>(Func<T> constructor, Predicate<T>? selector = null) where T : Window {
|
||||||
|
foreach (Window w in CurrentApp.Windows) {
|
||||||
|
if (w is T t && (selector == null || selector(t))) {
|
||||||
|
if (t.WindowState == WindowState.Minimized)
|
||||||
|
t.WindowState = WindowState.Normal;
|
||||||
|
t.Activate();
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var n = constructor();
|
||||||
|
n.Show();
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DeliveryAdminWindow FocusReceipt() {
|
||||||
|
return FocusWindow<DeliveryAdminWindow>(() => new(true), w => w.IsReceipt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DeliveryAdminWindow FocusMemberDeliveries(int mgnr) {
|
||||||
|
return FocusWindow<DeliveryAdminWindow>(() => new(mgnr), w => w.MgNr == mgnr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AreaComAdminWindow FocusMemberAreaComs(int mgnr) {
|
||||||
|
return FocusWindow<AreaComAdminWindow>(() => new(mgnr), w => w.MgNr == mgnr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BaseDataWindow FocusBaseData() {
|
||||||
|
return FocusWindow<BaseDataWindow>(() => new());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BaseDataWindow FocusBaseDataAreaComType() {
|
||||||
|
var w = FocusBaseData();
|
||||||
|
w.AreaCommitmentTypes.Focus();
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SeasonFinishWindow FocusSeasonFinish() {
|
||||||
|
return FocusWindow<SeasonFinishWindow>(() => new());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DeliveryConfirmationsWindow FocusDeliveryConfirmations(int year) {
|
||||||
|
return FocusWindow<DeliveryConfirmationsWindow>(() => new(year), w => w.Year == year);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,13 @@ namespace Elwig.Helpers {
|
|||||||
return c + 1;
|
return c + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<int> NextRdNr(int kgnr) {
|
||||||
|
int c = 0;
|
||||||
|
(await WbRde.Where(r => r.KgNr == kgnr).Select(r => r.RdNr).ToListAsync())
|
||||||
|
.ForEach(a => { if (a <= c + 100) c = a; });
|
||||||
|
return c + 1;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<WineQualLevel> GetWineQualityLevel(double kmw) {
|
public async Task<WineQualLevel> GetWineQualityLevel(double kmw) {
|
||||||
return await WineQualityLevels
|
return await WineQualityLevels
|
||||||
.Where(q => !q.IsPredicate && (q.MinKmw == null || q.MinKmw <= kmw))
|
.Where(q => !q.IsPredicate && (q.MinKmw == null || q.MinKmw <= kmw))
|
||||||
|
@ -572,5 +572,13 @@ namespace Elwig.Windows {
|
|||||||
protected void UpperCaseInput_LostFocus(object sender, RoutedEventArgs evt) {
|
protected void UpperCaseInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
InputLostFocus((TextBox)sender, Validator.CheckUpperCase);
|
InputLostFocus((TextBox)sender, Validator.CheckUpperCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void KgDetailsButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
// TODO open origin window
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void AreaComTypeDetailsButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
App.FocusBaseDataAreaComType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,10 @@
|
|||||||
|
|
||||||
<Label Content="Vertragsart:" Margin="10,70,0,0" Grid.Column="0" Grid.ColumnSpan="2"/>
|
<Label Content="Vertragsart:" Margin="10,70,0,0" Grid.Column="0" Grid.ColumnSpan="2"/>
|
||||||
<ComboBox x:Name="AreaComTypeInput" DisplayMemberPath="DisplayName" TextSearch.TextPath="DisplayName"
|
<ComboBox x:Name="AreaComTypeInput" DisplayMemberPath="DisplayName" TextSearch.TextPath="DisplayName"
|
||||||
HorizontalAlignment="Stretch" Margin="0,70,10,0" Grid.Column="1" Grid.ColumnSpan="3"/>
|
HorizontalAlignment="Stretch" Margin="0,70,40,10" Grid.Column="1" Grid.ColumnSpan="3"/>
|
||||||
|
<Button x:Name="AreaComTypeDetailsButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="14" Padding="0,1,0,0"
|
||||||
|
Click="AreaComTypeDetailsButton_Click"
|
||||||
|
Grid.Column="3" VerticalAlignment="Top" HorizontalAlignment="Right" Width="25" Height="25" Margin="10,70,10,10"/>
|
||||||
|
|
||||||
<Label Content="Bewirt.-Art:" Margin="10,100,0,0" Grid.Column="0" Grid.ColumnSpan="2"/>
|
<Label Content="Bewirt.-Art:" Margin="10,100,0,0" Grid.Column="0" Grid.ColumnSpan="2"/>
|
||||||
<ComboBox x:Name="WineCultivationInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
<ComboBox x:Name="WineCultivationInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
||||||
@ -165,13 +168,19 @@
|
|||||||
|
|
||||||
<Label Content="KG:" Margin="10,10,0,0" Grid.Column="0"/>
|
<Label Content="KG:" Margin="10,10,0,0" Grid.Column="0"/>
|
||||||
<ComboBox x:Name="KgInput" ItemTemplate="{StaticResource KgNrTemplate}" TextSearch.TextPath="Name"
|
<ComboBox x:Name="KgInput" ItemTemplate="{StaticResource KgNrTemplate}" TextSearch.TextPath="Name"
|
||||||
HorizontalAlignment="Stretch" Margin="0,10,10,0" Grid.Column="1"
|
HorizontalAlignment="Stretch" Margin="0,10,40,10" Grid.Column="1"
|
||||||
SelectionChanged="KgInput_SelectionChanged"/>
|
SelectionChanged="KgInput_SelectionChanged"/>
|
||||||
|
<Button x:Name="KgDetailsButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="14" Padding="0,1,0,0"
|
||||||
|
Click="KgDetailsButton_Click"
|
||||||
|
Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Right" Width="25" Height="25" Margin="10,10,10,10"/>
|
||||||
|
|
||||||
<Label Content="Ried:" Margin="10,40,0,0" Grid.Column="0"/>
|
<Label Content="Ried:" Margin="10,40,0,0" Grid.Column="0"/>
|
||||||
<ComboBox x:Name="RdInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
<ComboBox x:Name="RdInput" DisplayMemberPath="Name" TextSearch.TextPath="Name" IsEditable="True"
|
||||||
HorizontalAlignment="Stretch" Margin="0,40,10,0" Grid.Column="1"/>
|
HorizontalAlignment="Stretch" Margin="0,40,40,10" Grid.Column="1"
|
||||||
|
SelectionChanged="RdInput_SelectionChanged"/>
|
||||||
|
<Button x:Name="RdAddButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="16" Padding="0,0,0,0" IsEnabled="False"
|
||||||
|
Click="RdAddButton_Click"
|
||||||
|
Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Right" Width="25" Height="25" Margin="10,40,10,10"/>
|
||||||
|
|
||||||
<Label Content="Parzelle(n):" Margin="10,70,0,0" Grid.Column="0"/>
|
<Label Content="Parzelle(n):" Margin="10,70,0,0" Grid.Column="0"/>
|
||||||
<TextBox x:Name="GstNrInput" Margin="0,70,10,0" Grid.Column="1" HorizontalAlignment="Stretch"
|
<TextBox x:Name="GstNrInput" Margin="0,70,10,0" Grid.Column="1" HorizontalAlignment="Stretch"
|
||||||
|
@ -12,6 +12,9 @@ using Xceed.Wpf.Toolkit.Primitives;
|
|||||||
|
|
||||||
namespace Elwig.Windows {
|
namespace Elwig.Windows {
|
||||||
public partial class AreaComAdminWindow : AdministrationWindow {
|
public partial class AreaComAdminWindow : AdministrationWindow {
|
||||||
|
|
||||||
|
public int MgNr => Member.MgNr;
|
||||||
|
|
||||||
private readonly Member Member;
|
private readonly Member Member;
|
||||||
private List<string> TextFilter = new();
|
private List<string> TextFilter = new();
|
||||||
|
|
||||||
@ -165,6 +168,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
FbNrInput.Text = (await Context.NextFbNr()).ToString();
|
FbNrInput.Text = (await Context.NextFbNr()).ToString();
|
||||||
MgNrInput.Text = Member.MgNr.ToString();
|
MgNrInput.Text = Member.MgNr.ToString();
|
||||||
|
YearFromInput.Text = DateTime.Now.Year.ToString();
|
||||||
|
|
||||||
SetDefaultValue(FbNrInput);
|
SetDefaultValue(FbNrInput);
|
||||||
ValidateRequiredInputs();
|
ValidateRequiredInputs();
|
||||||
@ -231,11 +235,21 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
EntityEntry<AreaCom>? tr = null;
|
EntityEntry<AreaCom>? tr = null;
|
||||||
try {
|
try {
|
||||||
|
if (RdInput.SelectedItem is WbRd wbRd) {
|
||||||
|
a.RdNr = wbRd.RdNr;
|
||||||
|
var e = Context.Entry(wbRd);
|
||||||
|
if (e.State == EntityState.Detached) {
|
||||||
|
await Context.AddAsync(wbRd);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
a.RdNr = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsEditing) {
|
if (IsEditing) {
|
||||||
tr = Context.Update(a);
|
tr = Context.Update(a);
|
||||||
} else if (IsCreating) {
|
} else if (IsCreating) {
|
||||||
a.FbNr = newFbNr;
|
a.FbNr = newFbNr;
|
||||||
tr = (await Context.AddAsync(a));
|
tr = await Context.AddAsync(a);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
@ -387,6 +401,19 @@ namespace Elwig.Windows {
|
|||||||
ComboBox_SelectionChanged(sender, evt);
|
ComboBox_SelectionChanged(sender, evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RdInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||||
|
RdAddButton.IsEnabled = RdInput.SelectedIndex == -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void RdAddButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
if (KgInput.SelectedItem is not AT_Kg kg) return;
|
||||||
|
string name = RdInput.Text.Trim();
|
||||||
|
if (name.Length == 0) return;
|
||||||
|
var s = RdInput.ItemsSource.Cast<object?>();
|
||||||
|
RdInput.ItemsSource = s.Append(new WbRd() { KgNr = kg.KgNr, Name = name, RdNr = await Context.NextRdNr(kg.KgNr)});
|
||||||
|
RdInput.SelectedIndex = s.Count();
|
||||||
|
}
|
||||||
|
|
||||||
protected void InputTextChanged(TextBox input, Func<TextBox, bool, AppDbContext, AreaCom?, ValidationResult> checker) {
|
protected void InputTextChanged(TextBox input, Func<TextBox, bool, AppDbContext, AreaCom?, ValidationResult> checker) {
|
||||||
InputTextChanged(input, checker(input, SenderIsRequired(input), Context, (AreaCom)AreaCommitmentList.SelectedItem));
|
InputTextChanged(input, checker(input, SenderIsRequired(input), Context, (AreaCom)AreaCommitmentList.SelectedItem));
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
<TabItem Header="Flächenbindungsverträge">
|
<TabItem Header="Flächenbindungsverträge" x:Name="AreaCommitmentTypes">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="260"/>
|
<ColumnDefinition Width="260"/>
|
||||||
|
@ -19,8 +19,10 @@ using Xceed.Wpf.Toolkit.Primitives;
|
|||||||
namespace Elwig.Windows {
|
namespace Elwig.Windows {
|
||||||
public partial class DeliveryAdminWindow : AdministrationWindow {
|
public partial class DeliveryAdminWindow : AdministrationWindow {
|
||||||
|
|
||||||
|
public readonly bool IsReceipt = false;
|
||||||
|
public int? MgNr => Member?.MgNr;
|
||||||
|
|
||||||
private bool IsUpdatingGradation = false;
|
private bool IsUpdatingGradation = false;
|
||||||
private readonly bool IsReceipt = false;
|
|
||||||
private 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();
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Elwig.Windows"
|
xmlns:local="clr-namespace:Elwig.Windows"
|
||||||
Title="Elwig" MinHeight="400" MinWidth="325" Height="450" Width="800" ResizeMode="CanResize"
|
Title="Elwig" MinHeight="400" MinWidth="325" Height="450" Width="800" ResizeMode="CanResize"
|
||||||
Loaded="Window_Loaded">
|
Loaded="Window_Loaded" Closing="Window_Closing">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<Style TargetType="Button">
|
<Style TargetType="Button">
|
||||||
<Setter Property="VerticalAlignment" Value="Top"/>
|
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
@ -16,6 +17,11 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs evt) { }
|
private void Window_Loaded(object sender, RoutedEventArgs evt) { }
|
||||||
|
|
||||||
|
private void Window_Closing(object sender, CancelEventArgs evt) {
|
||||||
|
if (App.NumWindows > 1)
|
||||||
|
evt.Cancel = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void MemberAdminButton_Click(object sender, RoutedEventArgs evt) {
|
private void MemberAdminButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
var w = new MemberAdminWindow();
|
var w = new MemberAdminWindow();
|
||||||
w.Show();
|
w.Show();
|
||||||
@ -27,8 +33,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ReceiptButton_Click(object sender, RoutedEventArgs evt) {
|
private void ReceiptButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
var w = new DeliveryAdminWindow(true);
|
App.FocusReceipt();
|
||||||
w.Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeliveryAdminButton_Click(object sender, RoutedEventArgs evt) {
|
private void DeliveryAdminButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
@ -51,13 +56,11 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void BaseDataButton_Click(object sender, RoutedEventArgs evt) {
|
private void BaseDataButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
var w = new BaseDataWindow();
|
App.FocusBaseData();
|
||||||
w.Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SeasonFinishButton_Click(object sender, RoutedEventArgs e) {
|
private void SeasonFinishButton_Click(object sender, RoutedEventArgs e) {
|
||||||
var w = new SeasonFinishWindow();
|
App.FocusSeasonFinish();
|
||||||
w.Show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,7 +381,10 @@
|
|||||||
|
|
||||||
<Label Content="Stammgemeinde:" Margin="10,160,0,0" Grid.Column="0"/>
|
<Label Content="Stammgemeinde:" Margin="10,160,0,0" Grid.Column="0"/>
|
||||||
<ComboBox x:Name="DefaultKgInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
<ComboBox x:Name="DefaultKgInput" DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
||||||
Margin="0,160,10,0" Grid.Column="1" Grid.ColumnSpan="2"/>
|
Margin="0,160,40,10" Grid.Column="1" Grid.ColumnSpan="2"/>
|
||||||
|
<Button x:Name="KgDetailsButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="14" Padding="0,1,0,0"
|
||||||
|
Click="KgDetailsButton_Click"
|
||||||
|
Grid.Column="2" VerticalAlignment="Top" HorizontalAlignment="Right" Width="25" Height="25" Margin="10,160,10,10"/>
|
||||||
|
|
||||||
<Label Content="Anmerkung:" Margin="10,190,0,0" Grid.Column="0"/>
|
<Label Content="Anmerkung:" Margin="10,190,0,0" Grid.Column="0"/>
|
||||||
<TextBox x:Name="CommentInput" Margin="0,190,10,0" Grid.Column="1" Grid.ColumnSpan="2"
|
<TextBox x:Name="CommentInput" Margin="0,190,10,0" Grid.Column="1" Grid.ColumnSpan="2"
|
||||||
|
@ -257,13 +257,11 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void AreaCommitmentButton_Click(object sender, RoutedEventArgs evt) {
|
private void AreaCommitmentButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
var w = new AreaComAdminWindow(((Member)MemberList.SelectedItem).MgNr);
|
App.FocusMemberAreaComs(((Member)MemberList.SelectedItem).MgNr);
|
||||||
w.Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeliveryButton_Click(object sender, RoutedEventArgs evt) {
|
private void DeliveryButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
var w = new DeliveryAdminWindow(((Member)MemberList.SelectedItem).MgNr);
|
App.FocusMemberDeliveries(((Member)MemberList.SelectedItem).MgNr);
|
||||||
w.Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void SearchInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private async void SearchInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
|
@ -51,8 +51,7 @@ namespace Elwig.Windows {
|
|||||||
private void DeliveryConfirmationButton_Click(object sender, RoutedEventArgs evt) {
|
private void DeliveryConfirmationButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
if (SeasonInput.Value is not int year)
|
if (SeasonInput.Value is not int year)
|
||||||
return;
|
return;
|
||||||
var w = new DeliveryConfirmationsWindow(year);
|
App.FocusDeliveryConfirmations(year);
|
||||||
w.Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OverUnderDeliveryButton_Click(object sender, RoutedEventArgs evt) {
|
private async void OverUnderDeliveryButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
Reference in New Issue
Block a user