Compare commits

...

17 Commits

Author SHA1 Message Date
39279a5dda Bump version to 0.3.2 2023-09-19 16:29:34 +02:00
5271f357f5 DeliveryAdminWindow: Add DeliveryJournal 2023-09-19 02:11:30 +02:00
13ba3f90f6 DeliveryAdminWindow: Add Filter to BKI export 2023-09-19 00:57:59 +02:00
43be8bf391 DeliveryAdminWindow: Empty scale only after saving to database 2023-09-19 00:47:10 +02:00
826a76c56c AppDbUpdater: Add schema_version 2 2023-09-19 00:37:46 +02:00
efaae5f490 DeliveryAdminWindow: 'Activate()' window after awaiting doc.Print(2) 2023-09-18 21:48:03 +02:00
3a73265a75 ContextWindow: Change renew context event handling 2023-09-18 21:46:14 +02:00
a6fef7fd9b Utils: Fix GetSearchScore for multiple occurances of keyword in haystack 2023-09-18 21:17:37 +02:00
a08df4c3ed DeliveryAdminWindow: Add auto focus for weighing buttons on enter 2023-09-18 20:59:59 +02:00
9701af9e36 AppDbUpdater: Fix version comparison 2023-09-18 10:03:48 +02:00
b4f1eeee84 Bump version to 0.3.1 2023-09-18 02:05:16 +02:00
2922fe0138 BaseDataWindow: Remove DecimalInput check 2023-09-18 01:40:59 +02:00
704facbc6b App: Use Ort insteas of Destination for Branch Location 2023-09-18 01:32:54 +02:00
404e8a0c27 BaseDataWindow: Fix Modifier creation 2023-09-18 01:30:45 +02:00
ef621fab2d Validator: Fix usage of maxLen and maxDecimal in CheckDecimal 2023-09-18 01:27:15 +02:00
0938e33fe1 DeliveryAdminWindow: Fix LNr calculation for new deliveries 2023-09-18 01:04:09 +02:00
6b5c283e10 Update dependencies 2023-09-17 22:12:15 +02:00
18 changed files with 279 additions and 77 deletions

View File

@ -82,7 +82,7 @@ namespace Elwig {
Dictionary<string, (string, string, int?, string?, string?, string?, string?, string?)> branches = new();
using (var ctx = new AppDbContext()) {
branches = ctx.Branches.ToDictionary(b => b.Name.ToLower(), b => (b.ZwstId, b.Name, b.PostalDest?.AtPlz?.Plz, b.PostalDest?.AtPlz?.Dest, b.Address, b.PhoneNr, b.FaxNr, b.MobileNr));
branches = ctx.Branches.ToDictionary(b => b.Name.ToLower(), b => (b.ZwstId, b.Name, b.PostalDest?.AtPlz?.Plz, b.PostalDest?.AtPlz?.Ort.Name, b.Address, b.PhoneNr, b.FaxNr, b.MobileNr));
try {
Client = new(ctx);
} catch (Exception e) {

View File

@ -0,0 +1,67 @@
@using RazorLight
@inherits TemplatePage<Elwig.Documents.DeliveryJournal>
@model Elwig.Documents.DeliveryJournal
@{ Layout = "Document"; }
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\style-deliveryjournal.css"/>
<main>
<h1>Lieferjournal</h1>
<h2>@Model.Filter</h2>
<table class="journal">
<colgroup>
<col style="width: 25mm;"/>
<col style="width: 5mm;"/>
<col style="width: 17mm;"/>
<col style="width: 10mm;"/>
<col style="width: 8mm;"/>
<col style="width: 38mm;"/>
<col style="width: 28mm;"/>
<col style="width: 10mm;"/>
<col style="width: 10mm;"/>
<col style="width: 14mm;"/>
</colgroup>
<thead>
<tr>
<th rowspan="2" style="text-align: left;">Lieferschein-Nr.</th>
<th rowspan="2">Pos.</th>
<th rowspan="2">Datum</th>
<th rowspan="2">Zeit</th>
<th colspan="2" rowspan="2" style="text-align: left;">Mitglied</th>
<th rowspan="2" style="text-align: left;">Sorte</th>
<th colspan="2">Gradation</th>
<th>Gewicht</th>
</tr>
<tr>
<th>[°Oe]</th>
<th>[°KMW]</th>
<th>[kg]</th>
</tr>
</thead>
<tbody>
@foreach (var p in Model.Deliveries) {
<tr>
<td>@p.Delivery.LsNr</td>
<td>@p.DPNr</td>
<td>@($"{p.Delivery.Date:dd.MM.yyyy}")</td>
<td>@($"{p.Delivery.Time:HH:mm}")</td>
<td class="mgnr">@p.Delivery.Member.MgNr</td>
<td>@p.Delivery.Member.AdministrativeName</td>
<td>@p.Variant.Name</td>
<td class="grad">@($"{p.Oe:N0}")</td>
<td class="grad">@($"{p.Kmw:N1}")</td>
<td class="weight">@($"{p.Weight:N0}")</td>
</tr>
}
<tr class="sum">
@{
var kmw = Elwig.Helpers.Utils.AggregateDeliveryPartsKmw(Model.Deliveries);
var oe = Elwig.Helpers.Utils.KmwToOe(kmw);
}
<td colspan="2">Gesamt:</td>
<td colspan="5">(Teil-)Lieferungen: @($"{Model.Deliveries.DistinctBy(p => p.Delivery).Count():N0}") (@($"{Model.Deliveries.Count():N0}"))</td>
<td class="grad">@($"{oe:N0}")</td>
<td class="grad">@($"{kmw:N1}")</td>
<td class="weight">@($"{Model.Deliveries.Sum(p => p.Weight):N0}")</td>
</tr>
</tbody>
</table>
</main>

View File

@ -0,0 +1,25 @@
using Elwig.Helpers;
using Elwig.Models;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Elwig.Documents {
public class DeliveryJournal : Document {
public string Filter;
public IEnumerable<DeliveryPart> Deliveries;
public DeliveryJournal(string filter, IEnumerable<DeliveryPart> deliveries) : base($"Lieferjournal {filter}") {
Filter = filter;
Deliveries = deliveries;
}
public DeliveryJournal(AppDbContext ctx, DateOnly date) :
this(date.ToString("dd.MM.yyyy"), ctx.DeliveryParts
.Where(p => p.Delivery.DateString == date.ToString("yyy-MM-dd"))
.OrderBy(p => p.Delivery.LsNr)
.ThenBy(p => p.DPNr)
.ToList()) { }
}
}

View File

@ -53,6 +53,8 @@ namespace Elwig.Documents {
name = "DeliveryNote";
} else if (this is CreditNote) {
name = "CreditNote";
} else if (this is DeliveryJournal) {
name = "DeliveryJournal";
} else {
throw new InvalidOperationException("Invalid document object");
}

View File

@ -19,6 +19,7 @@ namespace Elwig.Documents {
await e.CompileTemplateAsync("BusinessLetter");
await e.CompileTemplateAsync("DeliveryNote");
await e.CompileTemplateAsync("CreditNote");
await e.CompileTemplateAsync("DeliveryJournal");
Engine = e;
evtHandler();

View File

@ -0,0 +1,47 @@
h1 {
text-align: center;
font-size: 24pt;
margin-bottom: 2mm;
}
h2 {
text-align: center;
font-size: 14pt;
margin-top: 2mm;
}
table.journal {
font-size: 10pt;
}
table.journal thead {
font-size: 8pt;
}
table.journal th {
font-weight: normal;
font-style: italic;
}
table.journal td {
overflow: hidden;
white-space: nowrap;
}
table.journal .mgnr,
table.journal .weight {
text-align: right;
}
table.journal .grad {
text-align: center;
}
table.journal tr.sum {
font-weight: bold;
}
table.journal tr.sum td {
border-top: 0.5pt solid black;
}

View File

@ -7,7 +7,7 @@
<UseWPF>true</UseWPF>
<PreserveCompilationContext>true</PreserveCompilationContext>
<ApplicationIcon>elwig.ico</ApplicationIcon>
<Version>0.3.0</Version>
<Version>0.3.2</Version>
<SatelliteResourceLanguages>de-AT</SatelliteResourceLanguages>
</PropertyGroup>
@ -19,9 +19,9 @@
<PackageReference Include="Balbarak.WeasyPrint" Version="2.0.2" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.1" />
<PackageReference Include="ini-parser" Version="2.5.2" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="6.0.21" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="6.0.22" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.11" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1938.49" />
<PackageReference Include="RazorLight" Version="2.3.1" />
<PackageReference Include="ScottPlot.WPF" Version="4.1.67" />

View File

@ -4,7 +4,7 @@ using System;
namespace Elwig.Helpers {
public static class AppDbUpdater {
public static readonly int RequiredSchemaVersion = 1;
public static readonly int RequiredSchemaVersion = 2;
private static int _versionOffset = 0;
private static readonly Action<SqliteConnection>[] _updaters = new[] {
@ -42,7 +42,10 @@ namespace Elwig.Helpers {
var minor = (userVers >> 16) & 0xFF;
var patch = userVers & 0xFFFF;
if (App.VersionMajor > major || App.VersionMinor > minor || App.VersionPatch > patch) {
if (App.VersionMajor > major ||
(App.VersionMajor == major && App.VersionMinor > minor) ||
(App.VersionMajor == major && App.VersionMinor == minor && App.VersionPatch > patch))
{
long vers = (App.VersionMajor << 24) | (App.VersionMinor << 16) | App.VersionPatch;
ExecuteNonQuery(cnx, $"PRAGMA user_version = {vers}");
}
@ -71,7 +74,11 @@ namespace Elwig.Helpers {
ExecuteNonQuery(cnx, $"PRAGMA schema_version = {toVersion * 100 + _versionOffset}");
}
private static void UpdateDbSchema_1_To_2(SqliteConnection cnx) { }
private static void UpdateDbSchema_1_To_2(SqliteConnection cnx) {
ExecuteNonQuery(cnx, "DROP VIEW v_area_commitment");
ExecuteNonQuery(cnx, "ALTER TABLE delivery_part DROP COLUMN weighing_reason");
ExecuteNonQuery(cnx, "ALTER TABLE delivery_part ADD COLUMN weighing_reason TEXT CHECK(NOT (manual_weighing = FALSE AND weighing_reason IS NOT NULL))");
}
private static void UpdateDbSchema_2_To_3(SqliteConnection cnx) { }
}

View File

@ -193,28 +193,27 @@ namespace Elwig.Helpers {
if (!searchKeywords.Any())
return 0;
return words
.Select(w => {
w = w?.ToLower();
var p = w?.ToLower()?.Split(" ");
if (w == null || p == null)
return 0;
var t1 = searchKeywords.Where(f => w == f).Select(f => f.Length).OrderDescending().FirstOrDefault(0);
var t2 = searchKeywords.Where(f => p.Any(a => a == f)).Select(f => f.Length).OrderDescending().FirstOrDefault(0);
var t3 = searchKeywords.Where(f => p.Any(a => a.StartsWith(f))).Select(f => f.Length).OrderDescending().FirstOrDefault(0);
var t4 = searchKeywords.Where(f => w.Contains(f)).Select(f => f.Length).OrderDescending().FirstOrDefault(0);
if (t1 > 0) {
return 4 + t1;
} else if (t2 > 0) {
return 3 + t2;
} else if (t3 > 0) {
return 2 + t3;
} else if (t4 > 0) {
return 1 + t4;
} else {
return 0;
}
return searchKeywords
.Select(k => {
k = k.ToLower();
var scores = words.Select(w => {
w = w?.ToLower();
var p = w?.ToLower()?.Split(" ");
if (w == null || p == null) {
return 0;
} else if (k == w) {
return 4 + k.Length;
} else if (p.Any(a => a == k)) {
return 3 + k.Length;
} else if (p.Any(a => a.StartsWith(k))) {
return 2 + k.Length;
} else if (w.Contains(k)) {
return 1 + k.Length;
} else {
return 0;
}
});
return scores.Max() + scores.Count(s => s > 0);
})
.Sum();
}

View File

@ -70,9 +70,9 @@ namespace Elwig.Helpers {
for (int i = 0; i < input.Text.Length; i++) {
char ch = input.Text[i];
if (char.IsAsciiDigit(ch)) {
if (v2 == -1 && v1 < maxLen) {
if (v2 == -1 && (maxLen == -1 || v1 < maxLen)) {
text += ch; v1++;
} else if (v2 != -1 && v2 < maxDecimal) {
} else if (v2 != -1 && (maxDecimal == -1 || v2 < maxDecimal)) {
text += ch; v2++;
}
} else if (v2 == 0-1 && ch == ',' || ch == '.') {

View File

@ -16,20 +16,20 @@ namespace Elwig.Windows {
protected Control[] ExemptInputs { private get; set; }
protected Control[] RequiredInputs { private get; set; }
private bool _IsEditing;
private bool _IsCreating;
private bool _isEditing;
private bool _isCreating;
protected bool IsEditing {
get { return _IsEditing; }
get { return _isEditing; }
set {
_IsEditing = value;
LockContext = IsEditing;
_isEditing = value;
LockContext = IsEditing || IsCreating;
}
}
protected bool IsCreating {
get { return _IsCreating; }
get { return _isCreating; }
set {
_IsCreating = value;
LockContext = IsEditing;
_isCreating = value;
LockContext = IsEditing || IsCreating;
}
}
protected bool DoShowWarningWindows = true;
@ -99,7 +99,7 @@ namespace Elwig.Windows {
abstract protected void UpdateButtons();
protected override async Task RenewContext() {
protected override async Task OnRenewContext() {
for (int i = 0; i < PlzInputs.Length; i++)
UpdatePlz(PlzInputs[i], PlzOrtInputs[i]);
}
@ -462,6 +462,10 @@ namespace Elwig.Windows {
InputTextChanged((TextBox)sender, Validator.CheckInteger);
}
protected void DecimalInput_TextChanged(object sender, RoutedEventArgs evt) {
InputTextChanged((TextBox)sender, Validator.CheckDecimal);
}
protected void PartialDateInput_TextChanged(object sender, RoutedEventArgs evt) {
InputTextChanged((TextBox)sender, Validator.CheckPartialDate);
}

View File

@ -95,8 +95,8 @@ namespace Elwig.Windows {
ValidateRequiredInputs();
}
protected override async Task RenewContext() {
await base.RenewContext();
protected override async Task OnRenewContext() {
await base.OnRenewContext();
ControlUtils.RenewItemsSource(KgInput, await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync(), i => (i as AT_Kg)?.KgNr);
ControlUtils.RenewItemsSource(AreaComTypeInput, await Context.AreaCommitmentTypes.OrderBy(v => v.VtrgId).ToListAsync(), i => (i as AreaComType)?.VtrgId);
ControlUtils.RenewItemsSource(WineCultivationInput, await Context.WineCultivations.OrderBy(c => c.Name).ToListAsync(), i => (i as WineCult)?.CultId);

View File

@ -52,8 +52,8 @@ namespace Elwig.Windows {
FillInputs(App.Client);
}
protected override async Task RenewContext() {
await base.RenewContext();
protected override async Task OnRenewContext() {
await base.OnRenewContext();
ControlUtils.RenewItemsSource(SeasonList, await Context.Seasons.OrderByDescending(s => s.Year).ToListAsync(), s => (s as Season)?.Year, null, ControlUtils.RenewSourceDefault.First);
var year = (SeasonList.SelectedItem as Season)?.Year;
ControlUtils.RenewItemsSource(SeasonModifierList, await Context.Modifiers.Where(m => m.Year == year).OrderBy(m => m.Ordering).ToListAsync(), m => (m as Modifier)?.ModId);
@ -117,6 +117,7 @@ namespace Elwig.Windows {
await Context.SaveChangesAsync();
foreach (var mod in ModifierList.Where(m => !ModifierIds.ContainsKey(m))) {
if (mod.ModId == null) continue;
await Context.AddAsync(mod);
}
await Context.SaveChangesAsync();
@ -321,6 +322,7 @@ namespace Elwig.Windows {
}
private void SeasonModifierRelInput_TextChanged(object sender, TextChangedEventArgs evt) {
// DecimalInput_TextChanged(sender, evt); FIXME '-' is ignored
if ((!IsEditing && !IsCreating) || SeasonModifierList.SelectedItem is not Modifier mod) return;
ModifiersChanged = ModifiersChanged || (SeasonModifierRelInput.Text ?? "") != ((SeasonModifierList.SelectedItem as Modifier)?.Rel?.ToString() ?? "");
if (ModifierUpdate) return;
@ -331,11 +333,13 @@ namespace Elwig.Windows {
}
private void SeasonModifierAbsInput_TextChanged(object sender, TextChangedEventArgs evt) {
if ((!IsEditing && !IsCreating) || SeasonModifierList.SelectedItem is not Modifier mod) return;
// DecimalInput_TextChanged(sender, evt); FIXME '-' is ignored
if ((!IsEditing && !IsCreating) || SeasonModifierList.SelectedItem is not Modifier mod || SeasonList.SelectedItem is not Season s) return;
ModifiersChanged = ModifiersChanged || (SeasonModifierAbsInput.Text ?? "") != ((SeasonModifierList.SelectedItem as Modifier)?.Abs?.ToString() ?? "");
if (ModifierUpdate) return;
mod.Abs = decimal.TryParse(SeasonModifierAbsInput.Text, out var v) ? v : null;
if (mod.Abs != null) SeasonModifierRelInput.Text = "";
// FIXME ValueStr does not work in ModifierList when modifier is newly created
mod.AbsValue = decimal.TryParse(SeasonModifierAbsInput.Text, out var v) ? Utils.DecToDb(v, s.Precision) : null;
if (mod.AbsValue != null) SeasonModifierRelInput.Text = "";
CollectionViewSource.GetDefaultView(ModifierList).Refresh();
UpdateButtons();
}

View File

@ -214,8 +214,8 @@ namespace Elwig.Windows {
FinishInputFilling();
}
protected override async Task RenewContext() {
await base.RenewContext();
protected override async Task OnRenewContext() {
await base.OnRenewContext();
await RefreshGraphList();
}

View File

@ -7,30 +7,32 @@ using System.Windows.Threading;
namespace Elwig.Windows {
public abstract class ContextWindow : Window {
public static readonly int RenewSec = 10;
protected AppDbContext Context { get; private set; }
protected bool LockContext { get; set; } = false;
private readonly DispatcherTimer ContextRenewTimer;
private static readonly int ContextRenewSec = 10;
private readonly DispatcherTimer _timer;
private bool _renewPending = false;
public ContextWindow() : base() {
ContextRenewTimer = new DispatcherTimer();
ContextRenewTimer.Tick += new EventHandler(OnRenewContext);
ContextRenewTimer.Interval = new TimeSpan(0, 0, ContextRenewSec);
ContextRenewTimer.Start();
_timer = new DispatcherTimer();
_timer.Tick += new EventHandler(OnShouldRenewContext);
_timer.Interval = new TimeSpan(0, 0, RenewSec);
_timer.Start();
Context = new();
Loaded += OnLoaded;
}
private void OnRenewContext(object? sender, EventArgs evt) {
if (LockContext || !Context.HasBackendChanged) return;
Context.Dispose();
Context = new();
RenewContext().GetAwaiter().GetResult();
private async void OnShouldRenewContext(object? sender, EventArgs evt) {
if (!Context.HasBackendChanged) return;
_renewPending = true;
if (LockContext) return;
await RenewContext();
}
private void OnLoaded(object sender, RoutedEventArgs evt) {
RenewContext().GetAwaiter().GetResult();
OnRenewContext().GetAwaiter().GetResult();
}
protected override void OnClosed(EventArgs evt) {
@ -38,6 +40,14 @@ namespace Elwig.Windows {
Context.Dispose();
}
abstract protected Task RenewContext();
protected async Task RenewContext() {
if (!_renewPending) return;
Context.Dispose();
Context = new();
await OnRenewContext();
_renewPending = false;
}
abstract protected Task OnRenewContext();
}
}

View File

@ -63,6 +63,10 @@
Click="Menu_Print_ShowDeliveryNote_Click"/>
<MenuItem x:Name="Menu_Print_PrintDeliveryNote" Header="Lieferschein drucken" IsEnabled="False"
Click="Menu_Print_PrintDeliveryNote_Click"/>
<MenuItem x:Name="Menu_Print_ShowDeliveryJournalToday" Header="Lieferjournal anzeigen (heute)"
Click="Menu_Print_ShowDeliveryJournalToday_Click"/>
<MenuItem x:Name="Menu_Print_ShowDeliveryJournalYesterday" Header="Lieferjournal anzeigen (gestern)"
Click="Menu_Print_ShowDeliveryJournalYesterday_Click"/>
</MenuItem>
<MenuItem Header="Exportieren">
<MenuItem x:Name="Menu_Export_Bki" Header="Traubentransportscheinliste (BKI)"/>
@ -209,7 +213,7 @@
<Label Content="Sorte:" Margin="10,10,0,0" Grid.Column="0"/>
<TextBox x:Name="SortIdInput" Width="36" Grid.Row="1" Grid.Column="1" Margin="0,10,0,0" HorizontalAlignment="Left"
TextChanged="SortIdInput_TextChanged" LostFocus="SortIdInput_LostFocus" KeyUp="Input_KeyUp"/>
TextChanged="SortIdInput_TextChanged" LostFocus="SortIdInput_LostFocus" KeyUp="Input_KeyUp"/>
<ComboBox x:Name="WineVarietyInput" Grid.Row="1" Grid.Column="1" Margin="41,10,10,10"
ItemTemplate="{StaticResource WineVarietyTemplate}" TextSearch.TextPath="Name"
SelectionChanged="WineVarietyInput_SelectionChanged" KeyUp="Input_KeyUp"/>
@ -230,20 +234,20 @@
<Label Content="Gradation:" Margin="10,10,10,10"/>
<Grid Grid.Column="1" Width="54" Height="25" Margin="0,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top">
<TextBox x:Name="GradationOeInput" TextAlignment="Right" Padding="2,2,23,2"
TextChanged="GradationOeInput_TextChanged" LostFocus="GradationOeInput_LostFocus"/>
TextChanged="GradationOeInput_TextChanged" LostFocus="GradationOeInput_LostFocus" KeyUp="Input_KeyUp"/>
<Label Content="°Oe" Margin="0,4,3,0" HorizontalAlignment="Right" FontSize="10"/>
</Grid>
<Label Content="=" Margin="60,10,10,10" Grid.Column="1"/>
<Grid Grid.Column="1" Width="68" Height="25" Margin="78,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top">
<TextBox x:Name="GradationKmwInput" TextAlignment="Right" Padding="2,2,34,2" SnapsToDevicePixels="True"
TextChanged="GradationKmwInput_TextChanged" LostFocus="GradationKmwInput_LostFocus"/>
TextChanged="GradationKmwInput_TextChanged" LostFocus="GradationKmwInput_LostFocus" KeyUp="Input_KeyUp"/>
<Label Content="°KMW" Margin="0,4,3,0" HorizontalAlignment="Right" FontSize="10"/>
</Grid>
<Label Content="Qualitätsstufe:" Margin="10,40,10,10"/>
<ComboBox x:Name="WineQualityLevelInput" Width="146" Margin="0,40,10,10" Grid.Column="1" HorizontalAlignment="Left"
ItemTemplate="{StaticResource WineQualityLevelTemplate}"
SelectionChanged="WineQualityLevelInput_SelectionChanged"/>
SelectionChanged="WineQualityLevelInput_SelectionChanged" KeyUp="Input_KeyUp"/>
<CheckBox x:Name="AbgewertetInput" Content="Abgewertet" IsEnabled="False"
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,75,10,10" Grid.Column="0" Grid.ColumnSpan="2"/>

View File

@ -128,8 +128,9 @@ namespace Elwig.Windows {
if (sender is not MenuItem m) return;
var year = int.Parse(m.Header.ToString()?.Split(" ")[^1] ?? Utils.CurrentLastSeason.ToString());
var d = new SaveFileDialog() {
FileName = $"{App.Client.NameToken}-Traubentransportscheinliste-{year}",
FileName = $"{App.Client.NameToken}-Traubentransportscheinliste-{year}.{Bki.FileExtension}",
DefaultExt = Bki.FileExtension,
Filter = "CSV-Datei (*.csv)|*.csv",
Title = $"Traubentransportscheinliste (BKI) speichern unter - Elwig"
};
if (d.ShowDialog() == true) {
@ -140,6 +141,22 @@ namespace Elwig.Windows {
}
}
private async void Menu_Print_ShowDeliveryJournalToday_Click(object sender, RoutedEventArgs evt) {
Mouse.OverrideCursor = Cursors.Wait;
var doc = new DeliveryJournal(Context, DateOnly.FromDateTime(Utils.Today));
await doc.Generate();
Mouse.OverrideCursor = null;
doc.Show();
}
private async void Menu_Print_ShowDeliveryJournalYesterday_Click(object sender, RoutedEventArgs evt) {
Mouse.OverrideCursor = Cursors.Wait;
var doc = new DeliveryJournal(Context, DateOnly.FromDateTime(Utils.Today.AddDays(-1)));
await doc.Generate();
Mouse.OverrideCursor = null;
doc.Show();
}
private void OnSecondPassed(object? sender, EventArgs? evt) {
if (IsReceipt && IsCreating) {
var now = DateTime.Now;
@ -195,9 +212,14 @@ namespace Elwig.Windows {
if (sender is not Control ctrl) return;
if (evt.Key != Key.Enter) return;
if (ctrl == MgNrInput || ctrl == MemberInput) {
SortIdInput.Focus(); SortIdInput.SelectAll();
SortIdInput.Focus();
SortIdInput.SelectAll();
} else if (ctrl == SortIdInput || ctrl == WineVarietyInput || ctrl == AttributesInput) {
GradationOeInput.Focus(); GradationOeInput.SelectAll();
GradationOeInput.Focus();
GradationOeInput.SelectAll();
} else if (ctrl == GradationKmwInput || ctrl == GradationOeInput || ctrl == WineQualityLevelInput) {
if (WeighingAButton.IsVisible) WeighingAButton.Focus();
else WeighingManualButton.Focus();
}
}
@ -410,8 +432,8 @@ namespace Elwig.Windows {
}
}
protected override async Task RenewContext() {
await base.RenewContext();
protected override async Task OnRenewContext() {
await base.OnRenewContext();
if (Member != null) {
if (Context.Members.Find(Member.MgNr) is not Member m) {
@ -560,7 +582,7 @@ namespace Elwig.Windows {
p.DPNr = dpnr;
d.DateString = string.Join("-", DateInput.Text.Split(".").Reverse());
if (IsCreating || InputHasChanged(DateInput)) {
if (deliveryNew || InputHasChanged(DateInput)) {
d.LNr = await Context.NextLNr(d.Date);
}
if (IsCreating) {
@ -651,7 +673,6 @@ namespace Elwig.Windows {
WeightInput.Text = $"{res.Weight:N0}";
ScaleId = s.ScaleId;
WeighingId = res.FullWeighingId;
s.Empty();
} else {
WeightInput.Text = "";
ScaleId = null;
@ -757,12 +778,19 @@ namespace Elwig.Windows {
}
}
private void EmptyScale() {
var scale = App.Scales.Where(s => s.ScaleId == ScaleId).FirstOrDefault();
if (scale == null) return;
scale.Empty();
}
private async void NewDeliveryPartButton_Click(object sender, RoutedEventArgs evt) {
FinishButton.IsEnabled = false;
NewDeliveryPartButton.IsEnabled = false;
NewDeliveryPartButton.Cursor = Cursors.Wait;
DeliveryPartList.IsEnabled = false;
var p = await UpdateDeliveryPart(DeliveryList.SelectedItem as Delivery, DeliveryPartList.SelectedItem as DeliveryPart);
EmptyScale();
await RefreshDeliveryList();
await RefreshDeliveryParts();
NewDeliveryPartButton.Cursor = null;
@ -778,7 +806,8 @@ namespace Elwig.Windows {
FinishButton.Cursor = Cursors.Wait;
DeliveryPartList.IsEnabled = false;
var p = await UpdateDeliveryPart(DeliveryList.SelectedItem as Delivery, DeliveryPartList.SelectedItem as DeliveryPart);
await RefreshDeliveryList();
EmptyScale();
await RefreshDeliveryList();
await RefreshDeliveryParts();
if (p?.Delivery != null) {
Mouse.OverrideCursor = Cursors.Wait;
@ -789,10 +818,12 @@ namespace Elwig.Windows {
doc.Show();
} else {
await doc.Print(2);
Activate();
}
}
FinishButton.Cursor = null;
DeliveryList.SelectedItem = null;
await RenewContext();
RefreshInputs();
InitInputs();
}
@ -815,6 +846,7 @@ namespace Elwig.Windows {
DisableWeighingButtons();
HideFinishNewPartDeliveryCancelButtons();
ShowNewEditDeleteButtons();
await RenewContext();
RefreshInputs();
ClearInputStates();
LockInputs();

View File

@ -131,8 +131,8 @@ namespace Elwig.Windows {
ValidateRequiredInputs();
}
protected override async Task RenewContext() {
await base.RenewContext();
protected override async Task OnRenewContext() {
await base.OnRenewContext();
ControlUtils.RenewItemsSource(BranchInput, await Context.Branches.OrderBy(b => b.Name).ToListAsync(), i => (i as Branch)?.ZwstId);
ControlUtils.RenewItemsSource(DefaultKgInput, await Context.WbKgs.Select(k => k.AtKg).OrderBy(k => k.Name).ToListAsync(), i => (i as AT_Kg)?.KgNr);
await RefreshMemberList();