Lieferscheine
This commit is contained in:
@ -20,6 +20,13 @@ namespace Elwig {
|
||||
public static readonly Config Config = new(DataPath + "config.ini");
|
||||
|
||||
public static string ZwstId { get; private set; }
|
||||
public static string BranchName { get; private set; }
|
||||
public static int? BranchPlz { get; private set; }
|
||||
public static string? BranchOrt { get; private set; }
|
||||
public static string? BranchAddress { get; private set; }
|
||||
public static string? BranchPhoneNr { get; private set; }
|
||||
public static string? BranchFaxNr { get; private set; }
|
||||
public static string? BranchMobileNr { get; private set; }
|
||||
public static IEnumerable<IScale> Scales { get; private set; }
|
||||
public static ClientParameters Client { get; private set; }
|
||||
|
||||
@ -48,13 +55,13 @@ namespace Elwig {
|
||||
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))
|
||||
);
|
||||
|
||||
Dictionary<string, string> branches = new();
|
||||
Dictionary<string, (string, string, int?, string?, string?, string?, string?, string?)> branches = new();
|
||||
using (var ctx = new AppDbContext()) {
|
||||
if (!ctx.Database.CanConnect()) {
|
||||
MessageBox.Show($"Invalid Database:\n\n{Config.DatabaseFile}", "Invalid Database", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Shutdown();
|
||||
} else {
|
||||
branches = ctx.Branches.ToDictionary(b => b.Name.ToLower(), b => b.ZwstId);
|
||||
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));
|
||||
}
|
||||
}
|
||||
Utils.RunBackground("HTML Initialization", () => Documents.Html.Init(PrintingReadyChanged));
|
||||
@ -88,10 +95,26 @@ namespace Elwig {
|
||||
MessageBox.Show("Invalid branch name in config!", "Invalid Branch Config", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Shutdown();
|
||||
} else {
|
||||
ZwstId = branches[Config.Branch.ToLower()];
|
||||
var entry = branches[Config.Branch.ToLower()];
|
||||
ZwstId = entry.Item1;
|
||||
BranchName = entry.Item2;
|
||||
BranchPlz = entry.Item3;
|
||||
BranchOrt = entry.Item4;
|
||||
BranchAddress = entry.Item5;
|
||||
BranchPhoneNr = entry.Item6;
|
||||
BranchFaxNr = entry.Item7;
|
||||
BranchMobileNr = entry.Item8;
|
||||
}
|
||||
} else if (branches.Count == 1) {
|
||||
ZwstId = branches.First().Value;
|
||||
var entry = branches.First().Value;
|
||||
ZwstId = entry.Item1;
|
||||
BranchName = entry.Item2;
|
||||
BranchPlz = entry.Item3;
|
||||
BranchOrt = entry.Item4;
|
||||
BranchAddress = entry.Item5;
|
||||
BranchPhoneNr = entry.Item6;
|
||||
BranchFaxNr = entry.Item7;
|
||||
BranchMobileNr = entry.Item8;
|
||||
} else {
|
||||
MessageBox.Show("Unable to determine local branch!", "Invalid Branch Config", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Shutdown();
|
||||
|
Reference in New Issue
Block a user