Do not require ComboBoxes to be valid if they are not required
This commit is contained in:
@ -13,7 +13,8 @@ namespace Elwig.Helpers {
|
|||||||
public DbSet<AT_Gem> Gemeinden { get; set; }
|
public DbSet<AT_Gem> Gemeinden { get; set; }
|
||||||
public DbSet<AT_Kg> Katastralgemeinden { get; set; }
|
public DbSet<AT_Kg> Katastralgemeinden { get; set; }
|
||||||
public DbSet<AT_Ort> Orte { get; set; }
|
public DbSet<AT_Ort> Orte { get; set; }
|
||||||
public DbSet<AT_PlzDest> Postleitzahlen { get; set; }
|
public DbSet<AT_Plz> Postleitzahlen { get; set; }
|
||||||
|
public DbSet<AT_PlzDest> PlzDestinations { get; set; }
|
||||||
public DbSet<PostalDest> PostalDestinations { get; set; }
|
public DbSet<PostalDest> PostalDestinations { get; set; }
|
||||||
public DbSet<Branch> Branches { get; set; }
|
public DbSet<Branch> Branches { get; set; }
|
||||||
public DbSet<WbKg> WbKgs { get; set; }
|
public DbSet<WbKg> WbKgs { get; set; }
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
using Elwig.Helpers;
|
using Elwig.Helpers;
|
||||||
using Elwig.Models;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
||||||
namespace Elwig.Windows {
|
namespace Elwig.Windows {
|
||||||
public abstract class AdministrationWindow : ContextWindow {
|
public abstract class AdministrationWindow : ContextWindow {
|
||||||
|
|
||||||
protected Control[] ExemptInputs { private get; set; }
|
protected Control[] ExemptInputs { private get; set; }
|
||||||
protected Control[] RequiredInputs { private get; set; }
|
protected Control[] RequiredInputs { private get; set; }
|
||||||
private TextBox[] TextBoxInputs;
|
private TextBox[] TextBoxInputs;
|
||||||
@ -66,14 +64,10 @@ namespace Elwig.Windows {
|
|||||||
if (input is TextBox tb && tb.Text.Length == 0) {
|
if (input is TextBox tb && tb.Text.Length == 0) {
|
||||||
Utils.SetInputInvalid(input);
|
Utils.SetInputInvalid(input);
|
||||||
Valid[input] = false;
|
Valid[input] = false;
|
||||||
} else if (input is ComboBox cb && cb.SelectedItem == null) {
|
} else if (input is ComboBox cb && cb.SelectedItem == null && cb.ItemsSource != null) {
|
||||||
Utils.SetInputInvalid(input);
|
Utils.SetInputInvalid(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (var cb in ComboBoxInputs) {
|
|
||||||
if (cb.ItemsSource != null && cb.SelectedItem == null)
|
|
||||||
Utils.SetInputInvalid(cb);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void LockInputs() {
|
protected void LockInputs() {
|
||||||
@ -155,8 +149,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
protected void UpdatePlz(TextBox plzInput, ComboBox ortInput) {
|
protected void UpdatePlz(TextBox plzInput, ComboBox ortInput) {
|
||||||
if (plzInput.Text.Length == 4) {
|
if (plzInput.Text.Length == 4) {
|
||||||
int plz = int.Parse(plzInput.Text);
|
ortInput.ItemsSource = Context.Postleitzahlen.Find(int.Parse(plzInput.Text))?.Orte.ToList();
|
||||||
ortInput.ItemsSource = Context.Postleitzahlen.Where(p => p.Plz == plz).ToHashSet();
|
|
||||||
} else {
|
} else {
|
||||||
ortInput.ItemsSource = null;
|
ortInput.ItemsSource = null;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
using Elwig.Helpers;
|
using Elwig.Helpers;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace Elwig.Windows {
|
namespace Elwig.Windows {
|
||||||
public abstract class ContextWindow : Window {
|
public abstract class ContextWindow : Window {
|
||||||
|
|
||||||
protected readonly AppDbContext Context;
|
protected readonly AppDbContext Context;
|
||||||
|
|
||||||
public ContextWindow() : base() {
|
public ContextWindow() : base() {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@ -29,7 +28,7 @@ namespace Elwig.Windows {
|
|||||||
};
|
};
|
||||||
RequiredInputs = new Control[] {
|
RequiredInputs = new Control[] {
|
||||||
MgNrInput, GivenNameInput, FamilyNameInput,
|
MgNrInput, GivenNameInput, FamilyNameInput,
|
||||||
AddressInput, PlzInput,
|
AddressInput, PlzInput, OrtInput, BillingOrtInput,
|
||||||
BusinessSharesInput, BranchInput, DefaultKgInput
|
BusinessSharesInput, BranchInput, DefaultKgInput
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user