Change code formatting
This commit is contained in:
@ -6,12 +6,10 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace WGneu
|
namespace WGneu {
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for App.xaml
|
/// Interaction logic for App.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class App : Application
|
public partial class App : Application {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace WGneu.Models
|
namespace WGneu.Models {
|
||||||
{
|
|
||||||
[Table("AT_gem"), PrimaryKey("Gkz")]
|
[Table("AT_gem"), PrimaryKey("Gkz")]
|
||||||
public class AT_Gem
|
public class AT_Gem {
|
||||||
{
|
|
||||||
[Column("gkz")]
|
[Column("gkz")]
|
||||||
public int Gkz { get; set; }
|
public int Gkz { get; set; }
|
||||||
|
|
||||||
|
@ -6,11 +6,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace WGneu.Models
|
namespace WGneu.Models {
|
||||||
{
|
|
||||||
[Table("AT_kg"), PrimaryKey("KgNr")]
|
[Table("AT_kg"), PrimaryKey("KgNr")]
|
||||||
public class AT_Kg
|
public class AT_Kg {
|
||||||
{
|
|
||||||
[Column("kgnr")]
|
[Column("kgnr")]
|
||||||
public int KgNr { get; set; }
|
public int KgNr { get; set; }
|
||||||
|
|
||||||
|
@ -6,11 +6,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace WGneu.Models
|
namespace WGneu.Models {
|
||||||
{
|
|
||||||
[Table("AT_ort"), PrimaryKey("Okz")]
|
[Table("AT_ort"), PrimaryKey("Okz")]
|
||||||
public class AT_Ort
|
public class AT_Ort {
|
||||||
{
|
|
||||||
[Column("okz")]
|
[Column("okz")]
|
||||||
public int Okz { get; set; }
|
public int Okz { get; set; }
|
||||||
|
|
||||||
|
@ -7,11 +7,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace WGneu.Models
|
namespace WGneu.Models {
|
||||||
{
|
|
||||||
[Table("AT_plz"), PrimaryKey("Plz", "Okz"), Index("Id", IsUnique = true)]
|
[Table("AT_plz"), PrimaryKey("Plz", "Okz"), Index("Id", IsUnique = true)]
|
||||||
public class AT_Plz
|
public class AT_Plz {
|
||||||
{
|
|
||||||
[Column("plz")]
|
[Column("plz")]
|
||||||
public int Plz { get; set; }
|
public int Plz { get; set; }
|
||||||
|
|
||||||
@ -33,8 +31,7 @@ namespace WGneu.Models
|
|||||||
[ForeignKey("CountryCode")]
|
[ForeignKey("CountryCode")]
|
||||||
public virtual Country Country { get; set; }
|
public virtual Country Country { get; set; }
|
||||||
|
|
||||||
public ISet<AT_Plz> Orte(WgContext ctx)
|
public ISet<AT_Plz> Orte(WgContext ctx) {
|
||||||
{
|
|
||||||
return ctx.Postleitzahlen.Where(p => p.Plz == Plz).ToHashSet();
|
return ctx.Postleitzahlen.Where(p => p.Plz == Plz).ToHashSet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace WGneu.Models
|
namespace WGneu.Models {
|
||||||
{
|
|
||||||
[Table("branch"), PrimaryKey("ZwstId")]
|
[Table("branch"), PrimaryKey("ZwstId")]
|
||||||
public class Branch
|
public class Branch {
|
||||||
{
|
|
||||||
[Column("zwstid")]
|
[Column("zwstid")]
|
||||||
public string ZwstId { get; set; }
|
public string ZwstId { get; set; }
|
||||||
|
|
||||||
|
@ -6,11 +6,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace WGneu.Models
|
namespace WGneu.Models {
|
||||||
{
|
|
||||||
[Table("country"), PrimaryKey("Alpha2")]
|
[Table("country"), PrimaryKey("Alpha2")]
|
||||||
public class Country
|
public class Country {
|
||||||
{
|
|
||||||
[Column("alpha2")]
|
[Column("alpha2")]
|
||||||
public string Alpha2 { get; set; }
|
public string Alpha2 { get; set; }
|
||||||
|
|
||||||
|
@ -4,59 +4,49 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace WGneu.Models
|
namespace WGneu.Models {
|
||||||
{
|
|
||||||
// 1 °KMW =
|
// 1 °KMW =
|
||||||
// 1 °NM = kg/100L = 10g/L
|
// 1 °NM = kg/100L = 10g/L
|
||||||
// 1 °Oe =
|
// 1 °Oe =
|
||||||
// 1 °Bé =
|
// 1 °Bé =
|
||||||
// 1 °Bx = g/100g (x Gramm Zucker pro 100 Gramm Flüssigkeit)
|
// 1 °Bx = g/100g (x Gramm Zucker pro 100 Gramm Flüssigkeit)
|
||||||
internal class Gradation
|
internal class Gradation {
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gradation in mg/L.
|
/// Gradation in mg/L.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
uint mgpl;
|
uint mgpl;
|
||||||
|
|
||||||
public Gradation(uint mgpl)
|
public Gradation(uint mgpl) {
|
||||||
{
|
|
||||||
this.mgpl = mgpl;
|
this.mgpl = mgpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double relativeDensity(double todo)
|
public static double relativeDensity(double todo) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double KmwToOe(double kmw)
|
public static double KmwToOe(double kmw) {
|
||||||
{
|
|
||||||
return 0; // TODO
|
return 0; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double OeToKmw(double oe)
|
public static double OeToKmw(double oe) {
|
||||||
{
|
|
||||||
return 0; // TODO
|
return 0; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Gradation FromKmw(double kwm)
|
public static Gradation FromKmw(double kwm) {
|
||||||
{
|
|
||||||
return new Gradation(0); // TODO
|
return new Gradation(0); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Gradation FromKmw(double kmw, double t)
|
public static Gradation FromKmw(double kmw, double t) {
|
||||||
{
|
|
||||||
// The temperature can be ignored, because no volumetric unit is involved.
|
// The temperature can be ignored, because no volumetric unit is involved.
|
||||||
// 1 °KMW = 1g/100g
|
// 1 °KMW = 1g/100g
|
||||||
return FromKmw(kmw);
|
return FromKmw(kmw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Gradation FromOe(double oe)
|
public static Gradation FromOe(double oe) {
|
||||||
{
|
|
||||||
return new Gradation(0); // TODO
|
return new Gradation(0); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Gradation FromOe(double oe, double t)
|
public static Gradation FromOe(double oe, double t) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace WGneu.Models
|
namespace WGneu.Models {
|
||||||
{
|
|
||||||
[Table("member"), PrimaryKey("MgNr")]
|
[Table("member"), PrimaryKey("MgNr")]
|
||||||
public class Member
|
public class Member {
|
||||||
{
|
|
||||||
[Column("mgnr")]
|
[Column("mgnr")]
|
||||||
public int MgNr { get; set; }
|
public int MgNr { get; set; }
|
||||||
|
|
||||||
|
@ -6,11 +6,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace WGneu.Models
|
namespace WGneu.Models {
|
||||||
{
|
|
||||||
[Table("postal_dest"), PrimaryKey("CountryCode", "Id")]
|
[Table("postal_dest"), PrimaryKey("CountryCode", "Id")]
|
||||||
public class PostalDest
|
public class PostalDest {
|
||||||
{
|
|
||||||
[Column("country")]
|
[Column("country")]
|
||||||
public string CountryCode { get; set; }
|
public string CountryCode { get; set; }
|
||||||
|
|
||||||
@ -20,8 +18,7 @@ namespace WGneu.Models
|
|||||||
[ForeignKey("CountryCode")]
|
[ForeignKey("CountryCode")]
|
||||||
public virtual Country Country { get; set; }
|
public virtual Country Country { get; set; }
|
||||||
|
|
||||||
public AT_Plz? Plz(WgContext ctx)
|
public AT_Plz? Plz(WgContext ctx) {
|
||||||
{
|
|
||||||
if (CountryCode != "AT") return null;
|
if (CountryCode != "AT") return null;
|
||||||
return ctx.Postleitzahlen.Where(p => p.Id == Id).FirstOrDefault();
|
return ctx.Postleitzahlen.Where(p => p.Id == Id).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace WGneu.Models
|
namespace WGneu.Models {
|
||||||
{
|
|
||||||
[Table("wb_kg"), PrimaryKey("KgNr")]
|
[Table("wb_kg"), PrimaryKey("KgNr")]
|
||||||
public class WbKg
|
public class WbKg {
|
||||||
{
|
|
||||||
[Column("kgnr")]
|
[Column("kgnr")]
|
||||||
public int KgNr { get; set; }
|
public int KgNr { get; set; }
|
||||||
|
|
||||||
|
@ -6,16 +6,12 @@ using System.Threading.Tasks;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace WGneu
|
namespace WGneu {
|
||||||
{
|
class Utils {
|
||||||
class Utils
|
public static IEnumerable<T> FindVisualChilds<T>(DependencyObject depObj) where T : DependencyObject {
|
||||||
{
|
|
||||||
public static IEnumerable<T> FindVisualChilds<T>(DependencyObject depObj) where T : DependencyObject
|
|
||||||
{
|
|
||||||
if (depObj == null)
|
if (depObj == null)
|
||||||
yield return (T)Enumerable.Empty<T>();
|
yield return (T)Enumerable.Empty<T>();
|
||||||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
|
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++) {
|
||||||
{
|
|
||||||
DependencyObject ithChild = VisualTreeHelper.GetChild(depObj, i);
|
DependencyObject ithChild = VisualTreeHelper.GetChild(depObj, i);
|
||||||
if (ithChild == null)
|
if (ithChild == null)
|
||||||
continue;
|
continue;
|
||||||
|
@ -6,10 +6,8 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
||||||
namespace WGneu
|
namespace WGneu {
|
||||||
{
|
static class Validator {
|
||||||
static class Validator
|
|
||||||
{
|
|
||||||
|
|
||||||
private static readonly Dictionary<string, string[][]> PHONE_NRS = new() {
|
private static readonly Dictionary<string, string[][]> PHONE_NRS = new() {
|
||||||
{ "43", new string[][] {
|
{ "43", new string[][] {
|
||||||
@ -35,17 +33,14 @@ namespace WGneu
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public static ValidationResult CheckNumericInput(TextBox input)
|
public static ValidationResult CheckNumericInput(TextBox input) {
|
||||||
{
|
|
||||||
return CheckNumericInput(input, -1);
|
return CheckNumericInput(input, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ValidationResult CheckNumericInput(TextBox input, int maxLen)
|
private static ValidationResult CheckNumericInput(TextBox input, int maxLen) {
|
||||||
{
|
|
||||||
string text = "";
|
string text = "";
|
||||||
int pos = input.CaretIndex;
|
int pos = input.CaretIndex;
|
||||||
for (int i = 0; i < input.Text.Length; i++)
|
for (int i = 0; i < input.Text.Length; i++) {
|
||||||
{
|
|
||||||
char ch = input.Text[i];
|
char ch = input.Text[i];
|
||||||
if (Char.IsDigit(ch))
|
if (Char.IsDigit(ch))
|
||||||
text += ch;
|
text += ch;
|
||||||
@ -55,8 +50,7 @@ namespace WGneu
|
|||||||
input.Text = text;
|
input.Text = text;
|
||||||
input.CaretIndex = pos;
|
input.CaretIndex = pos;
|
||||||
|
|
||||||
if (maxLen >= 0 && input.Text.Length > maxLen)
|
if (maxLen >= 0 && input.Text.Length > maxLen) {
|
||||||
{
|
|
||||||
input.Text = input.Text.Substring(0, maxLen);
|
input.Text = input.Text.Substring(0, maxLen);
|
||||||
input.CaretIndex = Math.Min(pos, maxLen);
|
input.CaretIndex = Math.Min(pos, maxLen);
|
||||||
}
|
}
|
||||||
@ -64,31 +58,23 @@ namespace WGneu
|
|||||||
return new(true, null);
|
return new(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckPhoneNumber(TextBox input)
|
public static ValidationResult CheckPhoneNumber(TextBox input) {
|
||||||
{
|
|
||||||
string text = "";
|
string text = "";
|
||||||
int pos = input.CaretIndex;
|
int pos = input.CaretIndex;
|
||||||
for (int i = 0, v = 0; i < input.Text.Length; i++)
|
for (int i = 0, v = 0; i < input.Text.Length; i++) {
|
||||||
{
|
|
||||||
char ch = input.Text[i];
|
char ch = input.Text[i];
|
||||||
if (v == 0 && input.Text.Length - i >= 2 && ch == '0' && input.Text[i + 1] == '0') {
|
if (v == 0 && input.Text.Length - i >= 2 && ch == '0' && input.Text[i + 1] == '0') {
|
||||||
v++; i++;
|
v++; i++;
|
||||||
text += "+";
|
text += "+";
|
||||||
} else if (ch == '(' && input.Text.Length - i >= 3 && input.Text[i + 1] == '0' && input.Text[i + 2] == ')') {
|
} else if (ch == '(' && input.Text.Length - i >= 3 && input.Text[i + 1] == '0' && input.Text[i + 2] == ')') {
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
} else if (v == 0 && ch == '0') {
|
||||||
else if (v == 0 && ch == '0')
|
|
||||||
{
|
|
||||||
v += 3;
|
v += 3;
|
||||||
text += "+43";
|
text += "+43";
|
||||||
}
|
} else if (v == 0 && ch == '+') {
|
||||||
else if (v == 0 && ch == '+')
|
|
||||||
{
|
|
||||||
v++;
|
v++;
|
||||||
text += ch;
|
text += ch;
|
||||||
}
|
} else if (v > 0 && char.IsDigit(ch)) {
|
||||||
else if (v > 0 && char.IsDigit(ch))
|
|
||||||
{
|
|
||||||
if (PHONE_NRS.Any(kv => text == "+" + kv.Key))
|
if (PHONE_NRS.Any(kv => text == "+" + kv.Key))
|
||||||
text += " ";
|
text += " ";
|
||||||
if (text.StartsWith("+43 ")) {
|
if (text.StartsWith("+43 ")) {
|
||||||
@ -118,24 +104,18 @@ namespace WGneu
|
|||||||
return new(true, null);
|
return new(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckEmailAddress(TextBox input)
|
public static ValidationResult CheckEmailAddress(TextBox input) {
|
||||||
{
|
|
||||||
string text = "";
|
string text = "";
|
||||||
int pos = input.CaretIndex;
|
int pos = input.CaretIndex;
|
||||||
bool domain = false;
|
bool domain = false;
|
||||||
for (int i = 0; i < input.Text.Length; i++)
|
for (int i = 0; i < input.Text.Length; i++) {
|
||||||
{
|
|
||||||
char ch = input.Text[i];
|
char ch = input.Text[i];
|
||||||
if (domain)
|
if (domain) {
|
||||||
{
|
if ((char.IsAscii(ch) && char.IsLetterOrDigit(ch)) || ".-_öäüßÖÄÜẞ".Any(c => c == ch)) {
|
||||||
if ((char.IsAscii(ch) && char.IsLetterOrDigit(ch)) || ".-_öäüßÖÄÜẞ".Any(c => c == ch))
|
|
||||||
{
|
|
||||||
if (!(text.Last() == '.' && ch == '.'))
|
if (!(text.Last() == '.' && ch == '.'))
|
||||||
text += char.ToLower(ch);
|
text += char.ToLower(ch);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ch == '@') domain = true;
|
if (ch == '@') domain = true;
|
||||||
if (!char.IsControl(ch) && !char.IsWhiteSpace(ch))
|
if (!char.IsControl(ch) && !char.IsWhiteSpace(ch))
|
||||||
text += ch;
|
text += ch;
|
||||||
@ -158,8 +138,7 @@ namespace WGneu
|
|||||||
return new(true, null);
|
return new(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckLfbisNr(TextBox input)
|
public static ValidationResult CheckLfbisNr(TextBox input) {
|
||||||
{
|
|
||||||
var res = CheckNumericInput(input, 7);
|
var res = CheckNumericInput(input, 7);
|
||||||
if (!res.IsValid)
|
if (!res.IsValid)
|
||||||
return res;
|
return res;
|
||||||
@ -173,18 +152,15 @@ namespace WGneu
|
|||||||
return new(true, "Not implemented yet");
|
return new(true, "Not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckUstIdInput(TextBox input)
|
public static ValidationResult CheckUstIdInput(TextBox input) {
|
||||||
{
|
|
||||||
return new(false, "Not implemented yet");
|
return new(false, "Not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetInputInvalid(TextBox input)
|
public static void SetInputInvalid(TextBox input) {
|
||||||
{
|
|
||||||
input.BorderBrush = System.Windows.Media.Brushes.Red;
|
input.BorderBrush = System.Windows.Media.Brushes.Red;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetInputValid(TextBox input)
|
public static void SetInputValid(TextBox input) {
|
||||||
{
|
|
||||||
input.ClearValue(TextBox.BorderBrushProperty);
|
input.ClearValue(TextBox.BorderBrushProperty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,8 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using WGneu.Models;
|
using WGneu.Models;
|
||||||
|
|
||||||
namespace WGneu
|
namespace WGneu {
|
||||||
{
|
public class WgContext : DbContext {
|
||||||
public class WgContext : DbContext
|
|
||||||
{
|
|
||||||
public DbSet<Country> Countries { get; set; }
|
public DbSet<Country> Countries { get; set; }
|
||||||
public DbSet<Member> Members { get; set; }
|
public DbSet<Member> Members { get; set; }
|
||||||
public DbSet<AT_Gem> Gemeinden { get; set; }
|
public DbSet<AT_Gem> Gemeinden { get; set; }
|
||||||
@ -20,8 +18,7 @@ namespace WGneu
|
|||||||
public DbSet<Branch> Branches { get; set; }
|
public DbSet<Branch> Branches { get; set; }
|
||||||
public DbSet<WbKg> WbKgs { get; set; }
|
public DbSet<WbKg> WbKgs { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
|
||||||
{
|
|
||||||
optionsBuilder.UseSqlite("Data Source=\"C:\\Users\\lorenz\\Desktop\\wgtest.sqlite3\"; foreign keys=true");
|
optionsBuilder.UseSqlite("Data Source=\"C:\\Users\\lorenz\\Desktop\\wgtest.sqlite3\"; foreign keys=true");
|
||||||
optionsBuilder.UseLazyLoadingProxies();
|
optionsBuilder.UseLazyLoadingProxies();
|
||||||
}
|
}
|
||||||
|
@ -14,27 +14,21 @@ using System.Windows.Shapes;
|
|||||||
using WGneu.Models;
|
using WGneu.Models;
|
||||||
|
|
||||||
|
|
||||||
namespace WGneu.Windows
|
namespace WGneu.Windows {
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaktionslogik für BankDetailsWindow.xaml
|
/// Interaktionslogik für BankDetailsWindow.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class BankDetailsWindow : Window
|
public partial class BankDetailsWindow : Window {
|
||||||
{
|
public BankDetailsWindow() {
|
||||||
public BankDetailsWindow()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Iban_TextChanged(object sender, TextChangedEventArgs e)
|
private void Iban_TextChanged(object sender, TextChangedEventArgs e) {
|
||||||
{
|
|
||||||
string iban = "";
|
string iban = "";
|
||||||
int pos = Iban.CaretIndex;
|
int pos = Iban.CaretIndex;
|
||||||
for (int i = 0, v = 0; i < Iban.Text.Length && v < 34; i++)
|
for (int i = 0, v = 0; i < Iban.Text.Length && v < 34; i++) {
|
||||||
{
|
|
||||||
char ch = Iban.Text[i];
|
char ch = Iban.Text[i];
|
||||||
if (Char.IsLetterOrDigit(ch) && Char.IsAscii(ch))
|
if (Char.IsLetterOrDigit(ch) && Char.IsAscii(ch)) {
|
||||||
{
|
|
||||||
if (v != 0 && v % 4 == 0)
|
if (v != 0 && v % 4 == 0)
|
||||||
iban += ' ';
|
iban += ' ';
|
||||||
v++;
|
v++;
|
||||||
@ -52,25 +46,20 @@ namespace WGneu.Windows
|
|||||||
GenerateBankDetails();
|
GenerateBankDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Iban_LostFocus(object sender, EventArgs e)
|
private void Iban_LostFocus(object sender, EventArgs e) {
|
||||||
{
|
|
||||||
// TODO vaildate checksum
|
// TODO vaildate checksum
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BankCode_TextChanged(object sender, TextChangedEventArgs e)
|
private void BankCode_TextChanged(object sender, TextChangedEventArgs e) {
|
||||||
{
|
|
||||||
string cc = "AT";
|
string cc = "AT";
|
||||||
string code = "";
|
string code = "";
|
||||||
int pos = BankCode.CaretIndex;
|
int pos = BankCode.CaretIndex;
|
||||||
|
|
||||||
if (cc == "AT")
|
if (cc == "AT") {
|
||||||
{
|
|
||||||
|
|
||||||
for (int i = 0, v = 0; i < BankCode.Text.Length && v < 5; i++)
|
for (int i = 0, v = 0; i < BankCode.Text.Length && v < 5; i++) {
|
||||||
{
|
|
||||||
char ch = BankCode.Text[i];
|
char ch = BankCode.Text[i];
|
||||||
if (Char.IsDigit(ch))
|
if (Char.IsDigit(ch)) {
|
||||||
{
|
|
||||||
v++;
|
v++;
|
||||||
code += ch;
|
code += ch;
|
||||||
}
|
}
|
||||||
@ -86,19 +75,15 @@ namespace WGneu.Windows
|
|||||||
GenerateIban();
|
GenerateIban();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AccountNumber_TextChanged(object sender, TextChangedEventArgs e)
|
private void AccountNumber_TextChanged(object sender, TextChangedEventArgs e) {
|
||||||
{
|
|
||||||
string cc = "AT";
|
string cc = "AT";
|
||||||
string num = "";
|
string num = "";
|
||||||
int pos = AccountNumber.CaretIndex;
|
int pos = AccountNumber.CaretIndex;
|
||||||
|
|
||||||
if (cc == "AT")
|
if (cc == "AT") {
|
||||||
{
|
for (int i = 0, v = 0; i < AccountNumber.Text.Length && v < 11; i++) {
|
||||||
for (int i = 0, v = 0; i < AccountNumber.Text.Length && v < 11; i++)
|
|
||||||
{
|
|
||||||
char ch = AccountNumber.Text[i];
|
char ch = AccountNumber.Text[i];
|
||||||
if (Char.IsLetterOrDigit(ch) && Char.IsAscii(ch))
|
if (Char.IsLetterOrDigit(ch) && Char.IsAscii(ch)) {
|
||||||
{
|
|
||||||
v++;
|
v++;
|
||||||
num += ch;
|
num += ch;
|
||||||
}
|
}
|
||||||
@ -114,13 +99,11 @@ namespace WGneu.Windows
|
|||||||
GenerateIban();
|
GenerateIban();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenerateIban()
|
private void GenerateIban() {
|
||||||
{
|
|
||||||
string cc = "AT";
|
string cc = "AT";
|
||||||
string iban = cc + "00";
|
string iban = cc + "00";
|
||||||
|
|
||||||
if (cc == "AT")
|
if (cc == "AT") {
|
||||||
{
|
|
||||||
iban += BankCode.Text.PadLeft(5, '0') + AccountNumber.Text.PadLeft(11, '0');
|
iban += BankCode.Text.PadLeft(5, '0') + AccountNumber.Text.PadLeft(11, '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,8 +113,7 @@ namespace WGneu.Windows
|
|||||||
Iban.CaretIndex = iban.Length;
|
Iban.CaretIndex = iban.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenerateBankDetails()
|
private void GenerateBankDetails() {
|
||||||
{
|
|
||||||
BankCode.Text = "";
|
BankCode.Text = "";
|
||||||
AccountNumber.Text = "";
|
AccountNumber.Text = "";
|
||||||
|
|
||||||
@ -140,26 +122,19 @@ namespace WGneu.Windows
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
string cc = iban.Substring(0, 2);
|
string cc = iban.Substring(0, 2);
|
||||||
if (cc == "AT")
|
if (cc == "AT") {
|
||||||
{
|
if (iban.Length > 4) {
|
||||||
if (iban.Length > 4)
|
|
||||||
{
|
|
||||||
string bankCodeStr = iban.Substring(4, Math.Min(5, iban.Length - 4));
|
string bankCodeStr = iban.Substring(4, Math.Min(5, iban.Length - 4));
|
||||||
if (bankCodeStr.All(Char.IsDigit))
|
if (bankCodeStr.All(Char.IsDigit)) {
|
||||||
{
|
|
||||||
int bankCode = int.Parse(bankCodeStr);
|
int bankCode = int.Parse(bankCodeStr);
|
||||||
BankCode.Text = bankCode.ToString();
|
BankCode.Text = bankCode.ToString();
|
||||||
}
|
}
|
||||||
if (iban.Length > 9)
|
if (iban.Length > 9) {
|
||||||
{
|
|
||||||
string accNumStr = iban.Substring(9, Math.Min(11, iban.Length - 9));
|
string accNumStr = iban.Substring(9, Math.Min(11, iban.Length - 9));
|
||||||
if (accNumStr.All(Char.IsDigit))
|
if (accNumStr.All(Char.IsDigit)) {
|
||||||
{
|
|
||||||
int accNum = int.Parse(accNumStr);
|
int accNum = int.Parse(accNumStr);
|
||||||
AccountNumber.Text = (accNum != 0) ? accNum.ToString() : "";
|
AccountNumber.Text = (accNum != 0) ? accNum.ToString() : "";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
AccountNumber.Text = accNumStr;
|
AccountNumber.Text = accNumStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,52 +18,43 @@ using System.Windows.Shapes;
|
|||||||
using WGneu.Models;
|
using WGneu.Models;
|
||||||
|
|
||||||
|
|
||||||
namespace WGneu.Windows
|
namespace WGneu.Windows {
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for MainWindow.xaml
|
/// Interaction logic for MainWindow.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window {
|
||||||
{
|
|
||||||
private readonly WgContext _context = new WgContext();
|
private readonly WgContext _context = new WgContext();
|
||||||
private CollectionViewSource countryViewSource;
|
private CollectionViewSource countryViewSource;
|
||||||
public MainWindow()
|
public MainWindow() {
|
||||||
{
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
countryViewSource = (CollectionViewSource) FindResource("countryViewSource");
|
countryViewSource = (CollectionViewSource)FindResource("countryViewSource");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
_context.Countries.Load();
|
_context.Countries.Load();
|
||||||
countryViewSource.Source = _context.Countries.Local.ToObservableCollection();
|
countryViewSource.Source = _context.Countries.Local.ToObservableCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClosing(CancelEventArgs e)
|
protected override void OnClosing(CancelEventArgs e) {
|
||||||
{
|
|
||||||
_context.Dispose();
|
_context.Dispose();
|
||||||
base.OnClosing(e);
|
base.OnClosing(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button1_Click(object sender, EventArgs e)
|
private void Button1_Click(object sender, EventArgs e) {
|
||||||
{
|
|
||||||
BankDetailsWindow w = new BankDetailsWindow();
|
BankDetailsWindow w = new BankDetailsWindow();
|
||||||
w.Show();
|
w.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button2_Click(object sender, EventArgs e)
|
private void Button2_Click(object sender, EventArgs e) {
|
||||||
{
|
|
||||||
MemberListWindow w = new MemberListWindow();
|
MemberListWindow w = new MemberListWindow();
|
||||||
w.Show();
|
w.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
private void Button_Click(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,8 @@ using System.Windows.Shapes;
|
|||||||
using WGneu.Models;
|
using WGneu.Models;
|
||||||
|
|
||||||
|
|
||||||
namespace WGneu.Windows
|
namespace WGneu.Windows {
|
||||||
{
|
public partial class MemberListWindow : Window {
|
||||||
public partial class MemberListWindow : Window
|
|
||||||
{
|
|
||||||
private bool IsEditing = false;
|
private bool IsEditing = false;
|
||||||
private bool IsCreating = false;
|
private bool IsCreating = false;
|
||||||
private List<string> TextFilter = new();
|
private List<string> TextFilter = new();
|
||||||
@ -30,8 +28,7 @@ namespace WGneu.Windows
|
|||||||
private static readonly RoutedCommand CtrlF = new();
|
private static readonly RoutedCommand CtrlF = new();
|
||||||
private readonly WgContext Context = new();
|
private readonly WgContext Context = new();
|
||||||
|
|
||||||
public MemberListWindow()
|
public MemberListWindow() {
|
||||||
{
|
|
||||||
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));
|
||||||
@ -39,26 +36,22 @@ namespace WGneu.Windows
|
|||||||
if (tb.Name != "SearchInput") Valid[tb] = true;
|
if (tb.Name != "SearchInput") Valid[tb] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
RefreshMemberList();
|
RefreshMemberList();
|
||||||
BranchInput.ItemsSource = Context.Branches.OrderBy(b => b.Name).ToList();
|
BranchInput.ItemsSource = Context.Branches.OrderBy(b => b.Name).ToList();
|
||||||
DefaultKgInput.ItemsSource = Context.WbKgs.Select(k => k.Kg).OrderBy(k => k.Name).ToList();
|
DefaultKgInput.ItemsSource = Context.WbKgs.Select(k => k.Kg).OrderBy(k => k.Name).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClosing(CancelEventArgs e)
|
protected override void OnClosing(CancelEventArgs e) {
|
||||||
{
|
|
||||||
Context.Dispose();
|
Context.Dispose();
|
||||||
base.OnClosing(e);
|
base.OnClosing(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int CountMatchesInMember(Member m)
|
private int CountMatchesInMember(Member m) {
|
||||||
{
|
|
||||||
if (TextFilter.Count == 0) return 0;
|
if (TextFilter.Count == 0) return 0;
|
||||||
string[] check = new string[] { m.MgNr.ToString(), m.FamilyName.ToLower(), m.GivenName.ToLower(), m.DefaultKg.Name.ToLower() };
|
string[] check = new string[] { m.MgNr.ToString(), m.FamilyName.ToLower(), m.GivenName.ToLower(), m.DefaultKg.Name.ToLower() };
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (string c in check)
|
foreach (string c in check) {
|
||||||
{
|
|
||||||
if (TextFilter.Any(f => c == f))
|
if (TextFilter.Any(f => c == f))
|
||||||
i += 10;
|
i += 10;
|
||||||
else if (TextFilter.Any(f => c.Contains(f)))
|
else if (TextFilter.Any(f => c.Contains(f)))
|
||||||
@ -67,13 +60,11 @@ namespace WGneu.Windows
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshMemberList()
|
private void RefreshMemberList() {
|
||||||
{
|
|
||||||
Context.Members.Load();
|
Context.Members.Load();
|
||||||
List<Member> members = Context.Members.OrderBy(m => m.FamilyName + " " + m.GivenName).ToList();
|
List<Member> members = Context.Members.OrderBy(m => m.FamilyName + " " + m.GivenName).ToList();
|
||||||
|
|
||||||
if (TextFilter.Count > 0)
|
if (TextFilter.Count > 0) {
|
||||||
{
|
|
||||||
members = members
|
members = members
|
||||||
.ToDictionary(m => m, m => CountMatchesInMember(m))
|
.ToDictionary(m => m, m => CountMatchesInMember(m))
|
||||||
.OrderByDescending(a => a.Value)
|
.OrderByDescending(a => a.Value)
|
||||||
@ -88,38 +79,30 @@ namespace WGneu.Windows
|
|||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshInputs()
|
private void RefreshInputs() {
|
||||||
{
|
|
||||||
Member m = (Member)MemberList.SelectedItem;
|
Member m = (Member)MemberList.SelectedItem;
|
||||||
if (m != null)
|
if (m != null) {
|
||||||
{
|
|
||||||
EditMemberButton.IsEnabled = true;
|
EditMemberButton.IsEnabled = true;
|
||||||
DeleteMemberButton.IsEnabled = true;
|
DeleteMemberButton.IsEnabled = true;
|
||||||
FillInputs(m);
|
FillInputs(m);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
EditMemberButton.IsEnabled = false;
|
EditMemberButton.IsEnabled = false;
|
||||||
DeleteMemberButton.IsEnabled = false;
|
DeleteMemberButton.IsEnabled = false;
|
||||||
ClearInputs();
|
ClearInputs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitInputs()
|
private void InitInputs() {
|
||||||
{
|
|
||||||
ClearInputs();
|
ClearInputs();
|
||||||
MgNrInput.Text = NextMgNr().ToString();
|
MgNrInput.Text = NextMgNr().ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MemberList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void MemberList_SelectionChanged(object sender, SelectionChangedEventArgs e) {
|
||||||
{
|
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlzInput_TextChanged(object sender, RoutedEventArgs e)
|
private void PlzInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||||
{
|
if (PlzInput.Text.Length == 4 && PlzInput.Text.All(char.IsDigit)) {
|
||||||
if (PlzInput.Text.Length == 4 && PlzInput.Text.All(char.IsDigit))
|
|
||||||
{
|
|
||||||
int plz = int.Parse(PlzInput.Text);
|
int plz = int.Parse(PlzInput.Text);
|
||||||
var o = Context.Postleitzahlen.Where(p => p.Plz == plz).ToHashSet();
|
var o = Context.Postleitzahlen.Where(p => p.Plz == plz).ToHashSet();
|
||||||
OrtInput.ItemsSource = o;
|
OrtInput.ItemsSource = o;
|
||||||
@ -127,8 +110,7 @@ namespace WGneu.Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NewMemberButton_Click(object sender, RoutedEventArgs e)
|
private void NewMemberButton_Click(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
IsCreating = true;
|
IsCreating = true;
|
||||||
MemberList.IsEnabled = false;
|
MemberList.IsEnabled = false;
|
||||||
InitInputs();
|
InitInputs();
|
||||||
@ -137,8 +119,7 @@ namespace WGneu.Windows
|
|||||||
UnlockInputs();
|
UnlockInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EditMemberButton_Click(object sender, RoutedEventArgs e)
|
private void EditMemberButton_Click(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
if (MemberList.SelectedItem == null)
|
if (MemberList.SelectedItem == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -150,24 +131,21 @@ namespace WGneu.Windows
|
|||||||
UnlockInputs();
|
UnlockInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteMemberButton_Click(object sender, RoutedEventArgs e)
|
private void DeleteMemberButton_Click(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
Member m = (Member)MemberList.SelectedItem;
|
Member m = (Member)MemberList.SelectedItem;
|
||||||
if (m == null) return;
|
if (m == null) return;
|
||||||
|
|
||||||
var r = MessageBox.Show(
|
var r = MessageBox.Show(
|
||||||
$"Soll das Mitglied \"{m.FamilyName} {m.GivenName}\" (MgNr. {m.MgNr}) wirklich unwiderruflich gelöscht werden?",
|
$"Soll das Mitglied \"{m.FamilyName} {m.GivenName}\" (MgNr. {m.MgNr}) wirklich unwiderruflich gelöscht werden?",
|
||||||
"Mitglied löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
"Mitglied löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||||
if (r == MessageBoxResult.Yes)
|
if (r == MessageBoxResult.Yes) {
|
||||||
{
|
|
||||||
Context.Remove(m);
|
Context.Remove(m);
|
||||||
Context.SaveChanges();
|
Context.SaveChanges();
|
||||||
RefreshMemberList();
|
RefreshMemberList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
private void SaveButton_Click(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
// TODO only allow to click button, if values were checked
|
// TODO only allow to click button, if values were checked
|
||||||
|
|
||||||
Member? m = new();
|
Member? m = new();
|
||||||
@ -214,8 +192,7 @@ namespace WGneu.Windows
|
|||||||
if (ContactEmailInput.IsChecked ?? false) m.DefaultContact = "email";
|
if (ContactEmailInput.IsChecked ?? false) m.DefaultContact = "email";
|
||||||
// TODO Buchhaltungskonto
|
// TODO Buchhaltungskonto
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
if (IsEditing)
|
if (IsEditing)
|
||||||
Context.Update(m);
|
Context.Update(m);
|
||||||
else if (IsCreating)
|
else if (IsCreating)
|
||||||
@ -224,9 +201,7 @@ namespace WGneu.Windows
|
|||||||
|
|
||||||
if (newMgNr != m.MgNr)
|
if (newMgNr != m.MgNr)
|
||||||
Context.Database.ExecuteSql($"UPDATE member SET mgnr = {newMgNr} WHERE mgnr = {m.MgNr}");
|
Context.Database.ExecuteSql($"UPDATE member SET mgnr = {newMgNr} WHERE mgnr = {m.MgNr}");
|
||||||
}
|
} catch (Exception exc) {
|
||||||
catch (Exception exc)
|
|
||||||
{
|
|
||||||
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||||
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||||
MessageBox.Show(str, "Mitglied aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show(str, "Mitglied aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
@ -241,16 +216,14 @@ namespace WGneu.Windows
|
|||||||
RefreshMemberList();
|
RefreshMemberList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResetButton_Click(object sender, RoutedEventArgs e)
|
private void ResetButton_Click(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
if (IsEditing)
|
if (IsEditing)
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
else if (IsCreating)
|
else if (IsCreating)
|
||||||
InitInputs();
|
InitInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CancelButton_Click(object sender, RoutedEventArgs e)
|
private void CancelButton_Click(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
IsEditing = false;
|
IsEditing = false;
|
||||||
IsCreating = false;
|
IsCreating = false;
|
||||||
MemberList.IsEnabled = true;
|
MemberList.IsEnabled = true;
|
||||||
@ -260,30 +233,25 @@ namespace WGneu.Windows
|
|||||||
LockInputs();
|
LockInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SearchInput_TextChanged(object sender, RoutedEventArgs e)
|
private void SearchInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
TextFilter = SearchInput.Text.ToLower().Split(" ").ToList().FindAll(s => s != "");
|
TextFilter = SearchInput.Text.ToLower().Split(" ").ToList().FindAll(s => s != "");
|
||||||
RefreshMemberList();
|
RefreshMemberList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FocusSearchInput(object sender, RoutedEventArgs e)
|
private void FocusSearchInput(object sender, RoutedEventArgs e) {
|
||||||
{
|
if (!IsEditing && !IsCreating) {
|
||||||
if (!IsEditing && !IsCreating)
|
|
||||||
{
|
|
||||||
SearchInput.Focus();
|
SearchInput.Focus();
|
||||||
SearchInput.SelectAll();
|
SearchInput.SelectAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int NextMgNr()
|
private int NextMgNr() {
|
||||||
{
|
|
||||||
int c = Context.Members.Select(m => m.MgNr).Min();
|
int c = Context.Members.Select(m => m.MgNr).Min();
|
||||||
Context.Members.OrderBy(m => m.MgNr).Select(m => m.MgNr).ToList().ForEach(a => { if (a <= c + 100) c = a; });
|
Context.Members.OrderBy(m => m.MgNr).Select(m => m.MgNr).ToList().ForEach(a => { if (a <= c + 100) c = a; });
|
||||||
return c + 1;
|
return c + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowSaveResetCancelButtons()
|
private void ShowSaveResetCancelButtons() {
|
||||||
{
|
|
||||||
SaveButton.IsEnabled = true;
|
SaveButton.IsEnabled = true;
|
||||||
ResetButton.IsEnabled = false;
|
ResetButton.IsEnabled = false;
|
||||||
CancelButton.IsEnabled = true;
|
CancelButton.IsEnabled = true;
|
||||||
@ -292,8 +260,7 @@ namespace WGneu.Windows
|
|||||||
CancelButton.Visibility = Visibility.Visible;
|
CancelButton.Visibility = Visibility.Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HideSaveResetCancelButtons()
|
private void HideSaveResetCancelButtons() {
|
||||||
{
|
|
||||||
SaveButton.IsEnabled = false;
|
SaveButton.IsEnabled = false;
|
||||||
ResetButton.IsEnabled = false;
|
ResetButton.IsEnabled = false;
|
||||||
CancelButton.IsEnabled = false;
|
CancelButton.IsEnabled = false;
|
||||||
@ -302,8 +269,7 @@ namespace WGneu.Windows
|
|||||||
CancelButton.Visibility = Visibility.Hidden;
|
CancelButton.Visibility = Visibility.Hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowNewEditDeleteButtons()
|
private void ShowNewEditDeleteButtons() {
|
||||||
{
|
|
||||||
NewMemberButton.IsEnabled = true;
|
NewMemberButton.IsEnabled = true;
|
||||||
EditMemberButton.IsEnabled = MemberList.SelectedItem != null;
|
EditMemberButton.IsEnabled = MemberList.SelectedItem != null;
|
||||||
DeleteMemberButton.IsEnabled = MemberList.SelectedItem != null;
|
DeleteMemberButton.IsEnabled = MemberList.SelectedItem != null;
|
||||||
@ -312,8 +278,7 @@ namespace WGneu.Windows
|
|||||||
DeleteMemberButton.Visibility = Visibility.Visible;
|
DeleteMemberButton.Visibility = Visibility.Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HideNewEditDeleteButtons()
|
private void HideNewEditDeleteButtons() {
|
||||||
{
|
|
||||||
NewMemberButton.IsEnabled = false;
|
NewMemberButton.IsEnabled = false;
|
||||||
EditMemberButton.IsEnabled = false;
|
EditMemberButton.IsEnabled = false;
|
||||||
DeleteMemberButton.IsEnabled = false;
|
DeleteMemberButton.IsEnabled = false;
|
||||||
@ -322,8 +287,7 @@ namespace WGneu.Windows
|
|||||||
DeleteMemberButton.Visibility = Visibility.Hidden;
|
DeleteMemberButton.Visibility = Visibility.Hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LockInputs()
|
private void LockInputs() {
|
||||||
{
|
|
||||||
foreach (var tb in Utils.FindVisualChilds<TextBox>(this))
|
foreach (var tb in Utils.FindVisualChilds<TextBox>(this))
|
||||||
if (tb.Name != "SearchInput") tb.IsReadOnly = true;
|
if (tb.Name != "SearchInput") tb.IsReadOnly = true;
|
||||||
foreach (var cb in Utils.FindVisualChilds<ComboBox>(this))
|
foreach (var cb in Utils.FindVisualChilds<ComboBox>(this))
|
||||||
@ -334,8 +298,7 @@ namespace WGneu.Windows
|
|||||||
rb.IsEnabled = false;
|
rb.IsEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UnlockInputs()
|
private void UnlockInputs() {
|
||||||
{
|
|
||||||
foreach (var tb in Utils.FindVisualChilds<TextBox>(this))
|
foreach (var tb in Utils.FindVisualChilds<TextBox>(this))
|
||||||
if (tb.Name != "SearchInput") tb.IsReadOnly = false;
|
if (tb.Name != "SearchInput") tb.IsReadOnly = false;
|
||||||
foreach (var cb in Utils.FindVisualChilds<ComboBox>(this))
|
foreach (var cb in Utils.FindVisualChilds<ComboBox>(this))
|
||||||
@ -346,8 +309,7 @@ namespace WGneu.Windows
|
|||||||
rb.IsEnabled = true;
|
rb.IsEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillInputs(Member m)
|
private void FillInputs(Member m) {
|
||||||
{
|
|
||||||
MgNrInput.Text = m.MgNr.ToString();
|
MgNrInput.Text = m.MgNr.ToString();
|
||||||
PredecessorMgNrInput.Text = m.PredecessorMgNr.ToString();
|
PredecessorMgNrInput.Text = m.PredecessorMgNr.ToString();
|
||||||
PrefixInput.Text = m.Prefix;
|
PrefixInput.Text = m.Prefix;
|
||||||
@ -357,14 +319,11 @@ namespace WGneu.Windows
|
|||||||
BirthdayInput.Text = (m.Birthday != null) ? string.Join(".", m.Birthday.Split("-").Reverse()) : null;
|
BirthdayInput.Text = (m.Birthday != null) ? string.Join(".", m.Birthday.Split("-").Reverse()) : null;
|
||||||
AddressInput.Text = m.Address;
|
AddressInput.Text = m.Address;
|
||||||
AT_Plz? p = m.PostalDest.Plz(Context);
|
AT_Plz? p = m.PostalDest.Plz(Context);
|
||||||
if (p != null)
|
if (p != null) {
|
||||||
{
|
|
||||||
PlzInput.Text = p.Plz.ToString();
|
PlzInput.Text = p.Plz.ToString();
|
||||||
OrtInput.ItemsSource = p.Orte(Context);
|
OrtInput.ItemsSource = p.Orte(Context);
|
||||||
OrtInput.SelectedItem = p;
|
OrtInput.SelectedItem = p;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
PlzInput.Text = null;
|
PlzInput.Text = null;
|
||||||
OrtInput.ItemsSource = null;
|
OrtInput.ItemsSource = null;
|
||||||
OrtInput.SelectedItem = null;
|
OrtInput.SelectedItem = null;
|
||||||
@ -393,15 +352,13 @@ namespace WGneu.Windows
|
|||||||
ActiveInput.IsChecked = m.Active;
|
ActiveInput.IsChecked = m.Active;
|
||||||
VollLieferantInput.IsChecked = m.VollLieferant;
|
VollLieferantInput.IsChecked = m.VollLieferant;
|
||||||
FunkionärInput.IsChecked = m.Funktionär;
|
FunkionärInput.IsChecked = m.Funktionär;
|
||||||
switch (m.DefaultContact)
|
switch (m.DefaultContact) {
|
||||||
{
|
|
||||||
case "post": ContactPostInput.IsChecked = true; break;
|
case "post": ContactPostInput.IsChecked = true; break;
|
||||||
case "email": ContactEmailInput.IsChecked = true; break;
|
case "email": ContactEmailInput.IsChecked = true; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearInputs()
|
private void ClearInputs() {
|
||||||
{
|
|
||||||
foreach (var tb in Utils.FindVisualChilds<TextBox>(this))
|
foreach (var tb in Utils.FindVisualChilds<TextBox>(this))
|
||||||
if (tb.Name != "SearchInput") tb.Text = "";
|
if (tb.Name != "SearchInput") tb.Text = "";
|
||||||
foreach (var cb in Utils.FindVisualChilds<ComboBox>(this))
|
foreach (var cb in Utils.FindVisualChilds<ComboBox>(this))
|
||||||
@ -412,27 +369,23 @@ namespace WGneu.Windows
|
|||||||
rb.IsChecked = false;
|
rb.IsChecked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsValid()
|
private bool IsValid() {
|
||||||
{
|
|
||||||
return Valid.All(kv => kv.Value) &&
|
return Valid.All(kv => kv.Value) &&
|
||||||
Utils.FindVisualChilds<ComboBox>(this).All(cb => cb.ItemsSource == null || cb.SelectedItem != null);
|
Utils.FindVisualChilds<ComboBox>(this).All(cb => cb.ItemsSource == null || cb.SelectedItem != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateButtons()
|
private void UpdateButtons() {
|
||||||
{
|
|
||||||
if (!IsEditing && !IsCreating) return;
|
if (!IsEditing && !IsCreating) return;
|
||||||
bool ch = HasChanged(), v = IsValid();
|
bool ch = HasChanged(), v = IsValid();
|
||||||
ResetButton.IsEnabled = (ch);
|
ResetButton.IsEnabled = (ch);
|
||||||
SaveButton.IsEnabled = (v && ch);
|
SaveButton.IsEnabled = (v && ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HasChanged()
|
private bool HasChanged() {
|
||||||
{
|
|
||||||
return true; // TODO
|
return true; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InputTextChanged(TextBox input, Func<TextBox, ValidationResult> checker)
|
private void InputTextChanged(TextBox input, Func<TextBox, ValidationResult> checker) {
|
||||||
{
|
|
||||||
var res = checker(input);
|
var res = checker(input);
|
||||||
Valid[input] = res.IsValid;
|
Valid[input] = res.IsValid;
|
||||||
if (res.IsValid)
|
if (res.IsValid)
|
||||||
@ -442,45 +395,37 @@ namespace WGneu.Windows
|
|||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InputLostFocus(TextBox input, Func<TextBox, ValidationResult> checker, string? msg)
|
private void InputLostFocus(TextBox input, Func<TextBox, ValidationResult> checker, string? msg) {
|
||||||
{
|
|
||||||
var res = checker(input);
|
var res = checker(input);
|
||||||
if (!res.IsValid)
|
if (!res.IsValid)
|
||||||
MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
|
MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComboBox_SelectionChanged(object sender, RoutedEventArgs e)
|
private void ComboBox_SelectionChanged(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PhoneNrInput_TextChanged(object sender, RoutedEventArgs e)
|
private void PhoneNrInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
InputTextChanged((TextBox)sender, Validator.CheckPhoneNumber);
|
InputTextChanged((TextBox)sender, Validator.CheckPhoneNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PhoneNrInput_LostFocus(object sender, RoutedEventArgs e)
|
private void PhoneNrInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
InputLostFocus((TextBox)sender, Validator.CheckPhoneNumber, null);
|
InputLostFocus((TextBox)sender, Validator.CheckPhoneNumber, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EmailInput_TextChanged(object sender, RoutedEventArgs e)
|
private void EmailInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
InputTextChanged((TextBox)sender, Validator.CheckEmailAddress);
|
InputTextChanged((TextBox)sender, Validator.CheckEmailAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EmailInput_LostFocus(object sender, RoutedEventArgs e)
|
private void EmailInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
InputLostFocus((TextBox)sender, Validator.CheckEmailAddress, null);
|
InputLostFocus((TextBox)sender, Validator.CheckEmailAddress, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LfbisNrInput_TextChanged(object sender, RoutedEventArgs e)
|
private void LfbisNrInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
InputTextChanged((TextBox)sender, Validator.CheckLfbisNr);
|
InputTextChanged((TextBox)sender, Validator.CheckLfbisNr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LfbisNrInput_LostFocus(object sender, RoutedEventArgs e)
|
private void LfbisNrInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||||
{
|
|
||||||
InputLostFocus((TextBox)sender, Validator.CheckLfbisNr, "Betriebsnummer ungültig");
|
InputLostFocus((TextBox)sender, Validator.CheckLfbisNr, "Betriebsnummer ungültig");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user