72 lines
2.8 KiB
C#
72 lines
2.8 KiB
C#
using Elwig.Documents;
|
|
using Elwig.Helpers;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using Xceed.Wpf.Toolkit.Primitives;
|
|
|
|
namespace Elwig.Windows {
|
|
public partial class TestWindow : Window {
|
|
|
|
public TestWindow() {
|
|
InitializeComponent();
|
|
MyComboBox.ItemsSource = new string[] { "Klasse A" , "Klasse B", "Klasse C", "Klasse D", "Klasse E", "Klasse F" };
|
|
MyListBox.ItemsSource = new string[] { "Test 1", "Test 2", "Test 3", "Test 4" };
|
|
}
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs evt) {
|
|
PdfDeliveryButton.IsEnabled = App.IsPrintingReady;
|
|
PdfCreditButton.IsEnabled = App.IsPrintingReady;
|
|
}
|
|
|
|
private void OnItemSelectionChanged(object sender, ItemSelectionChangedEventArgs e) {
|
|
MyText.Text = string.Join(", ", MyComboBox.SelectedItems.Cast<string>());
|
|
}
|
|
|
|
private async void WeighingButton1_Click(object sender, RoutedEventArgs evt) {
|
|
try {
|
|
var res = await App.Scales[0].GetCurrentWeight();
|
|
Output.Text = res.ToString();
|
|
} catch (Exception e) {
|
|
MessageBox.Show($"Beim Wiegen ist ein Fehler aufgetreten:\n\n{e.Message}", "Waagenfehler",
|
|
MessageBoxButton.OK, MessageBoxImage.Error);
|
|
}
|
|
}
|
|
|
|
private async void WeighingButton2_Click(object sender, RoutedEventArgs evt) {
|
|
try {
|
|
var res = await App.Scales[0].Weigh();
|
|
Output.Text = res.ToString();
|
|
} catch (Exception e) {
|
|
MessageBox.Show($"Beim Wiegen ist ein Fehler aufgetreten:\n\n{e.Message}", "Waagenfehler",
|
|
MessageBoxButton.OK, MessageBoxImage.Error);
|
|
}
|
|
}
|
|
|
|
private void ChartButton_Click(object sender, RoutedEventArgs evt) {
|
|
var w = new ChartWindow();
|
|
w.Show();
|
|
}
|
|
|
|
private async void PdfDeliveryButton_Click(object sender, RoutedEventArgs evt) {
|
|
Mouse.OverrideCursor = Cursors.Wait;
|
|
using var ctx = new AppDbContext();
|
|
using var doc = new DeliveryNote(await ctx.Deliveries.OrderBy(d => d.Parts.Count).ThenBy(d => d.Year).ThenBy(d => d.DId).LastAsync(), ctx);
|
|
await doc.Generate();
|
|
doc.Show();
|
|
Mouse.OverrideCursor = null;
|
|
}
|
|
|
|
private async void PdfCreditButton_Click(object sender, RoutedEventArgs evt) {
|
|
Mouse.OverrideCursor = Cursors.Wait;
|
|
using var ctx = new AppDbContext();
|
|
using var doc = new CreditNote(await ctx.Credits.FirstAsync(), ctx);
|
|
await doc.Generate();
|
|
doc.Show();
|
|
Mouse.OverrideCursor = null;
|
|
}
|
|
}
|
|
}
|