Tests: Update DatabaseSetup

This commit is contained in:
2024-02-13 11:29:23 +01:00
parent 825bd6f304
commit 912206f52d
3 changed files with 54 additions and 53 deletions

View File

@ -141,26 +141,10 @@ namespace Elwig {
MessageBox.Show("Invalid branch name in config!", "Invalid Branch Config", MessageBoxButton.OK, MessageBoxImage.Error);
Shutdown();
} else {
var entry = branches[Config.Branch.ToLower()];
ZwstId = entry.Item1;
BranchName = entry.Item2;
BranchPlz = entry.Item3;
BranchLocation = entry.Item4?.Split(" im ")[0].Split(" an ")[0].Split(" bei ")[0]; // FIXME
BranchAddress = entry.Item5;
BranchPhoneNr = entry.Item6;
BranchFaxNr = entry.Item7;
BranchMobileNr = entry.Item8;
SetBranch(branches[Config.Branch.ToLower()]);
}
} else if (branches.Count == 1) {
var entry = branches.First().Value;
ZwstId = entry.Item1;
BranchName = entry.Item2;
BranchPlz = entry.Item3;
BranchLocation = entry.Item4?.Split(" im ")[0].Split(" an ")[0].Split(" bei ")[0]; // FIXME
BranchAddress = entry.Item5;
BranchPhoneNr = entry.Item6;
BranchFaxNr = entry.Item7;
BranchMobileNr = entry.Item8;
SetBranch(branches.First().Value);
} else {
MessageBox.Show("Unable to determine local branch!", "Invalid Branch Config", MessageBoxButton.OK, MessageBoxImage.Error);
Shutdown();
@ -169,6 +153,21 @@ namespace Elwig {
base.OnStartup(evt);
}
public static void SetBranch(Branch b) {
SetBranch((b.ZwstId, b.Name, b.PostalDest?.AtPlz?.Plz, b.PostalDest?.AtPlz?.Ort.Name, b.Address, b.PhoneNr, b.FaxNr, b.MobileNr));
}
private static void SetBranch((string, string, int?, string?, string?, string?, string?, string?) entry) {
ZwstId = entry.Item1;
BranchName = entry.Item2;
BranchPlz = entry.Item3;
BranchLocation = entry.Item4?.Split(" im ")[0].Split(" an ")[0].Split(" bei ")[0]; // FIXME
BranchAddress = entry.Item5;
BranchPhoneNr = entry.Item6;
BranchFaxNr = entry.Item7;
BranchMobileNr = entry.Item8;
}
private void PrintingReadyChanged() {
Dispatcher.BeginInvoke(OnPrintingReadyChanged, new EventArgs());
}