Compare commits

...

219 Commits

Author SHA1 Message Date
d8c3578144 Version bump to 7.2.14.2 2026-01-30 07:15:56 +01:00
905a3cc636 fixed summing it up 2026-01-29 18:34:14 +01:00
3cfd642f66 Fixed WAS Excel import and added static utility function for both usage locations 2026-01-29 09:40:01 +01:00
a34c5b19ef Bumped Version to 7.2.14.1 2026-01-28 08:44:57 +01:00
79ddbf1572 Added a manual grid refresh after validation since this seems not to work automatically anymore 2026-01-28 08:35:41 +01:00
9d4f608383 fixed message group name settings in extra WAS validation 2026-01-28 07:50:52 +01:00
5932630635 Validation now runs async and hopefully solves the problem of some users where the app got unresponsive in the meantime 2026-01-27 11:24:19 +01:00
a1f6e6c113 Changed validation rules for WAS elements (Waste) 2026-01-26 18:56:24 +01:00
77c0491aa1 Color tab if the sheet contains a changed cell in ExcelComparer 2026-01-26 14:45:59 +01:00
d02cb0d56b Changed all Excel access to read-only access if sheet is actually opened for reading.
This should avoid errors when the sheet is still open in Excel.
2026-01-26 13:48:17 +01:00
782ae3138e Increased version to 7.2.14 2026-01-26 13:46:51 +01:00
1a89c204c9 Fixed import to l10ports visited and last30 days and centralized this code at ExcelLocalImportHelper.
In the future, I should refactor all the other places as well
2026-01-21 09:13:11 +01:00
d5d5be67e7 Bumped version to 7.2.13.1 2025-11-21 09:23:12 +01:00
f2a9bc9e0f Fixed small issues when reading Excel files using ClosedXML 2025-11-21 09:22:34 +01:00
e8b094b700 Small bugfix concerning saving TIEFD value in form sheet mode 2025-11-20 09:48:46 +01:00
03a9bd6e8e Version bump to 7.2.13.0 and updating all dependencies 2025-11-18 07:48:29 +01:00
bc64b14e34 Removed the rest of Excel.Interop references 2025-11-18 07:13:25 +01:00
76a8d33c2a Replaced ExcelSheetComparer simple functionality 2025-11-18 07:13:25 +01:00
7a7ea56c0f Replaced ExcelDataReader with ClosedXML code in remaining functions 2025-11-18 07:13:25 +01:00
a8adcb3167 Replaced Waste manual excel import with ClosedXML implementation 2025-11-18 07:13:25 +01:00
dbf15539d9 Added ref to ClosedXML lib and replaced usage of ExcelDataReader in PAS/CREW manual import 2025-11-18 07:13:25 +01:00
7a002abf63 Updated current packages 2025-11-18 07:13:19 +01:00
4257fdbea0 Added extra verification to catch a maybe very rare error 2025-11-10 17:00:08 +01:00
a3d6ed337a Improved error handling for message telemetry when sending messages 2025-11-10 16:48:10 +01:00
6375639387 Version bump to 7.2.12.7 2025-11-06 10:18:26 +01:00
9b45b902c7 Updated Gefahrgutliste 2025-11-06 10:09:02 +01:00
4174ea9e65 Net mass is now set to gross mass since the workaround doesn't seem to be necessary any more 2025-11-05 07:57:17 +01:00
b1b01532ca Version bump to 7.2.12.6 2025-10-23 22:00:33 +02:00
5eb181de91 minor fixes 2025-10-23 10:50:08 +02:00
6076b2529e Bumped Version to 7.2.12.5 2025-10-22 15:00:16 +02:00
5ee7cf2f2a Update messages when a id is received to show green line 2025-10-22 14:58:13 +02:00
be78399def Error correction fixes and some xtra functionality for easy peasy 2025-10-22 11:45:54 +02:00
3735735ef7 Error correction fixes 2025-10-22 09:48:29 +02:00
8bbf7e9cc9 Version bump to 7.2.12.4 2025-10-16 14:50:23 +02:00
83edca21de Fixes for comments 2025-10-15 07:08:58 +02:00
933a283a4b Version bump to 7.2.12.3 2025-10-14 09:15:57 +02:00
b6c1de3817 Added lighter green background for updated class in overview 2025-10-14 09:08:43 +02:00
bdc7131a1e Updated NuGet for ENI and NSWSendService 2025-10-14 08:53:41 +02:00
46ca051331 Refined the Easy Peasy Control with feedback from Christin 2025-10-10 09:57:49 +02:00
1d44b156f4 Bumped version and changed sendall button preselection behavior 2025-10-06 09:13:51 +02:00
eae9b42266 Fixed empty string/null comparison for waste disposal change detection 2025-10-06 08:47:59 +02:00
284d669dc7 lighter success background row for overview 2025-10-04 11:17:58 +02:00
731a7eff9c changed some details across various trello cards 2025-10-04 10:59:28 +02:00
4b49c78166 WAS not marked for change if the AGNT template (through WasteServiceProvider) did not change a field 2025-10-04 10:59:27 +02:00
d649c4ac16 Do not change PRE72H on Excel import for transit shipcalls 2025-10-04 10:59:27 +02:00
e3b12ae531 Added parsing from Excel and fixed grid refresh error 2025-10-04 10:59:27 +02:00
a0b72f63a8 Improved window labels and and layout 2025-10-04 10:59:27 +02:00
310819a527 bumped version to 7.2.12.1 2025-10-04 10:59:27 +02:00
012cbc4d6d Fix save and restore state 2025-10-04 10:59:27 +02:00
fa460ec8e4 Version bump 2025-10-04 10:59:11 +02:00
ec81631bd8 Adjusted the exporter to match the imported file better 2025-10-04 10:57:34 +02:00
e7ca08c65d Simpler erster ChatGPT Wurf :-) 2025-10-04 10:57:34 +02:00
680ebcdf84 Added plugin control 2025-10-04 10:57:34 +02:00
e965bc6b89 Version bump to 7.2.11.3 2025-09-10 17:11:48 +02:00
e96b03d595 fixed gefahrgutliste (this time including un-assigned entries) 2025-09-10 17:11:29 +02:00
6eb265ea55 Fixed a bug, updated hazard goods list and bumped version to 7.2.11.2 2025-09-10 11:51:04 +02:00
f58e9e7079 Version bump to 7.2.11.1 2025-09-04 07:42:17 +02:00
92998c2add Bugfixes and adjustments 2025-09-04 07:41:47 +02:00
c1e450c18b Updated assemblies to 7.2.11 2025-09-02 10:02:04 +02:00
8a836ed096 Applied some rules to the ready to send dialog (preselected messages) 2025-09-02 09:54:44 +02:00
cf81ec0225 Added default waste descriptions again for some waste types 2025-09-02 09:54:19 +02:00
43fc89c7d3 Highlight some overview rows depending on status 2025-09-02 08:35:03 +02:00
96ddbd5e0a Adjusted column width on overview page 2025-09-02 08:15:29 +02:00
3dd2439524 Untrack LockingService.csproj.user 2025-09-02 07:47:12 +02:00
1b97c7836b Bumped version and update Nuget packages 2025-09-02 07:44:58 +02:00
0e65d37ef9 Version bump to 7.2.10.8 2025-08-27 08:24:40 +02:00
0e43233edc fix cast when sending messages from grid 2025-08-27 08:20:19 +02:00
c650c78d90 Bumped version to 7.2.10.7 2025-08-25 20:35:13 +02:00
dd11e46a18 Bump version to 7.2.10.6 2025-08-25 20:29:38 +02:00
f5d473574e minor adjustments 2025-08-25 16:35:09 +02:00
97859d3cc8 Fixed distance of cancel button 2025-08-17 09:16:00 +02:00
dfa5b1cf33 Bump version to 7.2.10.5 2025-08-05 10:05:42 +02:00
a434b419ad Fixed a few bugs in the modified Excel import 2025-08-05 09:57:48 +02:00
973b0c267c Fixed small visual bugs 2025-08-05 09:05:11 +02:00
82c01c8936 Version bump to 7.2.10.4 2025-08-04 19:10:48 +02:00
1df95d2807 Excel: changed 2 subtables of SEC and a subtable of MDH to Dakosy read mode 2025-08-04 19:01:31 +02:00
9ad543e705 Fixes for things not understood.. ^^ 2025-08-04 18:06:47 +02:00
e620c2d0e5 Skip when HAZA HAZD BPOL are 'empty' based on the empty definition 2025-08-04 14:39:35 +02:00
f833aab844 Bump version to 7.2.10.3 2025-07-31 08:14:52 +02:00
4eacf85d8d if wrong values keep empty, if missing: use default placeholders 2025-07-30 17:27:37 +02:00
ce97aeca27 Always leave out ATA/ATD from send all dialog 2025-07-30 17:11:05 +02:00
ad2f7afd16 Added old and new value to confirmation dialog text 2025-07-30 16:51:22 +02:00
494e377b98 Bump Version to 7.2.10.2 2025-07-26 11:13:10 +02:00
9a4831283d Make WAS import via excel even dumber 2025-07-26 11:04:37 +02:00
0c9b38ddd9 Add a confirmation dialog if the waste service disposal provider field is not empty when the template is applied 2025-07-26 10:58:39 +02:00
54aa91afc1 Fixes for send all functionality 2025-07-26 10:44:22 +02:00
b979136467 Small adjustments to overview display 2025-07-26 09:55:01 +02:00
85bfd8b434 Bump version to 7.2.10.1 2025-07-26 09:31:19 +02:00
ffca8e5bdd Preview for send all functionality 2025-07-24 16:16:28 +02:00
4d65172fbf New Overview layout 2025-07-24 14:56:09 +02:00
87f5e601a3 Updated NuGet packages 2025-07-24 09:05:08 +02:00
36a79fe2dd Removing template from WAS, moving wasteserviceprovider template entry to AGNT 2025-07-23 18:50:08 +02:00
4d131f718f Remove default values from Waste import for amount and locode 2025-07-23 09:47:57 +02:00
8bc2ae99a8 Version bump to 7.2.10 2025-07-23 09:27:45 +02:00
57ed0b5b19 Bugfix font-resolver new MigraDoc Version 2025-07-15 11:09:23 +02:00
e2f7ef1486 Merge branch 'feature/echolot' into develop 2025-07-14 07:27:43 +02:00
d1e2e67d5f added SERV templates to the sheet display 2025-07-09 08:19:12 +02:00
ef96795bbf Fixed saving of name of master after programmatic update 2025-07-09 07:33:23 +02:00
abc2afdc11 SERV templates (only in classic mode yet) 2025-07-08 08:43:27 +02:00
626b058119 Add a button to copy masters name from first CREWA entry 2025-07-07 15:52:59 +02:00
a4a74da6f9 Layout changed in INFO, classic mode 2025-07-07 14:31:04 +02:00
37122c4144 Removing CREW effects from validation 2025-07-07 13:58:48 +02:00
37ee8e1edf Version bump and package updates 2025-07-07 13:39:37 +02:00
8e5a5b2d62 Added echolot tool 2025-06-15 13:58:33 +02:00
ba59b69f92 Updated port info database entries again and bumped version to 7.2.8 2025-05-14 10:06:52 +02:00
43df352318 Version bump and updated Nuget packages 2025-05-11 12:34:12 +02:00
1c5e938f9a Added DEWVN port mappings and allow multi-delete in value port mappings 2025-05-11 12:24:09 +02:00
2608b4fd5a Fixed broken image in report and bumped version to 7.2.7.9 2025-03-14 16:31:20 +01:00
9462920fce fixed dependencies 2025-03-14 15:57:10 +01:00
e50d165dc3 Added some missing defaults and bumped test version to 7.2.7.7 2025-03-14 08:06:12 +01:00
b7f0108f52 Fixed bug where index would not be read correctly 2025-03-14 07:54:22 +01:00
d1c131c52b Added logic to return to the previously selected tab page on a detail control,
but only if the control has a tab control and the save button was hit. In this case a complete reload happens.
2025-03-07 16:04:53 +01:00
83d57328fc Added some boolean defaults to avoid three-state checkboxes in display 2025-03-07 14:46:26 +01:00
c85291b179 fix for some smaller issues 2025-03-07 14:06:53 +01:00
78a3168d79 Even more fixes 2025-03-06 10:59:06 +01:00
8029aeeac3 Small corrections for testing feedback 2025-03-05 12:05:04 +01:00
bcee0383b7 smaller bugfixes for comments 2025-03-05 10:52:36 +01:00
6d0a258236 second number of smaller issues 2025-03-04 12:59:51 +01:00
c206226b3c a number of smaller issues 2025-03-04 10:02:39 +01:00
11d6bedc71 increase waste grid height 2025-03-04 09:15:36 +01:00
db92b35dec fixed layout of DG 2025-03-04 09:08:13 +01:00
4f1e4fca12 Fixed data binding on crew/pas counters 2025-03-04 08:48:31 +01:00
ef5cca3aab Resized some sheet displays by 50% to make them better align left 2025-03-04 08:03:38 +01:00
d97692ff94 Moved display selection to pw change, fixed bug in BRKD, increased version 2025-03-04 07:46:11 +01:00
afb33fd249 Updated package refs in test version and created a last-minute test release 2025-03-02 11:56:58 +01:00
6b456fc4f4 Merge branch 'feature/spreadsheet_layout' into develop 2025-02-25 10:52:15 +01:00
cabbdd88d6 Version bump to 7.2.6.3 2025-02-16 13:36:20 +01:00
b29811e6d7 Imported new DG table (GEFAHRGUTLISTE.xlsx) 2025-02-16 13:22:36 +01:00
63aca94ec4 Added new key for expired publish key 2025-02-12 09:30:50 +01:00
a10e7178f2 Added new key for expired publish key 2025-02-12 09:28:30 +01:00
f53b37eb12 Included tabs in some views to make the display more compact 2025-02-12 09:27:53 +01:00
661768abdd Grouped some view with tab controls as defined by CH 2025-02-11 11:26:46 +01:00
2004362e1a Set SetEnabled per override on top-level groupboxes. Not sure yet if this is going to cut it. 2025-01-31 18:28:42 +01:00
071b0ff5ee fix dbh send version string 2025-01-31 15:58:57 +01:00
7c8eed08bd Added sheet / logic part 12,13 ATA and WAS_RCPT 2025-01-30 09:25:42 +01:00
006a253fd7 Fixed test comments and bumped version to 7.2.6.2 2025-01-30 07:44:14 +01:00
40b9fff121 Added sheet / logic part 10,11 HAZ arrival/departure 2025-01-29 20:36:32 +01:00
082266f47c Version bump to 7.2.7 2025-01-29 16:13:52 +01:00
f3e398e07d Added sheet / logic part 8,9 PAS arrival/departure 2025-01-29 16:10:13 +01:00
c4006d0585 Added sheet / logic part 7 CREW departure 2025-01-29 15:07:54 +01:00
579e704a1b Added sheet / logic part 6 CREW arrival 2025-01-29 14:29:26 +01:00
0d80f6e514 bumped version to 7.2.6.1 2025-01-29 08:07:29 +01:00
b1051546b7 Fixed test comments 2025-01-29 07:57:04 +01:00
daf20a49b3 Added sheet / logic to part 5 Ship data 2025-01-27 15:47:28 +01:00
ebbcd1ad97 Added sheet / logic to part 4 Pre-Departure 2025-01-27 08:49:59 +01:00
51d6aeee74 Added sheet / logic to part 3 Pre-Arrival 2025-01-24 15:53:57 +01:00
ee1c17bb4f Added sheet / logic to Part 2. Port 2025-01-24 07:57:09 +01:00
e0e46b8613 Added logic to Part 1 Voyage 2025-01-23 16:06:34 +01:00
3c3fa5e1bd Added sample sheet control, made display type selectable through reporting party dialog, updated references 2025-01-22 17:05:28 +01:00
b2062c3227 Updated NuGet packages for NSW send service 2025-01-22 07:37:13 +01:00
2ce1d692d2 Updated old SQLite refs. These installer refs should go somewhere else 2024-12-29 13:07:12 +01:00
c8e22c6511 Fixed import error where a string was erroneously converted to a date 2024-12-29 12:35:51 +01:00
bdb50ea901 make KGM mass fields > 0 if they are included in HAZA HAZD 2024-12-29 11:52:00 +01:00
c15fdb8ee2 Set function on board to unknown if left null or empty for CREW 2024-12-29 11:28:01 +01:00
6ee9293fc8 Allow null for place of birth and country of birth for CREW/PAS 2024-12-29 10:54:43 +01:00
b0b6cef327 Limit BKRA/D fuel type to 25 chars (was 100) 2024-12-29 10:32:44 +01:00
c5bfc505d8 Version bump and library updates 2024-12-29 10:22:53 +01:00
b552bf2dd0 Make HiS-Nord transmitter a bit more verbose when it returns a failure in log 2024-11-07 14:35:39 +01:00
14931ce2c3 Version bump to 7.2.5.3 2024-11-06 10:22:53 +01:00
8e1d41cc0d create errors instead of violations for too large waste amounts 2024-11-06 10:22:31 +01:00
11b9b14fbd Version bump to 7.2.5.2 2024-11-05 14:51:44 +01:00
0dcae7cafe Limit waste input to 9999.999 2024-11-05 14:51:27 +01:00
5e8f111997 Added DEWHV back to locode DB 2024-11-04 15:42:59 +01:00
06509767e5 Fixed HAZ validation logic when there are positions and checkbox is set 2024-11-04 15:42:42 +01:00
ed666aff0c Disallow values larger than 10000 for waste quantities and improve the violation wording 2024-11-04 14:59:46 +01:00
135542ed70 Eliminated code warnings 2024-10-29 09:58:24 +01:00
3c57936caa Added validation if PRE72H is marked as tanker compared with STAT ship type 2024-10-26 12:43:28 +02:00
82a98ab9e6 Added violation for missing no DPG flag set 2024-10-25 19:09:23 +02:00
2ebb3f1838 Bump version to 7.2.5 2024-10-25 12:58:36 +02:00
4b34ca9c31 fixed small bug in log output 2024-10-23 08:31:24 +02:00
3c1e35a012 fixed small bug in log output 2024-10-23 07:27:14 +02:00
d299a286a9 Updated alle sender packages to release NSWSendService 2024-10-21 12:14:18 +02:00
74665defb3 Replaced MessageBox, returned to sqlite Version 117 2024-10-19 18:03:20 +02:00
2bb1dd03f4 Consolidated / Upgraded packages Pt.2 2024-10-14 07:31:46 +02:00
472c1e1b81 Consolidated / Upgraded packages Pt.1 2024-10-14 07:29:13 +02:00
c636c9b931 Merge branch 'feature/new_transmitter_tool' into develop 2024-10-14 07:21:32 +02:00
a3f2e4f7b3 Merge branch 'feature/new_transmitter_tool' into develop 2024-10-14 07:19:09 +02:00
56934660c1 small bugfixes regarding failsave moving of files and setting core state after receiving dbh messages 2024-09-27 10:42:27 +02:00
7db2736e12 removed unused/Test attribute 2024-09-09 18:35:39 +02:00
63a1436afc complete grid reload in case of dialog-editing a failed validation result entry 2024-09-02 14:24:49 +02:00
7e992576c8 Build project version bump to 7.2.4.2 2024-09-01 11:24:11 +02:00
ff574c1a5c Fixed missing enum vals 2024-09-01 11:22:30 +02:00
b5db6cdb33 fixed typo 2024-09-01 10:42:10 +02:00
259fe00f43 Update to new HIS-Nord Transmitter Tool (still experimental), upgraded log4net refs etc. 2024-08-28 09:40:03 +02:00
7967b4336d Updated dangerous goods table with provided Excel sheet 2024-08-26 14:46:18 +02:00
5d02cf1cfa Multi-Edit from Grid for CREWA/D und PASA/D 2024-08-26 11:08:36 +02:00
5085b82a13 bumped version to 7.2.4.1 2024-08-24 08:11:31 +02:00
50b65e6dea Fixed async call bug 2024-08-24 08:10:37 +02:00
c46881698f Fixed bug and added functionality to BKRD, LADG and WAS_RCPT 2024-08-24 07:19:24 +02:00
a90aa4b1ab fixed saving if change is only in grid 2024-08-14 11:52:35 +02:00
d83413c623 Added in-grid editing experimentically for BKRA in Arrival detail control 2024-08-14 11:38:27 +02:00
36b596709a Added special case for DEWHV for new Id dialogs (duh) 2024-08-12 16:09:27 +02:00
40908e1bb3 Remove DEWHV as a valid code for declaration classes, but leave it for initial application 2024-08-12 15:27:14 +02:00
c26c19d401 Added delete all buttons to CREWA CREWD PASA PASD in Border police ctrl 2024-08-12 13:56:37 +02:00
bed3fc397a Add copy shipname button to search control 2024-08-12 12:40:23 +02:00
c11e571473 Do not show ATA message as changed when changing CORE values on Overview page 2024-08-12 12:16:25 +02:00
c4cd477002 Allow trailing characters (m, cbm etc.) when importing numbers in Excel 2024-08-12 11:14:46 +02:00
28878447b8 Increased version to 7.2.4 2024-08-11 09:34:55 +02:00
47d6d4d073 Changed a dialog when closing a core without having SERV sent for DEHAM 2024-08-02 15:45:44 +02:00
a59daa7a78 Small bugfix and version bump 2024-07-30 08:36:11 +02:00
121ccaf295 Changed automatic notification if a call to BRE BRV or HAM is closed without SERV data 2024-07-29 07:54:17 +02:00
a4c340c2ec Adjust document expiry date to 31.12.2100 for all PAS/CREW if date cannot be read 2024-07-29 07:00:39 +02:00
3743b55ef6 Version bump to 7.2.3 2024-07-29 06:55:19 +02:00
f9f8980e09 completely reload core after copy operation 2024-07-23 08:48:27 +02:00
1947c30010 Removed unused VorgaengeControl 2024-07-23 07:24:40 +02:00
e0ca7a9074 Added templates for WAS_RCPT the same as for WAS. Templates are shared between these controls 2024-07-22 18:51:49 +02:00
d4db41de2c treat CREWA/D PASA/D the same on excel import for lastname and IdentityDocumentExpiryDate 2024-07-22 14:37:05 +02:00
fadc975b83 Validation for SERV missing or not confirmed 2024-07-22 14:20:12 +02:00
f6d74e87db fixed wrong existance check for new serv entries 2024-07-22 13:58:48 +02:00
ee6658bafd Replaced port area helper and avoided crash when searching at a harbour that has no entries 2024-07-22 13:29:54 +02:00
703986bbbc Updated address for Maersk when auto-generating SERV class entry 2024-07-12 13:28:33 +02:00
9d4eea244a example for evaluation telemetry 2024-07-08 07:19:09 +02:00
c7e502d658 Bugfix für gleichzeitiges Schließen / Ändern von Dialogen
..führt offenbar zu Placement Problemen (Timing). Für Error/Validation habe ich daher unterschiedliche Position genommen. Im
Grunde ist das aber immer noch ein gräßlicher Häck der von der Tatsache ablenkt, dass jedes Fenster seinen Position separat
gespeichert haben sollte.
2024-03-26 12:04:29 +01:00
7950d16f2b Merge branch 'feature/send_telemetry' into develop 2024-03-22 13:20:48 +01:00
cb1ff8a533 added special Excel import case for BRV/BRE, NSW by BSMD in INFO class 2024-03-21 08:19:41 +01:00
0d0cbe1949 fixed merge conflict 2024-03-20 08:26:56 +01:00
a695da8b4e Fixed another dumb error 2024-03-20 08:25:32 +01:00
5ac41ec075 fixed some small bugs and created new test version 7.2.2.6 2024-03-16 19:26:42 +01:00
cdeae588be Fixed some bugs with FCT Junge in Port notification ctrl. 2024-03-15 08:34:48 +01:00
202 changed files with 15769 additions and 3097 deletions

View File

@ -1,20 +1,8 @@
// Copyright (c) 2017 Informatibüro Daniel Schick // Copyright (c) 2017 Informatibüro Daniel Schick
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using bsmd.database; using bsmd.database;
using System.Windows.Controls;
using System.Windows.Input;
namespace ENI2 namespace ENI2
{ {
@ -44,7 +32,6 @@ namespace ENI2
DataGrid grid = sender as DataGrid; DataGrid grid = sender as DataGrid;
if(grid?.SelectedItems?.Count == 1) if(grid?.SelectedItems?.Count == 1)
{ {
DataGridRow dgr = grid.ItemContainerGenerator.ContainerFromItem(grid.SelectedItem) as DataGridRow;
MessageCore selectedCore = grid.SelectedItem as MessageCore; MessageCore selectedCore = grid.SelectedItem as MessageCore;
this.DisplayCore(selectedCore); this.DisplayCore(selectedCore);
} }
@ -63,7 +50,7 @@ namespace ENI2
{ {
if((this.MessageCoreSelected != null) && (aMessageCore != null)) if((this.MessageCoreSelected != null) && (aMessageCore != null))
{ {
this.MessageCoreSelected(aMessageCore); this.MessageCoreSelected(aMessageCore, DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].ShipcallDisplayMode);
} }
} }

View File

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
(c) 2017-present Informatikbüro Daniel Schick (c) 2017-present Informatikbüro Daniel Schick
--> -->
<configuration> <configuration>
<configSections> <configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ENI2.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> <section name="ENI2.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup> </sectionGroup>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ENI2.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/> <section name="ENI2.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup> </sectionGroup>
</configSections> </configSections>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" />
</startup> </startup>
<applicationSettings> <applicationSettings>
<ENI2.Properties.Settings> <ENI2.Properties.Settings>
@ -59,16 +59,86 @@
<setting name="W2Top" serializeAs="String"> <setting name="W2Top" serializeAs="String">
<value>0</value> <value>0</value>
</setting> </setting>
<setting name="W3Left" serializeAs="String">
<value>0</value>
</setting>
<setting name="W3Top" serializeAs="String">
<value>0</value>
</setting>
</ENI2.Properties.Settings> </ENI2.Properties.Settings>
</userSettings> </userSettings>
<system.serviceModel> <system.serviceModel>
<bindings> <bindings>
<basicHttpBinding> <basicHttpBinding>
<binding name="BasicHttpBinding_IService" maxReceivedMessageSize="2147483647"/> <binding name="BasicHttpBinding_IService" maxReceivedMessageSize="2147483647" />
</basicHttpBinding> </basicHttpBinding>
</bindings> </bindings>
<client> <client>
<endpoint address="http://localhost:11651/LockingService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService" contract="LockingServiceReference.IService" name="BasicHttpBinding_IService"/> <endpoint address="http://localhost:11651/LockingService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService" contract="LockingServiceReference.IService" name="BasicHttpBinding_IService" />
</client> </client>
</system.serviceModel> </system.serviceModel>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.3" newVersion="9.0.0.3" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.4.0" newVersion="4.2.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.1" newVersion="6.0.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.2" newVersion="6.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.3" newVersion="9.0.0.3" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.3" newVersion="9.0.0.3" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Pkcs" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.6.0" newVersion="4.1.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DocumentFormat.OpenXml.Framework" publicKeyToken="8fb06cb64d019a17" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="8fb06cb64d019a17" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.HashCode" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration> </configuration>

View File

@ -6,20 +6,22 @@ using System.Windows;
using System.Windows.Markup; using System.Windows.Markup;
using bsmd.database; using bsmd.database;
using log4net;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System; using System;
using System.Net;
using ENI2.LockingServiceReference; using ENI2.LockingServiceReference;
using ENI2.Util; using ENI2.Util;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
namespace ENI2 namespace ENI2
{ {
/// <summary> /// <summary>
/// Interaction logic for App.xaml /// Interaction logic for App.xaml
/// </summary> /// </summary>
public partial class App : Application public partial class App : System.Windows.Application
{ {
// "global" statics, da gibt es sicher noch einen eleganteren Weg.. // "global" statics, da gibt es sicher noch einen eleganteren Weg..
private static ServiceClient _lockingServiceClient = null; private static ServiceClient _lockingServiceClient = null;
@ -30,6 +32,8 @@ namespace ENI2
private ManualResetEvent ResetSplashCreated; private ManualResetEvent ResetSplashCreated;
private Thread _splashThread; private Thread _splashThread;
private readonly ILog _log = LogManager.GetLogger(typeof(App).Name);
public App() : base() public App() : base()
{ {
this.Dispatcher.UnhandledException += Dispatcher_UnhandledException; this.Dispatcher.UnhandledException += Dispatcher_UnhandledException;
@ -68,12 +72,10 @@ namespace ENI2
// initialize static / localized lookups from sqlite database // initialize static / localized lookups from sqlite database
string langKey = CultureInfo.CurrentCulture.TwoLetterISOLanguageName; string langKey = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
Dictionary<int, string> cargoHandlingDict = LocalizedLookup.getLADGCargoHandlingStrings(langKey); Dictionary<int, string> cargoHandlingDict = LocalizedLookup.getLADGCargoHandlingStrings(langKey);
foreach (int key in cargoHandlingDict.Keys) foreach (int key in cargoHandlingDict.Keys)
LADG.CargoHandlingDict.Add(key, cargoHandlingDict[key]); LADG.CargoHandlingDict.Add(key, cargoHandlingDict[key]);
LADG.MVSHLocodes.AddRange(LocalizedLookup.getMVSHLocodes()); LADG.MVSHLocodes.AddRange(LocalizedLookup.getMVSHLocodes());
EventManager.RegisterClassHandler(typeof(DatePicker), DatePicker.PreviewKeyDownEvent, new KeyEventHandler(this.DatePicker_PreviewKeyDown)); EventManager.RegisterClassHandler(typeof(DatePicker), DatePicker.PreviewKeyDownEvent, new KeyEventHandler(this.DatePicker_PreviewKeyDown));
CREW.NationalityDict = LocalizedLookup.getNationalities(); CREW.NationalityDict = LocalizedLookup.getNationalities();
STAT.VesselTypeDict = LocalizedLookup.getVesselTypes(); STAT.VesselTypeDict = LocalizedLookup.getVesselTypes();
@ -84,7 +86,7 @@ namespace ENI2
LADG.CargoCodesNST3 = LocalizedLookup.getCargoCodesNST3(); LADG.CargoCodesNST3 = LocalizedLookup.getCargoCodesNST3();
// Load import value mappings // Load import value mappings
ValueMapping.LoadDicts(); Task.Run(async () => await ValueMapping.LoadDicts());
// Preload validation fields // Preload validation fields
List<ValidationField> vFields = bsmd.database.ValidationRule.ValidationFields; List<ValidationField> vFields = bsmd.database.ValidationRule.ValidationFields;
@ -154,9 +156,9 @@ namespace ENI2
private void Dispatcher_UnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) private void Dispatcher_UnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{ {
string errorMessage = string.Format("An unhandled exception occurred: {0}\r\n{1}", e.Exception.Message, e.Exception.StackTrace); string errorMessage = string.Format("An unhandled exception occurred: {0}\r\n{1}", e.Exception.Message, e.Exception.StackTrace);
MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error); Xceed.Wpf.Toolkit.MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
// TODO: Dieser Fehler muss irgendwohin gesendet / gespeichert werden
e.Handled = true; e.Handled = true;
_log.Error(errorMessage);
} }
private void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e) private void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e)

View File

@ -56,6 +56,33 @@
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
<!-- Validation Error Template for a DataGrid Row -->
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="ValidationErrorTemplate">
<Setter.Value>
<ControlTemplate>
<Grid Margin="0,-2,0,-2"
ToolTip="{Binding RelativeSource={RelativeSource
FindAncestor, AncestorType={x:Type DataGridRow}},
Path=(Validation.Errors)[0].ErrorContent}">
<Ellipse StrokeThickness="0" Fill="Red"
Width="{TemplateBinding FontSize}"
Height="{TemplateBinding FontSize}" />
<TextBlock Text="!" FontSize="{TemplateBinding FontSize}"
FontWeight="Bold" Foreground="White"
HorizontalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type ToolTip}" > <Style TargetType="{x:Type ToolTip}" >
<Setter Property="OverridesDefaultStyle" Value="true" /> <Setter Property="OverridesDefaultStyle" Value="true" />

View File

@ -8,6 +8,7 @@ using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
using System.Windows.Threading;
namespace ENI2.Controls namespace ENI2.Controls
{ {
@ -161,8 +162,9 @@ namespace ENI2.Controls
} }
if (!abort) if (!abort)
{ {
var tabControl = Parent as ItemsControl; var tabControl = Parent as TabControl;
tabControl.Items.Remove(this); tabControl.SelectedItem = null;
_ = Dispatcher.BeginInvoke(new Action(() => tabControl.Items.Remove(this)), DispatcherPriority.Background);
} }
}; };
dockPanel.Children.Add(closeButton); dockPanel.Children.Add(closeButton);

View File

@ -56,6 +56,7 @@ namespace ENI2.Controls
// das hier bildet 1:1 das Kontext-Menü des ANSW ab // das hier bildet 1:1 das Kontext-Menü des ANSW ab
public event Action<DatabaseEntity> EditRequested; public event Action<DatabaseEntity> EditRequested;
public event Action<List<DatabaseEntity>> MultiEditRequested;
public event Action<DatabaseEntity> DeleteRequested; public event Action<DatabaseEntity> DeleteRequested;
public event Action CreateRequested; public event Action CreateRequested;
public event Action RefreshGrid; public event Action RefreshGrid;
@ -206,6 +207,14 @@ namespace ENI2.Controls
if (this.SelectedItems[0] is DatabaseEntity selectedEntity) if (this.SelectedItems[0] is DatabaseEntity selectedEntity)
this.EditRequested?.Invoke(selectedEntity); this.EditRequested?.Invoke(selectedEntity);
} }
if((this.SelectedItems != null) && (this.SelectedItems.Count > 1) && !this.IsReadOnly)
{
List<DatabaseEntity> databaseEntities = new List<DatabaseEntity>();
foreach(DatabaseEntity databaseEntity in this.SelectedItems)
databaseEntities.Add(databaseEntity);
this.MultiEditRequested?.Invoke(databaseEntities);
}
} }
protected void printItem(object sender, RoutedEventArgs e) protected void printItem(object sender, RoutedEventArgs e)

View File

@ -0,0 +1,113 @@
<UserControl x:Class="ENI2.Controls.EasyPeasyControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ENI2.Controls"
mc:Ignorable="d"
d:DesignHeight="650" d:DesignWidth="1024" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded">
<DockPanel>
<!-- Header with logo -->
<Border DockPanel.Dock="Top" Padding="10" Background="#FFFDF6">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
<!-- Embed SVG via Image (optional): place your SVG as a DrawingImage in resources, or replace with PNG -->
<TextBlock Text="🍋 easy-peasy" FontSize="20" FontWeight="Bold" Margin="0,0,16,0"/>
<TextBlock Text="Edit • Paste • Export XML" VerticalAlignment="Center"/>
</StackPanel>
</Border>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Margin="12" Orientation="Vertical" >
<!-- Top-level fields -->
<UniformGrid Columns="4" Rows="3" Margin="0,0,0,12" Height="84">
<TextBlock Text="Art der Identification (Vertreter)" Margin="0,0,4,0" VerticalAlignment="Center" TextAlignment="Right"/>
<TextBox Text="{Binding DelegateIdentificationType, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock Text="Art der Identifikation (Kunde)" VerticalAlignment="Center" Margin="0,0,4,0" TextAlignment="Right" />
<TextBox Text="{Binding TraderIdentificationType, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock Text="LRN" TextAlignment="Right" Margin="0,0,4,0" VerticalAlignment="Center"/>
<TextBox Text="{Binding LRN, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock Text="Identifikationsnummer (Kunde)" Margin="0,0,4,0" VerticalAlignment="Center" TextAlignment="Right" />
<TextBox Text="{Binding TraderIdentificationNumber, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock Text="Land" TextAlignment="Right" Margin="0,0,4,0" VerticalAlignment="Center"/>
<TextBox Text="{Binding Country, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock Text="Identifikationsnummer (Vertreter)" Margin="0,0,4,0" VerticalAlignment="Center" TextAlignment="Right"/>
<TextBox Text="{Binding DelegateIdentificationNumber, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/>
</UniformGrid>
<!-- ProofInformation -->
<GroupBox Header="Kennung des Antrags auf Nachweis TZ2L(F)">
<StackPanel Margin="8">
<UniformGrid Columns="4" Rows="4" Margin="0,0,0,12" >
<TextBlock Text="Zuständige Zollstelle" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Text="{Binding ProofInformationT2LT2LF.CompetentCustomsOffice, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock Text="Art der Anmeldung" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Text="{Binding ProofInformationT2LT2LF.DeclarationType, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="Datum Anmeldung
(yyyy-MM-ddTHH:mm:ss)" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Text="{Binding ProofInformationT2LT2LF.DeclarationDate, StringFormat={}{0:yyyy-MM-ddTHH:mm:ss}, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center" />
<TextBlock Text="Gesamtrohmasse (kg)" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox x:Name="textBoxTotalGrossMass" Text="{Binding ProofInformationT2LT2LF.TotalGrossMassKg, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="Antrag auf Gültigkeitsdauer des Nachweises (in Tagen)" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Text="{Binding ProofInformationT2LT2LF.RequestedValidityOfTheProof.NumberOfDays, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock Text="Art des Antrags" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Text="{Binding ProofInformationT2LT2LF.RequestType, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/>
</UniformGrid>
<GroupBox Header="Warenort">
<UniformGrid Columns="6" Margin="8" Height="28">
<TextBlock Text="Art des Ortes" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Text="{Binding ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.LocationOfGoods.TypeOfLocation}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock Text="Art der Ortsbestimmung" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Text="{Binding ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.LocationOfGoods.QualifierOfIdentification}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock Text="UNLocode" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Text="{Binding ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.LocationOfGoods.UNLocode}" Margin="2" VerticalContentAlignment="Center"/>
</UniformGrid>
</GroupBox>
<CheckBox Content="In Containern beförderte Waren" Margin="8"
IsChecked="{Binding ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.ContainerIndication}"/>
<!-- Goods Items grid (paste target) -->
<TextBlock Text="Warenpositionen (Paste tab/CSV with columns: HS, Item#, Description, Gross, Net, Pkgs, Type, Marks)" Margin="4,12,0,4"/>
<DataGrid ItemsSource="{Binding ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF}"
AutoGenerateColumns="False" SelectionMode="Extended" x:Name="dataGridGoodsItems" CanUserAddRows="False"
PreviewKeyDown="DataGrid_PreviewKeyDown" Focusable="True" MinHeight="80" IsTabStop="True" MaxHeight="320">
<DataGrid.Columns>
<DataGridTextColumn Header="HS Code" Binding="{Binding Commodity.HarmonizedSystemSubHeadingCode}"/>
<DataGridTextColumn Header="Item #" Binding="{Binding GoodsItemNumber}"/>
<DataGridTextColumn Header="Description" Binding="{Binding DescriptionOfGoods}" Width="2*"/>
<DataGridTextColumn Header="Gross" Binding="{Binding GoodsMeasure.GrossMass}"/>
<DataGridTextColumn Header="Net" Binding="{Binding GoodsMeasure.NetMass}"/>
<DataGridTextColumn Header="Pkgs" Binding="{Binding Packaging.NumberOfPackages}"/>
<DataGridTextColumn Header="Type" Binding="{Binding Packaging.TypeOfPackages}"/>
<DataGridTextColumn Header="Marks" Binding="{Binding Packaging.ShippingMarks}" Width="*"/>
</DataGrid.Columns>
</DataGrid>
<GroupBox Header="Dokumente" Margin="0,12,0,0">
<UniformGrid Columns="4" Margin="8" Height="28">
<TextBlock Text="Art des Dokuments" Margin="0,0,4,0" VerticalAlignment="Center" TextAlignment="Right"/>
<TextBox Text="{Binding ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.TransportDocuments.Type}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock Text="Referenznummer" Margin="0,0,4,0" VerticalAlignment="Center" TextAlignment="Right"/>
<TextBox Text="{Binding ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.TransportDocuments.ReferenceNumber}" Margin="2" VerticalContentAlignment="Center" />
</UniformGrid>
</GroupBox>
</StackPanel>
</GroupBox>
<!-- Actions -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,16,0,0">
<Button x:Name="buttonImport" Content="Import" Width="100" Margin="0,0,8,0" Click="buttonImport_Click" />
<Button x:Name="buttonClear" Content="Clear" Width="100" Margin="0,0,8,0" Click="buttonClear_Click"/>
<Button x:Name="buttonExport" Content="Export" Width="120" Click="buttonExport_Click"/>
</StackPanel>
</StackPanel>
</ScrollViewer>
</DockPanel>
</UserControl>

View File

@ -0,0 +1,506 @@
// Copyright (c) 2017- schick Informatik
// Description: Display dialog for customs XML data upload app
//
using bsmd.database.EasyPeasy;
using ENI2.Util;
using Microsoft.Win32;
using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using System.Xml;
using System.Xml.Serialization;
namespace ENI2.Controls
{
/// <summary>
/// Interaction logic for EasyPeasyControl.xaml
/// </summary>
public partial class EasyPeasyControl : UserControl
{
private ProofRequest _vm;
#region Construction
public EasyPeasyControl()
{
InitializeComponent();
this.dataGridGoodsItems.ContextMenu = new ContextMenu();
MenuItem addItem = new MenuItem();
addItem.Header = Properties.Resources.textAdd;
addItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/add.png")) };
addItem.Click += AddItem_Click;
this.dataGridGoodsItems.ContextMenu.Items.Add(addItem);
MenuItem deleteItem = new MenuItem();
deleteItem.Header = Properties.Resources.textDelete;
deleteItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/delete.png")) };
deleteItem.Click += DeleteItem_Click;
this.dataGridGoodsItems.ContextMenu.Items.Add(deleteItem);
// Add separator and paste option
this.dataGridGoodsItems.ContextMenu.Items.Add(new Separator());
MenuItem pasteItem = new MenuItem();
pasteItem.Header = "Paste";
pasteItem.Click += (s, e) => HandlePasteOperation();
this.dataGridGoodsItems.ContextMenu.Items.Add(pasteItem);
// Add command bindings for proper keyboard handling
this.dataGridGoodsItems.CommandBindings.Add(new CommandBinding(
ApplicationCommands.Paste,
(s, e) => HandlePasteOperation(),
(s, e) => e.CanExecute = Clipboard.ContainsText()));
}
#endregion
public void SaveState()
{
try
{
EasyPeasyState.Save(_vm);
}
catch { }
}
#region context menu event handler
private void AddItem_Click(object sender, RoutedEventArgs e)
{
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF == null) return;
var list = _vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF;
int nextItemNo = list.Any() ? list.Max(x => x.GoodsItemNumber) + 1 : 1;
var item = new GoodsItemForT2LT2LF
{
GoodsItemNumber = nextItemNo
};
list.Add(item);
}
private void DeleteItem_Click(object sender, RoutedEventArgs e)
{
foreach(GoodsItemForT2LT2LF item in this.dataGridGoodsItems.SelectedItems.Cast<GoodsItemForT2LT2LF>().ToArray())
{
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF == null) return;
var list = _vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF;
list.Remove(item);
}
}
#endregion
#region button event handler
private void buttonClear_Click(object sender, RoutedEventArgs e)
{
CleanupAutoCalculation();
this._vm = EasyPeasyState.CreateDefault();
if (_vm.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF == null)
_vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF = new ObservableCollection<GoodsItemForT2LT2LF>();
_vm.ProofInformationT2LT2LF.DeclarationDate = DateTime.Now; // reset to today
_vm.ProofInformationT2LT2LF.RequestedValidityOfTheProof.NumberOfDays = 90; // default 90 days
this.DataContext = this._vm;
SetupAutoCalculation();
}
private void buttonExport_Click(object sender, RoutedEventArgs e)
{
var dlg = new SaveFileDialog
{
FileName = "proofRequest.xml",
Filter = "XML file|*.xml",
OverwritePrompt = true
};
if (dlg.ShowDialog() == true)
{
try
{
var ser = new XmlSerializer(typeof(ProofRequest));
// Namespaces (if needed)
// var ns = new XmlSerializerNamespaces();
// ns.Add("xsd", "http://www.w3.org/2001/XMLSchema");
// ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
var settings = new XmlWriterSettings
{
Indent = true,
OmitXmlDeclaration = true
};
using (var fs = File.Create(dlg.FileName))
using (var xw = XmlWriter.Create(fs, settings))
{
ser.Serialize(xw, _vm); //, ns);
}
MessageBox.Show("Exported successfully.", "easy-peasy", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
MessageBox.Show("Export failed:\n" + ex.Message, "easy-peasy", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
private void buttonImport_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "XML file|*.xml";
ofd.RestoreDirectory = true;
ofd.Multiselect = false;
if (ofd.ShowDialog() == true)
{
using (var fs = File.OpenRead(ofd.FileName))
{
CleanupAutoCalculation();
var ser = new XmlSerializer(typeof(ProofRequest));
_vm = (ProofRequest)ser.Deserialize(fs);
// after loading/creating _vm
if (_vm.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF == null)
_vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF = new ObservableCollection<GoodsItemForT2LT2LF>();
_vm.ProofInformationT2LT2LF.DeclarationDate = DateTime.Now; // reset to today
if(_vm.ProofInformationT2LT2LF.RequestedValidityOfTheProof.NumberOfDays == 9)
_vm.ProofInformationT2LT2LF.RequestedValidityOfTheProof.NumberOfDays = 90; // default 90 days
this.DataContext = _vm;
SetupAutoCalculation();
}
}
}
#endregion
#region loaded/unloaded event handler
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
_vm = EasyPeasyState.LoadOrCreate();
if (_vm.ProofInformationT2LT2LF == null)
_vm.ProofInformationT2LT2LF = new ProofInformationT2LT2LF();
if (_vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF == null)
_vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF = new GoodsShipmentForT2LT2LF
{
LocationOfGoods = new LocationOfGoods(),
TransportDocuments = new TransportDocuments()
};
_vm.ProofInformationT2LT2LF.DeclarationDate = DateTime.Now; // reset to today
this.DataContext = _vm;
SetupAutoCalculation();
}
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
{
CleanupAutoCalculation();
try
{
EasyPeasyState.Save(_vm);
}
catch { }
}
#endregion
#region auto calculation total gross mass
private void SetupAutoCalculation()
{
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF != null)
{
// Subscribe to collection changes (add/remove items)
_vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF.CollectionChanged += GoodsItems_CollectionChanged;
// Subscribe to DataGrid cell changes
dataGridGoodsItems.CellEditEnding += DataGridGoodsItems_CellEditEnding;
// Calculate initial total
CalculateTotalGrossMass();
}
}
private void CleanupAutoCalculation()
{
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF != null)
{
// Unsubscribe from collection changes
_vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF.CollectionChanged -= GoodsItems_CollectionChanged;
dataGridGoodsItems.CellEditEnding -= DataGridGoodsItems_CellEditEnding;
}
}
private void DataGridGoodsItems_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
// Check if the edited column is GrossMass
if (e.Column.Header.ToString() == "Gross")
{
// Delay calculation to allow the binding to update
Dispatcher.BeginInvoke(new Action(() => {
CalculateTotalGrossMass();
}), System.Windows.Threading.DispatcherPriority.Background);
}
}
private void GoodsItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
// Recalculate total after any collection change
CalculateTotalGrossMass();
}
private void CalculateTotalGrossMass()
{
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF != null)
{
var total = _vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF
.Sum(item => item.GoodsMeasure?.GrossMass ?? 0m);
_vm.ProofInformationT2LT2LF.TotalGrossMassKg = total;
// Force UI update by refreshing the binding
var binding = BindingOperations.GetBindingExpression(
FindTotalGrossMassTextBox(), TextBox.TextProperty);
binding?.UpdateTarget();
}
}
// Simple property changed notification helper
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private TextBox FindTotalGrossMassTextBox()
{
// Find the TextBox that displays TotalGrossMassKg
return this.FindName("textBoxTotalGrossMass") as TextBox ??
this.GetTemplateChild("textBoxTotalGrossMass") as TextBox;
}
#endregion
#region cut & paste logic
private void HandlePasteOperation()
{
if (Clipboard.ContainsText())
{
var text = Clipboard.GetText();
if (!TryPaste_EspHsPkgsGross(text))
PasteGoodsItems(text);
}
}
private void DataGrid_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.V && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
{
if (Clipboard.ContainsText())
{
var text = Clipboard.GetText();
if(!TryPaste_EspHsPkgsGross(text))
PasteGoodsItems(text);
e.Handled = true;
}
}
}
private void PasteGoodsItems(string text)
{
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF == null) return;
var lines = text.Replace("\r\n", "\n").Replace('\r', '\n')
.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines)
{
// Split by tab first; if only one column, try CSV
var cells = line.Split('\t');
if (cells.Length == 1) cells = SplitCsv(line);
// Expected order: HS, Item#, Description, Gross, Net, Pkgs, Type, Marks
var item = new GoodsItemForT2LT2LF();
if (cells.Length > 0) item.Commodity.HarmonizedSystemSubHeadingCode = cells[0].Trim();
if (cells.Length > 1 && int.TryParse(cells[1], out var n)) item.GoodsItemNumber = n;
if (cells.Length > 2) item.DescriptionOfGoods = cells[2].Trim();
if (cells.Length > 3 && decimal.TryParse(cells[3], out var gross)) item.GoodsMeasure.GrossMass = gross;
if (cells.Length > 4 && decimal.TryParse(cells[4], out var net)) item.GoodsMeasure.NetMass = net;
if (cells.Length > 5 && int.TryParse(cells[5], out var pkgs)) item.Packaging.NumberOfPackages = pkgs;
if (cells.Length > 6) item.Packaging.TypeOfPackages = cells[6].Trim();
if (cells.Length > 7) item.Packaging.ShippingMarks = cells[7].Trim();
_vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF.Add(item);
}
}
// Very small CSV splitter (handles quotes)
private static string[] SplitCsv(string line)
{
var res = new System.Collections.Generic.List<string>();
var sb = new StringBuilder();
bool inQuotes = false;
for (int i = 0; i < line.Length; i++)
{
char c = line[i];
if (c == '\"')
{
if (inQuotes && i + 1 < line.Length && line[i + 1] == '\"')
{ sb.Append('\"'); i++; }
else { inQuotes = !inQuotes; }
}
else if (c == ',' && !inQuotes)
{ res.Add(sb.ToString()); sb.Clear(); }
else { sb.Append(c); }
}
res.Add(sb.ToString());
return res.ToArray();
}
private bool TryPaste_EspHsPkgsGross(string text)
{
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF == null) return false;
// Normalize and split lines
var lines = text.Replace("\r\n", "\n").Replace('\r', '\n')
.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
if (lines.Length == 0) return false;
// Determine next item number
var list = _vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF;
int nextItemNo = list.Any() ? list.Max(x => x.GoodsItemNumber) + 1 : 1;
bool anyAdded = false;
bool countrySeen = false;
foreach (var raw in lines)
{
var line = raw; // do not Trim() entirely; keep leading tab as empty first cell
var cells = line.Split('\t'); // keeps empty entries
// Expected:
// - 4 cells: [ESP or ""], [HS], [Pkgs], [Gross]
// - 3 cells: [HS], [Pkgs], [Gross]
string hs = null, pkgs = null, gross = null;
if (cells.Length >= 4)
{
string c0 = cells[0]?.Trim();
// Optionally capture the first token like "ESP" (country tag),
// only once and only if alphabetic (won't throw if numeric)
if (!countrySeen && !string.IsNullOrWhiteSpace(c0) && c0.All(ch => char.IsLetter(ch)))
{
// If you decide later this should set a field, uncomment:
// if (string.IsNullOrWhiteSpace(_vm.Country)) _vm.Country = c0;
countrySeen = true;
}
hs = (cells.Length > 1 ? cells[1] : null);
pkgs = (cells.Length > 2 ? cells[2] : null);
gross = (cells.Length > 3 ? cells[3] : null);
}
else if (cells.Length == 3)
{
hs = cells[0];
pkgs = cells[1];
gross = cells[2];
}
else
{
// Not enough data for this format; skip the row
continue;
}
if (string.IsNullOrWhiteSpace(hs)) continue;
var item = new GoodsItemForT2LT2LF
{
GoodsItemNumber = nextItemNo++,
DescriptionOfGoods = "" // per spec
};
item.Commodity.HarmonizedSystemSubHeadingCode = hs.Trim();
if (TryParseIntFlexible(pkgs, out var pk))
item.Packaging.NumberOfPackages = pk;
if (TryParseDecimalFlexible(gross, out var g))
{
item.GoodsMeasure.GrossMass = g;
var net = g; // - 1m; // now net mass equals gross mass (no deduction)
if (net < 0m) net = 0m;
item.GoodsMeasure.NetMass = net;
}
item.DescriptionOfGoods = "Brand New Vehicles"; // per spec
item.Packaging.TypeOfPackages = "UN"; // per spec
item.Packaging.ShippingMarks = "-"; // per spec
list.Add(item);
anyAdded = true;
}
return anyAdded;
}
#endregion
#region static utils
// this will go somewhere else later
// Try parse decimal with current culture, invariant, and comma/dot flip
private static bool TryParseDecimalFlexible(string s, out decimal value)
{
s = (s ?? "").Trim();
// 1) current culture
if (decimal.TryParse(s, NumberStyles.Number, CultureInfo.CurrentCulture, out value)) return true;
// 2) invariant
if (decimal.TryParse(s, NumberStyles.Number, CultureInfo.InvariantCulture, out value)) return true;
// 3) flip comma/dot and retry (helps when clipboard mixes locales)
string flipped = s.Contains(",") ? s.Replace(",", ".") : s.Replace(".", ",");
if (decimal.TryParse(flipped, NumberStyles.Number, CultureInfo.CurrentCulture, out value)) return true;
if (decimal.TryParse(flipped, NumberStyles.Number, CultureInfo.InvariantCulture, out value)) return true;
value = 0m;
return false;
}
private static bool TryParseIntFlexible(string s, out int value)
{
s = (s ?? "").Trim();
// Extract leading integer if something like "12 pcs"
var digits = new string(s.TakeWhile(ch => char.IsDigit(ch) || ch == '-' || ch == '+').ToArray());
if (string.IsNullOrEmpty(digits)) digits = s;
return int.TryParse(digits, NumberStyles.Integer, CultureInfo.CurrentCulture, out value)
|| int.TryParse(digits, NumberStyles.Integer, CultureInfo.InvariantCulture, out value);
}
#endregion
}
}

View File

@ -63,10 +63,17 @@ namespace ENI2.Controls
get { var addButton = (Button)Template.FindName("buttonAdd", this); return addButton.Visibility == Visibility.Visible; } get { var addButton = (Button)Template.FindName("buttonAdd", this); return addButton.Visibility == Visibility.Visible; }
set set
{ {
var addButton = (Button)Template.FindName("buttonAdd", this); addButton.Visibility = value ? Visibility.Visible : Visibility.Hidden; var addButton = (Button)Template.FindName("buttonAdd", this);
if (addButton != null)
{
addButton.Visibility = value ? Visibility.Visible : Visibility.Hidden;
}
var okButton = (Button)Template.FindName("buttonOK", this); var okButton = (Button)Template.FindName("buttonOK", this);
if (okButton.Visibility == Visibility.Hidden) if (okButton != null)
okButton.Width = 1; // we are in a DockPanel, try to collapse okButton to place addButton more to the right {
if (okButton.Visibility == Visibility.Hidden)
okButton.Width = 1; // we are in a DockPanel, try to collapse okButton to place addButton more to the right
}
} }
} }

View File

@ -79,6 +79,11 @@ namespace ENI2.Controls
portName = LocodeDB.PortNameFromLocode(value); break; portName = LocodeDB.PortNameFromLocode(value); break;
case RuleEngine.LocodeMode.SSN: case RuleEngine.LocodeMode.SSN:
portName = LocodeDB.SSNPortNameFromLocode(value); break; portName = LocodeDB.SSNPortNameFromLocode(value); break;
case RuleEngine.LocodeMode.OLD:
portName = LocodeDB.PortNameFromLocode(value);
if ((portName == null) && value.Equals("DEWHV"))
portName = "Stadthafen Wilhelmshaven";
break;
} }
LocodeState locodeState = portName.IsNullOrEmpty() ? LocodeState.INVALID : LocodeState.OK; LocodeState locodeState = portName.IsNullOrEmpty() ? LocodeState.INVALID : LocodeState.OK;
this.SetLocodeStateImage(this.imageLocodeState, locodeState); this.SetLocodeStateImage(this.imageLocodeState, locodeState);
@ -164,6 +169,18 @@ namespace ENI2.Controls
portname = LocodeDB.PortNameFromLocode(directLocode); break; portname = LocodeDB.PortNameFromLocode(directLocode); break;
case RuleEngine.LocodeMode.SSN: case RuleEngine.LocodeMode.SSN:
portname = LocodeDB.SSNPortNameFromLocode(directLocode); break; portname = LocodeDB.SSNPortNameFromLocode(directLocode); break;
case RuleEngine.LocodeMode.OLD:
{
if (directLocode.Equals("DEWHV"))
{
portname = "Stadthafen Wilhelmshaven";
}
else
{
portname = LocodeDB.PortNameFromLocode(directLocode);
}
}
break;
} }
bool isLocode = !portname.IsNullOrEmpty(); bool isLocode = !portname.IsNullOrEmpty();
@ -191,6 +208,8 @@ namespace ENI2.Controls
locodeEntries = LocodeDB.AllLocodesForCityNameAsEntries(lookupString); break; locodeEntries = LocodeDB.AllLocodesForCityNameAsEntries(lookupString); break;
case RuleEngine.LocodeMode.SSN: case RuleEngine.LocodeMode.SSN:
locodeEntries = LocalizedLookup.SSNAllLocodesForCityNameAsEntries(lookupString); break; locodeEntries = LocalizedLookup.SSNAllLocodesForCityNameAsEntries(lookupString); break;
case RuleEngine.LocodeMode.OLD:
locodeEntries = LocodeDB.AllLocodesForCityNameAsEntries(lookupString); break;
} }
locodeEntries.Sort(); locodeEntries.Sort();

View File

@ -2,23 +2,23 @@
// Description: Request dbh ids for Maersk data lists // Description: Request dbh ids for Maersk data lists
// //
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Win32;
using bsmd.database; using bsmd.database;
using ExcelDataReader; using ClosedXML.Excel;
using System.Collections.ObjectModel;
using ENI2.Excel; using ENI2.Excel;
using ENI2.Locode; using ENI2.Locode;
using ENI2.Util; using ENI2.Util;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace ENI2.Controls namespace ENI2.Controls
{ {
@ -290,25 +290,11 @@ namespace ENI2.Controls
} }
} }
this.TimeFilterItemSource(); this.TimeFilterItemSource();
// this.SortItemSource();
this.dataGridPOCores.SelectedItem = null; this.dataGridPOCores.SelectedItem = null;
busyControl.BusyState = Util.UIHelper.BusyStateEnum.NEUTRAL; busyControl.BusyState = Util.UIHelper.BusyStateEnum.NEUTRAL;
} }
private string ReadFieldAsString(IExcelDataReader reader, int fieldNum)
{
if (fieldNum >= reader.FieldCount) return null;
if (reader.GetFieldType(fieldNum) == typeof(string))
return reader.GetString(fieldNum).Clean();
if (reader.GetFieldType(fieldNum) == typeof(DateTime))
return reader.GetDateTime(fieldNum).ToString();
if (reader.GetFieldType(fieldNum) == typeof(int))
return reader.GetInt32(fieldNum).ToString();
if (reader.GetFieldType(fieldNum) == typeof(double))
return ((int) reader.GetDouble(fieldNum)).ToString();
return null;
}
private void TimeFilterItemSource() private void TimeFilterItemSource()
{ {
List<MaerskData> removeList = new List<MaerskData>(); List<MaerskData> removeList = new List<MaerskData>();
@ -332,15 +318,6 @@ namespace ENI2.Controls
this.maerskDataList.Remove(md); this.maerskDataList.Remove(md);
} }
private void SortItemSource()
{
ObservableCollection<MaerskData> temp;
temp = new ObservableCollection<MaerskData>(this.maerskDataList.OrderBy(p => p.ColA));
this.maerskDataList.Clear();
foreach (MaerskData md in temp)
this.maerskDataList.Add(md);
}
#endregion #endregion
#region button event handler #region button event handler
@ -359,80 +336,73 @@ namespace ENI2.Controls
}; };
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.Read); using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
} using (var workbook = new XLWorkbook(stream))
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
using (IExcelDataReader reader = ExcelReaderFactory.CreateReader(stream))
{
List<MaerskData> importData = new List<MaerskData>();
bool isFirstRow = true;
int currentRow = 0;
bool imosAreOkay = true;
try
{ {
while (reader.Read()) var worksheet = workbook.Worksheet(1); // Get first worksheet
var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row
List<MaerskData> importData = new List<MaerskData>();
int currentRow = 1; // Start at 1 since we skip header
bool imosAreOkay = true;
foreach (var row in rows)
{ {
currentRow++; currentRow++;
if (isFirstRow) if (worksheet.RangeUsed().ColumnCount() < 13)
{
isFirstRow = false; // this must be a header row, skip
continue;
}
if (reader.FieldCount < 13)
{ {
throw new InvalidDataException("Sheet must have 13 columns of data"); throw new InvalidDataException("Sheet must have 13 columns of data");
} }
MaerskData md = new MaerskData(); MaerskData md = new MaerskData();
if (!reader.IsDBNull(0))
if (!row.Cell(1).IsEmpty())
{ {
if (reader.GetFieldType(0) == typeof(DateTime)) var cellValue = row.Cell(1).Value;
if (cellValue.IsDateTime)
{ {
md.ETA = reader.GetDateTime(0); var dateTime = cellValue.GetDateTime();
md.ETA = dateTime;
md.ColA = md.ETA.ToString(); md.ColA = md.ETA.ToString();
} }
else else
{ {
md.ColA = reader.GetString(0); md.ColA = row.Cell(1).GetString();
if (DateTime.TryParse(md.ColA, out DateTime aDateTime)) if (DateTime.TryParse(md.ColA, out DateTime aDateTime))
md.ETA = aDateTime; md.ETA = aDateTime;
} }
} }
if (!reader.IsDBNull(1)) md.ColB = ReadFieldAsString(reader, 1);
if (!reader.IsDBNull(2)) md.ColC = ReadFieldAsString(reader, 2); if (!row.Cell(2).IsEmpty()) md.ColB = row.Cell(2).GetString();
if (!reader.IsDBNull(3)) md.ColD = ReadFieldAsString(reader, 3); if (!row.Cell(3).IsEmpty()) md.ColC = row.Cell(3).GetString();
if (!reader.IsDBNull(4)) md.ColE = ReadFieldAsString(reader, 4); if (!row.Cell(4).IsEmpty()) md.ColD = row.Cell(4).GetString();
if (!reader.IsDBNull(5)) md.ColF = ReadFieldAsString(reader, 5); if (!row.Cell(5).IsEmpty()) md.ColE = row.Cell(5).GetString();
if (!reader.IsDBNull(6)) md.ColG = ReadFieldAsString(reader, 6); if (!row.Cell(6).IsEmpty()) md.ColF = row.Cell(6).GetString();
if (!reader.IsDBNull(7)) md.ColH = ReadFieldAsString(reader, 7); if (!row.Cell(7).IsEmpty()) md.ColG = row.Cell(7).GetString();
if (!reader.IsDBNull(8)) md.ColI = ReadFieldAsString(reader, 8); if (!row.Cell(8).IsEmpty()) md.ColH = row.Cell(8).GetString();
if (!row.Cell(9).IsEmpty()) md.ColI = row.Cell(9).GetString();
if (md.ColI != null) if (md.ColI != null)
{ {
if ((md.ColI.Contains("bremerhaven", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEWVN")) || if ((md.ColI.Contains("bremerhaven", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEWVN")) ||
(md.ColI.Contains("eurogate", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEBRV"))) (md.ColI.Contains("eurogate", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEBRV")))
throw new InvalidOperationException($"{md.ColI} found in import to {PortLocode}, this is probably an error. Aborting import"); throw new InvalidOperationException($"{md.ColI} found in import to {PortLocode}, this is probably an error. Aborting import");
} }
if (!reader.IsDBNull(9)) md.ColJ = ReadFieldAsString(reader, 9);
if (!row.Cell(10).IsEmpty()) md.ColJ = row.Cell(10).GetString();
if (md.ColJ == null) continue; if (md.ColJ == null) continue;
if (!(md.ColJ.Equals("msk", StringComparison.OrdinalIgnoreCase) || md.ColJ.Equals("sgl", StringComparison.OrdinalIgnoreCase))) continue; // skip operator we are not interested in if (!(md.ColJ.Equals("msk", StringComparison.OrdinalIgnoreCase) || md.ColJ.Equals("sgl", StringComparison.OrdinalIgnoreCase))) continue; // skip operator we are not interested in
if (!reader.IsDBNull(10)) md.ColK = ReadFieldAsString(reader, 10);
if (!reader.IsDBNull(11)) md.ColL = ReadFieldAsString(reader, 11);
if (!reader.IsDBNull(12)) md.ColM = ReadFieldAsString(reader, 12);
if (!reader.IsDBNull(13)) md.Remark = ReadFieldAsString(reader, 13);
if(!md.ColF.IsNullOrEmpty()) if (!row.Cell(11).IsEmpty()) md.ColK = row.Cell(11).GetString();
if (!row.Cell(12).IsEmpty()) md.ColL = row.Cell(12).GetString();
if (!row.Cell(13).IsEmpty()) md.ColM = row.Cell(13).GetString();
if (!row.Cell(14).IsEmpty()) md.Remark = row.Cell(14).GetString();
if (!md.ColF.IsNullOrEmpty())
{ {
if (Int32.TryParse(md.ColF, out int imo)) if (Int32.TryParse(md.ColF, out int imo))
{ {
@ -458,72 +428,67 @@ namespace ENI2.Controls
} }
importData.Add(md); importData.Add(md);
if (isFirstRow) isFirstRow = false;
} }
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (imosAreOkay && importData.Count > 0) if (imosAreOkay && importData.Count > 0)
{
busyControl.BusyState = Util.UIHelper.BusyStateEnum.BUSY;
foreach (MaerskData md in importData)
{ {
if (this.maerskDataList.Contains(md)) busyControl.BusyState = Util.UIHelper.BusyStateEnum.BUSY;
{
// update record with imported record
MaerskData foundData = this.maerskDataList.First((m) => (m.ColF != null) ? m.ColF.Equals(md.ColF) : (md.ColF == null) &&
(m.ColG != null) ? m.ColG.Equals(md.ColG) : (md.ColG == null) &&
(m.ColH != null) ? m.ColH.Equals(md.ColH) : (md.ColH == null));
if ((foundData.MessageCore == null) || !(foundData.MessageCore.Cancelled ?? false)) foreach (MaerskData md in importData)
{
if (foundData.ETA.HasValue && ((foundData.ETA.Value - DateTime.Now).TotalSeconds > 0) && foundData.Update(md))
foundData.Status = MaerskData.MDStatus.UPDATED;
}
}
else
{ {
if (!md.ColM.IsNullOrEmpty()) if (this.maerskDataList.Contains(md))
{ {
md.MessageCore = await DBManagerAsync.LoadCoreByVisitIdAsync(md.ColM); // update record with imported record
if (md.MessageCore != null) MaerskData foundData = this.maerskDataList.First((m) => (m.ColF != null) ? m.ColF.Equals(md.ColF) : (md.ColF == null) &&
(m.ColG != null) ? m.ColG.Equals(md.ColG) : (md.ColG == null) &&
(m.ColH != null) ? m.ColH.Equals(md.ColH) : (md.ColH == null));
if ((foundData.MessageCore == null) || !(foundData.MessageCore.Cancelled ?? false))
{ {
MaerskData existingMD = await DBManagerAsync.LoadMaerskDataForCoreAsync(md.MessageCore.Id.Value); if (foundData.ETA.HasValue && ((foundData.ETA.Value - DateTime.Now).TotalSeconds > 0) && foundData.Update(md))
if(existingMD == null) foundData.Status = MaerskData.MDStatus.UPDATED;
{
// we have a core but no MarskData for this import -> save it
md.MessageCoreId = (Guid) md.MessageCore.Id;
_ = DBManagerAsync.SaveAsync(md);
}
else
{
existingMD.Update(md);
_ = DBManagerAsync.SaveAsync(existingMD);
this.UpdateStatus(existingMD);
maerskDataList.Add(existingMD);
continue; // add existing instead of new one
}
} }
} }
else
{
if (!md.ColM.IsNullOrEmpty())
{
md.MessageCore = await DBManagerAsync.LoadCoreByVisitIdAsync(md.ColM);
if (md.MessageCore != null)
{
MaerskData existingMD = await DBManagerAsync.LoadMaerskDataForCoreAsync(md.MessageCore.Id.Value);
if (existingMD == null)
{
// we have a core but no MarskData for this import -> save it
md.MessageCoreId = (Guid)md.MessageCore.Id;
_ = DBManagerAsync.SaveAsync(md);
}
else
{
existingMD.Update(md);
_ = DBManagerAsync.SaveAsync(existingMD);
this.UpdateStatus(existingMD);
maerskDataList.Add(existingMD);
continue; // add existing instead of new one
}
}
}
this.UpdateStatus(md); this.UpdateStatus(md);
maerskDataList.Add(md); maerskDataList.Add(md);
}
} }
} this.TimeFilterItemSource();
this.TimeFilterItemSource(); busyControl.BusyState = Util.UIHelper.BusyStateEnum.NEUTRAL;
// this.SortItemSource();
busyControl.BusyState = Util.UIHelper.BusyStateEnum.NEUTRAL;
this.dataGridPOCores.Items.Refresh(); this.dataGridPOCores.Items.Refresh();
}
} }
} }
catch (Exception ex)
stream.Close(); {
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
} }
@ -631,7 +596,7 @@ namespace ENI2.Controls
MaerskData md = grid.SelectedItem as MaerskData; MaerskData md = grid.SelectedItem as MaerskData;
if(md.MessageCore != null) { if(md.MessageCore != null) {
Util.UIHelper.SetBusyState(); Util.UIHelper.SetBusyState();
this.MessageCoreSelected?.Invoke(md.MessageCore); this.MessageCoreSelected?.Invoke(md.MessageCore, DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].ShipcallDisplayMode);
} }
} }
} }

View File

@ -36,10 +36,19 @@ namespace ENI2.Controls
closeButton.Click += (s, e) => { if (this.IsModal()) DialogResult = true; CloseClicked?.Invoke(); this.Close(); }; closeButton.Click += (s, e) => { if (this.IsModal()) DialogResult = true; CloseClicked?.Invoke(); this.Close(); };
refreshButton.Click += (s, e) => { RefreshClicked?.Invoke(); }; refreshButton.Click += (s, e) => { RefreshClicked?.Invoke(); };
SettingBindingExtension stBinding = new SettingBindingExtension("W2Top"); string topProperty = "W2Top";
string leftProperty = "W2Left";
if(this.GetType().Name == "ViolationListDialog")
{
topProperty = "W3Top";
leftProperty = "W3Left";
}
SettingBindingExtension stBinding = new SettingBindingExtension(topProperty);
this.SetBinding(Window.TopProperty, stBinding); this.SetBinding(Window.TopProperty, stBinding);
SettingBindingExtension slBinding = new SettingBindingExtension("W2Left"); SettingBindingExtension slBinding = new SettingBindingExtension(leftProperty);
this.SetBinding (Window.LeftProperty, slBinding); this.SetBinding (Window.LeftProperty, slBinding);
}; };
} }

View File

@ -69,15 +69,21 @@ namespace ENI2.Controls
private async void DelItem_Click(object sender, RoutedEventArgs e) private async void DelItem_Click(object sender, RoutedEventArgs e)
{ {
if (this.dataGridValueMappings.SelectedItem is ValueMapping vm) if (this.dataGridValueMappings.SelectedItems.Count > 0)
{ {
if (MessageBox.Show($"Are you sure to delete {vm.Key} -> {vm.Value}?", Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == if (MessageBox.Show($"Are you sure to delete the selected values?", Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) ==
MessageBoxResult.Yes) MessageBoxResult.Yes)
{ {
int result = await DBManagerAsync.DeleteAsync(vm); var selectedItems = new List<ValueMapping>();
if (result == 1) foreach(ValueMapping vm in this.dataGridValueMappings.SelectedItems)
selectedItems.Add(vm);
foreach(ValueMapping vm in selectedItems)
{ {
_mappings.Remove(vm); int result = await DBManagerAsync.DeleteAsync(vm);
if (result == 1)
{
_mappings.Remove(vm);
}
} }
} }
} }

View File

@ -34,8 +34,7 @@ namespace ENI2
if (parentObject == null) return null; if (parentObject == null) return null;
//check if the parent matches the type we're looking for //check if the parent matches the type we're looking for
T parent = parentObject as T; if (parentObject is T parent)
if (parent != null)
return parent; return parent;
else else
return FindParent<T>(parentObject); return FindParent<T>(parentObject);

View File

@ -33,6 +33,7 @@ namespace ENI2
private DependencyPropertyDescriptor _dpComboboxValue; private DependencyPropertyDescriptor _dpComboboxValue;
private DependencyPropertyDescriptor _dpNumericUpdown; private DependencyPropertyDescriptor _dpNumericUpdown;
private DependencyPropertyDescriptor _dpIntUpdown; private DependencyPropertyDescriptor _dpIntUpdown;
private readonly Dictionary<Object, Message.NotificationClass> _controlClassDict = new Dictionary<object, Message.NotificationClass>(); private readonly Dictionary<Object, Message.NotificationClass> _controlClassDict = new Dictionary<object, Message.NotificationClass>();
private readonly Dictionary<Message.NotificationClass, Message> _typeMessageDict = new Dictionary<Message.NotificationClass, Message>(); private readonly Dictionary<Message.NotificationClass, Message> _typeMessageDict = new Dictionary<Message.NotificationClass, Message>();
@ -69,7 +70,7 @@ namespace ENI2
/// <summary> /// <summary>
/// Damit kann ein Listenelement eine Validierung der gesamten Anmeldung auslösen (inkl. Highlighting) (auf Knopfdruck) /// Damit kann ein Listenelement eine Validierung der gesamten Anmeldung auslösen (inkl. Highlighting) (auf Knopfdruck)
/// </summary> /// </summary>
public event Action RequestValidate; public event Action<bool> RequestValidate;
/// <summary> /// <summary>
/// Alle Meldeklassen die auf "zu versenden" stehen werden validiert und falls die Validierung scheitert auf "SUSPEND" gestellt /// Alle Meldeklassen die auf "zu versenden" stehen werden validiert und falls die Validierung scheitert auf "SUSPEND" gestellt
@ -89,7 +90,7 @@ namespace ENI2
/// <summary> /// <summary>
/// Eine in der Detailansicht enthaltene Meldeklasse hat sich geändert /// Eine in der Detailansicht enthaltene Meldeklasse hat sich geändert
/// </summary> /// </summary>
public event Action<Message.NotificationClass> NotificationClassChanged; public event Action<Message.NotificationClass?> NotificationClassChanged;
/// <summary> /// <summary>
/// Eine Maske soll neu erzeugt werden weil sich dort "indirekt" etwas geändert hat durch eine Änderung in einer anderen Maske. /// Eine Maske soll neu erzeugt werden weil sich dort "indirekt" etwas geändert hat durch eine Änderung in einer anderen Maske.
@ -134,7 +135,6 @@ namespace ENI2
_dpNumericUpdown = DependencyPropertyDescriptor.FromProperty(Xceed.Wpf.Toolkit.DoubleUpDown.ValueProperty, typeof(Xceed.Wpf.Toolkit.DoubleUpDown)); _dpNumericUpdown = DependencyPropertyDescriptor.FromProperty(Xceed.Wpf.Toolkit.DoubleUpDown.ValueProperty, typeof(Xceed.Wpf.Toolkit.DoubleUpDown));
_dpIntUpdown = DependencyPropertyDescriptor.FromProperty(Xceed.Wpf.Toolkit.IntegerUpDown.ValueProperty, typeof(Xceed.Wpf.Toolkit.IntegerUpDown)); _dpIntUpdown = DependencyPropertyDescriptor.FromProperty(Xceed.Wpf.Toolkit.IntegerUpDown.ValueProperty, typeof(Xceed.Wpf.Toolkit.IntegerUpDown));
foreach(Message message in this.Messages) foreach(Message message in this.Messages)
{ {
_typeMessageDict[message.MessageNotificationClass] = message; _typeMessageDict[message.MessageNotificationClass] = message;
@ -160,9 +160,9 @@ namespace ENI2
this.RequestReload?.Invoke(coreId); this.RequestReload?.Invoke(coreId);
} }
protected virtual void OnRequestValidate() protected virtual void OnRequestValidate(bool showDialog)
{ {
this.RequestValidate?.Invoke(); this.RequestValidate?.Invoke(showDialog);
} }
protected virtual void OnRequestSendValidation() protected virtual void OnRequestSendValidation()
@ -185,6 +185,17 @@ namespace ENI2
this.ResetControlCache?.Invoke(messageGroupName); this.ResetControlCache?.Invoke(messageGroupName);
} }
protected virtual void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
public virtual int SelectedTabIndex { get; set; } = -1;
#endregion
#region event handling for control content changes (signal dirty etc) #region event handling for control content changes (signal dirty etc)
protected void RegisterTextboxChange(TextBox textBox, Message.NotificationClass notificationClass) protected void RegisterTextboxChange(TextBox textBox, Message.NotificationClass notificationClass)
@ -258,12 +269,17 @@ namespace ENI2
{ {
_typeMessageDict[notificationClass].IsDirty = true; _typeMessageDict[notificationClass].IsDirty = true;
// signal this notification class changed.. // signal this notification class changed..
this.NotificationClassChanged?.Invoke(notificationClass); this.OnNotificationClassChanged(notificationClass);
} }
} }
} }
} }
protected void OnNotificationClassChanged(Message.NotificationClass? notificationClass)
{
this.NotificationClassChanged?.Invoke(notificationClass);
}
#region "BHV Spezial" Datetime Parsing.. #region "BHV Spezial" Datetime Parsing..
protected void DateTimePicker_PreviewKeyUp(object sender, System.Windows.Input.KeyEventArgs e) protected void DateTimePicker_PreviewKeyUp(object sender, System.Windows.Input.KeyEventArgs e)
@ -335,8 +351,6 @@ namespace ENI2
#endregion #endregion
#endregion
#region IHighlightControlContainer implementation #region IHighlightControlContainer implementation
public virtual void HighlightErrorMessageContainer() public virtual void HighlightErrorMessageContainer()

View File

@ -15,7 +15,7 @@
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="220" /> <ColumnDefinition Width="220" x:Name="leftColumnDefinition"/>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
@ -28,7 +28,7 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0" > <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0" >
<xctk:AutoSelectTextBox x:Name="displayIdLabel" Width="Auto" VerticalContentAlignment="Center" FontWeight="Bold" IsReadOnly="True" BorderThickness="0" AutoSelectBehavior="OnFocus" /> <xctk:AutoSelectTextBox x:Name="displayIdLabel" Width="Auto" VerticalContentAlignment="Center" FontWeight="Bold" IsReadOnly="True" BorderThickness="0" AutoSelectBehavior="OnFocus" />
<Label Margin="10,0,0,0" Content="Ship e-mail:" VerticalContentAlignment="Center" /> <Label Margin="10,0,0,0" Content="{x:Static p:Resources.textShipEmail}" VerticalContentAlignment="Center" />
<xctk:AutoSelectTextBox Width="400" x:Name="shipEMailLabel" VerticalContentAlignment="Center" FontWeight="Normal" IsReadOnly="True" BorderThickness="0" AutoSelectBehavior="OnFocus" /> <xctk:AutoSelectTextBox Width="400" x:Name="shipEMailLabel" VerticalContentAlignment="Center" FontWeight="Normal" IsReadOnly="True" BorderThickness="0" AutoSelectBehavior="OnFocus" />
</StackPanel> </StackPanel>
<Button Name="buttonSave" Grid.Column="1" Grid.Row="0" Margin="2" Click="buttonSave_Click" BorderThickness="0" Background="Transparent" Visibility="Hidden"> <Button Name="buttonSave" Grid.Column="1" Grid.Row="0" Margin="2" Click="buttonSave_Click" BorderThickness="0" Background="Transparent" Visibility="Hidden">

View File

@ -15,8 +15,9 @@ using ENI2.Util;
using ENI2.EditControls; using ENI2.EditControls;
using System.Windows.Input; using System.Windows.Input;
using Microsoft.Office.Interop.Excel;
using System.Linq; using System.Linq;
using ENI2.SheetDisplayControls;
using System.Threading.Tasks;
namespace ENI2 namespace ENI2
{ {
@ -34,6 +35,9 @@ namespace ENI2
// private readonly Dictionary<Message.NotificationClass, string> messageClassControlDict = new Dictionary<Message.NotificationClass, string>(); // private readonly Dictionary<Message.NotificationClass, string> messageClassControlDict = new Dictionary<Message.NotificationClass, string>();
private readonly object messageListLock = new object(); private readonly object messageListLock = new object();
private readonly HighlightService highlightService = new HighlightService(); private readonly HighlightService highlightService = new HighlightService();
private readonly object validationLock = new object();
private Task<ValidationResult> activeValidationTask = null;
private bool pendingShowMessages = false;
// Referenzen für Fehler/Violation Dialoge (können, müssen aber nicht offen bleiben) // Referenzen für Fehler/Violation Dialoge (können, müssen aber nicht offen bleiben)
protected ErrorListDialog _errorListDialog = null; protected ErrorListDialog _errorListDialog = null;
@ -108,31 +112,45 @@ namespace ENI2
} }
} }
public bool HasCriticalInfoMissing(out string messageText) public bool HasCriticalInfoMissing(out string messageText, string locode)
{ {
messageText = ""; messageText = "";
// Hier haben wir Logik für Spezialfälle, z.B. dass für BRE und BRV bestimmte Meldeklassen gesendet werden *müssen* // Hier haben wir Logik für Spezialfälle, z.B. dass für BRE und BRV bestimmte Meldeklassen gesendet werden *müssen*
if(this.Core.PoC.Equals("DEBRV") || this.Core.PoC.Equals("DEBRE")) switch (locode)
{ {
foreach(Message aMessage in _messages) case "DEBRV":
{ case "DEBRE":
if((aMessage.MessageNotificationClass == Message.NotificationClass.NOA_NOD) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "NOA_NOD"; return true; } {
if ((aMessage.MessageNotificationClass == Message.NotificationClass.AGNT) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "AGNT"; return true; } foreach (Message aMessage in _messages)
if ((aMessage.MessageNotificationClass == Message.NotificationClass.INFO) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "INFO"; return true; } {
if ((aMessage.MessageNotificationClass == Message.NotificationClass.SEC) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "SEC"; return true; } if ((aMessage.MessageNotificationClass == Message.NotificationClass.NOA_NOD) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "NOA_NOD"; return true; }
if ((aMessage.MessageNotificationClass == Message.NotificationClass.TIEFA) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "TIEFA"; return true; } if ((aMessage.MessageNotificationClass == Message.NotificationClass.AGNT) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "AGNT"; return true; }
} if ((aMessage.MessageNotificationClass == Message.NotificationClass.INFO) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "INFO"; return true; }
if ((aMessage.MessageNotificationClass == Message.NotificationClass.SEC) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "SEC"; return true; }
if ((aMessage.MessageNotificationClass == Message.NotificationClass.TIEFA) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "TIEFA"; return true; }
}
}
break;
case "DEHAM":
foreach (Message aMessage in _messages)
{
if ((aMessage.MessageNotificationClass == Message.NotificationClass.SERV) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "SERV"; return true; }
}
break;
default:
break;
} }
return false; return false;
} }
#endregion #endregion
#region Construction #region Construction
public DetailRootControl(MessageCore aCore) public DetailRootControl(MessageCore aCore, ReportingParty.ShipcallDisplayModeEnum displayMode)
{ {
Core = aCore; Core = aCore;
InitializeComponent(); InitializeComponent();
@ -140,23 +158,43 @@ namespace ENI2
shipEMailLabel.Text = aCore.HerbergEmailContactReportingVessel; shipEMailLabel.Text = aCore.HerbergEmailContactReportingVessel;
displayIdLabel.Text = aCore.DisplayId; displayIdLabel.Text = aCore.DisplayId;
// Unterscheidung in welchem Darstellungs-Mode der Anlauf dargestellt wird (Classic oder Formblatt)
// Listbox befüllen if (displayMode == ReportingParty.ShipcallDisplayModeEnum.CLASSIC)
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textOverview, MessageGroupControlType = typeof(OverViewDetailControl), ImagePath = "Resources/documents.png" }); {
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textPortCall, MessageGroupControlType = typeof(PortCallDetailControl), ImagePath = "Resources/eye_blue.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textOverview, MessageGroupControlType = typeof(OverViewDetailControl), ImagePath = "Resources/documents.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textPortNotification, MessageGroupControlType = typeof(PortNotificationDetailControl), ImagePath = "Resources/anchor.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textPortCall, MessageGroupControlType = typeof(PortCallDetailControl), ImagePath = "Resources/eye_blue.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textWaste, MessageGroupControlType = typeof(WasteDetailControl), ImagePath = "Resources/garbage.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textPortNotification, MessageGroupControlType = typeof(PortNotificationDetailControl), ImagePath = "Resources/anchor.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textArrivalNotification, MessageGroupControlType = typeof(ArrivalNotificationDetailControl), ImagePath = "Resources/arrow_down_right_red.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textWaste, MessageGroupControlType = typeof(WasteDetailControl), ImagePath = "Resources/garbage.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textSecurity, MessageGroupControlType = typeof(SecurityDetailControl), ImagePath = "Resources/shield_yellow.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textArrivalNotification, MessageGroupControlType = typeof(ArrivalNotificationDetailControl), ImagePath = "Resources/arrow_down_right_red.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textPSC72h, MessageGroupControlType = typeof(PSC72hDetailControl), ImagePath = "Resources/alarmclock.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textSecurity, MessageGroupControlType = typeof(SecurityDetailControl), ImagePath = "Resources/shield_yellow.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textMDH, MessageGroupControlType = typeof(MaritimeHealthDeclarationDetailControl), ImagePath = "Resources/medical_bag.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textPSC72h, MessageGroupControlType = typeof(PSC72hDetailControl), ImagePath = "Resources/alarmclock.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textDepartureNotification, MessageGroupControlType = typeof(DepartureNotificationDetailControl), ImagePath = "Resources/arrow_up_right_green.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textMDH, MessageGroupControlType = typeof(MaritimeHealthDeclarationDetailControl), ImagePath = "Resources/medical_bag.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textShipData, MessageGroupControlType = typeof(ShipDataDetailControl), ImagePath = "Resources/containership.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textDepartureNotification, MessageGroupControlType = typeof(DepartureNotificationDetailControl), ImagePath = "Resources/arrow_up_right_green.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textBorderPolice, MessageGroupControlType = typeof(BorderPoliceDetailControl), ImagePath = "Resources/policeman_german.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textShipData, MessageGroupControlType = typeof(ShipDataDetailControl), ImagePath = "Resources/containership.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textDGArrival, MessageGroupControlType = typeof(DangerousGoodsDetailControl), ImagePath = "Resources/sign_warning_radiation.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textBorderPolice, MessageGroupControlType = typeof(BorderPoliceDetailControl), ImagePath = "Resources/policeman_german.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textDGDeparture, MessageGroupControlType = typeof(DangerousGoodsDetailControl), ImagePath = "Resources/sign_warning_radiation.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textDGArrival, MessageGroupControlType = typeof(DangerousGoodsDetailControl), ImagePath = "Resources/sign_warning_radiation.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textTowage, MessageGroupControlType = typeof(TowageDetailControl), ImagePath = "Resources/ship2.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textDGDeparture, MessageGroupControlType = typeof(DangerousGoodsDetailControl), ImagePath = "Resources/sign_warning_radiation.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textTowage, MessageGroupControlType = typeof(TowageDetailControl), ImagePath = "Resources/ship2.png" });
}
else
{
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textOverview, MessageGroupControlType = typeof(OverViewDetailControl), ImagePath = "Resources/documents.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text1Voyage, MessageGroupControlType = typeof(VoyageControl), ImagePath = "Resources/ship2.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text2PortCall, MessageGroupControlType = typeof(PortControl), ImagePath = "Resources/anchor.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text3PreArrival, MessageGroupControlType = typeof(PreArrivalControl), ImagePath = "Resources/arrow_down_right_red.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text4PreDeparture, MessageGroupControlType = typeof(PreDepartureControl), ImagePath = "Resources/arrow_up_right_green.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text5ShipData, MessageGroupControlType = typeof(ShipDataControl), ImagePath = "Resources/containership.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text6CrewDataOnArrival, MessageGroupControlType = typeof(CrewPreArrivalControl), ImagePath = "Resources/arrival_worker.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text7CrewDeparture, MessageGroupControlType = typeof(CrewDepartureControl), ImagePath = "Resources/departure_worker.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text8PassengerArrival, MessageGroupControlType = typeof(PassengerPreArrivalControl), ImagePath = "Resources/arrival_user.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text9PassengerDeparture, MessageGroupControlType = typeof(PassengerDepartureControl), ImagePath = "Resources/departure_user.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text10DangerousCargoArrival, MessageGroupControlType = typeof(DangerousCargoControl), ImagePath = "Resources/sign_warning_radiation.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text11DangerousCargoDeparture, MessageGroupControlType = typeof(DangerousCargoControl), ImagePath = "Resources/sign_warning_radiation.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text12ATAATD, MessageGroupControlType = typeof(ATAControl), ImagePath = "Resources/clock.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text13WasteReceipts, MessageGroupControlType = typeof(WasteReceiptsControl), ImagePath = "Resources/garbage.png" });
this.leftColumnDefinition.Width = new GridLength(260);
}
this.listBoxMessages.ItemsSource = this._listBoxList; this.listBoxMessages.ItemsSource = this._listBoxList;
@ -192,6 +230,7 @@ namespace ENI2
public void CoreChanged(MessageCore newCore) public void CoreChanged(MessageCore newCore)
{ {
this.Core = newCore; this.Core = newCore;
this.ReloadCore();
System.Windows.Application.Current.Dispatcher.Invoke(delegate System.Windows.Application.Current.Dispatcher.Invoke(delegate
{ {
if(controlCache.ContainsKey(Properties.Resources.textOverview)) if(controlCache.ContainsKey(Properties.Resources.textOverview))
@ -238,6 +277,8 @@ namespace ENI2
// Spezial-Balkon für die Wiederverwendung von HAZD / HAZA als ein Control (es tut mir leid :D) // Spezial-Balkon für die Wiederverwendung von HAZD / HAZA als ein Control (es tut mir leid :D)
if (mg.MessageGroupName.Equals(Properties.Resources.textDGDeparture)) if (mg.MessageGroupName.Equals(Properties.Resources.textDGDeparture))
((DangerousGoodsDetailControl)detailControl).IsDeparture = true; ((DangerousGoodsDetailControl)detailControl).IsDeparture = true;
if (mg.MessageGroupName.Equals(Properties.Resources.text11DangerousCargoDeparture))
((DangerousCargoControl)detailControl).IsDeparture = true;
detailControl.Core = Core; detailControl.Core = Core;
detailControl.Messages = _messages; detailControl.Messages = _messages;
detailControl.LockedByOtherUser = this.LockedByOtherUser; detailControl.LockedByOtherUser = this.LockedByOtherUser;
@ -416,6 +457,7 @@ namespace ENI2
newMessage.SaveElements(); newMessage.SaveElements();
} }
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).LoadXtraData(newCore); // reload data from DB and set all rel properites
this.OnOpenNewCoreRequested(newCore); this.OnOpenNewCoreRequested(newCore);
} }
}; };
@ -449,6 +491,7 @@ namespace ENI2
{ {
Util.UIHelper.SetBusyState(); Util.UIHelper.SetBusyState();
int currentMainTabIndex = -1;
if (this.detailView.Children[0] is DetailBaseControl currentControl) if (this.detailView.Children[0] is DetailBaseControl currentControl)
{ {
@ -463,10 +506,24 @@ namespace ENI2
// ggf. hat sich die Ticketnr geändert.. // ggf. hat sich die Ticketnr geändert..
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(currentControl.Core); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(currentControl.Core);
} }
}
}
this.DetailControl_RequestReload(this.Core.Id.Value); currentMainTabIndex = currentControl.SelectedTabIndex;
}
this.DetailControl_RequestReload(this.Core.Id.Value);
System.Action<int> SetTabAction = x =>
{
// this hopefully happens *after* the view was completely reloaded
if (this.detailView.Children[0] is DetailBaseControl currentNewControl)
{
currentNewControl.SelectedTabIndex = x;
}
};
if (currentMainTabIndex >= 0)
Dispatcher.BeginInvoke(SetTabAction, currentMainTabIndex);
}
} }
private void SaveMessage(Message message) private void SaveMessage(Message message)
@ -475,9 +532,14 @@ namespace ENI2
{ {
if ((message.Status == Message.MessageStatus.ACCEPTED) && if ((message.Status == Message.MessageStatus.ACCEPTED) &&
((message.InternalStatus == Message.BSMDStatus.CONFIRMED) || (message.InternalStatus == Message.BSMDStatus.VIOLATION))) ((message.InternalStatus == Message.BSMDStatus.CONFIRMED) || (message.InternalStatus == Message.BSMDStatus.VIOLATION)))
{
message.InternalStatus = Message.BSMDStatus.UPDATED; message.InternalStatus = Message.BSMDStatus.UPDATED;
message.Status = null; // reset send status
}
else else
{
message.InternalStatus = Message.BSMDStatus.SAVED; message.InternalStatus = Message.BSMDStatus.SAVED;
}
string userName = "?"; string userName = "?";
if(App.UserId.HasValue && DBManager.Instance.GetReportingPartyDict().ContainsKey(App.UserId.Value)) if(App.UserId.HasValue && DBManager.Instance.GetReportingPartyDict().ContainsKey(App.UserId.Value))
@ -517,6 +579,7 @@ namespace ENI2
{ {
Util.UIHelper.SetBusyState(); Util.UIHelper.SetBusyState();
int currentMainTabIndex = -1;
foreach (Message message in this._messages) foreach (Message message in this._messages)
{ {
@ -530,13 +593,30 @@ namespace ENI2
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(currentControl.Core); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(currentControl.Core);
} }
currentMainTabIndex = currentControl.SelectedTabIndex;
Trace.WriteLine($"Last selected tab index: {currentMainTabIndex}");
this.buttonSaveAll.Visibility = Visibility.Hidden; this.buttonSaveAll.Visibility = Visibility.Hidden;
this.buttonSave.Visibility = Visibility.Hidden; this.buttonSave.Visibility = Visibility.Hidden;
this.DetailControl_RequestReload(this.Core.Id.Value);
Action<int> SetTabAction = x =>
{
// this hopefully happens *after* the view was completely reloaded
if (this.detailView.Children[0] is DetailBaseControl currentNewControl)
{
currentNewControl.SelectedTabIndex = x;
}
};
if(currentMainTabIndex >= 0)
Dispatcher.BeginInvoke(SetTabAction, currentMainTabIndex);
} }
this.DetailControl_RequestReload(this.Core.Id.Value);
} }
private void DetailControl_NotificationClassChanged(Message.NotificationClass notificationClass) private void DetailControl_NotificationClassChanged(Message.NotificationClass? notificationClass)
{ {
// in der Übersicht die Meldeklasse als geändert markieren..? // in der Übersicht die Meldeklasse als geändert markieren..?
this.buttonSaveAll.Visibility = Visibility.Visible; this.buttonSaveAll.Visibility = Visibility.Visible;
@ -588,7 +668,7 @@ namespace ENI2
private void ShortCutValidate(object sender, ExecutedRoutedEventArgs e) private void ShortCutValidate(object sender, ExecutedRoutedEventArgs e)
{ {
this.DetailControl_RequestValidate(); this.DetailControl_RequestValidate(true);
} }
private void DetailControl_RequestReload(Guid id) private void DetailControl_RequestReload(Guid id)
@ -608,12 +688,15 @@ namespace ENI2
this.detailView.Children.Clear(); this.detailView.Children.Clear();
this.controlCache.Clear(); this.controlCache.Clear();
// return to "new" overviewdan int currentIndex = this.listBoxMessages.SelectedIndex;
// return to "new" overview
Dispatcher.BeginInvoke((System.Action)(() => Dispatcher.BeginInvoke((System.Action)(() =>
{ {
this.listBoxMessages_SelectionChanged(this, null); this.listBoxMessages_SelectionChanged(this, null);
shipNameLabel.Text = this.Core.Shipname; shipNameLabel.Text = this.Core.Shipname;
shipEMailLabel.Text = this.Core.HerbergEmailContactReportingVessel; shipEMailLabel.Text = this.Core.HerbergEmailContactReportingVessel;
this.listBoxMessages.SelectedIndex = currentIndex;
} }
)); ));
@ -624,7 +707,13 @@ namespace ENI2
private void DetailControl_RequestSendValidation() private void DetailControl_RequestSendValidation()
{ {
this.Validate(false, out _, out List<MessageError> errorList); DetailControl_RequestSendValidationAsync();
}
private async void DetailControl_RequestSendValidationAsync()
{
ValidationResult result = await ValidateAndApplyAsync(false);
List<MessageError> errorList = result.Errors;
foreach (Message aMessage in this._messages) foreach (Message aMessage in this._messages)
{ {
@ -698,22 +787,60 @@ namespace ENI2
} }
} }
private void DetailControl_RequestValidate() private async void DetailControl_RequestValidate(bool showDialog)
{ {
this.Validate(true, out _, out _); await ValidateAndApplyAsync(showDialog);
} }
private void Validate(bool showMessages, out List<MessageViolation> vViolations, out List<MessageError> vErrors) private async Task<ValidationResult> ValidateAndApplyAsync(bool showMessages)
{ {
vViolations = new List<MessageViolation>(); Task<ValidationResult> validationTask = null;
vErrors = new List<MessageError>(); lock (validationLock)
{
if (activeValidationTask != null && !activeValidationTask.IsCompleted)
{
if (showMessages)
pendingShowMessages = true;
validationTask = activeValidationTask;
}
else
{
pendingShowMessages = showMessages;
activeValidationTask = ValidateAndApplyCoreAsync();
validationTask = activeValidationTask;
}
}
// TODO: clear highlighting return await validationTask;
}
private async Task<ValidationResult> ValidateAndApplyCoreAsync()
{
Util.UIHelper.SetBusyState(); Util.UIHelper.SetBusyState();
ApplyCrewEffectsWarningSuppression();
List<Message> messagesSnapshot = _messages.ToList();
ValidationResult result = await Task.Run(() => ValidateCore(messagesSnapshot));
bool showMessages;
lock (validationLock)
{
showMessages = pendingShowMessages;
pendingShowMessages = false;
activeValidationTask = null;
}
ApplyValidationResult(result, showMessages);
return result;
}
private ValidationResult ValidateCore(List<Message> messagesSnapshot)
{
List<MessageViolation> vViolations = new List<MessageViolation>();
List<MessageError> vErrors = new List<MessageError>();
RuleEngine ruleEngine = new RuleEngine(); RuleEngine ruleEngine = new RuleEngine();
foreach (Message aMessage in _messages) foreach (Message aMessage in messagesSnapshot)
{ {
if (!aMessage.EvaluateForValidation(this.Core.IsTransit)) continue; if (!aMessage.EvaluateForValidation(this.Core.IsTransit)) continue;
@ -735,19 +862,22 @@ namespace ENI2
vViolations.AddRange(violations); vViolations.AddRange(violations);
} }
#region 12.11.18 / 6.3.21 / 23.5.22: globale Plausi-Prüfungen #region 12.11.18 / 6.3.21 / 23.5.22 / 26.10.24 / 27.1.26: globale Plausi-Prüfungen
Message crewaMessage = _messages.Find(message => message.MessageNotificationClass == Message.NotificationClass.CREWA); Message crewaMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.CREWA);
Message crewdMessage = _messages.Find(message => message.MessageNotificationClass == Message.NotificationClass.CREWD); Message crewdMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.CREWD);
Message pasaMessage = _messages.Find(message => message.MessageNotificationClass == Message.NotificationClass.PASA); Message pasaMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.PASA);
Message pasdMessage = _messages.Find(message => message.MessageNotificationClass == Message.NotificationClass.PASD); Message pasdMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.PASD);
Message pobaMessage = _messages.Find(message => message.MessageNotificationClass == Message.NotificationClass.POBA); Message pobaMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.POBA);
Message pobdMessage = _messages.Find(message => message.MessageNotificationClass == Message.NotificationClass.POBD); Message pobdMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.POBD);
Message secMessage = _messages.Find(message => message.MessageNotificationClass == Message.NotificationClass.SEC); Message secMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.SEC);
Message noanodMessage = _messages.Find(message => message.MessageNotificationClass == Message.NotificationClass.NOA_NOD); Message noanodMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.NOA_NOD);
Message mdhMessage = _messages.Find(message => message.MessageNotificationClass == Message.NotificationClass.MDH); Message mdhMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.MDH);
Message was_rcptMessage = _messages.Find(message => message.MessageNotificationClass == Message.NotificationClass.WAS_RCPT); Message was_rcptMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.WAS_RCPT);
Message wasMessage = _messages.Find(message => message.MessageNotificationClass == Message.NotificationClass.WAS); Message wasMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.WAS);
Message servMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.SERV);
Message statMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.STAT);
Message pre72hMessage = messagesSnapshot.Find(message => message.MessageNotificationClass == Message.NotificationClass.PRE72H);
#region CREW / PAS Count Plausibility #region CREW / PAS Count Plausibility
@ -755,14 +885,14 @@ namespace ENI2
{ {
POBA poba = pobaMessage.Elements[0] as POBA; POBA poba = pobaMessage.Elements[0] as POBA;
if (crewaMessage.Elements.Count != poba.TotalCrewMembersOnBoardUponArrival) if (crewaMessage.Elements.Count != (poba.TotalCrewMembersOnBoardUponArrival ?? 0))
{ {
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "POBA crew member count different from CREW count!", null, "Crew count mismatch", null, "CREWA"); MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "POBA crew member count different from CREW count!", null, "Crew count mismatch", null, "CREWA");
mv.MessageGroupName = Properties.Resources.textOverview; mv.MessageGroupName = Properties.Resources.textOverview;
vViolations.Add(mv); vViolations.Add(mv);
} }
if(pasaMessage.Elements.Count != poba.TotalPassengersOnBoardUponArrival) if(pasaMessage.Elements.Count != (poba.TotalPassengersOnBoardUponArrival ?? 0))
{ {
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "POBA passenger count different from PAS count!", null, "Passenger count mismatch", null, "PASA"); MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "POBA passenger count different from PAS count!", null, "Passenger count mismatch", null, "PASA");
mv.MessageGroupName = Properties.Resources.textOverview; mv.MessageGroupName = Properties.Resources.textOverview;
@ -771,14 +901,14 @@ namespace ENI2
POBD pobd = pobdMessage.Elements[0] as POBD; POBD pobd = pobdMessage.Elements[0] as POBD;
if (crewdMessage.Elements.Count != pobd.TotalCrewMembersOnBoardUponDeparture) if (crewdMessage.Elements.Count != (pobd.TotalCrewMembersOnBoardUponDeparture ?? 0))
{ {
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "POBD crew member count different from CREW count!", null, "Crew count mismatch", null, "CREWD"); MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "POBD crew member count different from CREW count!", null, "Crew count mismatch", null, "CREWD");
mv.MessageGroupName = Properties.Resources.textOverview; mv.MessageGroupName = Properties.Resources.textOverview;
vViolations.Add(mv); vViolations.Add(mv);
} }
if (pasdMessage.Elements.Count != pobd.TotalPassengersOnBoardUponDeparture) if (pasdMessage.Elements.Count != (pobd.TotalPassengersOnBoardUponDeparture ?? 0))
{ {
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "POBD passenger count different from PAS count!", null, "Passenger count mismatch", null, "PASD"); MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "POBD passenger count different from PAS count!", null, "Passenger count mismatch", null, "PASD");
mv.MessageGroupName = Properties.Resources.textOverview; mv.MessageGroupName = Properties.Resources.textOverview;
@ -887,22 +1017,6 @@ namespace ENI2
#endregion #endregion
#region 4.1.23 no CREW effects warning for DE
if (crewaMessage != null)
{
MessageViolation mv = crewaMessage.ViolationList.Find((x) => x.PropertyName.Equals("Effects") && (x.ViolationCode == (int)ValidationCode.TRUNCATE));
if ((mv != null) && !Core.IsDK)
crewaMessage.ViolationList.Remove(mv);
}
if(crewdMessage != null)
{
MessageViolation mvd = crewdMessage.ViolationList.Find((x) => x.PropertyName.Equals("Effects") && (x.ViolationCode == (int)ValidationCode.TRUNCATE));
if ((mvd != null) && !Core.IsDK)
crewdMessage.ViolationList.Remove(mvd);
}
#endregion
#region WAS_RCPT double numbers #region WAS_RCPT double numbers
Dictionary<string, string> identDict = new Dictionary<string, string>(); Dictionary<string, string> identDict = new Dictionary<string, string>();
@ -930,35 +1044,37 @@ namespace ENI2
#region Kiel Canal Timing Plausibility #region Kiel Canal Timing Plausibility
if (!this.Core.IsTransit && (secMessage?.Elements.Count > 0) && (noanodMessage?.Elements.Count > 0))
{ {
SEC sec = secMessage.Elements[0] as SEC; if (!this.Core.IsTransit && (secMessage?.Elements.Count > 0) && (noanodMessage?.Elements.Count > 0))
NOA_NOD noa_nod = noanodMessage.Elements[0] as NOA_NOD;
if (sec.KielCanalPassagePlanned ?? false)
{ {
// Überprüfung, ob die eingehende NOK-Durchfahrt auch wirklich innerhalb der eingehenden Reise liegt (bei VISIT) SEC sec = secMessage.Elements[0] as SEC;
bool isValidIncoming = (noa_nod.ETDFromLastPort < sec.KielCanalPassagePlannedIncomming) && NOA_NOD noa_nod = noanodMessage.Elements[0] as NOA_NOD;
(sec.KielCanalPassagePlannedIncomming < noa_nod.ETAToPortOfCall);
if (!sec.KielCanalPassagePlannedIncomming.HasValue) isValidIncoming = true;
if(!isValidIncoming) if (sec.KielCanalPassagePlanned ?? false)
{ {
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Kiel Canal incoming implausible (ETD / ETA ports)!", null, "Kiel Canal timing", null, "SEC"); // Überprüfung, ob die eingehende NOK-Durchfahrt auch wirklich innerhalb der eingehenden Reise liegt (bei VISIT)
mv.MessageGroupName = Properties.Resources.textOverview; bool isValidIncoming = (noa_nod.ETDFromLastPort < sec.KielCanalPassagePlannedIncomming) &&
vViolations.Add(mv); (sec.KielCanalPassagePlannedIncomming < noa_nod.ETAToPortOfCall);
} if (!sec.KielCanalPassagePlannedIncomming.HasValue) isValidIncoming = true;
if (!isValidIncoming)
{
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Kiel Canal incoming implausible (ETD / ETA ports)!", null, "Kiel Canal timing", null, "SEC");
mv.MessageGroupName = Properties.Resources.textOverview;
vViolations.Add(mv);
}
bool isValidOutgoing = (noa_nod.ETDFromPortOfCall < sec.KielCanalPassagePlannedOutgoing) && bool isValidOutgoing = (noa_nod.ETDFromPortOfCall < sec.KielCanalPassagePlannedOutgoing) &&
((noa_nod.NextPort == "ZZUKN") || (sec.KielCanalPassagePlannedOutgoing < noa_nod.ETAToNextPort)); ((noa_nod.NextPort == "ZZUKN") || (sec.KielCanalPassagePlannedOutgoing < noa_nod.ETAToNextPort));
if (!sec.KielCanalPassagePlannedOutgoing.HasValue) isValidOutgoing = true; if (!sec.KielCanalPassagePlannedOutgoing.HasValue) isValidOutgoing = true;
if(!isValidOutgoing) if (!isValidOutgoing)
{ {
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Kiel Canal outgoing implausible (ETD / ETA ports)!", null, "Kiel Canal timing", null, "SEC"); MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Kiel Canal outgoing implausible (ETD / ETA ports)!", null, "Kiel Canal timing", null, "SEC");
mv.MessageGroupName = Properties.Resources.textOverview; mv.MessageGroupName = Properties.Resources.textOverview;
vViolations.Add(mv); vViolations.Add(mv);
}
} }
} }
} }
@ -1085,19 +1201,163 @@ namespace ENI2
#endregion #endregion
#region SERV existence for DEHAM / DEBRE / DEBRV
if ((!this.Core.DisplayId.IsNullOrEmpty() && this.Core.DisplayId.StartsWith("DEHAM")) || this.Core.PoC.Equals("DEHAM") ||
(!this.Core.DisplayId.IsNullOrEmpty() && this.Core.DisplayId.StartsWith("DEBRE")) || this.Core.PoC.Equals("DEBRE") ||
(!this.Core.DisplayId.IsNullOrEmpty() && this.Core.DisplayId.StartsWith("DEBRV")) || this.Core.PoC.Equals("DEBRV"))
{
if (servMessage.Elements.Count == 0)
{
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.LIST_EMPTY, "No entry for SERV found", null, "SERV service provider", null, "SERV");
mv.MessageGroupName = Properties.Resources.textPortNotification;
vViolations.Add(mv);
}
}
#endregion #endregion
foreach (MessageError me in vErrors) #region Tanker validation STAT/PRE72H
if ((statMessage.Elements[0] is STAT stat) && (pre72hMessage.Elements[0] is PRE72H pre72h))
{ {
this.highlightService.HighlightError(me, this.GetContainerForMessageGroupName(me.MessageGroupName)); if((pre72h.Tanker ?? false) != (stat.IsTanker ?? false))
} {
foreach (MessageViolation mv in vViolations) MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.LIST_EMPTY, "Tanker: Please check PRE72H / STAT", null, "PRE72H / STAT", null, "STAT");
{ mv.MessageGroupName = Properties.Resources.textPortNotification;
this.highlightService.HighlightViolation(mv, this.GetContainerForMessageGroupName(mv.MessageGroupName)); vViolations.Add(mv);
}
} }
#endregion
#region WAS special max capa rules regarding next port
{
string wasMessageGroup = this.MessageGroupForMessage(wasMessage);
// see WAS-Regulation.docx in parent projects misc folder
if ((noanodMessage?.Elements.Count > 0) && wasMessage?.Elements.Count > 0)
{
NOA_NOD noa_nod = noanodMessage.Elements[0] as NOA_NOD;
WAS was = wasMessage.Elements[0] as WAS;
bool isSpecialNextPort = RuleEngine.IsSpecialNextPort(noa_nod.NextPort);
if (isSpecialNextPort)
{
foreach (Waste waste in was.Waste)
{
switch (waste.WasteType)
{
case 101:
case 102:
case 103:
case 104:
case 105:
case 401:
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.5)
{
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
mv.MessageGroupName = wasMessageGroup;
vViolations.Add(mv);
}
break;
case 501:
case 502:
case 503:
case 504:
case 505:
case 506:
case 507:
case 508:
case 509:
case 510:
case 511:
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.25)
{
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
mv.MessageGroupName = wasMessageGroup;
vViolations.Add(mv);
}
break;
case 601:
case 602:
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.75)
{
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
mv.MessageGroupName = wasMessageGroup;
vViolations.Add(mv);
}
break;
}
}
}
else
{
foreach (Waste waste in was.Waste)
{
switch (waste.WasteType)
{
case 101:
case 102:
case 103:
case 104:
case 105:
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.25)
{
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
mv.MessageGroupName = wasMessageGroup;
vViolations.Add(mv);
}
break;
case 401:
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.5)
{
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
mv.MessageGroupName = wasMessageGroup;
vViolations.Add(mv);
}
break;
case 501:
case 502:
case 503:
case 504:
case 505:
case 506:
case 507:
case 508:
case 509:
case 510:
case 511:
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.2)
{
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
mv.MessageGroupName = wasMessageGroup;
vViolations.Add(mv);
}
break;
case 601:
case 602:
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.25)
{
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
mv.MessageGroupName = wasMessageGroup;
vViolations.Add(mv);
}
break;
}
}
}
}
}
#endregion
#endregion
// "neue" regelbasierte Validierung: Hier werden die einzelnen Regeln geprüft. // "neue" regelbasierte Validierung: Hier werden die einzelnen Regeln geprüft.
bsmd.database.ValidationRule.PrepareNameLookupDict(this.Core, this._messages); bsmd.database.ValidationRule.PrepareNameLookupDict(this.Core, messagesSnapshot);
List<bsmd.database.ValidationRule> validationRules = DBManager.Instance.GetValidationRules(); List<bsmd.database.ValidationRule> validationRules = DBManager.Instance.GetValidationRules();
@ -1124,10 +1384,94 @@ namespace ENI2
} }
} }
// Recompute per-message counts after all global validations
Dictionary<Message, MessageValidationCounts> counts = new Dictionary<Message, MessageValidationCounts>();
int assignViolationCounter = 0;
int assignErrorCounter = 0;
List<MessageViolation> tmpVList = new List<MessageViolation>(vViolations);
List<MessageError> tmpEList = new List<MessageError>(vErrors);
foreach (Message aMessage in messagesSnapshot)
{
counts[aMessage] = new MessageValidationCounts();
counts[aMessage].ErrorCount = tmpEList.Count(me => me.NotificationClass == aMessage.MessageNotificationClassDisplay); // generic
// special cases
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.WAS_RCPT) && (me.NotificationClass == "WasteReceived"));
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IMDGPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IGCPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IBCPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IMSBCPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "MARPOL_Annex_I_Position") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IMDGPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IGCPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IBCPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IMSBCPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "MARPOL_Annex_I_Position") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.WAS) && (me.NotificationClass == "Waste"));
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.SEC) && (me.NotificationClass == "LastTenPortFacilitiesCalled"));
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.SEC) && (me.NotificationClass == "ShipToShipActivitiesDuringLastTenPortFacilitiesCalled"));
if (counts[aMessage].ErrorCount == 0) counts[aMessage].ErrorCount = null; // set to empty if nothing counted
assignErrorCounter += counts[aMessage].ErrorCount ?? 0;
counts[aMessage].ViolationCount = vViolations.Count(mv => mv.NotificationClass == aMessage.MessageNotificationClassDisplay); // generic
// special cases
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.WAS_RCPT) && (me.NotificationClass == "WasteReceived"));
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IMDGPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IGCPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IBCPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IMSBCPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "MARPOL_Annex_I_Position") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IMDGPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IGCPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IBCPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IMSBCPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "MARPOL_Annex_I_Position") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.WAS) && (me.NotificationClass == "Waste"));
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.SEC) && (me.NotificationClass == "LastTenPortFacilitiesCalled"));
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.SEC) && (me.NotificationClass == "ShipToShipActivitiesDuringLastTenPortFacilitiesCalled"));
if (counts[aMessage].ViolationCount == 0) counts[aMessage].ViolationCount = null;
assignViolationCounter += counts[aMessage].ViolationCount ?? 0;
}
Trace.WriteLine(string.Format("Unassigned errors: {0}, unassigned violations: {1}", vErrors.Count - assignErrorCounter, vViolations.Count - assignViolationCounter));
return new ValidationResult(vViolations, vErrors, counts);
}
private void ApplyValidationResult(ValidationResult result, bool showMessages)
{
// TODO: clear highlighting
foreach (KeyValuePair<Message, MessageValidationCounts> entry in result.Counts)
{
Message aMessage = entry.Key;
MessageValidationCounts messageCounts = entry.Value;
aMessage.ErrorCount = messageCounts.ErrorCount;
aMessage.ViolationCount = messageCounts.ViolationCount;
}
foreach (MessageError me in result.Errors)
{
this.highlightService.HighlightError(me, this.GetContainerForMessageGroupName(me.MessageGroupName));
}
foreach (MessageViolation mv in result.Violations)
{
this.highlightService.HighlightViolation(mv, this.GetContainerForMessageGroupName(mv.MessageGroupName));
}
if (showMessages) if (showMessages)
{ {
// Show error and violation dialog // Show error and violation dialog
if (vErrors.Count > 0) if (result.Errors.Count > 0)
{ {
if(this._errorListDialog == null) if(this._errorListDialog == null)
{ {
@ -1142,10 +1486,10 @@ namespace ENI2
{ {
this._errorListDialog.BringUp(); this._errorListDialog.BringUp();
} }
this._errorListDialog.Errors = vErrors; this._errorListDialog.Errors = result.Errors;
} }
if (vViolations.Count > 0) if (result.Violations.Count > 0)
{ {
if(this._violationListDialog == null) if(this._violationListDialog == null)
{ {
@ -1160,20 +1504,67 @@ namespace ENI2
{ {
this._violationListDialog.BringUp(); this._violationListDialog.BringUp();
} }
_violationListDialog.Violations = vViolations; _violationListDialog.Violations = result.Violations;
} }
if((vErrors.Count == 0) && (vViolations.Count == 0)) if((result.Errors.Count == 0) && (result.Violations.Count == 0))
{ {
MessageBox.Show(Properties.Resources.textValidationOK, Properties.Resources.textValidation, MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show(Properties.Resources.textValidationOK, Properties.Resources.textValidation, MessageBoxButton.OK, MessageBoxImage.Information);
} }
} }
if (controlCache.TryGetValue(Properties.Resources.textOverview, out DetailBaseControl overviewControl) &&
overviewControl is OverViewDetailControl ovdc)
{
ovdc.RefreshMessageGrid();
}
}
private void ApplyCrewEffectsWarningSuppression()
{
// 4.1.23 no CREW effects warning for DE
Message crewaMessage = _messages.Find(message => message.MessageNotificationClass == Message.NotificationClass.CREWA);
Message crewdMessage = _messages.Find(message => message.MessageNotificationClass == Message.NotificationClass.CREWD);
if (crewaMessage != null)
{
MessageViolation mv = crewaMessage.ViolationList.Find((x) => x.PropertyName.Equals("Effects") && (x.ViolationCode == (int)ValidationCode.TRUNCATE));
if ((mv != null) && !Core.IsDK)
crewaMessage.ViolationList.Remove(mv);
}
if(crewdMessage != null)
{
MessageViolation mvd = crewdMessage.ViolationList.Find((x) => x.PropertyName.Equals("Effects") && (x.ViolationCode == (int)ValidationCode.TRUNCATE));
if ((mvd != null) && !Core.IsDK)
crewdMessage.ViolationList.Remove(mvd);
}
}
private sealed class ValidationResult
{
internal ValidationResult(List<MessageViolation> violations, List<MessageError> errors, Dictionary<Message, MessageValidationCounts> counts)
{
Violations = violations;
Errors = errors;
Counts = counts;
}
internal List<MessageViolation> Violations { get; }
internal List<MessageError> Errors { get; }
internal Dictionary<Message, MessageValidationCounts> Counts { get; }
}
private sealed class MessageValidationCounts
{
internal int? ErrorCount { get; set; }
internal int? ViolationCount { get; set; }
internal int? PositionViolationCount { get; set; }
} }
private void _errorListDialog_RefreshClicked() private void _errorListDialog_RefreshClicked()
{ {
DetailControl_RequestValidate(); DetailControl_RequestValidate(true);
} }
private void _errorListDialog_ErrorSelected(DatabaseEntity obj) private void _errorListDialog_ErrorSelected(DatabaseEntity obj)

View File

@ -71,8 +71,24 @@
AutoGenerateColumns="False" Margin="0,5,0,0"> AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" /> <DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textBunkerType}" Binding="{Binding BunkerFuelType}" IsReadOnly="True" Width="0.2*" /> <DataGridTextColumn Header="{x:Static p:Resources.textBunkerType}" Width="0.2*">
<DataGridTextColumn Header="{x:Static p:Resources.textBunkerQuantity}" Binding="{Binding BunkerFuelQuantity_TNE, Mode=TwoWay}" IsReadOnly="True" Width="0.8*" /> <DataGridTextColumn.Binding>
<Binding Path="BunkerFuelType" Mode="TwoWay">
<Binding.ValidationRules>
<util:StringValidationRule MaxLength="25" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textBunkerQuantity}" IsReadOnly="False" Width="0.8*">
<DataGridTextColumn.Binding>
<Binding Path="BunkerFuelQuantity_TNE" Mode="TwoWay">
<Binding.ValidationRules>
<util:NumberValidationRule MaxValue="10000"/>
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
</DataGrid.Columns> </DataGrid.Columns>
</enictrl:ENIDataGrid> </enictrl:ENIDataGrid>
</GroupBox> </GroupBox>

View File

@ -39,6 +39,7 @@ namespace ENI2.DetailViewControls
this.RegisterIntegerUpDownChange(this.integerUpDownPassengersOnBoard, Message.NotificationClass.POBA); this.RegisterIntegerUpDownChange(this.integerUpDownPassengersOnBoard, Message.NotificationClass.POBA);
this.RegisterIntegerUpDownChange(this.integerUpDownPersonsOnBoard, Message.NotificationClass.POBA); this.RegisterIntegerUpDownChange(this.integerUpDownPersonsOnBoard, Message.NotificationClass.POBA);
this.RegisterIntegerUpDownChange(this.integerUpDownStowawaysOnBoard, Message.NotificationClass.POBA); this.RegisterIntegerUpDownChange(this.integerUpDownStowawaysOnBoard, Message.NotificationClass.POBA);
this.dataGridBKRA.CellEditEnding += (obj, ev) => { this.SublistElementChanged(Message.NotificationClass.BKRA); };
startupComplete = true; startupComplete = true;
} }
@ -183,6 +184,8 @@ namespace ENI2.DetailViewControls
private void DataGridBKRA_CreateRequested() private void DataGridBKRA_CreateRequested()
{ {
this.dataGridBKRA.CancelEdit();
this.dataGridBKRA.CancelEdit();
EditBKRDialog ebd = new EditBKRDialog(); EditBKRDialog ebd = new EditBKRDialog();
ebd.BRKA = new BRKA(); ebd.BRKA = new BRKA();
ebd.BRKA.Identifier = BRKA.GetNewIdentifier(this._bkraMessage.Elements); ebd.BRKA.Identifier = BRKA.GetNewIdentifier(this._bkraMessage.Elements);
@ -215,6 +218,8 @@ namespace ENI2.DetailViewControls
{ {
if (obj is BRKA brka) if (obj is BRKA brka)
{ {
this.dataGridBKRA.CancelEdit();
this.dataGridBKRA.CancelEdit();
// are you sure dialog is in base class // are you sure dialog is in base class
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(brka); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(brka);
this._bkraMessage.Elements.Remove(brka); this._bkraMessage.Elements.Remove(brka);
@ -226,6 +231,10 @@ namespace ENI2.DetailViewControls
private void DataGridBKRA_EditRequested(DatabaseEntity obj) private void DataGridBKRA_EditRequested(DatabaseEntity obj)
{ {
// I am not shitting you: this has to be called TWICE(!) in a row in order to work
// see: https://stackoverflow.com/questions/20204592/wpf-datagrid-refresh-is-not-allowed-during-an-addnew-or-edititem-transaction-m
this.dataGridBKRA.CancelEdit(DataGridEditingUnit.Row);
this.dataGridBKRA.CommitEdit(DataGridEditingUnit.Row, true);
EditBKRDialog eld = new EditBKRDialog(); EditBKRDialog eld = new EditBKRDialog();
eld.IsDeparture = false; eld.IsDeparture = false;
@ -236,7 +245,8 @@ namespace ENI2.DetailViewControls
eld.CopyValuesToEntity(); eld.CopyValuesToEntity();
if(!_bkraMessage.Elements.Contains(eld.BRKA)) if(!_bkraMessage.Elements.Contains(eld.BRKA))
_bkraMessage.Elements.Add(eld.BRKA); _bkraMessage.Elements.Add(eld.BRKA);
this.dataGridBKRA.Items.Refresh(); this.dataGridBKRA.ItemsSource = null;
this.dataGridBKRA.ItemsSource = this._bkraMessage.Elements;
eld.BRKA = new BRKA(); eld.BRKA = new BRKA();
eld.BRKA.Identifier = BRKA.GetNewIdentifier(this._bkraMessage.Elements); eld.BRKA.Identifier = BRKA.GetNewIdentifier(this._bkraMessage.Elements);
eld.BRKA.MessageHeader = _bkraMessage; eld.BRKA.MessageHeader = _bkraMessage;
@ -247,7 +257,8 @@ namespace ENI2.DetailViewControls
{ {
if (!_bkraMessage.Elements.Contains(eld.BRKA)) if (!_bkraMessage.Elements.Contains(eld.BRKA))
_bkraMessage.Elements.Add(eld.BRKA); _bkraMessage.Elements.Add(eld.BRKA);
this.dataGridBKRA.Items.Refresh(); this.dataGridBKRA.ItemsSource = null;
this.dataGridBKRA.ItemsSource = this._bkraMessage.Elements;
this.SublistElementChanged(Message.NotificationClass.BKRA); this.SublistElementChanged(Message.NotificationClass.BKRA);
} }
} }
@ -279,17 +290,6 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
#endregion
#region special datetimepicker validation popup (OMG) #region special datetimepicker validation popup (OMG)
private void dateTimePickerATA_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e) private void dateTimePickerATA_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)

View File

@ -65,6 +65,7 @@
<Label Name="labelCrewNotificationSchengen" Content="{x:Static p:Resources.textNotificationSchengen}" /> <Label Name="labelCrewNotificationSchengen" Content="{x:Static p:Resources.textNotificationSchengen}" />
<CheckBox Name="checkBoxCrewNotificationPAX" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationPAX_Click"/> <CheckBox Name="checkBoxCrewNotificationPAX" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationPAX_Click"/>
<Label Name="labelCrewNotificationPAX" Content="{x:Static p:Resources.textNotificationPAX}" /> <Label Name="labelCrewNotificationPAX" Content="{x:Static p:Resources.textNotificationPAX}" />
<Button Name="buttonDeleteAllCrewA" Margin="2" Content="{x:Static p:Resources.textDeleteAllEntries}" Background="Transparent" Click="buttonDeleteAllCrewA_Click"/>
<TextBlock Margin="30,0,0,0" FontWeight="Bold" FontSize="16" Text="CREWA" VerticalAlignment="Center" /> <TextBlock Margin="30,0,0,0" FontWeight="Bold" FontSize="16" Text="CREWA" VerticalAlignment="Center" />
</StackPanel> </StackPanel>
@ -107,6 +108,7 @@
<Label Name="labelCrewNotificationSchengenDeparture" Content="{x:Static p:Resources.textNotificationSchengen}" /> <Label Name="labelCrewNotificationSchengenDeparture" Content="{x:Static p:Resources.textNotificationSchengen}" />
<CheckBox Name="checkBoxCrewNotificationPAXDeparture" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationPAXDeparture_Click"/> <CheckBox Name="checkBoxCrewNotificationPAXDeparture" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationPAXDeparture_Click"/>
<Label Name="labelCrewNotificationPAXDeparture" Content="{x:Static p:Resources.textNotificationPAX}" /> <Label Name="labelCrewNotificationPAXDeparture" Content="{x:Static p:Resources.textNotificationPAX}" />
<Button Name="buttonDeleteAllCrewD" Margin="2" Content="{x:Static p:Resources.textDeleteAllEntries}" Background="Transparent" Click="buttonDeleteAllCrewD_Click"/>
<TextBlock Margin="30,0,0,0" FontWeight="Bold" FontSize="16" Text="CREWD" VerticalAlignment="Center" /> <TextBlock Margin="30,0,0,0" FontWeight="Bold" FontSize="16" Text="CREWD" VerticalAlignment="Center" />
</StackPanel> </StackPanel>
<enictrl:ENIDataGrid Grid.Row="1" Grid.Column="0" x:Name="dataGridCrewListDeparture" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" <enictrl:ENIDataGrid Grid.Row="1" Grid.Column="0" x:Name="dataGridCrewListDeparture" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
@ -147,6 +149,7 @@
<Label Name="labelPasNotificationSchengen" Content="{x:Static p:Resources.textNotificationSchengen}" /> <Label Name="labelPasNotificationSchengen" Content="{x:Static p:Resources.textNotificationSchengen}" />
<CheckBox Name="checkBoxPasNotificationPAX" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationPAX_Click"/> <CheckBox Name="checkBoxPasNotificationPAX" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationPAX_Click"/>
<Label Name="labelPasNotificationPAX" Content="{x:Static p:Resources.textNotificationPAX}" /> <Label Name="labelPasNotificationPAX" Content="{x:Static p:Resources.textNotificationPAX}" />
<Button Name="buttonDeleteAllPasA" Margin="2" Content="{x:Static p:Resources.textDeleteAllEntries}" Background="Transparent" Click="buttonDeleteAllPasA_Click"/>
<TextBlock Margin="30,0,0,0" FontWeight="Bold" FontSize="16" Text="PASA" VerticalAlignment="Center" /> <TextBlock Margin="30,0,0,0" FontWeight="Bold" FontSize="16" Text="PASA" VerticalAlignment="Center" />
</StackPanel> </StackPanel>
<enictrl:ENIDataGrid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" x:Name="dataGridPassengerList" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" <enictrl:ENIDataGrid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" x:Name="dataGridPassengerList" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
@ -192,6 +195,7 @@
<Label Name="labelPasNotificationSchengenDeparture" Content="{x:Static p:Resources.textNotificationSchengen}" /> <Label Name="labelPasNotificationSchengenDeparture" Content="{x:Static p:Resources.textNotificationSchengen}" />
<CheckBox Name="checkBoxPasNotificationPAXDeparture" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationPAXDeparture_Click"/> <CheckBox Name="checkBoxPasNotificationPAXDeparture" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationPAXDeparture_Click"/>
<Label Name="labelPasNotificationPAXDeparture" Content="{x:Static p:Resources.textNotificationPAX}" /> <Label Name="labelPasNotificationPAXDeparture" Content="{x:Static p:Resources.textNotificationPAX}" />
<Button Name="buttonDeleteAllPasD" Margin="2" Content="{x:Static p:Resources.textDeleteAllEntries}" Background="Transparent" Click="buttonDeleteAllPasD_Click"/>
<TextBlock Margin="30,0,0,0" FontWeight="Bold" FontSize="16" Text="PASD" VerticalAlignment="Center" /> <TextBlock Margin="30,0,0,0" FontWeight="Bold" FontSize="16" Text="PASD" VerticalAlignment="Center" />
</StackPanel> </StackPanel>
<enictrl:ENIDataGrid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" x:Name="dataGridPassengerListDeparture" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" <enictrl:ENIDataGrid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" x:Name="dataGridPassengerListDeparture" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"

View File

@ -11,9 +11,10 @@ using System.Windows.Controls;
using ENI2.EditControls; using ENI2.EditControls;
using ENI2.Util; using ENI2.Util;
using ENI2.Locode; using ENI2.Locode;
using ExcelDataReader; using ClosedXML.Excel;
using bsmd.database; using bsmd.database;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Linq;
namespace ENI2.DetailViewControls namespace ENI2.DetailViewControls
{ {
@ -113,6 +114,7 @@ namespace ENI2.DetailViewControls
this.dataGridCrewList.DeleteRequested += DataGridCrewList_DeleteRequested; this.dataGridCrewList.DeleteRequested += DataGridCrewList_DeleteRequested;
this.dataGridCrewList.CreateRequested += DataGridCrewList_CreateRequested; this.dataGridCrewList.CreateRequested += DataGridCrewList_CreateRequested;
this.dataGridCrewList.RefreshGrid += DataGridCrewList_RefreshGrid; this.dataGridCrewList.RefreshGrid += DataGridCrewList_RefreshGrid;
this.dataGridCrewList.MultiEditRequested += DataGridCrewList_MultiEditRequested;
if(this._crewMessage.Elements.Count > 0) if(this._crewMessage.Elements.Count > 0)
{ {
@ -149,6 +151,7 @@ namespace ENI2.DetailViewControls
this.dataGridCrewListDeparture.DeleteRequested += DataGridCrewListDeparture_DeleteRequested; this.dataGridCrewListDeparture.DeleteRequested += DataGridCrewListDeparture_DeleteRequested;
this.dataGridCrewListDeparture.CreateRequested += DataGridCrewListDeparture_CreateRequested; this.dataGridCrewListDeparture.CreateRequested += DataGridCrewListDeparture_CreateRequested;
this.dataGridCrewListDeparture.RefreshGrid += DataGridCrewListDeparture_RefreshGrid; this.dataGridCrewListDeparture.RefreshGrid += DataGridCrewListDeparture_RefreshGrid;
this.dataGridCrewListDeparture.MultiEditRequested += DataGridCrewListDeparture_MultiEditRequested;
if (this._crewdMessage.Elements.Count > 0) if (this._crewdMessage.Elements.Count > 0)
{ {
@ -185,6 +188,7 @@ namespace ENI2.DetailViewControls
this.dataGridPassengerList.DeleteRequested += DataGridPassengerList_DeleteRequested; this.dataGridPassengerList.DeleteRequested += DataGridPassengerList_DeleteRequested;
this.dataGridPassengerList.CreateRequested += DataGridPassengerList_CreateRequested; this.dataGridPassengerList.CreateRequested += DataGridPassengerList_CreateRequested;
this.dataGridPassengerList.RefreshGrid += DataGridPassengerList_RefreshGrid; this.dataGridPassengerList.RefreshGrid += DataGridPassengerList_RefreshGrid;
this.dataGridPassengerList.MultiEditRequested += DataGridPassengerList_MultiEditRequested;
if (this._pasMessage.Elements.Count > 0) if (this._pasMessage.Elements.Count > 0)
{ {
@ -221,6 +225,7 @@ namespace ENI2.DetailViewControls
this.dataGridPassengerListDeparture.DeleteRequested += DataGridPassengerListDeparture_DeleteRequested; this.dataGridPassengerListDeparture.DeleteRequested += DataGridPassengerListDeparture_DeleteRequested;
this.dataGridPassengerListDeparture.CreateRequested += DataGridPassengerListDeparture_CreateRequested; this.dataGridPassengerListDeparture.CreateRequested += DataGridPassengerListDeparture_CreateRequested;
this.dataGridPassengerListDeparture.RefreshGrid += DataGridPassengerListDeparture_RefreshGrid; this.dataGridPassengerListDeparture.RefreshGrid += DataGridPassengerListDeparture_RefreshGrid;
this.dataGridPassengerListDeparture.MultiEditRequested += DataGridPassengerListDeparture_MultiEditRequested;
if (this._pasdMessage.Elements.Count > 0) if (this._pasdMessage.Elements.Count > 0)
{ {
@ -234,13 +239,19 @@ namespace ENI2.DetailViewControls
MenuItem copyPASDItem = new MenuItem(); MenuItem copyPASDItem = new MenuItem();
copyPASDItem.Header = Properties.Resources.textCopyToPASA; copyPASDItem.Header = Properties.Resources.textCopyToPASA;
copyPASDItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) }; copyPASDItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
copyPASDItem.Click += CopyPASDItem_Click; ; copyPASDItem.Click += CopyPASDItem_Click;
this.dataGridPassengerListDeparture.ContextMenu.Items.Add(copyPASDItem); this.dataGridPassengerListDeparture.ContextMenu.Items.Add(copyPASDItem);
} }
#endregion #endregion
} }
public override int SelectedTabIndex
{
get { return this.mainFrame.SelectedIndex; }
set { this.mainFrame.SelectedIndex = value; }
}
#region Grid copy handlers #region Grid copy handlers
private void CopyPASDItem_Click(object sender, RoutedEventArgs e) private void CopyPASDItem_Click(object sender, RoutedEventArgs e)
@ -629,6 +640,28 @@ namespace ENI2.DetailViewControls
this.DataGridPassengerList_CreateRequested(); this.DataGridPassengerList_CreateRequested();
} }
private void DataGridPassengerList_MultiEditRequested(List<DatabaseEntity> databaseEntities)
{
List<PAS> pasList = new List<PAS>();
foreach (PAS apas in databaseEntities.Cast<PAS>())
pasList.Add(apas);
// write common values of all PAS entities to template entity
PAS pas = PAS.CreateCommon(pasList);
EditPASDialog dialog = new EditPASDialog();
dialog.PAS = pas;
dialog.AddVisible = false;
if (dialog.ShowDialog() ?? false)
{
// write back changed values from pas to all entities and mark them as changed
PAS.WriteTemplateToList(pas, pasList);
this.SublistElementChanged(Message.NotificationClass.PASA);
this.dataGridPassengerList.Items.Refresh();
}
}
#endregion #endregion
#region passenger grid departure #region passenger grid departure
@ -651,7 +684,7 @@ namespace ENI2.DetailViewControls
this._pasdMessage.Elements.Add(epd.PAS); this._pasdMessage.Elements.Add(epd.PAS);
this.CheckPASD(); this.CheckPASD();
} }
this.dataGridPassengerList.Items.Refresh(); this.dataGridPassengerListDeparture.Items.Refresh();
epd.PAS = new PASD epd.PAS = new PASD
{ {
IsDeparture = true, IsDeparture = true,
@ -705,7 +738,7 @@ namespace ENI2.DetailViewControls
_pasMessage.Elements.Add(epd.PAS); _pasMessage.Elements.Add(epd.PAS);
this.CheckPASD(); this.CheckPASD();
} }
this.dataGridPassengerList.Items.Refresh(); this.dataGridPassengerListDeparture.Items.Refresh();
epd.PAS = new PASD epd.PAS = new PASD
{ {
IsDeparture = true, IsDeparture = true,
@ -733,6 +766,28 @@ namespace ENI2.DetailViewControls
this.DataGridPassengerListDeparture_CreateRequested(); this.DataGridPassengerListDeparture_CreateRequested();
} }
private void DataGridPassengerListDeparture_MultiEditRequested(List<DatabaseEntity> databaseEntities)
{
List<PAS> pasList = new List<PAS>();
foreach (PAS apas in databaseEntities.Cast<PAS>())
pasList.Add(apas);
// write common values of all PAS entities to template entity
PAS pas = PAS.CreateCommon(pasList);
EditPASDialog dialog = new EditPASDialog();
dialog.PAS = pas;
dialog.AddVisible = false;
if (dialog.ShowDialog() ?? false)
{
// write back changed values from pas to all entities and mark them as changed
PAS.WriteTemplateToList(pas, pasList);
this.SublistElementChanged(Message.NotificationClass.PASD);
this.dataGridPassengerListDeparture.Items.Refresh();
}
}
#endregion #endregion
#region crew grid arrival #region crew grid arrival
@ -834,6 +889,28 @@ namespace ENI2.DetailViewControls
this.DataGridCrewList_CreateRequested(); this.DataGridCrewList_CreateRequested();
} }
private void DataGridCrewList_MultiEditRequested(List<DatabaseEntity> databaseEntities)
{
List<CREW> crewList = new List<CREW>();
foreach (CREW acrew in databaseEntities.Cast<CREW>())
crewList.Add(acrew);
// write common values of all CREW entities to template entity
CREW crew = CREW.CreateCommon(crewList);
EditCREWDialog dialog = new EditCREWDialog();
dialog.CREW = crew;
dialog.AddVisible = false;
if(dialog.ShowDialog() ?? false)
{
// write back changed values from crew to all entities and mark them as changed
CREW.WriteTemplateToList(crew, crewList);
this.SublistElementChanged(Message.NotificationClass.CREWA);
this.dataGridCrewList.Items.Refresh();
}
}
#endregion #endregion
#region crew grid departure #region crew grid departure
@ -938,21 +1015,32 @@ namespace ENI2.DetailViewControls
this.DataGridCrewListDeparture_CreateRequested(); this.DataGridCrewListDeparture_CreateRequested();
} }
private void DataGridCrewListDeparture_MultiEditRequested(List<DatabaseEntity> databaseEntities)
{
List<CREW> crewList = new List<CREW>();
foreach (CREW acrew in databaseEntities.Cast<CREW>())
crewList.Add(acrew);
// write common values of all CREW entities to template entity
CREW crew = CREW.CreateCommon(crewList);
EditCREWDialog dialog = new EditCREWDialog();
dialog.CREW = crew;
dialog.AddVisible = false;
if (dialog.ShowDialog() ?? false)
{
// write back changed values from crew to all entities and mark them as changed
CREW.WriteTemplateToList(crew, crewList);
this.SublistElementChanged(Message.NotificationClass.CREWD);
this.dataGridCrewListDeparture.Items.Refresh();
}
}
#endregion #endregion
#region Excel import #region Excel import
private string getValueAsString(IExcelDataReader reader, int index)
{
Type fieldType = reader.GetFieldType(index);
if (fieldType == null) return null;
if (fieldType == typeof(double))
return reader.GetDouble(index).ToString();
if (fieldType == typeof(int))
return reader.GetInt32(index).ToString();
return reader.GetString(index);
}
private void buttonImportExcelCrew_Click(object sender, RoutedEventArgs e) private void buttonImportExcelCrew_Click(object sender, RoutedEventArgs e)
{ {
OpenFileDialog ofd = new OpenFileDialog OpenFileDialog ofd = new OpenFileDialog
@ -961,70 +1049,66 @@ namespace ENI2.DetailViewControls
}; };
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var workbook = new XLWorkbook(stream))
{
var worksheet = workbook.Worksheet(1); // Get first worksheet
var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
List<CREW> importCrew = new List<CREW>();
foreach (var row in rows)
{
if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
// Check if we have at least 13 columns
if (worksheet.RangeUsed().ColumnCount() < 13)
{
throw new InvalidDataException("Sheet must have 13 columns of data");
}
CREW crew = new CREW();
// Check if first two cells are empty
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (!row.Cell(1).IsEmpty()) crew.CrewMemberLastName = row.Cell(1).GetString().Clean();
if (crew.CrewMemberLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(crew.CrewMemberLastName)) continue;
if (!row.Cell(2).IsEmpty()) crew.CrewMemberFirstName = row.Cell(2).GetString().Clean();
if (!row.Cell(3).IsEmpty()) crew.CrewMemberGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
if (!row.Cell(4).IsEmpty()) crew.CrewMemberDuty = row.Cell(4).GetString().Clean();
if (!row.Cell(5).IsEmpty()) crew.CrewMemberNationality = row.Cell(5).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(6).IsEmpty()) crew.CrewMemberPlaceOfBirth = row.Cell(6).GetString().Clean();
if (!row.Cell(7).IsEmpty()) crew.CrewMemberCountryOfBirth = row.Cell(7).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(8).IsEmpty()) crew.CrewMemberDateOfBirth = row.Cell(8).GetDateTime();
if (!row.Cell(9).IsEmpty()) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(9).GetString());
if (!row.Cell(10).IsEmpty()) crew.CrewMemberIdentityDocumentId = row.Cell(10).GetString().Clean();
if (!row.Cell(11).IsEmpty()) crew.CrewMemberIdentityDocumentIssuingState = row.Cell(11).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(12).IsEmpty()) crew.CrewMemberIdentityDocumentExpiryDate = row.Cell(12).GetDateTime();
if (!row.Cell(13).IsEmpty()) crew.CrewMemberVisaNumber = row.Cell(13).GetString().Clean();
crew.MessageHeader = this._crewMessage;
crew.IsDirty = true;
crew.Identifier = CREW.GetNewIdentifier(this._crewMessage.Elements);
this._crewMessage.Elements.Add(crew);
importCrew.Add(crew);
}
if (importCrew.Count > 0)
{
this.dataGridCrewList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWA);
MessageBox.Show(String.Format(Properties.Resources.textCrewImported, importCrew.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
return;
} }
using (IExcelDataReader reader = ExcelReaderFactory.CreateReader(stream))
{
List<CREW> importCrew = new List<CREW>();
try
{
do
{
while (reader.Read())
{
if(reader.FieldCount < 13)
{
throw new InvalidDataException("Sheet must have 13 columns of data");
}
CREW crew = new CREW();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) crew.CrewMemberLastName = reader.GetString(0).Clean();
if (crew.CrewMemberLastName.Equals("Family Name") || (crew.CrewMemberLastName.Trim().Length == 0)) continue;
if (!reader.IsDBNull(1)) crew.CrewMemberFirstName = reader.GetString(1).Clean();
if (!reader.IsDBNull(2)) crew.CrewMemberGender = GlobalStructures.ParseGender(reader.GetString(2));
if (!reader.IsDBNull(3)) crew.CrewMemberDuty = reader.GetString(3).Clean();
if (!reader.IsDBNull(4)) crew.CrewMemberNationality = reader.GetString(4).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(5)) crew.CrewMemberPlaceOfBirth = reader.GetString(5).Clean();
if (!reader.IsDBNull(6)) crew.CrewMemberCountryOfBirth = reader.GetString(6).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(7)) crew.CrewMemberDateOfBirth = reader.GetDateTime(7);
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8));
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = this.getValueAsString(reader, 9).Clean();
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11);
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = this.getValueAsString(reader, 12).Clean();
crew.MessageHeader = this._crewMessage;
crew.IsDirty = true;
crew.Identifier = CREW.GetNewIdentifier(this._crewMessage.Elements);
this._crewMessage.Elements.Add(crew);
importCrew.Add(crew);
}
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importCrew.Count > 0)
{
this.dataGridCrewList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWA);
MessageBox.Show(String.Format(Properties.Resources.textCrewImported, importCrew.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
stream.Close();
} }
} }
@ -1036,72 +1120,67 @@ namespace ENI2.DetailViewControls
}; };
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var workbook = new XLWorkbook(stream))
{
var worksheet = workbook.Worksheet(1); // Get first worksheet
var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
List<CREWD> importCrew = new List<CREWD>();
foreach (var row in rows)
{
if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
// Check if we have at least 13 columns
if (worksheet.RangeUsed().ColumnCount() < 13)
{
throw new InvalidDataException("Sheet must have 13 columns of data");
}
CREWD crew = new CREWD();
crew.IsDeparture = true;
// Check if first two cells are empty
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (!row.Cell(1).IsEmpty()) crew.CrewMemberLastName = row.Cell(1).GetString().Clean();
if (crew.CrewMemberLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(crew.CrewMemberLastName)) continue;
if (!row.Cell(2).IsEmpty()) crew.CrewMemberFirstName = row.Cell(2).GetString().Clean();
if (!row.Cell(3).IsEmpty()) crew.CrewMemberGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
if (!row.Cell(4).IsEmpty()) crew.CrewMemberDuty = row.Cell(4).GetString().Clean();
if (!row.Cell(5).IsEmpty()) crew.CrewMemberNationality = row.Cell(5).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(6).IsEmpty()) crew.CrewMemberPlaceOfBirth = row.Cell(6).GetString().Clean();
if (!row.Cell(7).IsEmpty()) crew.CrewMemberCountryOfBirth = row.Cell(7).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(8).IsEmpty()) crew.CrewMemberDateOfBirth = row.Cell(8).GetDateTime();
if (!row.Cell(9).IsEmpty()) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(9).GetString());
if (!row.Cell(10).IsEmpty()) crew.CrewMemberIdentityDocumentId = row.Cell(10).GetString().Clean();
if (!row.Cell(11).IsEmpty()) crew.CrewMemberIdentityDocumentIssuingState = row.Cell(11).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(12).IsEmpty()) crew.CrewMemberIdentityDocumentExpiryDate = row.Cell(12).GetDateTime();
if (!row.Cell(13).IsEmpty()) crew.CrewMemberVisaNumber = row.Cell(13).GetString().Clean();
crew.MessageHeader = this._crewdMessage;
crew.IsDirty = true;
crew.Identifier = CREWD.GetNewIdentifier(this._crewdMessage.Elements);
this._crewdMessage.Elements.Add(crew);
importCrew.Add(crew);
}
if (importCrew.Count > 0)
{
this.dataGridCrewListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWD);
MessageBox.Show(String.Format(Properties.Resources.textCrewImported, importCrew.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
return;
} }
using (IExcelDataReader reader = ExcelReaderFactory.CreateReader(stream))
{
List<CREWD> importCrew = new List<CREWD>();
try
{
do
{
while (reader.Read())
{
if (reader.FieldCount < 13)
{
throw new InvalidDataException("Sheet must have 13 columns of data");
}
CREWD crew = new CREWD();
crew.IsDeparture = true;
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) crew.CrewMemberLastName = reader.GetString(0);
if (crew.CrewMemberLastName.Equals("Family Name") || (crew.CrewMemberLastName.Trim().Length == 0)) continue;
if (!reader.IsDBNull(1)) crew.CrewMemberFirstName = reader.GetString(1);
if (!reader.IsDBNull(2)) crew.CrewMemberGender = GlobalStructures.ParseGender(reader.GetString(2));
if (!reader.IsDBNull(3)) crew.CrewMemberDuty = reader.GetString(3);
if (!reader.IsDBNull(4)) crew.CrewMemberNationality = reader.GetString(4).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(5)) crew.CrewMemberPlaceOfBirth = reader.GetString(5);
if (!reader.IsDBNull(6)) crew.CrewMemberCountryOfBirth = reader.GetString(6).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(7)) crew.CrewMemberDateOfBirth = reader.GetDateTime(7);
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8));
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = this.getValueAsString(reader, 9);
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11);
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = this.getValueAsString(reader, 12);
crew.MessageHeader = this._crewMessage;
crew.IsDirty = true;
crew.Identifier = CREWD.GetNewIdentifier(this._crewdMessage.Elements);
this._crewdMessage.Elements.Add(crew);
importCrew.Add(crew);
}
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importCrew.Count > 0)
{
this.dataGridCrewListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWD);
MessageBox.Show(String.Format(Properties.Resources.textCrewImported, importCrew.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
stream.Close();
} }
} }
@ -1113,83 +1192,75 @@ namespace ENI2.DetailViewControls
}; };
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var workbook = new XLWorkbook(stream))
{
var worksheet = workbook.Worksheet(1);
var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
List<PAS> importPassenger = new List<PAS>();
foreach (var row in rows)
{
if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
if (worksheet.RangeUsed().ColumnCount() < 17)
{
throw new InvalidDataException("Sheet must have 17 columns of data");
}
PAS pas = new PAS();
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (!row.Cell(1).IsEmpty()) pas.PassengerLastName = row.Cell(1).GetString().Clean();
if (pas.PassengerLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(pas.PassengerLastName)) continue;
if (!row.Cell(2).IsEmpty()) pas.PassengerFirstName = row.Cell(2).GetString().Clean();
if (!row.Cell(3).IsEmpty()) pas.PassengerGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
if (!row.Cell(4).IsEmpty()) pas.PassengerPortOfEmbarkation = row.Cell(4).GetString().Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
pas.PassengerPortOfEmbarkation = null;
if (!row.Cell(5).IsEmpty()) pas.PassengerPortOfDisembarkation = row.Cell(5).GetString().Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
pas.PassengerPortOfDisembarkation = null;
if (!row.Cell(6).IsEmpty()) pas.PassengerInTransit = GlobalStructures.ReadBoolean(row.Cell(6).GetString());
if (!row.Cell(7).IsEmpty()) pas.PassengerNationality = row.Cell(7).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(8).IsEmpty()) pas.PassengerPlaceOfBirth = row.Cell(8).GetString().Clean();
if (!row.Cell(9).IsEmpty()) pas.PassengerCountryOfBirth = row.Cell(9).GetString().Substring(0, 2).ToUpper().Clean();
if (!row.Cell(10).IsEmpty()) pas.PassengerDateOfBirth = row.Cell(10).GetDateTime();
if (!row.Cell(11).IsEmpty()) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(11).GetString());
if (!row.Cell(12).IsEmpty()) pas.PassengerIdentityDocumentId = row.Cell(12).GetString().Clean();
if (!row.Cell(13).IsEmpty()) pas.PassengerIdentityDocumentIssuingState = row.Cell(13).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(14).IsEmpty()) pas.PassengerIdentityDocumentExpiryDate = row.Cell(14).GetDateTime();
if (!row.Cell(15).IsEmpty()) pas.PassengerVisaNumber = row.Cell(15).GetString().Clean();
if (!row.Cell(16).IsEmpty()) pas.EmergencyCare = row.Cell(16).GetString().Clean();
if (!row.Cell(17).IsEmpty()) pas.EmergencyContactNumber = row.Cell(17).GetString().Clean();
pas.MessageHeader = this._pasMessage;
pas.IsDirty = true;
pas.Identifier = PAS.GetNewIdentifier(this._pasMessage.Elements);
this._pasMessage.Elements.Add(pas);
importPassenger.Add(pas);
}
if (importPassenger.Count > 0)
{
this.dataGridPassengerList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASA);
MessageBox.Show(String.Format(Properties.Resources.textPassengerImported, importPassenger.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
return;
} }
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
List<PAS> importPassenger = new List<PAS>();
try
{
do
{
while (reader.Read())
{
if (((IExcelDataReader)reader).FieldCount < 17)
{
throw new InvalidDataException("Sheet must have 17 columns of data");
}
PAS pas = new PAS();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) pas.PassengerLastName = reader.GetValue(0).ToString().Clean();
if (pas.PassengerLastName.Equals("Family Name") || (pas.PassengerLastName.Trim().Length == 0)) continue;
if (!reader.IsDBNull(1)) pas.PassengerFirstName = reader.GetValue(1).ToString().Clean();
if (!reader.IsDBNull(2)) pas.PassengerGender = GlobalStructures.ParseGender(reader.GetString(2));
if (!reader.IsDBNull(3)) pas.PassengerPortOfEmbarkation = reader.GetString(3).Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
pas.PassengerPortOfEmbarkation = null;
if (!reader.IsDBNull(4)) pas.PassengerPortOfDisembarkation = reader.GetString(4).Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
pas.PassengerPortOfDisembarkation = null;
if (!reader.IsDBNull(5)) pas.PassengerInTransit = GlobalStructures.ReadBoolean(reader.GetString(5));
if (!reader.IsDBNull(6)) pas.PassengerNationality = reader.GetString(6).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(7)) pas.PassengerPlaceOfBirth = reader.GetString(7).Clean();
if (!reader.IsDBNull(8)) pas.PassengerCountryOfBirth = reader.GetString(8).Substring(0, 2).ToUpper().Clean();
if (!reader.IsDBNull(9)) pas.PassengerDateOfBirth = reader.GetDateTime(9);
if (!reader.IsDBNull(10)) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(10));
if (!reader.IsDBNull(11)) pas.PassengerIdentityDocumentId = this.getValueAsString(reader, 11).Clean();
if (!reader.IsDBNull(12)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(12).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(13)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(13);
if (!reader.IsDBNull(14)) pas.PassengerVisaNumber = this.getValueAsString(reader, 14).Clean();
if (!reader.IsDBNull(15)) pas.EmergencyCare = reader.GetString(15).Clean();
if (!reader.IsDBNull(16)) pas.EmergencyContactNumber = this.getValueAsString(reader, 16).Clean();
pas.MessageHeader = this._pasMessage;
pas.IsDirty = true;
pas.Identifier = PAS.GetNewIdentifier(this._pasMessage.Elements);
this._pasMessage.Elements.Add(pas);
importPassenger.Add(pas);
}
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importPassenger.Count > 0)
{
this.dataGridPassengerList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASA);
MessageBox.Show(String.Format(Properties.Resources.textPassengerImported, importPassenger.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
stream.Close();
} }
} }
private void buttonImportExcelPassengerDeparture_Click(object sender, RoutedEventArgs e) private void buttonImportExcelPassengerDeparture_Click(object sender, RoutedEventArgs e)
{ {
OpenFileDialog ofd = new OpenFileDialog OpenFileDialog ofd = new OpenFileDialog
@ -1198,78 +1269,72 @@ namespace ENI2.DetailViewControls
}; };
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var workbook = new XLWorkbook(stream))
{
var worksheet = workbook.Worksheet(1);
var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
List<PASD> importPassenger = new List<PASD>();
foreach (var row in rows)
{
if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
if (worksheet.RangeUsed().ColumnCount() < 17)
{
throw new InvalidDataException("Sheet must have 17 columns of data");
}
PASD pas = new PASD();
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (!row.Cell(1).IsEmpty()) pas.PassengerLastName = row.Cell(1).GetString().Clean();
if (pas.PassengerLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(pas.PassengerLastName)) continue;
if (!row.Cell(2).IsEmpty()) pas.PassengerFirstName = row.Cell(2).GetString().Clean();
if (!row.Cell(3).IsEmpty()) pas.PassengerGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
if (!row.Cell(4).IsEmpty()) pas.PassengerPortOfEmbarkation = row.Cell(4).GetString().Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
pas.PassengerPortOfEmbarkation = null;
if (!row.Cell(5).IsEmpty()) pas.PassengerPortOfDisembarkation = row.Cell(5).GetString().Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
pas.PassengerPortOfDisembarkation = null;
if (!row.Cell(6).IsEmpty()) pas.PassengerInTransit = GlobalStructures.ReadBoolean(row.Cell(6).GetString());
if (!row.Cell(7).IsEmpty()) pas.PassengerNationality = row.Cell(7).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(8).IsEmpty()) pas.PassengerPlaceOfBirth = row.Cell(8).GetString().Clean();
if (!row.Cell(9).IsEmpty()) pas.PassengerCountryOfBirth = row.Cell(9).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(10).IsEmpty()) pas.PassengerDateOfBirth = row.Cell(10).GetDateTime();
if (!row.Cell(11).IsEmpty()) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(11).GetString());
if (!row.Cell(12).IsEmpty()) pas.PassengerIdentityDocumentId = row.Cell(12).GetString().Clean();
if (!row.Cell(13).IsEmpty()) pas.PassengerIdentityDocumentIssuingState = row.Cell(13).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(14).IsEmpty()) pas.PassengerIdentityDocumentExpiryDate = row.Cell(14).GetDateTime();
if (!row.Cell(15).IsEmpty()) pas.PassengerVisaNumber = row.Cell(15).GetString().Clean();
if (!row.Cell(16).IsEmpty()) pas.EmergencyCare = row.Cell(16).GetString().Clean();
if (!row.Cell(17).IsEmpty()) pas.EmergencyContactNumber = row.Cell(17).GetString().Clean();
pas.MessageHeader = this._pasdMessage;
pas.IsDirty = true;
pas.Identifier = PASD.GetNewIdentifier(this._pasdMessage.Elements);
this._pasdMessage.Elements.Add(pas);
importPassenger.Add(pas);
}
if (importPassenger.Count > 0)
{
this.dataGridPassengerListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASD);
MessageBox.Show(String.Format(Properties.Resources.textPassengerImported, importPassenger.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
return;
} }
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
List<PASD> importPassenger = new List<PASD>();
try
{
do
{
while (reader.Read())
{
if (((IExcelDataReader)reader).FieldCount < 17)
{
throw new InvalidDataException("Sheet must have 17 columns of data");
}
PASD pas = new PASD();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) pas.PassengerLastName = reader.GetValue(0).ToString();
if (pas.PassengerLastName.Equals("Family Name") || (pas.PassengerLastName.Trim().Length == 0)) continue;
if (!reader.IsDBNull(1)) pas.PassengerFirstName = reader.GetValue(1).ToString();
if (!reader.IsDBNull(2)) pas.PassengerGender = GlobalStructures.ParseGender(reader.GetString(2));
if (!reader.IsDBNull(3)) pas.PassengerPortOfEmbarkation = reader.GetString(3);
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
pas.PassengerPortOfEmbarkation = null;
if (!reader.IsDBNull(4)) pas.PassengerPortOfDisembarkation = reader.GetString(4);
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
pas.PassengerPortOfDisembarkation = null;
if (!reader.IsDBNull(5)) pas.PassengerInTransit = GlobalStructures.ReadBoolean(reader.GetString(5));
if (!reader.IsDBNull(6)) pas.PassengerNationality = reader.GetString(6).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(7)) pas.PassengerPlaceOfBirth = reader.GetString(7);
if (!reader.IsDBNull(8)) pas.PassengerCountryOfBirth = reader.GetString(8).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(9)) pas.PassengerDateOfBirth = reader.GetDateTime(9);
if (!reader.IsDBNull(10)) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(10));
if (!reader.IsDBNull(11)) pas.PassengerIdentityDocumentId = this.getValueAsString(reader, 11);
if (!reader.IsDBNull(12)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(12).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(13)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(13);
if (!reader.IsDBNull(14)) pas.PassengerVisaNumber = this.getValueAsString(reader, 14);
if (!reader.IsDBNull(15)) pas.EmergencyCare = reader.GetString(15);
if (!reader.IsDBNull(16)) pas.EmergencyContactNumber = this.getValueAsString(reader, 16);
pas.MessageHeader = this._pasMessage;
pas.IsDirty = true;
pas.Identifier = PASD.GetNewIdentifier(this._pasdMessage.Elements);
this._pasdMessage.Elements.Add(pas);
importPassenger.Add(pas);
}
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importPassenger.Count > 0)
{
this.dataGridPassengerListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASD);
MessageBox.Show(String.Format(Properties.Resources.textPassengerImported, importPassenger.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
stream.Close();
} }
} }
@ -1299,22 +1364,11 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
#endregion
#region Schengen/PAX checkboxes changed event handler #region Schengen/PAX checkboxes changed event handler
private void checkBoxCrewNotificationSchengen_Click(object sender, RoutedEventArgs e) private void checkBoxCrewNotificationSchengen_Click(object sender, RoutedEventArgs e)
{ {
foreach(CREW crew in _crewMessage.Elements) foreach(CREW crew in _crewMessage.Elements.Cast<CREW>())
{ {
crew.NotificationSchengen = checkBoxCrewNotificationSchengen.IsChecked; crew.NotificationSchengen = checkBoxCrewNotificationSchengen.IsChecked;
} }
@ -1324,7 +1378,7 @@ namespace ENI2.DetailViewControls
private void checkBoxCrewNotificationPAX_Click(object sender, RoutedEventArgs e) private void checkBoxCrewNotificationPAX_Click(object sender, RoutedEventArgs e)
{ {
foreach (CREW crew in _crewMessage.Elements) foreach (CREW crew in _crewMessage.Elements.Cast<CREW>())
{ {
crew.NotificationPAX = checkBoxCrewNotificationPAX.IsChecked; crew.NotificationPAX = checkBoxCrewNotificationPAX.IsChecked;
} }
@ -1333,7 +1387,7 @@ namespace ENI2.DetailViewControls
private void checkBoxCrewNotificationSchengenDeparture_Click(object sender, RoutedEventArgs e) private void checkBoxCrewNotificationSchengenDeparture_Click(object sender, RoutedEventArgs e)
{ {
foreach(CREWD crewd in _crewdMessage.Elements) foreach(CREWD crewd in _crewdMessage.Elements.Cast<CREWD>())
{ {
crewd.NotificationSchengen = checkBoxCrewNotificationSchengenDeparture.IsChecked; crewd.NotificationSchengen = checkBoxCrewNotificationSchengenDeparture.IsChecked;
} }
@ -1342,7 +1396,7 @@ namespace ENI2.DetailViewControls
private void checkBoxCrewNotificationPAXDeparture_Click(object sender, RoutedEventArgs e) private void checkBoxCrewNotificationPAXDeparture_Click(object sender, RoutedEventArgs e)
{ {
foreach (CREWD crewd in _crewdMessage.Elements) foreach (CREWD crewd in _crewdMessage.Elements.Cast<CREWD>())
{ {
crewd.NotificationPAX = checkBoxCrewNotificationPAXDeparture.IsChecked; crewd.NotificationPAX = checkBoxCrewNotificationPAXDeparture.IsChecked;
} }
@ -1351,7 +1405,7 @@ namespace ENI2.DetailViewControls
private void checkBoxPasNotificationSchengen_Click(object sender, RoutedEventArgs e) private void checkBoxPasNotificationSchengen_Click(object sender, RoutedEventArgs e)
{ {
foreach(PAS pas in _pasMessage.Elements) foreach(PAS pas in _pasMessage.Elements.Cast<PAS>())
{ {
pas.NotificationSchengen = checkBoxPasNotificationSchengen.IsChecked; pas.NotificationSchengen = checkBoxPasNotificationSchengen.IsChecked;
} }
@ -1360,7 +1414,7 @@ namespace ENI2.DetailViewControls
private void checkBoxPasNotificationPAX_Click(object sender, RoutedEventArgs e) private void checkBoxPasNotificationPAX_Click(object sender, RoutedEventArgs e)
{ {
foreach(PAS pas in _pasMessage.Elements) foreach(PAS pas in _pasMessage.Elements.Cast<PAS>())
{ {
pas.NotificationPAX = checkBoxPasNotificationPAX.IsChecked; pas.NotificationPAX = checkBoxPasNotificationPAX.IsChecked;
} }
@ -1369,7 +1423,7 @@ namespace ENI2.DetailViewControls
private void checkBoxPasNotificationSchengenDeparture_Click(object sender, RoutedEventArgs e) private void checkBoxPasNotificationSchengenDeparture_Click(object sender, RoutedEventArgs e)
{ {
foreach(PASD pasd in _pasdMessage.Elements) foreach(PASD pasd in _pasdMessage.Elements.Cast<PASD>())
{ {
pasd.NotificationSchengen = checkBoxPasNotificationSchengenDeparture.IsChecked; pasd.NotificationSchengen = checkBoxPasNotificationSchengenDeparture.IsChecked;
} }
@ -1378,7 +1432,7 @@ namespace ENI2.DetailViewControls
private void checkBoxPasNotificationPAXDeparture_Click(object sender, RoutedEventArgs e) private void checkBoxPasNotificationPAXDeparture_Click(object sender, RoutedEventArgs e)
{ {
foreach(PASD pasd in _pasdMessage.Elements) foreach(PASD pasd in _pasdMessage.Elements.Cast<PASD>())
{ {
pasd.NotificationPAX = checkBoxPasNotificationPAXDeparture.IsChecked; pasd.NotificationPAX = checkBoxPasNotificationPAXDeparture.IsChecked;
} }
@ -1387,5 +1441,65 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region Buttons to delete all entries from CREWA CREWD PASA PASD
private async void buttonDeleteAllCrewA_Click(object sender, RoutedEventArgs e)
{
if(MessageBox.Show(Properties.Resources.textConfimDeleteAllEntries, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
foreach(CREW crewa in this._crewMessage.Elements.Cast<CREW>())
{
await DBManagerAsync.DeleteAsync(crewa);
}
this._crewMessage.Elements.Clear();
this.dataGridCrewList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWA);
}
}
private async void buttonDeleteAllCrewD_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show(Properties.Resources.textConfimDeleteAllEntries, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
foreach (CREWD crewd in this._crewdMessage.Elements.Cast<CREWD>())
{
await DBManagerAsync.DeleteAsync(crewd);
}
this._crewdMessage.Elements.Clear();
this.dataGridCrewListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
}
private async void buttonDeleteAllPasA_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show(Properties.Resources.textConfimDeleteAllEntries, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
foreach (PAS pasa in this._pasMessage.Elements.Cast<PAS>())
{
await DBManagerAsync.DeleteAsync(pasa);
}
this._pasMessage.Elements.Clear();
this.dataGridPassengerList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASA);
}
}
private async void buttonDeleteAllPasD_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show(Properties.Resources.textConfimDeleteAllEntries, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
foreach (PASD pasd in this._pasdMessage.Elements.Cast<PASD>())
{
await DBManagerAsync.DeleteAsync(pasd);
}
this._pasdMessage.Elements.Clear();
this.dataGridPassengerListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASD);
}
}
#endregion
} }
} }

View File

@ -197,6 +197,12 @@ namespace ENI2.DetailViewControls
this._initialized = true; this._initialized = true;
} }
public override int SelectedTabIndex
{
get { return this.tabControlPositions.SelectedIndex; }
set { this.tabControlPositions.SelectedIndex = value; }
}
#region SetEnabled #region SetEnabled
public override void SetEnabled(bool enabled) public override void SetEnabled(bool enabled)
@ -326,23 +332,6 @@ namespace ENI2.DetailViewControls
#endregion #endregion
/// <summary>
/// Beim Hinzufügen der allerersten Gefahrgutposition sollen die Flags vorbelegt werden
/// </summary>
void SetHAZGlobalFlags()
{
HAZ haz = this.IsDeparture ? this.hazd : this.haza;
int totalCount = haz.MARPOLPositions.Count + haz.IMDGPositions.Count + haz.IGCPositions.Count + haz.IBCPositions.Count + haz.IMSBCPositions.Count;
if(totalCount == 1)
{
if (!(this.checkBoxDangerousGoodsOnBoard.IsChecked ?? false)) this.checkBoxDangerousGoodsOnBoard.IsChecked = true;
if (this.checkBoxMoUBaltic.IsChecked ?? true) this.checkBoxMoUBaltic.IsChecked = false;
haz.NoDPGOnBoardOnArrival = false;
haz.MOUBaltic = false;
}
}
#region MARPOL datagrid handlers #region MARPOL datagrid handlers
private void DataGridMARPOLItems_DeleteRequested(DatabaseEntity obj) private void DataGridMARPOLItems_DeleteRequested(DatabaseEntity obj)
@ -898,5 +887,26 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region private methods
/// <summary>
/// Beim Hinzufügen der allerersten Gefahrgutposition sollen die Flags vorbelegt werden
/// </summary>
void SetHAZGlobalFlags()
{
HAZ haz = this.IsDeparture ? this.hazd : this.haza;
int totalCount = haz.MARPOLPositions.Count + haz.IMDGPositions.Count + haz.IGCPositions.Count + haz.IBCPositions.Count + haz.IMSBCPositions.Count;
if (totalCount == 1)
{
if (!(this.checkBoxDangerousGoodsOnBoard.IsChecked ?? false)) this.checkBoxDangerousGoodsOnBoard.IsChecked = true;
if (this.checkBoxMoUBaltic.IsChecked ?? true) this.checkBoxMoUBaltic.IsChecked = false;
haz.NoDPGOnBoardOnArrival = false;
haz.MOUBaltic = false;
}
}
#endregion
} }
} }

View File

@ -70,8 +70,24 @@
AutoGenerateColumns="False" Margin="0,5,0,0"> AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" /> <DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textBunkerType}" Binding="{Binding BunkerFuelType}" IsReadOnly="True" Width="0.2*" /> <DataGridTextColumn Header="{x:Static p:Resources.textBunkerType}" Width="0.2*">
<DataGridTextColumn Header="{x:Static p:Resources.textBunkerQuantity}" Binding="{Binding BunkerFuelQuantity_TNE, Mode=TwoWay}" IsReadOnly="True" Width="0.8*" /> <DataGridTextColumn.Binding>
<Binding Path="BunkerFuelType" Mode="TwoWay">
<Binding.ValidationRules>
<util:StringValidationRule MaxLength="25" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textBunkerQuantity}" IsReadOnly="False" Width="0.8*">
<DataGridTextColumn.Binding>
<Binding Path="BunkerFuelQuantity_TNE" Mode="TwoWay">
<Binding.ValidationRules>
<util:NumberValidationRule MaxValue="10000" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
</DataGrid.Columns> </DataGrid.Columns>
</enictrl:ENIDataGrid> </enictrl:ENIDataGrid>
</GroupBox> </GroupBox>

View File

@ -40,6 +40,7 @@ namespace ENI2.DetailViewControls
this.RegisterIntegerUpDownChange(this.integerUpDownPassengersOnBoard, Message.NotificationClass.POBD); this.RegisterIntegerUpDownChange(this.integerUpDownPassengersOnBoard, Message.NotificationClass.POBD);
this.RegisterIntegerUpDownChange(this.integerUpDownPersonsOnBoard, Message.NotificationClass.POBD); this.RegisterIntegerUpDownChange(this.integerUpDownPersonsOnBoard, Message.NotificationClass.POBD);
this.RegisterIntegerUpDownChange(this.integerUpDownStowawaysOnBoard, Message.NotificationClass.POBD); this.RegisterIntegerUpDownChange(this.integerUpDownStowawaysOnBoard, Message.NotificationClass.POBD);
this.dataGridBKRD.CellEditEnding += (obj, ev) => { this.SublistElementChanged(Message.NotificationClass.BKRD); };
startupComplete = true; startupComplete = true;
} }
@ -167,6 +168,8 @@ namespace ENI2.DetailViewControls
private void DataGridBKRD_CreateRequested() private void DataGridBKRD_CreateRequested()
{ {
this.dataGridBKRD.CancelEdit();
this.dataGridBKRD.CancelEdit();
EditBKRDialog ebd = new EditBKRDialog(); EditBKRDialog ebd = new EditBKRDialog();
ebd.IsDeparture = true; ebd.IsDeparture = true;
ebd.BRKD = new BRKD(); ebd.BRKD = new BRKD();
@ -199,6 +202,8 @@ namespace ENI2.DetailViewControls
{ {
if (obj is BRKD brkd) if (obj is BRKD brkd)
{ {
this.dataGridBKRD.CancelEdit();
this.dataGridBKRD.CancelEdit();
// are you sure dialog is in base class // are you sure dialog is in base class
this._bkrdMessage.Elements.Remove(brkd); this._bkrdMessage.Elements.Remove(brkd);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(brkd); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(brkd);
@ -210,6 +215,8 @@ namespace ENI2.DetailViewControls
private void DataGridBKRD_EditRequested(DatabaseEntity obj) private void DataGridBKRD_EditRequested(DatabaseEntity obj)
{ {
this.dataGridBKRD.CancelEdit(DataGridEditingUnit.Row);
this.dataGridBKRD.CommitEdit(DataGridEditingUnit.Row, true);
EditBKRDialog eld = new EditBKRDialog(); EditBKRDialog eld = new EditBKRDialog();
eld.IsDeparture = true; eld.IsDeparture = true;
eld.BRKD = obj as BRKD; eld.BRKD = obj as BRKD;
@ -230,7 +237,8 @@ namespace ENI2.DetailViewControls
{ {
if (!_bkrdMessage.Elements.Contains(eld.BRKD)) if (!_bkrdMessage.Elements.Contains(eld.BRKD))
_bkrdMessage.Elements.Add(eld.BRKD); _bkrdMessage.Elements.Add(eld.BRKD);
this.dataGridBKRD.Items.Refresh(); this.dataGridBKRD.ItemsSource = null;
this.dataGridBKRD.ItemsSource = this._bkrdMessage.Elements;
this.SublistElementChanged(Message.NotificationClass.BKRD); this.SublistElementChanged(Message.NotificationClass.BKRD);
} }
} }
@ -292,17 +300,6 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
#endregion
#region special datetimepicker validation popup (OMG) #region special datetimepicker validation popup (OMG)
private void dateTimePickerATD_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e) private void dateTimePickerATD_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)

View File

@ -2,18 +2,16 @@
// Description: MDH Meldung Bearbeitungsseite // Description: MDH Meldung Bearbeitungsseite
// //
using System; using bsmd.database;
using System.Collections.Generic; using ClosedXML.Excel;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Win32;
using System.IO;
using ENI2.EditControls; using ENI2.EditControls;
using ENI2.Util; using ENI2.Util;
using bsmd.database; using Microsoft.Win32;
using System;
using ExcelDataReader; using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Windows.Controls;
namespace ENI2.DetailViewControls namespace ENI2.DetailViewControls
{ {
@ -130,6 +128,12 @@ namespace ENI2.DetailViewControls
} }
public override int SelectedTabIndex
{
get { return this.mainFrame.SelectedIndex; }
set { this.mainFrame.SelectedIndex = value; }
}
#region SetEnabled #region SetEnabled
public override void SetEnabled(bool enabled) public override void SetEnabled(bool enabled)
@ -277,86 +281,15 @@ namespace ENI2.DetailViewControls
private void ButtonImportFromExcel_Click(object sender, RoutedEventArgs e) private void ButtonImportFromExcel_Click(object sender, RoutedEventArgs e)
{ {
OpenFileDialog ofd = new OpenFileDialog int cnt = Excel.ExcelLocalImportHelper.ImportLast30Days(this._mdh);
if (cnt > 0)
{ {
Filter = "Excel Files|*.xls;*.xlsx" this.dataGridPortOfCallLast30Days.Items.Refresh();
}; this.SublistElementChanged(Message.NotificationClass.MDH);
if (ofd.ShowDialog() ?? false) MessageBox.Show(String.Format(Properties.Resources.textPoC30Imported, cnt),
{ Properties.Resources.textCaptionInformation,
FileStream stream; MessageBoxButton.OK, MessageBoxImage.Information);
try
{
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
List<PortOfCallLast30Days> importPoC30 = new List<PortOfCallLast30Days>();
try
{
do
{
while (reader.Read())
{
if (reader.FieldCount < 3)
{
throw new InvalidDataException("Sheet must have at least 3 Columns of data");
}
PortOfCallLast30Days poc30 = new PortOfCallLast30Days();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) poc30.PortOfCallLast30DaysLocode = reader.GetString(0);
if (!reader.IsDBNull(1)) poc30.PortOfCallLast30DaysDateOfDeparture = reader.GetDateTime(1);
string boolString = "";
if (!reader.IsDBNull(2)) boolString = reader.GetString(2);
poc30.PortOfCallLast30DaysCrewMembersJoined = (boolString.Equals("y", StringComparison.OrdinalIgnoreCase) || (boolString.Equals("yes", StringComparison.OrdinalIgnoreCase)) ||
(boolString.Equals("j", StringComparison.OrdinalIgnoreCase)));
if(reader.FieldCount > 3)
{
string allNewCrew = reader.GetString(3)?.Trim();
if(!allNewCrew.IsNullOrEmpty())
{
string[] crewNames = allNewCrew.Split(',', ';');
for(int i=0;i<crewNames.Length;i++)
{
string crewName = crewNames[i].Trim();
if (crewName.IsNullOrEmpty()) continue;
PortOfCallLast30DaysCrewJoinedShip poc30Crew = new PortOfCallLast30DaysCrewJoinedShip();
poc30Crew.PortOfCallLast30DaysCrewJoinedShipName = crewName;
poc30Crew.PortOfCallLast30Days = poc30;
poc30.CrewJoinedShip.Add(poc30Crew);
}
}
}
poc30.MDH = this._mdh;
this._mdh.PortOfCallLast30Days.Add(poc30);
importPoC30.Add(poc30);
}
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importPoC30.Count > 0)
{
this.dataGridPortOfCallLast30Days.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.MDH);
MessageBox.Show(String.Format(Properties.Resources.textPoC30Imported, importPoC30.Count), Properties.Resources.textCaptionInformation,
MessageBoxButton.OK, MessageBoxImage.Information);
}
}
stream.Close();
} }
} }
@ -603,16 +536,5 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
#endregion
} }
} }

View File

@ -11,7 +11,7 @@
xmlns:data="clr-namespace:bsmd.database;assembly=bsmd.database" xmlns:data="clr-namespace:bsmd.database;assembly=bsmd.database"
xmlns:local="clr-namespace:ENI2.DetailViewControls" xmlns:local="clr-namespace:ENI2.DetailViewControls"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="800"> d:DesignHeight="768" d:DesignWidth="1024">
<xctk:BusyIndicator Name="busyIndicator"> <xctk:BusyIndicator Name="busyIndicator">
<xctk:BusyIndicator.ProgressBarStyle> <xctk:BusyIndicator.ProgressBarStyle>
<Style TargetType="ProgressBar"> <Style TargetType="ProgressBar">
@ -26,104 +26,144 @@
</StackPanel> </StackPanel>
</xctk:BusyIndicator.BusyContent> </xctk:BusyIndicator.BusyContent>
<GroupBox Name="visitTransitGroupBox" Header="{x:Static p:Resources.textVisitTransit}"> <GroupBox Name="visitTransitGroupBox" Header="{x:Static p:Resources.textOverview}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel"> <ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="4" />
<RowDefinition Height="32" />
<RowDefinition Height="32" />
<RowDefinition Height="4" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textPortCall}" Margin="0,0,10,0"/>
<enictrl:LocodeControl Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="0" Width="Auto" x:Name="locodePoC" LocodeValue="{Binding PoC, Mode=TwoWay}" IsEnabled="False" />
<!--Grid Grid.Column="1" Grid.Row="0" Width="Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<xctk:WatermarkComboBox Grid.Column="0" x:Name="comboBoxPoC" Margin="2" IsEditable="True" Watermark="Type for Locode.." TextBoxBase.TextChanged="ComboBox_TextChanged" ItemsSource="{Binding LocodePoCList, Mode=TwoWay}" SelectedItem="{Binding PoC, Mode=TwoWay}" />
<Image Name="imagePoCState" Grid.Column="1" Source="../Resources/bullet_ball_grey.png" />
</-->
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="3" Content="{x:Static p:Resources.textVisitTransitId}" Margin="0,0,10,0" />
<TextBox Name="textBoxDisplayId" Grid.Row="0" Grid.Column="4" Grid.ColumnSpan="2" IsReadOnly="True" Margin="2" VerticalContentAlignment="Center" />
<Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textIMO}" Margin="0,0,10,0" />
<TextBox Name="textBoxIMO" Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="1" Text="{Binding IMO, Mode=TwoWay, Converter={util:TrimStringConverter}}" Margin="2" IsReadOnly="True" VerticalContentAlignment="Center"/>
<Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="3" Content="{x:Static p:Resources.textENI}" Margin="0,0,10,0" />
<TextBox Name="textBoxENI" Grid.Row="1" Grid.Column="4" Grid.ColumnSpan="2" Text="{Binding ENI, Mode=TwoWay, Converter={util:TrimStringConverter}}" Margin="2" IsReadOnly="True" VerticalContentAlignment="Center"/>
<Label HorizontalContentAlignment="Right" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textETAPortOfCall}" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="2" Grid.Column="3" Content="{x:Static p:Resources.textETDPortOfCall}" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textATAPortOfCall}" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="3" Content="{x:Static p:Resources.textATDPortOfCall}" Margin="0,0,10,0" />
<xctk:DateTimePicker Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2" Value="{Binding ETAToPortOfCall, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePickerETA" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00" />
<xctk:DateTimePicker Grid.Column="4" Grid.ColumnSpan="2" Grid.Row="2" Value="{Binding ETDFromPortOfCall, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePickerETD" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00"/>
<xctk:DateTimePicker Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="3" Value="{Binding ATAPortOfCall, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePickerATA" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00"/>
<xctk:DateTimePicker Grid.Column="4" Grid.ColumnSpan="2" Grid.Row="3" Value="{Binding ATDPortOfCall, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePickerATD" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00"/>
<Label HorizontalAlignment="Right" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textTicketNo}" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="4" Grid.Column="3" Content="{x:Static p:Resources.textCreated}" Margin="0,0,10,0" />
<Label Name="labelCreated" Grid.Column="4" Grid.Row="4" Margin="2, 0, 0, 0" />
<Button Name="buttonFormblattNeu" Grid.Column="4" Grid.Row="7" Margin="2" Click="buttonFormblattNeu_Click" >
<StackPanel Orientation="Horizontal">
<TextBlock Text="Formblatt neu"></TextBlock>
<Image Source="../Resources/excel.png" Margin="10,0,5,0" Height="16"/>
</StackPanel>
</Button>
<TextBox Name="textBoxTicketNo" Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="2" Text="{Binding TicketNo, Mode=TwoWay, Converter={util:TrimStringConverter}}" Margin="2" VerticalContentAlignment="Center" MaxLength="50"/>
<Label Grid.Column="0" Grid.Row="6" Margin="0,0,10,0" HorizontalContentAlignment="Right" Name="labelBSMDStatusInternal" Content="{Binding BSMDStatusInternal, StringFormat={}{0}}" VerticalContentAlignment="Center" FontWeight="Bold" /> <Grid>
<Button IsEnabled="True" Name="buttonStorno" Grid.Column="1" Grid.Row="6" Margin="2" Click="buttonStorno_Click" Content="{x:Static p:Resources.textCancelDeclaration}" Background="Red"/> <Grid.ColumnDefinitions>
<Button IsEnabled="True" Name="buttonCopy" Grid.Column="2" Grid.Row="6" Margin="2" Click="buttonCopy_Click" Content="{x:Static p:Resources.textCopyData}"/> <ColumnDefinition Width="400" />
<Button IsEnabled="True" Name="buttonSendPDF" Grid.Column="3" Grid.Row="6" Margin="2" Click="buttonSendPDF_Click"> <ColumnDefinition Width="*" />
<StackPanel Orientation="Horizontal"> </Grid.ColumnDefinitions>
<TextBlock Text="{x:Static p:Resources.textCreatePDF}"></TextBlock>
<Image Source="../Resources/document_pdf.png" Margin="10,0,5,0" Height="16"/> <Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="4" />
<RowDefinition Height="36" />
<RowDefinition Height="4" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="4" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textVisitTransitId}" Margin="0,0,10,0" />
<TextBox Name="textBoxDisplayId" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" IsReadOnly="True" Margin="2" VerticalContentAlignment="Center" />
<Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textPortCall}" Margin="0,0,10,0"/>
<enictrl:LocodeControl Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" Width="Auto" x:Name="locodePoC" LocodeValue="{Binding PoC, Mode=TwoWay}" IsEnabled="False" />
<Label HorizontalContentAlignment="Right" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textIMO}" Margin="0,0,10,0" />
<TextBox Name="textBoxIMO" Grid.Row="2" Grid.ColumnSpan="2" Grid.Column="1" Text="{Binding IMO, Mode=TwoWay, Converter={util:TrimStringConverter}}" Margin="2" IsReadOnly="True" VerticalContentAlignment="Center"/>
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textENI}" Margin="0,0,10,0" />
<TextBox Name="textBoxENI" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding ENI, Mode=TwoWay, Converter={util:TrimStringConverter}}" Margin="2" IsReadOnly="True" VerticalContentAlignment="Center"/>
<Label HorizontalContentAlignment="Right" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textETAPortOfCall}" Margin="0,0,10,0" />
<xctk:DateTimePicker Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="4" Value="{Binding ETAToPortOfCall, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePickerETA" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00" />
<Label HorizontalContentAlignment="Right" Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textETDPortOfCall}" Margin="0,0,10,0" />
<xctk:DateTimePicker Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="5" Value="{Binding ETDFromPortOfCall, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePickerETD" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00"/>
<Label HorizontalContentAlignment="Right" Grid.Row="6" Grid.Column="0" Content="{x:Static p:Resources.textATAPortOfCall}" Margin="0,0,10,0" />
<xctk:DateTimePicker Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="6" Value="{Binding ATAPortOfCall, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePickerATA" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00"/>
<Label HorizontalContentAlignment="Right" Grid.Row="7" Grid.Column="0" Content="{x:Static p:Resources.textATDPortOfCall}" Margin="0,0,10,0" />
<xctk:DateTimePicker Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="7" Value="{Binding ATDPortOfCall, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePickerATD" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00"/>
<Label HorizontalAlignment="Right" Grid.Row="8" Grid.Column="0" Content="{x:Static p:Resources.textRemarks}" Margin="0,0,10,0" />
<TextBox Name="textBoxTicketNo" Grid.Column="1" Grid.Row="8" Grid.ColumnSpan="2" Text="{Binding TicketNo, Mode=TwoWay, Converter={util:TrimStringConverter}}" Margin="2" VerticalContentAlignment="Center" MaxLength="50"/>
<Label HorizontalContentAlignment="Right" Grid.Row="9" Grid.Column="0" Content="{x:Static p:Resources.textCreated}" Margin="0,0,10,0" />
<Label Name="labelCreated" Grid.Column="1" Grid.Row="9" Margin="2, 0, 0, 0" />
<Label Grid.Column="2" Grid.Row="9" Margin="0,0,10,0" HorizontalContentAlignment="Right" Name="labelBSMDStatusInternal" Content="{Binding BSMDStatusInternal, StringFormat={}{0}}" VerticalContentAlignment="Center" FontWeight="Bold" />
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="11">
<Button Name="buttonRefresh" Margin="2" Click="buttonRefresh_Click" BorderThickness="0" Background="Transparent" ToolTip="{x:Static p:Resources.textTooltipRefresh}">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/nav_refresh_blue.png" Margin="0,0,5,0" Height="24"/>
<!--TextBlock Text="{x:Static p:Resources.textRefresh}" VerticalAlignment="Center"/-->
</StackPanel>
</Button>
<Button Name="buttonInfoCore" Margin="2" Click="buttonInfoCore_Click" BorderThickness="0" Background="Transparent" ToolTip="{x:Static p:Resources.textTooltipDetails}">
<Image Source="../Resources/document_view.png" Margin="0,0,5,0" Height="24" />
</Button>
<Button Name="buttonValidate" Margin="2" Click="buttonValidate_Click" BorderThickness="0" Background="Transparent" ToolTip="{x:Static p:Resources.textTooltipValidation}">
<Image Source="../Resources/hand_point.png" Margin="0,0,5,0" Height="24" />
</Button>
<!--
<Button Name="buttonWarnings" Margin="2" Click="buttonWarnings_Click" BorderThickness="0" Background="Transparent" Visibility="Hidden">
<Image Source="../Resources/sign_warning.png" Margin="0,0,5,0" Height="24" />
</Button>
-->
</StackPanel> </StackPanel>
</Button> <StackPanel Orientation="Horizontal" Grid.Column="2" Grid.Row="11" Visibility="Hidden" Name="stackPanelLock">
<Button Name="buttonQueryHIS" Grid.Column="4" Grid.Row="6" Margin="2" Click="buttonQueryHIS_Click" Content="{x:Static p:Resources.textQueryHIS}"/> <Image Source="../Resources/lock.png" Margin="0,0,5,0" Height="24" />
<StackPanel Orientation="Horizontal" Grid.Column="5" Grid.Row="6"> <TextBlock Name="textBlockLockUserName" VerticalAlignment="Center" />
<Button Name="buttonRefresh" Margin="2" Click="buttonRefresh_Click" BorderThickness="0" Background="Transparent" ToolTip="{x:Static p:Resources.textTooltipRefresh}"> </StackPanel>
<Label Grid.Column="0" Grid.Row="13" Margin="0,0,10,0" HorizontalContentAlignment="Right" Name="labelHIS" VerticalContentAlignment="Center" Content="{x:Static p:Resources.textSendToHIS}" />
<ComboBox Grid.Column="1" Grid.Row="13" Margin="2" Name="comboBoxInitialHis" VerticalContentAlignment="Center" SelectedValuePath="Key" DisplayMemberPath="Value" SelectedValue="{Binding Path=InitialHIS}" />
<Button IsEnabled="True" Name="buttonSendAll" Grid.Column="1" Grid.Row="14" Content="{x:Static p:Resources.textSendAll}" Margin="2" Click="buttonSendAll_Click" />
<Button Grid.Column="1" Grid.Row="16" Margin="2" Name="buttonExcelImport" Click="buttonExcelImport_Click">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Image Source="../Resources/nav_refresh_blue.png" Margin="0,0,5,0" Height="24"/> <TextBlock Text="{x:Static p:Resources.textExcelImport}"></TextBlock>
<!--TextBlock Text="{x:Static p:Resources.textRefresh}" VerticalAlignment="Center"/--> <Image Source="../Resources/excel.png" Margin="10,0,5,0" Height="16"/>
</StackPanel> </StackPanel>
</Button> </Button>
<Button Name="buttonInfoCore" Margin="2" Click="buttonInfoCore_Click" BorderThickness="0" Background="Transparent" ToolTip="{x:Static p:Resources.textTooltipDetails}">
<Image Source="../Resources/document_view.png" Margin="0,0,5,0" Height="24" /> <Button IsEnabled="True" Name="buttonSendPDF" Grid.Column="1" Grid.Row="17" Margin="2" Click="buttonSendPDF_Click">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{x:Static p:Resources.textCreatePDF}"></TextBlock>
<Image Source="../Resources/document_pdf.png" Margin="10,0,5,0" Height="16"/>
</StackPanel>
</Button> </Button>
<Button Name="buttonValidate" Margin="2" Click="buttonValidate_Click" BorderThickness="0" Background="Transparent" ToolTip="{x:Static p:Resources.textTooltipValidation}"> <Button Name="buttonQueryHIS" Grid.Column="1" Grid.Row="18" Margin="2" Click="buttonQueryHIS_Click" Content="{x:Static p:Resources.textQueryHIS}"/>
<Image Source="../Resources/hand_point.png" Margin="0,0,5,0" Height="24" /> <Button IsEnabled="True" Name="buttonCopy" Grid.Column="1" Grid.Row="19" Margin="2" Click="buttonCopy_Click" Content="{x:Static p:Resources.textCopyData}"/>
<Button Name="buttonFormblattNeu" Grid.Column="1" Grid.Row="20" Margin="2" Click="buttonFormblattNeu_Click" >
<StackPanel Orientation="Horizontal">
<TextBlock Text="Formblatt neu"></TextBlock>
<Image Source="../Resources/excel.png" Margin="10,0,5,0" Height="16"/>
</StackPanel>
</Button> </Button>
<Button IsEnabled="True" Name="buttonStorno" Grid.Column="1" Grid.Row="22" Margin="2" Click="buttonStorno_Click" Content="{x:Static p:Resources.textCancelDeclaration}" Background="Red"/>
<Label Grid.Column="2" Grid.Row="21" Margin="0,0,10,0" HorizontalContentAlignment="Right" Name="labelCancelled" VerticalContentAlignment="Center" FontWeight="Bold" />
<!-- <!--
<Button Name="buttonWarnings" Margin="2" Click="buttonWarnings_Click" BorderThickness="0" Background="Transparent" Visibility="Hidden">
<Image Source="../Resources/sign_warning.png" Margin="0,0,5,0" Height="24" />
</Button>
-->
</StackPanel>
<Label Grid.Column="0" Grid.Row="7" Margin="0,0,10,0" HorizontalContentAlignment="Right" Name="labelCancelled" VerticalContentAlignment="Center" FontWeight="Bold" />
<Label Grid.Column="1" Grid.Row="7" Margin="0,0,10,0" HorizontalContentAlignment="Right" Name="labelHIS" VerticalContentAlignment="Center" Content="{x:Static p:Resources.textSendToHIS}" />
<ComboBox Grid.Column="2" Grid.Row="7" Margin="2" Name="comboBoxInitialHis" VerticalContentAlignment="Center" SelectedValuePath="Key" DisplayMemberPath="Value" SelectedValue="{Binding Path=InitialHIS}" />
<Button Grid.Column="3" Grid.Row="7" Margin="2" Name="buttonExcelImport" Click="buttonExcelImport_Click">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{x:Static p:Resources.textExcelImport}"></TextBlock>
<Image Source="../Resources/excel.png" Margin="10,0,5,0" Height="16"/>
</StackPanel>
</Button>
<!--
<Button Grid.Column="4" Grid.Row="7" Margin="2" Name="buttonExcelExport" Click="buttonExcelExport_Click"> <Button Grid.Column="4" Grid.Row="7" Margin="2" Name="buttonExcelExport" Click="buttonExcelExport_Click">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="{x:Static p:Resources.textExcelExport}"></TextBlock> <TextBlock Text="{x:Static p:Resources.textExcelExport}"></TextBlock>
@ -131,14 +171,64 @@
</StackPanel> </StackPanel>
</Button> </Button>
--> -->
<StackPanel Orientation="Horizontal" Grid.Column="5" Grid.Row="4" Visibility="Hidden" Name="stackPanelLock">
<Image Source="../Resources/lock.png" Margin="0,0,5,0" Height="24" />
<TextBlock Name="textBlockLockUserName" VerticalAlignment="Center" />
</StackPanel>
</Grid>
<!-- Data Grid --> <!-- Data Grid -->
<DataGrid Grid.Row="9" Grid.ColumnSpan="6" Margin="0,8,0,0" x:Name="dataGridMessages" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" CanUserAddRows="False" <DataGrid Grid.Row="0" Grid.ColumnSpan="1" Grid.Column="1" Margin="2" x:Name="dataGridMessages" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" CanUserAddRows="False"
SelectionMode="Extended" AutoGenerateColumns="False" MouseDoubleClick="dataGrid_MouseDoubleClick" PreviewKeyDown="dataGrid_PreviewKeyDown"> SelectionMode="Extended" AutoGenerateColumns="False" MouseDoubleClick="dataGrid_MouseDoubleClick" PreviewKeyDown="dataGrid_PreviewKeyDown">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridColumnHeadersPresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridColumnHeadersPresenter}">
<Grid Background="Transparent" Grid.IsSharedSizeScope="True">
<!-- 3 header rows: 0 = main title, 1 = group headers, 2 = real column headers -->
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- One ColumnDefinition per DataGridTextColumn (or sharedsize groups) -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding Columns[0].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[1].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[2].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[3].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[4].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[5].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[6].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[7].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[8].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[9].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[10].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[11].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[12].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[13].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[14].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<ColumnDefinition Width="{Binding Columns[15].ActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
<!-- …add as many as you need… -->
</Grid.ColumnDefinitions>
<!-- Row0: A single big header across all columns -->
<!--TextBlock Grid.Row="0" Grid.ColumnSpan="4" Text="Main Application" HorizontalAlignment="Center" FontWeight="Bold"/ -->
<!-- Row1: your “banded” group headers -->
<TextBlock Grid.Row="0" Grid.Column="5" Grid.ColumnSpan="2" Text="{x:Static p:Resources.textENIStatus}" HorizontalAlignment="Stretch" TextAlignment="Center" Padding="0,2,0,4" Background="AntiqueWhite" />
<TextBlock Grid.Row="0" Grid.Column="7" Grid.ColumnSpan="9" Text="{x:Static p:Resources.textNSWStatus}" HorizontalAlignment="Stretch" TextAlignment="Center" Padding="0,2,0,4" Background="AliceBlue"/>
<!-- Row2: the real column headers -->
<!-- This invisible filler ensures the layout lines up -->
<DataGridColumnHeader x:Name="PART_FillerColumnHeader" Grid.Row="1" Grid.ColumnSpan="14" IsHitTestVisible="False"/>
<!-- And here the ItemsPresenter will place each DataGridColumnHeader -->
<ItemsPresenter Grid.Row="1" Grid.ColumnSpan="16"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGrid.Resources>
<DataGrid.RowStyle> <DataGrid.RowStyle>
<Style TargetType="DataGridRow"> <Style TargetType="DataGridRow">
<Style.Triggers> <Style.Triggers>
@ -162,22 +252,40 @@
</MultiDataTrigger.Conditions> </MultiDataTrigger.Conditions>
<Setter Property="Background" Value="Yellow" /> <Setter Property="Background" Value="Yellow" />
</MultiDataTrigger> </MultiDataTrigger>
<DataTrigger Binding="{Binding SendSuccess}" Value="True">
<Setter Property="Background" Value="#92F592"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding InternalStatus}" Value="UPDATED">
<Setter Property="Background" Value="#DFFDDF"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding InternalStatus}" Value="TOSEND">
<Setter Property="Background" Value="#BFFDBF"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding InternalStatus}" Value="SENT">
<Setter Property="Background" Value="#BFFDBF"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding HasSystemErrors}" Value="True">
<Setter Property="Background" Value="MistyRose"></Setter>
</DataTrigger>
<!--DataTrigger Binding="{Binding HasErrors}" Value="True">
<Setter Property="Background" Value="PaleVioletRed"></Setter>
</DataTrigger-->
</Style.Triggers> </Style.Triggers>
</Style> </Style>
</DataGrid.RowStyle> </DataGrid.RowStyle>
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTemplateColumn Header=" " Width="SizeToCells" IsReadOnly="True"> <DataGridTemplateColumn Header=" " Width="SizeToCells" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<!--Image Source="{Binding src:Util.ImageDict[ENINotificationDetailGroup]}" /--> <!--Image Source="{Binding src:Util.ImageDict[ENINotificationDetailGroup]}" /-->
<!--Image Source="{Binding Source={x:Static src:Util.ImageDict}, Path=[ENINotificationDetailGroup]}"></--> <!--Image Source="{Binding Source={x:Static src:Util.ImageDict}, Path=[ENINotificationDetailGroup]}"></-->
<Image Source="{Binding ENINotificationIconString, Converter={util:NullImageConverter}}" /> <Image Source="{Binding ENINotificationIconString, Converter={util:NullImageConverter}}" Height="24" />
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textNotificationClass}" Binding="{Binding MessageNotificationClassDisplay}" <DataGridTextColumn Header="{x:Static p:Resources.textNotificationClass}" Binding="{Binding MessageNotificationClassDisplay}" IsReadOnly="True" Width="0.1*" FontWeight="Bold">
IsReadOnly="True" Width="0.075*" FontWeight="Bold">
<DataGridTextColumn.ElementStyle> <DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock"> <Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>
@ -185,6 +293,75 @@
</Style> </Style>
</DataGridTextColumn.ElementStyle> </DataGridTextColumn.ElementStyle>
</DataGridTextColumn> </DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textStatus}" Binding="{Binding BSMDStatusOverviewDisplay}" IsReadOnly="True" Width="0.1*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textChangedBy}" Binding="{Binding ChangedBy}" IsReadOnly="True" Width="0.2*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textChanged}" Binding="{Binding Changed}" IsReadOnly="True" Width="0.15*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textErrors}" IsReadOnly="True" Width="0.06*" Binding="{Binding ErrorCount}">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="FontWeight" Value="DemiBold" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textViolations}" IsReadOnly="True" Width="0.06*" Binding="{Binding ViolationCount}">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="FontWeight" Value="DemiBold" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="HIS" Binding="{Binding HISOverviewDisplay}" IsReadOnly="True" Width="0.06*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textReceivedAt}" Binding="{Binding ReceivedAt}" IsReadOnly="True" Width="0.15*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textSentBy}" Binding="{Binding SentBy}" IsReadOnly="True" Width="0.1*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTemplateColumn Header="" Width="SizeToCells" IsReadOnly="True"> <DataGridTemplateColumn Header="" Width="SizeToCells" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
@ -222,29 +399,29 @@
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
<!--DataGridTemplateColumn Header="" Width="SizeToCells" IsReadOnly="True"> <!--DataGridTemplateColumn Header="" Width="SizeToCells" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Image x:Name="imageHasUpdate"/> <Image x:Name="imageHasUpdate"/>
<DataTemplate.Triggers> <DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=HasUpdates}" Value="True"> <DataTrigger Binding="{Binding Path=HasUpdates}" Value="True">
<Setter Property="Source" Value="/Resources/recycle.png" TargetName="imageHasUpdate"/> <Setter Property="Source" Value="/Resources/recycle.png" TargetName="imageHasUpdate"/>
</DataTrigger> </DataTrigger>
</DataTemplate.Triggers> </DataTemplate.Triggers>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</--> </-->
<!--DataGridTemplateColumn Header="" Width="SizeToCells" IsReadOnly="True"> <!--DataGridTemplateColumn Header="" Width="SizeToCells" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Image x:Name="imageHasReminder"/> <Image x:Name="imageHasReminder"/>
<DataTemplate.Triggers> <DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=HasReminder}" Value="True"> <DataTrigger Binding="{Binding Path=HasReminder}" Value="True">
<Setter Property="Source" Value="/Resources/hand_point.png" TargetName="imageHasReminder"/> <Setter Property="Source" Value="/Resources/hand_point.png" TargetName="imageHasReminder"/>
</DataTrigger> </DataTrigger>
</DataTemplate.Triggers> </DataTemplate.Triggers>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</--> </-->
<DataGridTemplateColumn Header="" Width="SizeToCells" IsReadOnly="True"> <DataGridTemplateColumn Header="" Width="SizeToCells" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
@ -257,6 +434,7 @@
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
<DataGridTemplateColumn Header="" Width="SizeToCells" IsReadOnly="True"> <DataGridTemplateColumn Header="" Width="SizeToCells" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
@ -269,41 +447,7 @@
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textChanged}" Binding="{Binding Changed}" IsReadOnly="True" Width="0.15*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textReceivedAt}" Binding="{Binding ReceivedAt}" IsReadOnly="True" Width="0.15*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textStatus}" Binding="{Binding InternalStatus}" IsReadOnly="True" Width="0.1*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="HIS" Binding="{Binding HIS}" IsReadOnly="True" Width="0.1*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textSentBy}" Binding="{Binding SentBy}" IsReadOnly="True" Width="0.1*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textStatusInfo}" Binding="{Binding StatusInfo}" IsReadOnly="True" Width="0.2*"> <DataGridTextColumn Header="{x:Static p:Resources.textStatusInfo}" Binding="{Binding StatusInfo}" IsReadOnly="True" Width="0.2*">
<DataGridTextColumn.ElementStyle> <DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock"> <Style TargetType="TextBlock">
@ -311,13 +455,7 @@
</Style> </Style>
</DataGridTextColumn.ElementStyle> </DataGridTextColumn.ElementStyle>
</DataGridTextColumn> </DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textChangedBy}" Binding="{Binding ChangedBy}" IsReadOnly="True" Width="0.2*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</Grid> </Grid>

View File

@ -19,6 +19,10 @@ using System.Collections.Generic;
using System.Windows.Media; using System.Windows.Media;
using Microsoft.Win32; using Microsoft.Win32;
using System.Diagnostics; using System.Diagnostics;
using System.ComponentModel;
using static bsmd.database.Message;
using PdfSharp.Fonts;
using System.Linq;
namespace ENI2.DetailViewControls namespace ENI2.DetailViewControls
{ {
@ -27,6 +31,9 @@ namespace ENI2.DetailViewControls
/// </summary> /// </summary>
public partial class OverViewDetailControl : DetailBaseControl public partial class OverViewDetailControl : DetailBaseControl
{ {
#region Fields
private Message _message = null; private Message _message = null;
private Message _ataMessage; private Message _ataMessage;
private Message _atdMessage; private Message _atdMessage;
@ -36,21 +43,29 @@ namespace ENI2.DetailViewControls
private readonly object _collectionLock = new object(); private readonly object _collectionLock = new object();
// private MessageSendStatusDialog mssd = null; // private MessageSendStatusDialog mssd = null;
#endregion
#region Construction
public OverViewDetailControl() public OverViewDetailControl()
{ {
InitializeComponent(); InitializeComponent();
this.Loaded += OverViewDetailControl_Loaded; this.Loaded += OverViewDetailControl_Loaded;
} }
#endregion
#region Initialize
private void OverViewDetailControl_Loaded(object sender, RoutedEventArgs e) private void OverViewDetailControl_Loaded(object sender, RoutedEventArgs e)
{ {
// die Controls nach Änderungen monitoren // die Controls nach Änderungen monitoren
// diese Einträge gehen auf core // diese Einträge gehen auf core
this.RegisterTextboxChange(this.textBoxTicketNo, Message.NotificationClass.ATA); this.textBoxTicketNo.TextChanged += CoreTextBox_TextChanged;
this.RegisterTextboxChange(this.textBoxDisplayId, Message.NotificationClass.ATA); this.textBoxDisplayId.TextChanged += CoreTextBox_TextChanged;
this.RegisterTextboxChange(this.textBoxIMO, Message.NotificationClass.ATA); this.textBoxIMO.TextChanged += CoreTextBox_TextChanged;
this.RegisterTextboxChange(this.textBoxENI, Message.NotificationClass.ATA); this.textBoxENI.TextChanged += CoreTextBox_TextChanged;
this.RegisterLocodeChange(this.locodePoC, Message.NotificationClass.ATA); this.locodePoC.PropertyChanged += CoreLocode_LocodeChanged;
this.RegisterDateTimePickerChange(this.dateTimePickerATA, Message.NotificationClass.ATA); this.RegisterDateTimePickerChange(this.dateTimePickerATA, Message.NotificationClass.ATA);
this.RegisterDateTimePickerChange(this.dateTimePickerATD, Message.NotificationClass.ATD); this.RegisterDateTimePickerChange(this.dateTimePickerATD, Message.NotificationClass.ATD);
@ -58,8 +73,6 @@ namespace ENI2.DetailViewControls
this.RegisterDateTimePickerChange(this.dateTimePickerETD, Message.NotificationClass.NOA_NOD); this.RegisterDateTimePickerChange(this.dateTimePickerETD, Message.NotificationClass.NOA_NOD);
} }
#region Initialize
public override void Initialize() public override void Initialize()
{ {
bool iAmAdmin = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsAdmin; bool iAmAdmin = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsAdmin;
@ -305,6 +318,8 @@ namespace ENI2.DetailViewControls
BindingOperations.EnableCollectionSynchronization(this.Messages, _collectionLock); BindingOperations.EnableCollectionSynchronization(this.Messages, _collectionLock);
this.dataGridMessages.ItemsSource = this.Messages; this.dataGridMessages.ItemsSource = this.Messages;
this.OnRequestValidate(false);
base.Initialize(); // wenn Meldeklassen erst bei der Init. erzeugt werden, fehlen die Handler, die hier erneut festgelegt werden base.Initialize(); // wenn Meldeklassen erst bei der Init. erzeugt werden, fehlen die Handler, die hier erneut festgelegt werden
this._initialized = true; this._initialized = true;
} }
@ -342,6 +357,9 @@ namespace ENI2.DetailViewControls
this.buttonExcelImport.IsEnabled = !this.Core.DisplayId.IsNullOrEmpty(); this.buttonExcelImport.IsEnabled = !this.Core.DisplayId.IsNullOrEmpty();
this.dataGridMessages.ItemsSource = null;
this.dataGridMessages.ItemsSource = this.Messages;
//MessageBox.Show(string.Format("Visit/Transit ID updated: {0}", this.Core.DisplayId)); //MessageBox.Show(string.Format("Visit/Transit ID updated: {0}", this.Core.DisplayId));
//ShowIdDialog sid = new ShowIdDialog(this.Core) //ShowIdDialog sid = new ShowIdDialog(this.Core)
//{ //{
@ -352,6 +370,11 @@ namespace ENI2.DetailViewControls
this.Core.IsDirty = false; // ist ja schon gespeichert.. this.Core.IsDirty = false; // ist ja schon gespeichert..
} }
internal void RefreshMessageGrid()
{
this.dataGridMessages?.Items?.Refresh();
}
#endregion #endregion
#region private methods #region private methods
@ -419,44 +442,50 @@ namespace ENI2.DetailViewControls
MessageBoxResult result = MessageBox.Show(Properties.Resources.textConfirmSend, Properties.Resources.textConfirm, MessageBoxButton.YesNo, MessageBoxImage.Question); MessageBoxResult result = MessageBox.Show(Properties.Resources.textConfirmSend, Properties.Resources.textConfirm, MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes) if (result == MessageBoxResult.Yes)
{ {
bool somethingsNotSaved = false; this.SendMessages(this.dataGridMessages.SelectedItems.Cast<Message>());
foreach (Message selectedMessage in this.dataGridMessages.SelectedItems) }
}
private void SendMessages(IEnumerable<Message> messages)
{
bool somethingsNotSaved = false;
foreach (Message selectedMessage in messages)
{
if (selectedMessage.IsDirty) somethingsNotSaved = true;
}
if (somethingsNotSaved)
{
if (MessageBox.Show(Properties.Resources.textUnsavedChangesSendAnyWay, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
return;
}
List<Message> watchList = new List<Message>();
foreach (Message selectedMessage in messages)
{
if (selectedMessage.Reset) selectedMessage.Reset = false; // "nochmal" Versenden ist möglich
selectedMessage.InternalStatus = Message.BSMDStatus.TOSEND;
string userName = "?";
if (App.UserId.HasValue && DBManager.Instance.GetReportingPartyDict().ContainsKey(App.UserId.Value))
{ {
if (selectedMessage.IsDirty) somethingsNotSaved = true; userName = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].Logon;
} }
selectedMessage.ChangedBy = string.Format("{0} at {1} (Send)", userName, DateTime.Now);
selectedMessage.StatusInfo = string.Format(Properties.Resources.textMessageSentAt, DateTime.Now);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(selectedMessage);
watchList.Add(selectedMessage);
}
if(somethingsNotSaved) // komplette Anmeldung auf "zu versenden" stellen
{ this.Core.BSMDStatusInternal = MessageCore.BSMDStatus.TOSEND;
if (MessageBox.Show(Properties.Resources.textUnsavedChangesSendAnyWay, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No) this.Core.DefaultReportingPartyId = App.UserId;
return;
}
List<Message> watchList = new List<Message>(); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(this.Core); // löst auch den Watchdog aus
foreach (Message selectedMessage in this.dataGridMessages.SelectedItems) this.OnRequestSendValidation();
{ this.dataGridMessages.Items.Refresh();
if (selectedMessage.Reset) selectedMessage.Reset = false; // "nochmal" Versenden ist möglich
selectedMessage.InternalStatus = Message.BSMDStatus.TOSEND;
string userName = "?";
if (App.UserId.HasValue && DBManager.Instance.GetReportingPartyDict().ContainsKey(App.UserId.Value))
{
userName = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].Logon;
}
selectedMessage.ChangedBy = string.Format("{0} at {1} (Send)", userName, DateTime.Now);
selectedMessage.StatusInfo = string.Format(Properties.Resources.textMessageSentAt, DateTime.Now);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(selectedMessage);
watchList.Add(selectedMessage);
}
// komplette Anmeldung auf "zu versenden" stellen /*
this.Core.BSMDStatusInternal = MessageCore.BSMDStatus.TOSEND;
this.Core.DefaultReportingPartyId = App.UserId;
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(this.Core); // löst auch den Watchdog aus
this.OnRequestSendValidation();
this.dataGridMessages.Items.Refresh();
/*
if (this.mssd == null) if (this.mssd == null)
{ {
this.mssd = new MessageSendStatusDialog(this.Core); this.mssd = new MessageSendStatusDialog(this.Core);
@ -476,7 +505,6 @@ namespace ENI2.DetailViewControls
this.mssd.Activate(); // bring to foreground this.mssd.Activate(); // bring to foreground
this.mssd.AddMessages(watchList); this.mssd.AddMessages(watchList);
*/ */
}
} }
private void contextResetMessage(object sender, RoutedEventArgs e) private void contextResetMessage(object sender, RoutedEventArgs e)
@ -564,6 +592,12 @@ namespace ENI2.DetailViewControls
Util.UIHelper.SetBusyState(); Util.UIHelper.SetBusyState();
ReportManager rm = new ReportManager(); ReportManager rm = new ReportManager();
// TODO!!
// https://docs.pdfsharp.net/PDFsharp/Topics/Fonts/Font-Resolving.html
// https://docs.pdfsharp.net/MigraDoc/DOM/Document/MigraDocSettings.html
GlobalFontSettings.UseWindowsFontsUnderWindows = true;
GlobalFontSettings.UseWindowsFontsUnderWsl2 = true;
// create PDF from message classes // create PDF from message classes
if (rm.Create(sfd.FileName, this.Core, sicd.SelectedClasses, out string importResultText)) if (rm.Create(sfd.FileName, this.Core, sicd.SelectedClasses, out string importResultText))
{ {
@ -604,6 +638,16 @@ namespace ENI2.DetailViewControls
#region event handler #region event handler
private void CoreLocode_LocodeChanged(object sender, PropertyChangedEventArgs e)
{
this.OnNotificationClassChanged(null);
}
private void CoreTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
this.OnNotificationClassChanged(null);
}
private void _checkStatusTimer_Elapsed(object sender, ElapsedEventArgs e) private void _checkStatusTimer_Elapsed(object sender, ElapsedEventArgs e)
{ {
bool? statusFlag = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoreQueryStatusFlag(this.Core.Id.Value); bool? statusFlag = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoreQueryStatusFlag(this.Core.Id.Value);
@ -712,7 +756,7 @@ namespace ENI2.DetailViewControls
private void buttonValidate_Click(object sender, RoutedEventArgs e) private void buttonValidate_Click(object sender, RoutedEventArgs e)
{ {
this.OnRequestValidate(); this.OnRequestValidate(true);
} }
/// <summary> /// <summary>
@ -742,7 +786,7 @@ namespace ENI2.DetailViewControls
this.OnRequestReload(this.Core.Id.Value); this.OnRequestReload(this.Core.Id.Value);
// validate all selected import classes (Finger with "selection") // validate all selected import classes (Finger with "selection")
this.OnRequestValidate(); this.OnRequestValidate(true);
} }
else else
@ -796,15 +840,71 @@ namespace ENI2.DetailViewControls
} }
} }
#endregion private void buttonSendAll_Click(object sender, RoutedEventArgs e)
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{ {
ScrollViewer scv = (ScrollViewer)sender; SelectImportClassesDialog sicd = new SelectImportClassesDialog();
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta); List<Message.NotificationClass> readyToSendMessages = new List<Message.NotificationClass>();
e.Handled = true;
// Evaluate a number of criteria for messages that should not be preselected for sending
bool addToSend;
foreach (Message message in this.Messages)
{
addToSend = true;
// if ((message.ErrorCount ?? 0) > 0) continue; // skip selection if there are any errors left
switch(message.MessageNotificationClass)
{
case NotificationClass.HAZA:
addToSend = XtraSendLogic.ShouldSendMessage(message); break;
case NotificationClass.HAZD:
addToSend = XtraSendLogic.ShouldSendMessage(message); break;
case NotificationClass.BPOL:
if (message.Elements.Count > 0)
{
if (message.Elements[0] is BPOL bpol)
{
if (bpol.PortOfItineraries.Count == 0) addToSend = false;
}
}
break;
case NotificationClass.WAS_RCPT:
addToSend = false;
break;
case NotificationClass.INFO:
if (Core.PoC == "DEHAM") addToSend = false;
break;
default:
if(Message.IsListClass(message.MessageNotificationClass) && (message.Elements.Count == 0)) addToSend = false;
break;
}
if(addToSend)
readyToSendMessages.Add(message.MessageNotificationClass);
}
sicd.Messages = this.Messages;
sicd.PreselectedClasses.AddRange(readyToSendMessages);
sicd.IsTransit = this.Core.IsTransit;
sicd.IsImportMode = false;
if ((sicd.ShowDialog() ?? false) && (sicd.SelectedClasses.Count > 0))
{
// now send all selected messages
List<Message> toSendMessages = new List<Message>();
foreach(NotificationClass notificationClass in sicd.SelectedClasses)
{
Message selectedMessage = this.Messages.Find(x => x.MessageNotificationClass == notificationClass);
if (selectedMessage != null)
{
toSendMessages.Add(selectedMessage);
}
}
if (toSendMessages.Count > 0)
{
this.SendMessages(toSendMessages);
}
}
} }
#endregion #endregion

View File

@ -18,13 +18,13 @@ namespace ENI2.DetailViewControls
private Message _pre72hMessage; private Message _pre72hMessage;
private static string[] hullConfiguration = { private static readonly string[] hullConfiguration = {
Properties.Resources.textSingleHull, Properties.Resources.textSingleHull,
Properties.Resources.textSingleHullBallast, Properties.Resources.textSingleHullBallast,
Properties.Resources.textDoubleHull Properties.Resources.textDoubleHull
}; };
private static string[] conditionCargoTanks = private static readonly string[] conditionCargoTanks =
{ {
Properties.Resources.textFull, Properties.Resources.textFull,
Properties.Resources.textEmpty, Properties.Resources.textEmpty,
@ -118,17 +118,6 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
#endregion
} }
} }

View File

@ -12,7 +12,7 @@
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="800"> d:DesignHeight="600" d:DesignWidth="800">
<GroupBox Name="portCallGroupBox" Header="{x:Static p:Resources.textPortCall}"> <GroupBox Name="portCallGroupBox" Header="{x:Static p:Resources.textPortCall}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel"> <ScrollViewer>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="300" /> <RowDefinition Height="300" />
@ -92,8 +92,9 @@
<Label HorizontalContentAlignment="Right" Grid.Row="6" Grid.Column="0" Content="{x:Static p:Resources.textPhone}" Name="label_AgentPhone" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="6" Grid.Column="0" Content="{x:Static p:Resources.textPhone}" Name="label_AgentPhone" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="7" Grid.Column="0" Content="{x:Static p:Resources.textEMail}" Name="label_AgentEMail" Margin="0,0,10,0" /> <Label HorizontalContentAlignment="Right" Grid.Row="7" Grid.Column="0" Content="{x:Static p:Resources.textEMail}" Name="label_AgentEMail" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="2" Content="{x:Static p:Resources.textCity}" Name="label_AgentCity" Margin="0,0,10,0" /> <Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="2" Content="{x:Static p:Resources.textCity}" Name="label_AgentCity" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="6" Grid.Column="2" Content="{x:Static p:Resources.textFirstName}" Name="label_AgentFirstName" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="5" Grid.Column="2" Content="{x:Static p:Resources.textFirstName}" Name="label_AgentFirstName" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="7" Grid.Column="2" Content="{x:Static p:Resources.textFax}" Name="label_AgentFax" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="6" Grid.Column="2" Content="{x:Static p:Resources.textFax}" Name="label_AgentFax" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="7" Grid.Column="2" Content="{x:Static p:Resources.textWasteDisposalServiceProvider}" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textCountry}" Name="label_AgentCountry" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textCountry}" Name="label_AgentCountry" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="2" Content="{x:Static p:Resources.textAgentTemplate}" Name="labelAgentTemplate" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="2" Content="{x:Static p:Resources.textAgentTemplate}" Name="labelAgentTemplate" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="2" Content="{x:Static p:Resources.textTitle}" Name="labelAgentTemplateTitle" Margin="0,0,10,0" Visibility="Hidden" /> <Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="2" Content="{x:Static p:Resources.textTitle}" Name="labelAgentTemplateTitle" Margin="0,0,10,0" Visibility="Hidden" />
@ -104,10 +105,11 @@
<TextBox Grid.Row="3" Grid.Column="3" Name="textBox_AgentCity" MaxLength="99" Margin="2" Text="{Binding AgentCity, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/> <TextBox Grid.Row="3" Grid.Column="3" Name="textBox_AgentCity" MaxLength="99" Margin="2" Text="{Binding AgentCity, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="3" Grid.Column="1" Name="textBox_AgentCountry" MaxLength="99" Margin="2" Text="{Binding AgentCountry, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center" /> <TextBox Grid.Row="3" Grid.Column="1" Name="textBox_AgentCountry" MaxLength="99" Margin="2" Text="{Binding AgentCountry, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center" />
<TextBox Grid.Row="5" Grid.Column="1" Name="textBox_AgentLastName" MaxLength="99" Margin="2" Text="{Binding AgentLastName, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/> <TextBox Grid.Row="5" Grid.Column="1" Name="textBox_AgentLastName" MaxLength="99" Margin="2" Text="{Binding AgentLastName, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="6" Grid.Column="3" Name="textBox_AgentFirstName" MaxLength="99" Margin="2" Text="{Binding AgentFirstName, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/> <TextBox Grid.Row="5" Grid.Column="3" Name="textBox_AgentFirstName" MaxLength="99" Margin="2" Text="{Binding AgentFirstName, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="6" Grid.Column="1" Name="textBox_AgentPhone" MaxLength="99" Margin="2" Text="{Binding AgentPhone, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/> <TextBox Grid.Row="6" Grid.Column="1" Name="textBox_AgentPhone" MaxLength="99" Margin="2" Text="{Binding AgentPhone, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="7" Grid.Column="3" Name="textBox_AgentFax" MaxLength="99" Margin="2" Text="{Binding AgentFax, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/> <TextBox Grid.Row="6" Grid.Column="3" Name="textBox_AgentFax" MaxLength="99" Margin="2" Text="{Binding AgentFax, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="7" Grid.Column="1" Name="textBox_AgentEMail" MaxLength="99" Margin="2" Text="{Binding AgentEMail, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/> <TextBox Grid.Row="7" Grid.Column="1" Name="textBox_AgentEMail" MaxLength="99" Margin="2" Text="{Binding AgentEMail, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="7" Grid.Column="3" Name="textBox_WasteDisposalServiceProvider" MaxLength="99" Margin="2" Text="{Binding WasteDisposalServiceProviderText, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<ComboBox Grid.Row="0" Grid.Column="3" Name="comboBox_AgentTemplate" Margin="2" SelectedValuePath="Id" DisplayMemberPath="AgentTitle" SelectionChanged="comboBox_AgentTemplate_SelectionChanged" /> <ComboBox Grid.Row="0" Grid.Column="3" Name="comboBox_AgentTemplate" Margin="2" SelectedValuePath="Id" DisplayMemberPath="AgentTitle" SelectionChanged="comboBox_AgentTemplate_SelectionChanged" />
<Grid Grid.Column="2" Grid.Row="1" HorizontalAlignment="Right"> <Grid Grid.Column="2" Grid.Row="1" HorizontalAlignment="Right">

View File

@ -25,6 +25,7 @@ namespace ENI2.DetailViewControls
private NOA_NOD _noa_nod; private NOA_NOD _noa_nod;
private AGNT _agnt; private AGNT _agnt;
private WAS _was;
private static List<AGNT_Template> _agntTemplates = null; private static List<AGNT_Template> _agntTemplates = null;
private AGNT_Template _currentTemplate; private AGNT_Template _currentTemplate;
private AGNT_Template _undoTemplate; private AGNT_Template _undoTemplate;
@ -68,6 +69,9 @@ namespace ENI2.DetailViewControls
this.RegisterTextboxChange(this.textBox_AgentStreetAndNumber, Message.NotificationClass.AGNT); this.RegisterTextboxChange(this.textBox_AgentStreetAndNumber, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_AgentCountry, Message.NotificationClass.AGNT); this.RegisterTextboxChange(this.textBox_AgentCountry, Message.NotificationClass.AGNT);
// WAS
this.RegisterTextboxChange(this.textBox_WasteDisposalServiceProvider, Message.NotificationClass.WAS);
this.buttonSaveTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor; this.buttonSaveTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor;
this.buttonDeleteTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor; this.buttonDeleteTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor;
} }
@ -95,6 +99,16 @@ namespace ENI2.DetailViewControls
_agnt = new AGNT(); _agnt = new AGNT();
this.ControlMessages.Add(aMessage); this.ControlMessages.Add(aMessage);
} }
if(aMessage.MessageNotificationClass == Message.NotificationClass.WAS)
{
if (aMessage.Elements.Count > 0)
_was = aMessage.Elements[0] as WAS;
else
_was = new WAS();
this.ControlMessages.Add(aMessage);
}
} }
this.dateTimePicker_ETAToKielCanal.IsEnabled = this.Core.IsTransit; this.dateTimePicker_ETAToKielCanal.IsEnabled = this.Core.IsTransit;
@ -123,6 +137,8 @@ namespace ENI2.DetailViewControls
this.dateTimePicker_ETDFromLastPort.DataContext = _noa_nod; this.dateTimePicker_ETDFromLastPort.DataContext = _noa_nod;
this.dateTimePicker_ETDFromPortOfCall.DataContext = _noa_nod; this.dateTimePicker_ETDFromPortOfCall.DataContext = _noa_nod;
this.textBox_WasteDisposalServiceProvider.DataContext = _was;
this.checkBox_IsAnchored.IsEnabled = this.Core.IsDK; this.checkBox_IsAnchored.IsEnabled = this.Core.IsDK;
if(_agntTemplates == null) if(_agntTemplates == null)
@ -242,17 +258,6 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
#endregion
#region AGNT templates combo #region AGNT templates combo
private void comboBox_AgentTemplate_SelectionChanged(object sender, SelectionChangedEventArgs e) private void comboBox_AgentTemplate_SelectionChanged(object sender, SelectionChangedEventArgs e)
@ -348,6 +353,8 @@ namespace ENI2.DetailViewControls
this.textBox_AgentPostalCode.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentPostalCode.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentStreetAndNumber.Text = this._undoTemplate.AgentStreetAndNumber; this.textBox_AgentStreetAndNumber.Text = this._undoTemplate.AgentStreetAndNumber;
this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_WasteDisposalServiceProvider.Text = this._undoTemplate.WasteDisposalServiceProviderName;
this.textBox_WasteDisposalServiceProvider.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.buttonUndoTemplate.IsEnabled = false; // can't undo after undo this.buttonUndoTemplate.IsEnabled = false; // can't undo after undo
} }
@ -356,6 +363,13 @@ namespace ENI2.DetailViewControls
{ {
if (this._currentTemplate == null) return; if (this._currentTemplate == null) return;
// confirm overwrite of waste disposal service provider
if (this.textBox_WasteDisposalServiceProvider.Text.Length > 0)
{
string message = string.Format(Properties.Resources.textConfirmWSDPOverwrite, this.textBox_WasteDisposalServiceProvider.Text, this._currentTemplate.WasteDisposalServiceProviderName);
if (MessageBox.Show(message, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No) { return; }
}
this._undoTemplate = createFromCurrentText(null, null); this._undoTemplate = createFromCurrentText(null, null);
this.textBox_AgentCity.Text = this._currentTemplate.AgentCity; this.textBox_AgentCity.Text = this._currentTemplate.AgentCity;
@ -367,7 +381,7 @@ namespace ENI2.DetailViewControls
this.textBox_AgentEMail.Text = this._currentTemplate.AgentEMail; this.textBox_AgentEMail.Text = this._currentTemplate.AgentEMail;
this.textBox_AgentEMail.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentEMail.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentFax.Text = this._currentTemplate.AgentFax; this.textBox_AgentFax.Text = this._currentTemplate.AgentFax;
this.textBox_AgentEMail.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentFax.GetBindingExpression (TextBox.TextProperty).UpdateSource();
this.textBox_AgentFirstName.Text = this._currentTemplate.AgentFirstName; this.textBox_AgentFirstName.Text = this._currentTemplate.AgentFirstName;
this.textBox_AgentFirstName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentFirstName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentLastName.Text = this._currentTemplate.AgentLastName; this.textBox_AgentLastName.Text = this._currentTemplate.AgentLastName;
@ -378,6 +392,11 @@ namespace ENI2.DetailViewControls
this.textBox_AgentPostalCode.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentPostalCode.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentStreetAndNumber.Text = this._currentTemplate.AgentStreetAndNumber; this.textBox_AgentStreetAndNumber.Text = this._currentTemplate.AgentStreetAndNumber;
this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if ((this._currentTemplate.WasteDisposalServiceProviderName ?? "").Trim() != (this.textBox_WasteDisposalServiceProvider.Text ?? "").Trim())
{
this.textBox_WasteDisposalServiceProvider.Text = this._currentTemplate.WasteDisposalServiceProviderName;
this.textBox_WasteDisposalServiceProvider.GetBindingExpression(TextBox.TextProperty).UpdateSource();
}
this.buttonUndoTemplate.IsEnabled = true; this.buttonUndoTemplate.IsEnabled = true;
this.buttonSetTemplate.IsEnabled = false; this.buttonSetTemplate.IsEnabled = false;
@ -403,6 +422,7 @@ namespace ENI2.DetailViewControls
at.AgentPhone = this.textBox_AgentPhone.Text; at.AgentPhone = this.textBox_AgentPhone.Text;
at.AgentPostalCode = this.textBox_AgentPostalCode.Text; at.AgentPostalCode = this.textBox_AgentPostalCode.Text;
at.AgentStreetAndNumber = textBox_AgentStreetAndNumber.Text; at.AgentStreetAndNumber = textBox_AgentStreetAndNumber.Text;
at.WasteDisposalServiceProviderName = textBox_WasteDisposalServiceProvider.Text;
return at; return at;
} }

View File

@ -24,11 +24,11 @@
</col:ArrayList> </col:ArrayList>
</UserControl.Resources> </UserControl.Resources>
<GroupBox Name="portNotificationGroupBox" Header="{x:Static p:Resources.textPortNotification}"> <GroupBox Name="portNotificationGroupBox" Header="{x:Static p:Resources.textPortNotification}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel"> <ScrollViewer>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="50" /> <RowDefinition Height="50" />
<RowDefinition Height="220" /> <RowDefinition Height="194" />
<RowDefinition Height="200" /> <RowDefinition Height="200" />
<RowDefinition Height="200" /> <RowDefinition Height="200" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
@ -36,10 +36,12 @@
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" /> <ColumnDefinition Width="1*" />
<ColumnDefinition Width="5*" /> <ColumnDefinition Width="4*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textNameMaster}" Name="label_nameMaster" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textNameMaster}" Name="label_nameMaster" Margin="0,0,10,0"/>
<TextBox Grid.Row="0" Grid.Column="1" Name="textBox_NameMaster" MaxLength="100" Margin="2" Text="{Binding NameOfMaster, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center" VerticalAlignment="Center"/> <TextBox Grid.Row="0" Grid.Column="1" Name="textBox_NameMaster" MaxLength="100" Margin="2" Text="{Binding NameOfMaster, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
<Button x:Name="buttonCopyNameFromCREWA" Grid.Row="0" Grid.Column="2" Margin="2" Content="{x:Static p:Resources.textCopyFromCREWA}" Click="buttonCopyNameFromCREWA_Click"/>
</Grid> </Grid>
</GroupBox> </GroupBox>
<GroupBox Name="infoGroupBox" Header="{x:Static p:Resources.textInfo}" Grid.Row="1" Margin="0,5,0,5"> <GroupBox Name="infoGroupBox" Header="{x:Static p:Resources.textInfo}" Grid.Row="1" Margin="0,5,0,5">
@ -57,34 +59,84 @@
<RowDefinition Height="26" /> <RowDefinition Height="26" />
<RowDefinition Height="26" /> <RowDefinition Height="26" />
<RowDefinition Height="26" /> <RowDefinition Height="26" />
<RowDefinition Height="26" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textShippingArea}" Name="label_INFOShippingArea" VerticalContentAlignment="Center" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textShippingArea}" Name="label_INFOShippingArea" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="2" Content="{x:Static p:Resources.textMaerskSeago}" Name="label_MaerskSeaGo" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textPortArea}" Name="label_INFOPortArea" VerticalContentAlignment="Center" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textPortArea}" Name="label_INFOPortArea" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textRequestedPositionInPortOfCall}" Name="label_INFORequestedBerth" VerticalContentAlignment="Center" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textRequestedPositionInPortOfCall}" Name="label_INFORequestedBerth" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textBowThrusterPower}" Name="label_INFOBowThrusterPower" VerticalContentAlignment="Center" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textBowThrusterPower}" Name="label_INFOBowThrusterPower" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textSternThrusterPower}" Name="label_INFOSternThrusterPower" VerticalContentAlignment="Center" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textSternThrusterPower}" Name="label_INFOSternThrusterPower" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textFumigatedBulkCargo}" Name="label_INFOFumigatedBulkCargo" VerticalContentAlignment="Center" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textFumigatedBulkCargo}" Name="label_INFOFumigatedBulkCargo" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="6" Grid.Column="0" Content="{x:Static p:Resources.textDeplacementSummerDraught}" Name="label_INFODeplacementSummerDraught" VerticalContentAlignment="Center" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="2" Content="{x:Static p:Resources.textDeplacementSummerDraught}" Name="label_INFODeplacementSummerDraught" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="2" Content="{x:Static p:Resources.textSpecialRequirementsOfShipAtBerth}" Name="label_INFOSpecialRequirements" VerticalContentAlignment="Center" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="2" Content="{x:Static p:Resources.textSpecialRequirementsOfShipAtBerth}" Name="label_INFOSpecialRequirements" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="5" Grid.Column="2" Content="{x:Static p:Resources.textConstructionCharacteristics}" Name="label_INFOConstructionCharacteristics" VerticalContentAlignment="Center" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="2" Content="{x:Static p:Resources.textConstructionCharacteristics}" Name="label_INFOConstructionCharacteristics" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<ComboBox Grid.Row="0" Grid.Column="1" x:Name="comboBoxShippingArea" Margin="2" SelectedIndex="{Binding ShippingArea, Converter={util:ByteConverter}}" ContextMenu="{DynamicResource ClearContextMenu}" /> <ComboBox Grid.Row="0" Grid.Column="1" x:Name="comboBoxShippingArea" Margin="2" SelectedIndex="{Binding ShippingArea, Converter={util:ByteConverter}}" ContextMenu="{DynamicResource ClearContextMenu}" />
<ComboBox Grid.Row="0" Grid.Column="3" x:Name="comboBoxGroup" Margin="2,2,4,2" ItemsSource="{StaticResource arrList}" DisplayMemberPath="Key" SelectedValuePath="Value" SelectionChanged="comboBoxGroup_SelectionChanged"/>
<Button Grid.Row="1" Grid.Column="3" x:Name="buttonSearchPortArea" Margin="2" Content="Lookup port area" Click="buttonSearchPortArea_Click" /> <Grid Grid.Row="1" Grid.Column="1">
<ComboBox Grid.Row="1" Grid.Column="1" Name="comboBoxPortArea" Margin="2" SelectedValue="{Binding PortArea}" SelectedValuePath="Key" DisplayMemberPath="Value" ContextMenu="{DynamicResource ClearContextMenu}" /> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="110" />
</Grid.ColumnDefinitions>
<ComboBox Grid.Column="0" Name="comboBoxPortArea" Margin="2" SelectedValue="{Binding PortArea}" SelectedValuePath="Key" DisplayMemberPath="Value" ContextMenu="{DynamicResource ClearContextMenu}" />
<Button Grid.Column="1" x:Name="buttonSearchPortArea" Margin="2" Content="Lookup port area" Click="buttonSearchPortArea_Click" />
</Grid>
<TextBox Grid.Row="2" Grid.Column="1" Name="textRequestedPostionInPortOfCall" Margin="2" Text="{Binding RequestedPositionInPortOfCall, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/> <TextBox Grid.Row="2" Grid.Column="1" Name="textRequestedPostionInPortOfCall" Margin="2" Text="{Binding RequestedPositionInPortOfCall, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="3" Grid.Column="1" Name="textBowThrusterPower" Margin="2" Text="{Binding BowThrusterPower, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/> <TextBox Grid.Row="3" Grid.Column="1" Name="textBowThrusterPower" Margin="2" Text="{Binding BowThrusterPower, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="4" Grid.Column="1" Name="textSternThrusterPower" Margin="2" Text="{Binding SternThrusterPower, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/> <TextBox Grid.Row="4" Grid.Column="1" Name="textSternThrusterPower" Margin="2" Text="{Binding SternThrusterPower, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<CheckBox Grid.Row="5" Grid.Column="1" Name="checkBoxFumigatedBulkCargo" VerticalContentAlignment="Center" IsChecked="{Binding FumigatedBulkCargoBool, Mode=TwoWay}" Margin="2"/> <CheckBox Grid.Row="5" Grid.Column="1" Name="checkBoxFumigatedBulkCargo" VerticalContentAlignment="Center" IsChecked="{Binding FumigatedBulkCargoBool, Mode=TwoWay}" Margin="2"/>
<xctk:DoubleUpDown Grid.Row="6" Grid.Column="1" Name="doubleUpDownDisplacementSummerDraught" ShowButtonSpinner="False" ParsingNumberStyle="Any" Value="{Binding DeplacementSummerDraught_TNE}" Margin="4,2,0,2" FormatString="N1" TextAlignment="Left"/> <xctk:DoubleUpDown Grid.Row="0" Grid.Column="3" Name="doubleUpDownDisplacementSummerDraught" ShowButtonSpinner="False" ParsingNumberStyle="Any" Value="{Binding DeplacementSummerDraught_TNE}" Margin="4,2,0,2" FormatString="N1" TextAlignment="Left"/>
<TextBox Grid.Row="3" Grid.Column="3" Grid.RowSpan="2" Name="textSpecialRequirements" Margin="2" Text="{Binding SpecialRequirementsOfShipAtBerth, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Top" /> <TextBox Grid.Row="1" Grid.Column="3" Grid.RowSpan="2" Name="textSpecialRequirements" Margin="2" Text="{Binding SpecialRequirementsOfShipAtBerth, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Top" />
<TextBox Grid.Row="5" Grid.Column="3" Grid.RowSpan="2" Name="textConstructionCharacteristics" Margin="2" Text="{Binding ConstructionCharacteristicsOfShip, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Top"/> <TextBox Grid.Row="3" Grid.Column="3" Grid.RowSpan="2" Name="textConstructionCharacteristics" Margin="2" Text="{Binding ConstructionCharacteristicsOfShip, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Top"/>
</Grid> </Grid>
</GroupBox> </GroupBox>
<GroupBox Name="servGroupBox" Header="{x:Static p:Resources.textServ}" Grid.Row="2"> <GroupBox Name="servGroupBox" Header="{x:Static p:Resources.textServ}" Grid.Row="2">
<enictrl:ENIDataGrid x:Name="dataGridSERV" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" <Grid>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".1*" />
<ColumnDefinition Width=".2*" />
<ColumnDefinition Width="26" />
<ColumnDefinition Width="26" />
<ColumnDefinition Width="26" />
<ColumnDefinition Width="26" />
<ColumnDefinition Width="26" />
<ColumnDefinition Width=".2*" />
</Grid.ColumnDefinitions>
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textSERVTemplate}" Name="label_MaerskSeaGo" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<ComboBox Grid.Row="0" Grid.Column="1" x:Name="comboBoxGroup" Margin="2,2,4,2" DisplayMemberPath="ServiceName"
SelectionChanged="comboBoxGroup_SelectionChanged" ContextMenu="{DynamicResource ClearContextMenu}" />
<Button Name="buttonSetTemplate" Margin="2" Click="buttonSetTemplate_Click" BorderThickness="0" Background="Transparent" Grid.Column="2"
ToolTip="Apply template" HorizontalContentAlignment="Right" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/check.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonEditTemplate" Grid.Column="4" Grid.Row="0" Margin="2" Click="buttonEditTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Edit template">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/pencil.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonNewTemplate" Grid.Column="5" Grid.Row="0" Margin="2" Click="buttonNewTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="New template">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/document_plain_new.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonDeleteTemplate" Grid.Column="6" Grid.Row="0" Margin="2" Click="buttonDeleteTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Delete template" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/delete.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
</Grid>
<enictrl:ENIDataGrid Grid.Row="1" x:Name="dataGridSERV" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AutoGenerateColumns="False" Margin="0,5,0,0"> AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" /> <DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
@ -93,7 +145,7 @@
<DataGridTextColumn Header="{x:Static p:Resources.textServiceInvoiceRecipient}" Binding="{Binding ServiceInvoiceRecipient, Mode=TwoWay}" IsReadOnly="True" Width="0.4*" /> <DataGridTextColumn Header="{x:Static p:Resources.textServiceInvoiceRecipient}" Binding="{Binding ServiceInvoiceRecipient, Mode=TwoWay}" IsReadOnly="True" Width="0.4*" />
</DataGrid.Columns> </DataGrid.Columns>
</enictrl:ENIDataGrid> </enictrl:ENIDataGrid>
</Grid>
</GroupBox> </GroupBox>
<GroupBox Name="ladgGroupBox" Header="{x:Static p:Resources.textLadg}" Grid.Row="3"> <GroupBox Name="ladgGroupBox" Header="{x:Static p:Resources.textLadg}" Grid.Row="3">
<enictrl:ENIDataGrid x:Name="dataGridLADG" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" <enictrl:ENIDataGrid x:Name="dataGridLADG" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
@ -104,8 +156,27 @@
<DataGridTextColumn Header="{x:Static p:Resources.textLACodes}" Binding="{Binding CargoLACode, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" /> <DataGridTextColumn Header="{x:Static p:Resources.textLACodes}" Binding="{Binding CargoLACode, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoCodeNST}" Binding="{Binding CargoCodeNST, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" /> <DataGridTextColumn Header="{x:Static p:Resources.textCargoCodeNST}" Binding="{Binding CargoCodeNST, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoCodeNST3}" Binding="{Binding CargoCodeNST_3, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" /> <DataGridTextColumn Header="{x:Static p:Resources.textCargoCodeNST3}" Binding="{Binding CargoCodeNST_3, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoNumberOfItems}" Binding="{Binding CargoNumberOfItems, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoGrossQuantity}" Binding="{Binding CargoGrossQuantity_TNE, Mode=TwoWay, StringFormat={}{0:N3}}" IsReadOnly="True" Width="0.15*" /> <DataGridTextColumn Header="{x:Static p:Resources.textCargoNumberOfItems}" IsReadOnly="False" Width="0.15*">
<DataGridTextColumn.Binding>
<Binding Path="CargoNumberOfItems" Mode="TwoWay">
<Binding.ValidationRules>
<util:NumberValidationRule MaxValue="9999999" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textCargoGrossQuantity}" IsReadOnly="False" Width="0.15*">
<DataGridTextColumn.Binding>
<Binding Path="CargoGrossQuantity_TNE" Mode="TwoWay" StringFormat="N3">
<Binding.ValidationRules>
<util:NumberValidationRule MaxValue="1000000" MinValue="0" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textCargoPortOfLoading}" Binding="{Binding PortOfLoading, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" /> <DataGridTextColumn Header="{x:Static p:Resources.textCargoPortOfLoading}" Binding="{Binding PortOfLoading, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoPortOfDischarge}" Binding="{Binding PortOfDischarge, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" /> <DataGridTextColumn Header="{x:Static p:Resources.textCargoPortOfDischarge}" Binding="{Binding PortOfDischarge, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
</DataGrid.Columns> </DataGrid.Columns>

View File

@ -16,6 +16,8 @@ using ENI2.EditControls;
using ENI2.Util; using ENI2.Util;
using bsmd.database; using bsmd.database;
using System.Threading.Tasks;
using System.Diagnostics;
namespace ENI2.DetailViewControls namespace ENI2.DetailViewControls
{ {
@ -25,11 +27,18 @@ namespace ENI2.DetailViewControls
public partial class PortNotificationDetailControl : DetailBaseControl public partial class PortNotificationDetailControl : DetailBaseControl
{ {
#region Fields
private Message _nameMessage; private Message _nameMessage;
private Message _infoMessage; private Message _infoMessage;
private Message _servMessage; private Message _servMessage;
private Message _ladgMessage; private Message _ladgMessage;
private Message _crewaMessage;
private Dictionary<string, string> portAreas = null; private Dictionary<string, string> portAreas = null;
private static List<SERV_Template> _servTemplates = null;
private SERV_Template _currentTemplate;
#endregion
private static readonly string[] shippingAreas = { private static readonly string[] shippingAreas = {
Properties.Resources.textShippingAreaNORTHBALTIC, Properties.Resources.textShippingAreaNORTHBALTIC,
@ -56,10 +65,10 @@ namespace ENI2.DetailViewControls
this.RegisterDoubleUpDownChange(this.doubleUpDownDisplacementSummerDraught, Message.NotificationClass.INFO); this.RegisterDoubleUpDownChange(this.doubleUpDownDisplacementSummerDraught, Message.NotificationClass.INFO);
this.RegisterTextboxChange(this.textSpecialRequirements, Message.NotificationClass.INFO); this.RegisterTextboxChange(this.textSpecialRequirements, Message.NotificationClass.INFO);
this.RegisterTextboxChange(this.textConstructionCharacteristics, Message.NotificationClass.INFO); this.RegisterTextboxChange(this.textConstructionCharacteristics, Message.NotificationClass.INFO);
this.dataGridLADG.CellEditEnding += (obj, ev) => { this.OnNotificationClassChanged(Message.NotificationClass.LADG); };
} }
public override void Initialize() public override async void Initialize()
{ {
base.Initialize(); base.Initialize();
@ -69,6 +78,7 @@ namespace ENI2.DetailViewControls
if (aMessage.MessageNotificationClass == Message.NotificationClass.INFO) { this._infoMessage = aMessage; this.ControlMessages.Add(aMessage); } if (aMessage.MessageNotificationClass == Message.NotificationClass.INFO) { this._infoMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.SERV) { this._servMessage = aMessage; this.ControlMessages.Add(aMessage); } if (aMessage.MessageNotificationClass == Message.NotificationClass.SERV) { this._servMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.LADG) { this._ladgMessage = aMessage; this.ControlMessages.Add(aMessage); } if (aMessage.MessageNotificationClass == Message.NotificationClass.LADG) { this._ladgMessage = aMessage; this.ControlMessages.Add(aMessage); }
if(aMessage.MessageNotificationClass == Message.NotificationClass.CREWA) { this._crewaMessage = aMessage;}
} }
#region init NAME #region init NAME
@ -157,14 +167,20 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region init helper Maersk / SeaGo Field #region init SERV templates
if (this.Core.IsFlagSet(MessageCore.CoreFlags.MAERSK_BHV)) this.comboBoxGroup.SelectedIndex = 1; if(_servTemplates == null)
if (this.Core.IsFlagSet(MessageCore.CoreFlags.SEAGO_BHV)) this.comboBoxGroup.SelectedIndex = 2; {
if (this.Core.IsFlagSet(MessageCore.CoreFlags.SEAGO_WHV)) this.comboBoxGroup.SelectedIndex = 3; _servTemplates = await DBManagerAsync.GetSERVTemplatesAsync(); // initial load
if (this.Core.IsFlagSet(MessageCore.CoreFlags.HOEGH)) this.comboBoxGroup.SelectedIndex = 4; _servTemplates.Sort();
if (this.Core.IsFlagSet(MessageCore.CoreFlags.ELBE_BULK)) this.comboBoxGroup.SelectedIndex = 5; Trace.WriteLine($"{_servTemplates.Count} SERV templates loaded");
if (this.Core.IsFlagSet(MessageCore.CoreFlags.FCT_JUNGE)) this.comboBoxGroup.SelectedIndex = 6; }
this.comboBoxGroup.ItemsSource = _servTemplates;
this.buttonDeleteTemplate.Visibility = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor ? Visibility.Visible : Visibility.Hidden;
this.buttonEditTemplate.Visibility = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor ? Visibility.Visible : Visibility.Hidden;
this.buttonNewTemplate.Visibility = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor ? Visibility.Visible : Visibility.Hidden;
#endregion #endregion
@ -174,6 +190,8 @@ namespace ENI2.DetailViewControls
private void DataGridLADG_CreateRequested() private void DataGridLADG_CreateRequested()
{ {
this.dataGridLADG.CancelEdit();
this.dataGridLADG.CancelEdit();
EditLADGDialog eld = new EditLADGDialog(); EditLADGDialog eld = new EditLADGDialog();
eld.LADG = new LADG(); eld.LADG = new LADG();
eld.LADG.MessageHeader = _ladgMessage; eld.LADG.MessageHeader = _ladgMessage;
@ -206,6 +224,8 @@ namespace ENI2.DetailViewControls
{ {
if (obj is LADG ladg) if (obj is LADG ladg)
{ {
this.dataGridLADG.CancelEdit();
this.dataGridLADG.CancelEdit();
// are you sure dialog is in base class // are you sure dialog is in base class
this._ladgMessage.Elements.Remove(ladg); this._ladgMessage.Elements.Remove(ladg);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(ladg); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(ladg);
@ -217,6 +237,9 @@ namespace ENI2.DetailViewControls
private void DataGridLADG_EditRequested(DatabaseEntity obj) private void DataGridLADG_EditRequested(DatabaseEntity obj)
{ {
this.dataGridLADG.CancelEdit();
this.dataGridLADG.CancelEdit();
LADG ladg = obj as LADG; LADG ladg = obj as LADG;
EditLADGDialog eld = new EditLADGDialog(); EditLADGDialog eld = new EditLADGDialog();
@ -358,177 +381,141 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region mouse wheel #region SERV template event handler
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
#endregion
#region Spezialbalkon für die Gruppenauswahl im Core (Maersk BHV / Seago usw.)
private void comboBoxGroup_SelectionChanged(object sender, SelectionChangedEventArgs e) private void comboBoxGroup_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
// clear all if(this.comboBoxGroup.SelectedItem is SERV_Template st)
this.Core.SetFlag(false, MessageCore.CoreFlags.MAERSK_BHV);
this.Core.SetFlag(false, MessageCore.CoreFlags.SEAGO_BHV);
this.Core.SetFlag(false, MessageCore.CoreFlags.SEAGO_WHV);
this.Core.SetFlag(false, MessageCore.CoreFlags.HOEGH);
this.Core.SetFlag(false, MessageCore.CoreFlags.ELBE_BULK);
this.Core.SetFlag(false, MessageCore.CoreFlags.FCT_JUNGE);
DictionaryEntry selectedItem = (DictionaryEntry) this.comboBoxGroup.SelectedItem;
if(Int32.TryParse((string)selectedItem.Value, out int selectedValue))
{ {
if (selectedValue == (int)MessageCore.CoreFlags.MAERSK_BHV) CheckServiceEntryMaerskBHV(); this.buttonDeleteTemplate.IsEnabled = true;
if (selectedValue == (int)MessageCore.CoreFlags.SEAGO_BHV) CheckServiceEntrySeaGoBHV(); this.buttonSetTemplate.IsEnabled = true;
if (selectedValue == (int)MessageCore.CoreFlags.HOEGH) CheckServiceEntryHoegh(); this._currentTemplate = st;
if (selectedValue == (int)MessageCore.CoreFlags.ELBE_BULK) CheckServiceEntryElbeBulk(); }
if (selectedValue == (int)MessageCore.CoreFlags.FCT_JUNGE) CheckServiceEntryFctJunge(); }
this.Core.SetFlag(true, (MessageCore.CoreFlags)selectedValue);
DBManager.Instance.Save(this.Core); private void buttonSetTemplate_Click(object sender, RoutedEventArgs e)
{
if (this.comboBoxGroup.SelectedItem is SERV_Template st)
{
bool found = false;
foreach (SERV serv in _servMessage.Elements.Cast<SERV>())
{
if (serv.ServiceName.Equals(st.ServiceName))
{
found = true; break;
}
}
if (!found)
{
SERV newServ = new SERV();
newServ.ServiceName = st.ServiceName;
newServ.ServiceBeneficiary = st.ServiceBeneficiary;
newServ.ServiceInvoiceRecipient = st.ServiceInvoiceRecipient;
newServ.MessageHeader = this._servMessage;
newServ.Identifier = SERV.GetNewIdentifier(_servMessage.Elements);
this._servMessage.Elements.Add(newServ);
this.dataGridSERV.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.SERV);
}
}
}
private void buttonNewTemplate_Click(object sender, RoutedEventArgs e)
{
SERV_Template newTemplate = new SERV_Template();
EditSERVDialog esd = new EditSERVDialog();
esd.AddVisible = false;
esd.SERV_Template = newTemplate;
if(esd.ShowDialog() ?? false)
{
_ = DBManagerAsync.SaveAsync(esd.SERV_Template);
this.comboBoxGroup.ItemsSource = null;
_servTemplates.Add(newTemplate);
_servTemplates.Sort();
this.comboBoxGroup.ItemsSource = _servTemplates;
}
}
private void buttonEditTemplate_Click(object sender, RoutedEventArgs e)
{
if (this.comboBoxGroup.SelectedItem is SERV_Template st)
{
EditSERVDialog editSERVDialog = new EditSERVDialog();
editSERVDialog.AddVisible = false;
editSERVDialog.SERV_Template = st;
if (editSERVDialog.ShowDialog() ?? false)
{
_ = DBManagerAsync.SaveAsync(st);
this.comboBoxGroup.ItemsSource = null;
_servTemplates.Sort();
this.comboBoxGroup.ItemsSource = _servTemplates;
}
}
}
private void buttonDeleteTemplate_Click(object sender, RoutedEventArgs e)
{
if (_currentTemplate != null)
{
if (MessageBox.Show("Delete this template?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
this.comboBoxGroup.SelectedItem = null;
this.comboBoxGroup.ItemsSource = null;
_ = DBManagerAsync.DeleteAsync(_currentTemplate);
_servTemplates.Remove(_currentTemplate);
this.buttonDeleteTemplate.IsEnabled = false;
this.comboBoxGroup.ItemsSource = _servTemplates;
this.buttonSetTemplate.IsEnabled = false;
}
} }
} }
#endregion #endregion
#region special entry ship service check #region other event handler
private void CheckServiceEntryMaerskBHV()
{
bool found = false;
foreach(SERV serv in this._servMessage.Elements)
{
if (serv.ServiceBeneficiary.Equals("Maersk A/S, Esplanaden 50, DK-1263 Copenhagen K, VAT-ID: DK53139655"))
found = true;
}
if(!found)
{
SERV newServ = new SERV();
newServ.ServiceBeneficiary = "Maersk A/S, Esplanaden 50, DK-1263 Copenhagen K, VAT-ID: DK53139655";
newServ.ServiceInvoiceRecipient = "Maersk Deutschland A/S & Co.KG, Ericusspitze 2-4, 20457 Hamburg";
newServ.ServiceName = "Maersk BHV";
newServ.MessageHeader = this._servMessage;
newServ.Identifier = SERV.GetNewIdentifier(_servMessage.Elements);
this._servMessage.Elements.Add(newServ);
this.dataGridSERV.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.SERV);
}
}
private void CheckServiceEntrySeaGoBHV()
{
bool found = false;
foreach (SERV serv in this._servMessage.Elements)
{
if (serv.ServiceBeneficiary.Equals("Sealand Europe A/S, Dampfaergevej 10, 3.tv, DK- 2100 Copenhagen, VAT-ID: DK53139655"))
found = true;
}
if (!found)
{
SERV newServ = new SERV();
newServ.ServiceBeneficiary = "Sealand Europe A/S, Dampfaergevej 10, 3.tv, DK- 2100 Copenhagen, VAT-ID: DK53139655";
newServ.ServiceInvoiceRecipient = "Maersk Deutschland A/S & Co. KG on behalf of Sealand Europe A/S, Ericusspitze 2-4, 20457 Hamburg";
newServ.ServiceName = "SeaGo BHV";
newServ.MessageHeader = this._servMessage;
newServ.Identifier = SERV.GetNewIdentifier(_servMessage.Elements);
this._servMessage.Elements.Add(newServ);
this.dataGridSERV.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.SERV);
}
}
private void CheckServiceEntryHoegh()
{
bool found = false;
foreach (SERV serv in this._servMessage.Elements)
{
if (serv.ServiceBeneficiary.Equals("Höegh Autoliners AS, Oslo, Norway"))
found = true;
}
if (!found)
{
SERV newServ = new SERV();
newServ.ServiceBeneficiary = "Höegh Autoliners AS, Oslo, Norway";
newServ.ServiceInvoiceRecipient = " PWL Port Services GmbH & Co. KG";
newServ.ServiceName = "HOEGH BHV";
newServ.MessageHeader = this._servMessage;
newServ.Identifier = SERV.GetNewIdentifier(_servMessage.Elements);
this._servMessage.Elements.Add(newServ);
this.dataGridSERV.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.SERV);
}
}
private void CheckServiceEntryFctJunge()
{
bool found = false;
foreach (SERV serv in this._servMessage.Elements)
{
if (serv.ServiceBeneficiary.Equals("Fct Junge - Hamburg"))
found = true;
}
if (!found)
{
SERV newServ = new SERV();
newServ.ServiceBeneficiary = "";
newServ.ServiceInvoiceRecipient = " Frachtcontor Junge & Co. GmbH";
newServ.ServiceName = "FCT JUNGE";
newServ.MessageHeader = this._servMessage;
newServ.Identifier = SERV.GetNewIdentifier(_servMessage.Elements);
this._servMessage.Elements.Add(newServ);
this.dataGridSERV.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.SERV);
}
}
private void CheckServiceEntryElbeBulk()
{
bool found = false;
foreach (SERV serv in this._servMessage.Elements)
{
if (serv.ServiceBeneficiary.Equals("Elbe Bulk Schiffe - Hamburg"))
found = true;
}
if (!found)
{
SERV newServ = new SERV();
newServ.ServiceBeneficiary = "";
newServ.ServiceInvoiceRecipient = " Division Elbe Bulk, Frachtcontor Junge & Co. GmbH";
newServ.ServiceName = "ELBE BULK";
newServ.MessageHeader = this._servMessage;
newServ.Identifier = SERV.GetNewIdentifier(_servMessage.Elements);
this._servMessage.Elements.Add(newServ);
this.dataGridSERV.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.SERV);
}
}
private void buttonSearchPortArea_Click(object sender, RoutedEventArgs e) private void buttonSearchPortArea_Click(object sender, RoutedEventArgs e)
{ {
SelectPortAreaDialog spad = new SelectPortAreaDialog(this.Core.PoC); if (portAreas != null)
if(spad.ShowDialog() ?? false)
{ {
if(spad.SelectedArea != null) SelectPortAreaDialog spad = new SelectPortAreaDialog(this.Core.PoC);
if (spad.ShowDialog() ?? false)
{ {
if (portAreas.ContainsKey(spad.SelectedArea)) if (spad.SelectedArea != null)
{ {
var pair = portAreas.SingleOrDefault(p => p.Key == spad.SelectedArea); if (portAreas.ContainsKey(spad.SelectedArea))
this.comboBoxPortArea.SelectedItem = pair; {
var pair = portAreas.SingleOrDefault(p => p.Key == spad.SelectedArea);
this.comboBoxPortArea.SelectedItem = pair;
}
} }
} }
} }
} }
private void buttonCopyNameFromCREWA_Click(object sender, RoutedEventArgs e)
{
CREW crewA = null;
if (this._crewaMessage.Elements.Count > 0)
{
crewA = this._crewaMessage.Elements[0] as CREW;
}
SelectCrewMemberDialog scmd = new SelectCrewMemberDialog();
scmd.CREW = crewA;
scmd.AddVisible = false;
if (scmd.ShowDialog() ?? false)
{
this.textBox_NameMaster.Text = $"{crewA.CrewMemberFirstName} {crewA.CrewMemberLastName}";
this.SublistElementChanged(Message.NotificationClass.NAME);
var binding = textBox_NameMaster.GetBindingExpression(TextBox.TextProperty);
binding?.UpdateSource();
}
}
#endregion #endregion
} }

View File

@ -2,18 +2,17 @@
// Description: SEC Meldung Bearbeitungsseite // Description: SEC Meldung Bearbeitungsseite
// //
using System.Windows; using bsmd.database;
using System.Windows.Controls; using ClosedXML.Excel;
using ENI2.EditControls; using ENI2.EditControls;
using ENI2.Util; using ENI2.Util;
using bsmd.database;
using System.Windows.Data;
using System;
using Microsoft.Win32; using Microsoft.Win32;
using System.IO; using System;
using ExcelDataReader;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace ENI2.DetailViewControls namespace ENI2.DetailViewControls
{ {
@ -116,6 +115,12 @@ namespace ENI2.DetailViewControls
} }
public override int SelectedTabIndex
{
get { return this.mainFrame.SelectedIndex; }
set { this.mainFrame.SelectedIndex = value; }
}
#region SetEnabled #region SetEnabled
public override void SetEnabled(bool enabled) public override void SetEnabled(bool enabled)
@ -332,83 +337,14 @@ namespace ENI2.DetailViewControls
private void buttonImportExcel_Click(object sender, RoutedEventArgs e) private void buttonImportExcel_Click(object sender, RoutedEventArgs e)
{ {
OpenFileDialog ofd = new OpenFileDialog int importedCount = Excel.ExcelLocalImportHelper.ImportLast10PortFacilities(this._sec);
if (importedCount > 0)
{ {
Filter = "Excel Files|*.xls;*.xlsx" this.dataGridLast10PortFacilities.Items.Refresh();
}; this.SublistElementChanged(Message.NotificationClass.SEC);
MessageBox.Show(String.Format(Properties.Resources.textL10PImported, importedCount),
if (ofd.ShowDialog() ?? false) Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
{
FileStream stream;
try
{
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
List<LastTenPortFacilitiesCalled> importL10C = new List<LastTenPortFacilitiesCalled>();
try
{
do
{
int cnt = 0;
while (reader.Read() && (cnt < 10))
{
if (((IExcelDataReader)reader).FieldCount < 8)
{
throw new InvalidDataException("Sheet must have 8 Columns of data");
}
LastTenPortFacilitiesCalled l10c = new LastTenPortFacilitiesCalled();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) l10c.PortFacilityPortName = reader.GetString(0);
if (!reader.IsDBNull(2)) l10c.PortFacilityPortCountry = reader.GetString(2);
if (!reader.IsDBNull(3)) l10c.PortFacilityPortLoCode = reader.GetString(3);
object o = null;
if (!reader.IsDBNull(4)) o = reader.GetValue(4);
if(o != null) l10c.PortFacilityDateOfArrival = Convert.ToDateTime(o);
if (!reader.IsDBNull(5)) o = reader.GetValue(5);
if (o != null) l10c.PortFacilityDateOfDeparture = Convert.ToDateTime(o);
// if (!reader.IsDBNull(4)) l10c.PortFacilityDateOfArrival = reader.GetDateTime(4);
// if (!reader.IsDBNull(5)) l10c.PortFacilityDateOfDeparture = reader.GetDateTime(5);
if (!reader.IsDBNull(6)) o = reader.GetValue(6);
if (o != null) l10c.PortFacilityShipSecurityLevel = Convert.ToByte(o);
if (!reader.IsDBNull(7)) o = reader.GetValue(7);
int gisis = Convert.ToInt32(o);
if (!reader.IsDBNull(7)) l10c.PortFacilityGISISCode = gisis.ToString().PadLeft(4, '0');
if (!reader.IsDBNull(8)) l10c.PortFacilitySecurityMattersToReport = reader.GetString(8);
if (l10c.PortFacilitySecurityMattersToReport.Equals("nil", StringComparison.CurrentCultureIgnoreCase))
l10c.PortFacilitySecurityMattersToReport = null;
if (!reader.IsDBNull(9)) l10c.PortFacilityGISISCodeLocode = reader.GetString(9);
l10c.SEC = this._sec;
l10c.IsDirty = true;
l10c.Identifier = LastTenPortFacilitiesCalled.GetNewIdentifier(this._sec.LastTenPortFacilitesCalled);
this._sec.LastTenPortFacilitesCalled.Add(l10c);
importL10C.Add(l10c);
cnt++;
}
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importL10C.Count > 0)
{
this.dataGridLast10PortFacilities.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.SEC);
MessageBox.Show(String.Format(Properties.Resources.textL10PImported, importL10C.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
stream.Close();
} }
} }
@ -504,16 +440,5 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
#endregion
} }
} }

View File

@ -12,7 +12,7 @@
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="800"> d:DesignHeight="600" d:DesignWidth="800">
<GroupBox Name="shipDataGroupBox" Header="{x:Static p:Resources.textShipData}" > <GroupBox Name="shipDataGroupBox" Header="{x:Static p:Resources.textShipData}" >
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="260" /> <RowDefinition Height="260" />
@ -104,6 +104,6 @@
</Grid> </Grid>
</GroupBox> </GroupBox>
</Grid> </Grid>
</ScrollViewer>
</GroupBox> </GroupBox>
</src:DetailBaseControl> </src:DetailBaseControl>

View File

@ -5,10 +5,8 @@
using System.Windows; using System.Windows;
using bsmd.database; using bsmd.database;
using ENI2.EditControls;
using System.Windows.Media;
using ENI2.Util; using ENI2.Util;
using System.Windows.Controls;
namespace ENI2.DetailViewControls namespace ENI2.DetailViewControls
{ {
@ -106,16 +104,5 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
#endregion
} }
} }

View File

@ -71,7 +71,7 @@ namespace ENI2.DetailViewControls
private void copyItemToTOWA(object sender, RoutedEventArgs e) private void copyItemToTOWA(object sender, RoutedEventArgs e)
{ {
// aus dem aktuell selektierten TOWA Element ein neues TOWD Element machen // aus dem aktuell selektierten TOWD Element ein neues TOWA Element machen
if (this.dataGridTowageOnDeparture.SelectedItems != null) if (this.dataGridTowageOnDeparture.SelectedItems != null)
{ {
foreach (TOWD selectedTOWD in this.dataGridTowageOnDeparture.SelectedItems) foreach (TOWD selectedTOWD in this.dataGridTowageOnDeparture.SelectedItems)
@ -166,8 +166,7 @@ namespace ENI2.DetailViewControls
private void DataGridTowageOnDeparture_DeleteRequested(DatabaseEntity obj) private void DataGridTowageOnDeparture_DeleteRequested(DatabaseEntity obj)
{ {
TOWD towd = obj as TOWD; if (obj is TOWD towd)
if (towd != null)
{ {
// are you sure dialog is in base class // are you sure dialog is in base class
this._towdMessage.Elements.Remove(towd); this._towdMessage.Elements.Remove(towd);
@ -245,8 +244,7 @@ namespace ENI2.DetailViewControls
private void DataGridTowageOnArrival_DeleteRequested(DatabaseEntity obj) private void DataGridTowageOnArrival_DeleteRequested(DatabaseEntity obj)
{ {
TOWA towa = obj as TOWA; if (obj is TOWA towa)
if (towa != null)
{ {
// are you sure dialog is in base class // are you sure dialog is in base class
this._towaMessage.Elements.Remove(towa); this._towaMessage.Elements.Remove(towa);
@ -312,16 +310,5 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
#endregion
} }
} }

View File

@ -35,7 +35,6 @@
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textAccurateDetailsGiven}" Name="label_AccurateDetailsGiven" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textAccurateDetailsGiven}" Name="label_AccurateDetailsGiven" Margin="0,0,10,0"/>
<!--TextBlock Grid.Row="0" Grid.Column="0" Text="{x:Static p:Resources.textAccurateDetailsGiven}" Name="label_ETAToPortOfCall" Margin="0,0,10,0" TextWrapping="Wrap" FontSize="10"/--> <!--TextBlock Grid.Row="0" Grid.Column="0" Text="{x:Static p:Resources.textAccurateDetailsGiven}" Name="label_ETAToPortOfCall" Margin="0,0,10,0" TextWrapping="Wrap" FontSize="10"/-->
@ -46,7 +45,7 @@
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="2" Content="{x:Static p:Resources.textValidExemption}" Name="label_ValidExemption" Margin="0,0,10,0"/> <Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="2" Content="{x:Static p:Resources.textValidExemption}" Name="label_ValidExemption" Margin="0,0,10,0"/>
<CheckBox Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Name="checkBoxAccurateCorrectDetails" IsChecked="{Binding ConfirmationOfCorrectness, Mode=TwoWay}" /> <CheckBox Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Name="checkBoxAccurateCorrectDetails" IsChecked="{Binding ConfirmationOfCorrectness, Mode=TwoWay}" />
<CheckBox Grid.Row="0" Grid.Column="3" VerticalAlignment="Center" Name="checkBoxValidExemption" IsChecked="{Binding WasteDisposalValidExemption, Mode=TwoWay}" /> <CheckBox Grid.Row="0" Grid.Column="3" VerticalAlignment="Center" Name="checkBoxValidExemption" IsChecked="{Binding WasteDisposalValidExemption, Mode=TwoWay}" />
<enictrl:LocodeControl Grid.Row="3" Grid.Column="1" x:Name="locodeCtrlNextWastePort" LocodeValue="{Binding NextWasteDisposalPort, Mode=TwoWay}" LocodeSource="SSN" />
<DatePicker Grid.Row="1" Grid.Column="1" Name="datePickerDateLastDisposal" Margin="2" SelectedDate="{Binding LastWasteDisposalDate, Mode=TwoWay}" DisplayDateStart="1/1/1800" DisplayDateEnd="12/31/2199" PreviewKeyUp="DateTimePicker_PreviewKeyUpDate"> <DatePicker Grid.Row="1" Grid.Column="1" Name="datePickerDateLastDisposal" Margin="2" SelectedDate="{Binding LastWasteDisposalDate, Mode=TwoWay}" DisplayDateStart="1/1/1800" DisplayDateEnd="12/31/2199" PreviewKeyUp="DateTimePicker_PreviewKeyUpDate">
<DatePicker.BlackoutDates> <DatePicker.BlackoutDates>
<CalendarDateRange Start="1/1/0001" End="12/31/1799"/> <CalendarDateRange Start="1/1/0001" End="12/31/1799"/>
@ -54,39 +53,11 @@
</DatePicker.BlackoutDates> </DatePicker.BlackoutDates>
</DatePicker> </DatePicker>
<enictrl:LocodeControl Grid.Row="2" Grid.Column="1" x:Name="locodeCtrlLastWastePort" LocodeValue="{Binding LastWasteDisposalPort, Mode=TwoWay}" LocodeSource="SSN" /> <enictrl:LocodeControl Grid.Row="2" Grid.Column="1" x:Name="locodeCtrlLastWastePort" LocodeValue="{Binding LastWasteDisposalPort, Mode=TwoWay}" LocodeSource="SSN" />
<enictrl:LocodeControl Grid.Row="3" Grid.Column="1" x:Name="locodeCtrlNextWastePort" LocodeValue="{Binding NextWasteDisposalPort, Mode=TwoWay}" LocodeSource="SSN" />
<TextBox Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" Grid.RowSpan="2" Name="textBoxWasteDisposalServiceProviders" Text="{Binding WasteDisposalServiceProviderText, Converter={util:TrimStringConverter}}" Margin="2" /> <TextBox Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" Grid.RowSpan="2" Name="textBoxWasteDisposalServiceProviders" Text="{Binding WasteDisposalServiceProviderText, Converter={util:TrimStringConverter}}" Margin="2" />
<Label Grid.Row="6" Grid.Column="0" HorizontalContentAlignment="Right" Content="{x:Static p:Resources.textAgentTemplate}" Margin="0,0,10,0" />
<ComboBox Grid.Row="6" Grid.Column="1" Grid.ColumnSpan="2" Name="comboBox_WSDPTemplate" Margin="2" SelectedValuePath="Id" DisplayMemberPath="Remark" SelectionChanged="comboBox_WSDPTemplate_SelectionChanged" /> <Button Grid.Row="6" Grid.Column="1" Grid.ColumnSpan="1" Name="buttonAddMissingEntries" Content="{x:Static p:Resources.textAddMissingEntries}" Margin="2" Click="buttonAddMissingEntries_Click"/>
<Grid Grid.Row="6" Grid.Column="3" Grid.ColumnSpan="1" Name="gridTemplateControls" Visibility="Visible"> <Button Grid.Row="6" Grid.Column="2" Grid.ColumnSpan="1" Name="buttonImportFromExcel" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Click="buttonImportFromExcel_Click" />
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<!-- Name -->
<ColumnDefinition Width="26"/>
<!-- Save button -->
<ColumnDefinition Width="26"/>
<!-- Delete button -->
<ColumnDefinition Width="52"/>
<!-- Undo button -->
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" Margin="2" Name="textBoxTemplateTitle" VerticalContentAlignment="Center"/>
<Button Name="buttonSaveTemplate" Grid.Column="1" Grid.Row="0" Margin="2" Click="buttonSaveTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Save template">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/floppy_disk_blue.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonDeleteTemplate" Grid.Column="2" Grid.Row="0" Margin="2" Click="buttonDeleteTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Delete template" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/delete.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonUndoTemplate" Grid.Column="3" Grid.Row="0" Margin="22,2,2,2" Click="buttonUndoTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Undo last overwrite" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/undo.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
</Grid>
<Button Grid.Row="7" Grid.Column="1" Grid.ColumnSpan="1" Name="buttonAddMissingEntries" Content="{x:Static p:Resources.textAddMissingEntries}" Margin="2" Click="buttonAddMissingEntries_Click"/>
<Button Grid.Row="7" Grid.Column="2" Grid.ColumnSpan="1" Name="buttonImportFromExcel" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Click="buttonImportFromExcel_Click" />
</Grid> </Grid>
<enictrl:ENIDataGrid x:Name="dataGridWaste" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" <enictrl:ENIDataGrid x:Name="dataGridWaste" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AutoGenerateColumns="False" Margin="0,5,0,0" Grid.Row="1" CanUserAddRows="False"> AutoGenerateColumns="False" Margin="0,5,0,0" Grid.Row="1" CanUserAddRows="False">
@ -195,7 +166,7 @@
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" /> <DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textCode}" Binding="{Binding WasteTypeDisplayGrid}" IsReadOnly="True" Width="0.2*" /> <DataGridTextColumn Header="{x:Static p:Resources.textCode}" Binding="{Binding WasteTypeDisplayGrid}" IsReadOnly="True" Width="0.2*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDescription}" Binding="{Binding WasteDescription}" IsReadOnly="True" Width="0.3*" /> <DataGridTextColumn Header="{x:Static p:Resources.textDescription}" Binding="{Binding WasteDescription}" IsReadOnly="True" Width="0.3*" />
<DataGridTemplateColumn IsReadOnly="True" Width="0.15*"> <!--DataGridTemplateColumn IsReadOnly="True" Width="0.15*">
<DataGridTemplateColumn.HeaderTemplate> <DataGridTemplateColumn.HeaderTemplate>
<DataTemplate> <DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{x:Static p:Resources.textAmountWasteReceived_MTQ}" FontSize="10"/> <TextBlock TextWrapping="Wrap" Text="{x:Static p:Resources.textAmountWasteReceived_MTQ}" FontSize="10"/>
@ -206,7 +177,16 @@
<TextBlock TextAlignment="Center" Text="{Binding AmountWasteReceived_MTQ, StringFormat={}{0:N3}}" /> <TextBlock TextAlignment="Center" Text="{Binding AmountWasteReceived_MTQ, StringFormat={}{0:N3}}" />
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn-->
<DataGridTextColumn Header="{x:Static p:Resources.textAmountWasteReceived_MTQ}" IsReadOnly="False" Width="0.15*">
<DataGridTextColumn.Binding>
<Binding Path="AmountWasteReceived_MTQ" Mode="TwoWay" StringFormat="N3" >
<Binding.ValidationRules>
<util:NumberValidationRule MaxValue="10000" MinValue="0" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
</DataGrid.Columns> </DataGrid.Columns>
</enictrl:ENIDataGrid> </enictrl:ENIDataGrid>

View File

@ -2,18 +2,18 @@
// Description: Detailansicht Müllmeldung // Description: Detailansicht Müllmeldung
// //
using System.Linq; using bsmd.database;
using ClosedXML.Excel;
using ENI2.EditControls;
using ENI2.Excel;
using ENI2.Util;
using Microsoft.Win32;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using ENI2.EditControls;
using ENI2.Util;
using bsmd.database;
using ExcelDataReader;
using System.IO;
using System;
using Microsoft.Win32;
using System.Diagnostics;
namespace ENI2.DetailViewControls namespace ENI2.DetailViewControls
{ {
@ -23,21 +23,14 @@ namespace ENI2.DetailViewControls
public partial class WasteDetailControl : DetailBaseControl public partial class WasteDetailControl : DetailBaseControl
{ {
#region Fields
private Message _wasMessage; private Message _wasMessage;
private WAS _was; private WAS _was;
private Message _wasRcptMessage; private Message _wasRcptMessage;
private WAS_RCPT _selectedWAS_RCPT; private WAS_RCPT _selectedWAS_RCPT;
private static List<WasteDisposalServiceProvider_Template> _wsdpTemplates = null; #endregion
private WasteDisposalServiceProvider_Template _currentTemplate;
private string _undoTemplate;
private static readonly string[] _wasteDeliveryList =
{
"ALL",
"SOME",
"NONE"
};
public WasteDetailControl() public WasteDetailControl()
{ {
@ -54,7 +47,7 @@ namespace ENI2.DetailViewControls
this.RegisterCheckboxChange(this.checkBoxValidExemption, Message.NotificationClass.WAS); this.RegisterCheckboxChange(this.checkBoxValidExemption, Message.NotificationClass.WAS);
this.RegisterDatePickerChange(this.datePickerDateLastDisposal, Message.NotificationClass.WAS); this.RegisterDatePickerChange(this.datePickerDateLastDisposal, Message.NotificationClass.WAS);
this.RegisterTextboxChange(this.textBoxWasteDisposalServiceProviders, Message.NotificationClass.WAS); this.RegisterTextboxChange(this.textBoxWasteDisposalServiceProviders, Message.NotificationClass.WAS);
this.dataGridWasteReceived.CellEditEnding += (obj, ev) => { this.SublistElementChanged(Message.NotificationClass.WAS_RCPT); };
} }
private void CheckBoxValidExemption_Checked(object sender, RoutedEventArgs e) private void CheckBoxValidExemption_Checked(object sender, RoutedEventArgs e)
@ -102,7 +95,7 @@ namespace ENI2.DetailViewControls
} }
} }
public async override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@ -183,18 +176,12 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region init WSDP provider }
if(_wsdpTemplates == null)
{
_wsdpTemplates = await DBManagerAsync.GetWastDisposalServiceProviderTemplatesAsync();
_wsdpTemplates.Sort();
Trace.WriteLine($"{_wsdpTemplates.Count} WSDP templates loaded");
}
this.comboBox_WSDPTemplate.ItemsSource = _wsdpTemplates;
#endregion
public override int SelectedTabIndex
{
get { return this.mainFrame.SelectedIndex; }
set { this.mainFrame.SelectedIndex = value; }
} }
#region Waste receipt grid event handler #region Waste receipt grid event handler
@ -230,6 +217,8 @@ namespace ENI2.DetailViewControls
this.dataGridWasteReceived.ItemsSource = null; this.dataGridWasteReceived.ItemsSource = null;
dataGridWasteReceipt_SelectionChanged(this, null); dataGridWasteReceipt_SelectionChanged(this, null);
} }
} }
private void DataGridWasteReceipt_DeleteRequested(DatabaseEntity obj) private void DataGridWasteReceipt_DeleteRequested(DatabaseEntity obj)
@ -275,6 +264,7 @@ namespace ENI2.DetailViewControls
this.dataGridWasteReceipt.Items.Refresh(); this.dataGridWasteReceipt.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT); this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
dataGridWasteReceipt_SelectionChanged(this, null); dataGridWasteReceipt_SelectionChanged(this, null);
} }
private void DataGridWasteReceipt_AddingNewItem(object sender, AddingNewItemEventArgs e) private void DataGridWasteReceipt_AddingNewItem(object sender, AddingNewItemEventArgs e)
@ -299,7 +289,8 @@ namespace ENI2.DetailViewControls
{ {
if (obj is WasteReceived wasteReceived) if (obj is WasteReceived wasteReceived)
{ {
this.dataGridWasteReceived.CancelEdit();
this.dataGridWasteReceived.CancelEdit();
// are you sure dialog is in base class // are you sure dialog is in base class
_selectedWAS_RCPT.WasteReceived.Remove(wasteReceived); _selectedWAS_RCPT.WasteReceived.Remove(wasteReceived);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(wasteReceived); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(wasteReceived);
@ -312,6 +303,8 @@ namespace ENI2.DetailViewControls
private void DataGridWasteReceived_CreateRequested() private void DataGridWasteReceived_CreateRequested()
{ {
if (_selectedWAS_RCPT == null) return; if (_selectedWAS_RCPT == null) return;
this.dataGridWasteReceived.CancelEdit();
this.dataGridWasteReceived.CancelEdit();
EditWasteReceivedDialog ewrd = new EditWasteReceivedDialog(); EditWasteReceivedDialog ewrd = new EditWasteReceivedDialog();
ewrd.WasteReceived = new WasteReceived(); ewrd.WasteReceived = new WasteReceived();
ewrd.WasteReceived.WAS_RCPT = _selectedWAS_RCPT; ewrd.WasteReceived.WAS_RCPT = _selectedWAS_RCPT;
@ -345,6 +338,9 @@ namespace ENI2.DetailViewControls
private void DataGridWasteReceived_EditRequested(DatabaseEntity obj) private void DataGridWasteReceived_EditRequested(DatabaseEntity obj)
{ {
this.dataGridWasteReceived.CancelEdit();
this.dataGridWasteReceived.CancelEdit();
EditWasteReceivedDialog ewrd = new EditWasteReceivedDialog(); EditWasteReceivedDialog ewrd = new EditWasteReceivedDialog();
ewrd.WasteReceived = obj as WasteReceived; ewrd.WasteReceived = obj as WasteReceived;
@ -480,209 +476,21 @@ namespace ENI2.DetailViewControls
#endregion #endregion
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
#endregion
#region Excel file import #region Excel file import
private void buttonImportFromExcel_Click(object sender, RoutedEventArgs e) private void buttonImportFromExcel_Click(object sender, RoutedEventArgs e)
{ {
OpenFileDialog ofd = new OpenFileDialog(); int importWasteListCnt = ExcelLocalImportHelper.ImportWaste(_was);
ofd.Filter = "Excel Files|*.xls;*.xlsx";
if (ofd.ShowDialog() ?? false) if (importWasteListCnt > 0)
{ {
FileStream stream; this.dataGridWaste.Items.Refresh();
try this.SublistElementChanged(Message.NotificationClass.WAS);
{ MessageBox.Show(String.Format(Properties.Resources.textWasteImported, importWasteListCnt), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
List<Waste> importWasteList = new List<Waste>();
try
{
do
{
// skip first three rows
reader.Read();
reader.Read();
reader.Read();
int cnt = 0;
object o = null;
// Diese Funktion kann das "alte" Sheet Format nicht mehr einlesen!
while (reader.Read() && (cnt < 35))
{
if (reader.FieldCount < 9)
{
throw new InvalidDataException("Sheet must have 9 Columns of data");
}
if (!reader.IsDBNull(1)) o = reader.GetValue(1); else o = null;
if ((o != null) && Int32.TryParse(o.ToString(), out int wasteType))
{
Waste waste = _was.GetWasteForType(wasteType);
if (waste == null)
{
waste = new Waste();
waste.WasteType = wasteType;
waste.WAS = this._was;
waste.IsDirty = true;
waste.Identifier = Waste.GetNewIdentifier(this._was.Waste);
this._was.Waste.Add(waste);
}
else
{
waste.IsDirty = true;
}
if (!reader.IsDBNull(4)) waste.WasteDescription = reader.GetString(4);
if (waste.WasteDescription.IsNullOrEmpty())
waste.WasteDescription = "-";
if (!reader.IsDBNull(5)) o = reader.GetValue(5); else o = null;
if (o != null) waste.WasteDisposalAmount_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(6)) o = reader.GetValue(6); else o = null;
if (o != null) waste.WasteCapacity_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(7)) o = reader.GetValue(7); else o = null;
if (o != null) waste.WasteAmountRetained_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(8)) waste.WasteDisposalPort = reader.GetString(8).ToUpper();
if (!reader.IsDBNull(9)) o = reader.GetValue(9); else o = null;
if (o != null) waste.WasteAmountGeneratedTillNextPort_MTQ = Convert.ToDouble(o);
importWasteList.Add(waste);
cnt++;
}
}
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importWasteList.Count > 0)
{
this.dataGridWaste.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.WAS);
MessageBox.Show(String.Format(Properties.Resources.textWasteImported, importWasteList.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
stream.Close();
} }
} }
#endregion
#region Waste disposal Service Provider templates event handler
private void comboBox_WSDPTemplate_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Trace.WriteLine("WSDP combo selection changed");
if(this.comboBox_WSDPTemplate.SelectedItem is WasteDisposalServiceProvider_Template wdsp_t)
{
this.textBoxTemplateTitle.Text = wdsp_t.Remark;
this.buttonDeleteTemplate.IsEnabled = true;
this._currentTemplate = wdsp_t;
this._undoTemplate = this.textBoxWasteDisposalServiceProviders.Text.Trim();
this.buttonUndoTemplate.IsEnabled = this._undoTemplate.Length > 0;
this.textBoxWasteDisposalServiceProviders.Text = wdsp_t.WasteDisposalServiceProviderName;
}
}
private async void buttonSaveTemplate_Click(object sender, RoutedEventArgs e)
{
string currentWSDPProviderName = this.textBoxWasteDisposalServiceProviders.Text.Trim();
string currentRemark = this.textBoxTemplateTitle.Text.Trim();
if ((currentWSDPProviderName.Length == 0) || (currentRemark.Length == 0)) return;
WasteDisposalServiceProvider_Template existingTemplate = null;
foreach(WasteDisposalServiceProvider_Template wdsp_template in _wsdpTemplates)
{
// bei gefundenem Match wird ggf. der Remark überschrieben
if (wdsp_template.Remark.Equals(currentRemark))
{
existingTemplate = wdsp_template;
break;
}
}
if(existingTemplate != null)
{
if (MessageBox.Show("A template with this name already exists, overwrite?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
return;
existingTemplate.WasteDisposalServiceProviderName = currentWSDPProviderName;
await DBManagerAsync.SaveAsync(existingTemplate);
return;
}
WasteDisposalServiceProvider_Template newTemplate = new WasteDisposalServiceProvider_Template();
newTemplate.WasteDisposalServiceProviderName = currentWSDPProviderName;
newTemplate.Remark = currentRemark;
await DBManagerAsync.SaveAsync(newTemplate);
comboBox_WSDPTemplate.ItemsSource = null;
_wsdpTemplates.Add(newTemplate);
_wsdpTemplates.Sort();
comboBox_WSDPTemplate.ItemsSource = _wsdpTemplates;
MessageBox.Show("Template saved", "OK", MessageBoxButton.OK, MessageBoxImage.Information);
}
private void buttonDeleteTemplate_Click(object sender, RoutedEventArgs e)
{
if(_currentTemplate != null)
{
if (MessageBox.Show("Delete this template?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
this.comboBox_WSDPTemplate.SelectedItem = null;
this.comboBox_WSDPTemplate.ItemsSource = null;
DBManager.Instance.Delete(_currentTemplate);
_wsdpTemplates.Remove(_currentTemplate);
this.textBoxTemplateTitle.Text = null;
this.buttonDeleteTemplate.IsEnabled = false;
this.comboBox_WSDPTemplate.ItemsSource = _wsdpTemplates;
}
}
}
private void buttonUndoTemplate_Click(object sender, RoutedEventArgs e)
{
if(this._undoTemplate != null)
{
this.textBoxWasteDisposalServiceProviders.Text = this._undoTemplate;
this.buttonUndoTemplate.IsEnabled = false;
this._undoTemplate = null;
this.comboBox_WSDPTemplate.SelectedItem = null;
}
}
#endregion #endregion
#region Copy WAS to WAS_RCPT handler #region Copy WAS to WAS_RCPT handler

View File

@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ENI2</RootNamespace> <RootNamespace>ENI2</RootNamespace>
<AssemblyName>ENI2Test</AssemblyName> <AssemblyName>ENI2Test</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
@ -36,8 +36,8 @@
<MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion> <MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish> <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage> <WebPage>publish.html</WebPage>
<ApplicationRevision>4</ApplicationRevision> <ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>7.2.2.4</ApplicationVersion> <ApplicationVersion>7.2.14.2</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut> <CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>
@ -62,7 +62,8 @@
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>0</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<StartupObject>ENI2.App</StartupObject> <StartupObject>ENI2.App</StartupObject>
@ -84,13 +85,13 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup /> <PropertyGroup />
<PropertyGroup> <PropertyGroup>
<ManifestCertificateThumbprint>FE53D3ADE2DCE4BD171A899FF41D43E63FEA7639</ManifestCertificateThumbprint> <ManifestCertificateThumbprint>C5FD306818D481FBECE3B2E74D7A912F515191E0</ManifestCertificateThumbprint>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignManifests>true</SignManifests> <SignManifests>true</SignManifests>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ManifestKeyFile>ENI2_6_TemporaryKey.pfx</ManifestKeyFile> <ManifestKeyFile>ENI2_7_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug 64|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug 64|AnyCPU'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -133,43 +134,132 @@
<CodeAnalysisRuleSet>..\code.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>..\code.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ExcelDataReader, Version=3.6.0.0, Culture=neutral, PublicKeyToken=93517dbe6a4012fa, processorArchitecture=MSIL"> <Reference Include="ClosedXML, Version=0.105.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b, processorArchitecture=MSIL">
<HintPath>packages\ExcelDataReader.3.6.0\lib\net45\ExcelDataReader.dll</HintPath> <HintPath>packages\ClosedXML.0.105.0\lib\netstandard2.0\ClosedXML.dll</HintPath>
</Reference> </Reference>
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="ClosedXML.Parser, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1d5f7376574c51ec, processorArchitecture=MSIL">
<HintPath>packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath> <HintPath>packages\ClosedXML.Parser.2.0.0\lib\netstandard2.0\ClosedXML.Parser.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL"> <Reference Include="DocumentFormat.OpenXml, Version=3.3.0.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Office.Interop.Excel.15.0.4795.1001\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath> <HintPath>packages\DocumentFormat.OpenXml.3.3.0\lib\net46\DocumentFormat.OpenXml.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference> </Reference>
<Reference Include="MigraDoc.DocumentObjectModel-gdi, Version=1.50.5147.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL"> <Reference Include="DocumentFormat.OpenXml.Framework, Version=3.3.0.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp-MigraDoc-gdi.1.50.5147\lib\net20\MigraDoc.DocumentObjectModel-gdi.dll</HintPath> <HintPath>packages\DocumentFormat.OpenXml.Framework.3.3.0\lib\net46\DocumentFormat.OpenXml.Framework.dll</HintPath>
</Reference> </Reference>
<Reference Include="MigraDoc.Rendering-gdi, Version=1.50.5147.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL"> <Reference Include="ExcelNumberFormat, Version=1.1.0.0, Culture=neutral, PublicKeyToken=23c6f5d73be07eca, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp-MigraDoc-gdi.1.50.5147\lib\net20\MigraDoc.Rendering-gdi.dll</HintPath> <HintPath>packages\ExcelNumberFormat.1.1.0\lib\net20\ExcelNumberFormat.dll</HintPath>
</Reference> </Reference>
<Reference Include="MigraDoc.RtfRendering-gdi, Version=1.50.5147.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL"> <Reference Include="log4net, Version=3.2.0.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp-MigraDoc-gdi.1.50.5147\lib\net20\MigraDoc.RtfRendering-gdi.dll</HintPath> <HintPath>packages\log4net.3.2.0\lib\net462\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="PdfSharp-gdi, Version=1.50.5147.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL"> <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp-MigraDoc-gdi.1.50.5147\lib\net20\PdfSharp-gdi.dll</HintPath> <HintPath>packages\Microsoft.Bcl.AsyncInterfaces.10.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference> </Reference>
<Reference Include="PdfSharp.Charting-gdi, Version=1.50.5147.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL"> <Reference Include="Microsoft.Bcl.Cryptography, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp-MigraDoc-gdi.1.50.5147\lib\net20\PdfSharp.Charting-gdi.dll</HintPath> <HintPath>packages\Microsoft.Bcl.Cryptography.10.0.0\lib\net462\Microsoft.Bcl.Cryptography.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.HashCode, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Bcl.HashCode.6.0.0\lib\net462\Microsoft.Bcl.HashCode.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.DependencyInjection.10.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.DependencyInjection.Abstractions.10.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.Logging.10.0.0\lib\net462\Microsoft.Extensions.Logging.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.Logging.Abstractions.10.0.0\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Options, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.Options.10.0.0\lib\net462\Microsoft.Extensions.Options.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Primitives, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.Primitives.10.0.0\lib\net462\Microsoft.Extensions.Primitives.dll</HintPath>
</Reference>
<Reference Include="MigraDoc.DocumentObjectModel, Version=6.2.3.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp-MigraDoc.6.2.3\lib\netstandard2.0\MigraDoc.DocumentObjectModel.dll</HintPath>
</Reference>
<Reference Include="MigraDoc.Rendering, Version=6.2.3.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp-MigraDoc.6.2.3\lib\netstandard2.0\MigraDoc.Rendering.dll</HintPath>
</Reference>
<Reference Include="MigraDoc.RtfRendering, Version=6.2.3.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp-MigraDoc.6.2.3\lib\netstandard2.0\MigraDoc.RtfRendering.dll</HintPath>
</Reference>
<Reference Include="PdfSharp, Version=6.2.3.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp.6.2.3\lib\netstandard2.0\PdfSharp.dll</HintPath>
</Reference>
<Reference Include="PdfSharp.BarCodes, Version=6.2.3.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp.6.2.3\lib\netstandard2.0\PdfSharp.BarCodes.dll</HintPath>
</Reference>
<Reference Include="PdfSharp.Charting, Version=6.2.3.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp.6.2.3\lib\netstandard2.0\PdfSharp.Charting.dll</HintPath>
</Reference>
<Reference Include="PdfSharp.Cryptography, Version=6.2.3.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp.6.2.3\lib\netstandard2.0\PdfSharp.Cryptography.dll</HintPath>
</Reference>
<Reference Include="PdfSharp.Quality, Version=6.2.3.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp.6.2.3\lib\netstandard2.0\PdfSharp.Quality.dll</HintPath>
</Reference>
<Reference Include="PdfSharp.Shared, Version=6.2.3.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp.6.2.3\lib\netstandard2.0\PdfSharp.Shared.dll</HintPath>
</Reference>
<Reference Include="PdfSharp.Snippets, Version=6.2.3.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp.6.2.3\lib\netstandard2.0\PdfSharp.Snippets.dll</HintPath>
</Reference>
<Reference Include="PdfSharp.System, Version=6.2.3.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp.6.2.3\lib\netstandard2.0\PdfSharp.System.dll</HintPath>
</Reference>
<Reference Include="PdfSharp.WPFonts, Version=6.2.3.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
<HintPath>packages\PDFsharp.6.2.3\lib\netstandard2.0\PdfSharp.WPFonts.dll</HintPath>
</Reference>
<Reference Include="RBush, Version=4.0.0.0, Culture=neutral, PublicKeyToken=c77e27b81f4d0187, processorArchitecture=MSIL">
<HintPath>packages\RBush.Signed.4.0.0\lib\net47\RBush.dll</HintPath>
</Reference>
<Reference Include="SixLabors.Fonts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
<HintPath>packages\SixLabors.Fonts.1.0.0\lib\netstandard2.0\SixLabors.Fonts.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Data.SQLite, Version=1.0.117.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> <Reference Include="System.Data.SQLite, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.117.0\lib\net46\System.Data.SQLite.dll</HintPath> <HintPath>packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\lib\net46\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Diagnostics.DiagnosticSource, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Diagnostics.DiagnosticSource.10.0.0\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Formats.Asn1, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Formats.Asn1.10.0.0\lib\net462\System.Formats.Asn1.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression" /> <Reference Include="System.IO.Compression" />
<Reference Include="System.Memory, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Memory.4.6.3\lib\net462\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" /> <Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Security.Cryptography.Pkcs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.Pkcs.10.0.0\lib\net462\System.Security.Cryptography.Pkcs.dll</HintPath>
</Reference>
<Reference Include="System.ServiceModel" /> <Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" /> <Reference Include="System.ServiceModel.Web" />
<Reference Include="System.ServiceProcess" /> <Reference Include="System.ServiceProcess" />
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@ -184,20 +274,20 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="Xceed.Wpf.AvalonDock, Version=4.5.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL"> <Reference Include="Xceed.Wpf.AvalonDock, Version=5.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>packages\Extended.Wpf.Toolkit.4.5.0\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath> <HintPath>packages\Extended.Wpf.Toolkit.5.0.0\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath>
</Reference> </Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero, Version=4.5.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL"> <Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero, Version=5.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>packages\Extended.Wpf.Toolkit.4.5.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath> <HintPath>packages\Extended.Wpf.Toolkit.5.0.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath>
</Reference> </Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro, Version=4.5.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL"> <Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro, Version=5.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>packages\Extended.Wpf.Toolkit.4.5.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath> <HintPath>packages\Extended.Wpf.Toolkit.5.0.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath>
</Reference> </Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010, Version=4.5.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL"> <Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010, Version=5.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>packages\Extended.Wpf.Toolkit.4.5.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath> <HintPath>packages\Extended.Wpf.Toolkit.5.0.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath>
</Reference> </Reference>
<Reference Include="Xceed.Wpf.Toolkit, Version=4.5.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL"> <Reference Include="Xceed.Wpf.Toolkit, Version=5.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>packages\Extended.Wpf.Toolkit.4.5.0\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath> <HintPath>packages\Extended.Wpf.Toolkit.5.0.0\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -224,6 +314,9 @@
<Compile Include="Controls\ConditionGroupControl.xaml.cs"> <Compile Include="Controls\ConditionGroupControl.xaml.cs">
<DependentUpon>ConditionGroupControl.xaml</DependentUpon> <DependentUpon>ConditionGroupControl.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\EasyPeasyControl.xaml.cs">
<DependentUpon>EasyPeasyControl.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\EditWindowBase.cs" /> <Compile Include="Controls\EditWindowBase.cs" />
<Compile Include="Controls\ENIDataGrid.cs" /> <Compile Include="Controls\ENIDataGrid.cs" />
<Compile Include="Controls\IHighlightControlContainer.cs" /> <Compile Include="Controls\IHighlightControlContainer.cs" />
@ -254,12 +347,16 @@
<Compile Include="EditControls\NewDGItemDialog.xaml.cs"> <Compile Include="EditControls\NewDGItemDialog.xaml.cs">
<DependentUpon>NewDGItemDialog.xaml</DependentUpon> <DependentUpon>NewDGItemDialog.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="EditControls\SelectCrewMemberDialog.xaml.cs">
<DependentUpon>SelectCrewMemberDialog.xaml</DependentUpon>
</Compile>
<Compile Include="EditControls\SelectPortAreaDialog.xaml.cs"> <Compile Include="EditControls\SelectPortAreaDialog.xaml.cs">
<DependentUpon>SelectPortAreaDialog.xaml</DependentUpon> <DependentUpon>SelectPortAreaDialog.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Excel\DakosyUtil.cs" /> <Compile Include="Excel\DakosyUtil.cs" />
<Compile Include="Excel\ExcelBase.cs" /> <Compile Include="Excel\ExcelBase.cs" />
<Compile Include="Excel\ExcelComparer.cs" /> <Compile Include="Excel\ExcelComparer.cs" />
<Compile Include="Excel\ExcelLocalImportHelper.cs" />
<Compile Include="Excel\ExcelManager.cs" /> <Compile Include="Excel\ExcelManager.cs" />
<Compile Include="Excel\ExcelReader.cs" /> <Compile Include="Excel\ExcelReader.cs" />
<Compile Include="Excel\ExcelSimpleWriter.cs" /> <Compile Include="Excel\ExcelSimpleWriter.cs" />
@ -436,6 +533,42 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>Reference.svcmap</DependentUpon> <DependentUpon>Reference.svcmap</DependentUpon>
</Compile> </Compile>
<Compile Include="SheetDisplayControls\ATAControl.xaml.cs">
<DependentUpon>ATAControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\CrewDepartureControl.xaml.cs">
<DependentUpon>CrewDepartureControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\CrewPreArrivalControl.xaml.cs">
<DependentUpon>CrewPreArrivalControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\DangerousCargoControl.xaml.cs">
<DependentUpon>DangerousCargoControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\PassengerDepartureControl.xaml.cs">
<DependentUpon>PassengerDepartureControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\PassengerPreArrivalControl.xaml.cs">
<DependentUpon>PassengerPreArrivalControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\PortControl.xaml.cs">
<DependentUpon>PortControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\PreArrivalControl.xaml.cs">
<DependentUpon>PreArrivalControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\PreDepartureControl.xaml.cs">
<DependentUpon>PreDepartureControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\ShipDataControl.xaml.cs">
<DependentUpon>ShipDataControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\VoyageControl.xaml.cs">
<DependentUpon>VoyageControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\WasteReceiptsControl.xaml.cs">
<DependentUpon>WasteReceiptsControl.xaml</DependentUpon>
</Compile>
<Compile Include="SplashScreenWindow.xaml.cs"> <Compile Include="SplashScreenWindow.xaml.cs">
<DependentUpon>SplashScreenWindow.xaml</DependentUpon> <DependentUpon>SplashScreenWindow.xaml</DependentUpon>
</Compile> </Compile>
@ -446,22 +579,23 @@
<Compile Include="Util\ByteConverter.cs" /> <Compile Include="Util\ByteConverter.cs" />
<Compile Include="Util\CutoffConverter.cs" /> <Compile Include="Util\CutoffConverter.cs" />
<Compile Include="Util\DatabaseEntityWatchdog.cs" /> <Compile Include="Util\DatabaseEntityWatchdog.cs" />
<Compile Include="Util\EasyPeasyState.cs" />
<Compile Include="Util\EnumHelper.cs" /> <Compile Include="Util\EnumHelper.cs" />
<Compile Include="Util\EnumToBooleanConverter.cs" /> <Compile Include="Util\EnumToBooleanConverter.cs" />
<Compile Include="Util\EnumToCollectionConverter.cs" /> <Compile Include="Util\EnumToCollectionConverter.cs" />
<Compile Include="Util\ExpandableListConverter.cs" /> <Compile Include="Util\ExpandableListConverter.cs" />
<Compile Include="Util\Extensions.cs" />
<Compile Include="Util\GlobalStructures.cs" /> <Compile Include="Util\GlobalStructures.cs" />
<Compile Include="Util\HighlightService.cs" /> <Compile Include="Util\HighlightService.cs" />
<Compile Include="Util\InverseBooleanConverter.cs" /> <Compile Include="Util\InverseBooleanConverter.cs" />
<Compile Include="Util\NullImageConverter.cs" /> <Compile Include="Util\NullImageConverter.cs" />
<Compile Include="Util\NumberValidationRule.cs" />
<Compile Include="Util\SettingBindingExtension.cs" /> <Compile Include="Util\SettingBindingExtension.cs" />
<Compile Include="Util\StringValidationRule.cs" />
<Compile Include="Util\TrimStringConverter.cs" /> <Compile Include="Util\TrimStringConverter.cs" />
<Compile Include="Util\UIHelper.cs" /> <Compile Include="Util\UIHelper.cs" />
<Compile Include="Util\UtcToLocalDateTimeConverter.cs" /> <Compile Include="Util\UtcToLocalDateTimeConverter.cs" />
<Compile Include="Util\ValidationContext.cs" /> <Compile Include="Util\ValidationContext.cs" />
<Compile Include="VorgaengeControl.xaml.cs">
<DependentUpon>VorgaengeControl.xaml</DependentUpon>
</Compile>
<Compile Include="WindowPlacement.cs" /> <Compile Include="WindowPlacement.cs" />
<Page Include="AnmeldungenControl.xaml"> <Page Include="AnmeldungenControl.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
@ -475,6 +609,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Controls\EasyPeasyControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\LocodeControl.xaml"> <Page Include="Controls\LocodeControl.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@ -703,6 +841,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="EditControls\SelectCrewMemberDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EditControls\SelectImportClassesDialog.xaml"> <Page Include="EditControls\SelectImportClassesDialog.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@ -746,6 +888,54 @@
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Page Include="SheetDisplayControls\ATAControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\CrewDepartureControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\CrewPreArrivalControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\DangerousCargoControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\PassengerDepartureControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\PassengerPreArrivalControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\PortControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\PreArrivalControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\PreDepartureControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\ShipDataControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\VoyageControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\WasteReceiptsControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SplashScreenWindow.xaml"> <Page Include="SplashScreenWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@ -758,10 +948,6 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="VorgaengeControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs"> <Compile Include="Properties\AssemblyInfo.cs">
@ -777,10 +963,6 @@
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<Content Include="..\misc\Logo.gif">
<Link>Report\Logo.gif</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\misc\report.db"> <Content Include="..\misc\report.db">
<Link>report.db</Link> <Link>report.db</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@ -799,6 +981,8 @@
<None Include="ENI2_4_TemporaryKey.pfx" /> <None Include="ENI2_4_TemporaryKey.pfx" />
<None Include="ENI2_5_TemporaryKey.pfx" /> <None Include="ENI2_5_TemporaryKey.pfx" />
<None Include="ENI2_6_TemporaryKey.pfx" /> <None Include="ENI2_6_TemporaryKey.pfx" />
<None Include="ENI2_7_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="Service References\LockingServiceReference\ENI2.LockingServiceReference.CoreLock.datasource"> <None Include="Service References\LockingServiceReference\ENI2.LockingServiceReference.CoreLock.datasource">
<DependentUpon>Reference.svcmap</DependentUpon> <DependentUpon>Reference.svcmap</DependentUpon>
</None> </None>
@ -881,6 +1065,15 @@
<Resource Include="Resources\document_plain_new.png" /> <Resource Include="Resources\document_plain_new.png" />
<Resource Include="Resources\exit.png" /> <Resource Include="Resources\exit.png" />
<Resource Include="Resources\document_exchange.png" /> <Resource Include="Resources\document_exchange.png" />
<Resource Include="Resources\arrival_user.png" />
<Resource Include="Resources\arrival_worker.png" />
<Resource Include="Resources\departure_user.png" />
<Resource Include="Resources\departure_worker.png" />
<Resource Include="Resources\clock.png" />
<Content Include="Report\Logo.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Resource Include="Resources\pencil.png" />
<Content Include="x64\SQLite.Interop.dll"> <Content Include="x64\SQLite.Interop.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
@ -907,7 +1100,6 @@
</Content> </Content>
<None Include="bsmdKey.snk" /> <None Include="bsmdKey.snk" />
<None Include="ENI2.licenseheader" /> <None Include="ENI2.licenseheader" />
<None Include="packages.config" />
<None Include="Properties\app.manifest" /> <None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
@ -930,9 +1122,9 @@
<Resource Include="Resources\containership.ico" /> <Resource Include="Resources\containership.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2"> <BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible> <Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName> <ProductName>Microsoft .NET Framework 4.8 %28x86 and x64%29</ProductName>
<Install>true</Install> <Install>true</Install>
</BootstrapperPackage> </BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
@ -1030,15 +1222,17 @@
<SignToolPath Condition="'$(SignToolPath)' == '' And '$(SignToolPathBase)' != ''">$(SignToolPathBase)$(Platform)\</SignToolPath> <SignToolPath Condition="'$(SignToolPath)' == '' And '$(SignToolPathBase)' != ''">$(SignToolPathBase)$(Platform)\</SignToolPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<PostBuildEvent>"$(SignToolPath)signtool.exe" sign /f $(ProjectDir)\ENI2_6_TemporaryKey.pfx /p FgrMFUWsTVGQeb6L6i0e /fd SHA256 $(TargetPath)</PostBuildEvent> <PostBuildEvent>"$(SignToolPath)signtool.exe" sign /f $(ProjectDir)\ENI2_7_TemporaryKey.pfx /p FgrMFUWsTVGQeb6L6i0e /fd SHA256 $(TargetPath)</PostBuildEvent>
</PropertyGroup> </PropertyGroup>
<Import Project="packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.117.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.117.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" /> <Import Project="packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.117.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.117.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" /> <Error Condition="!Exists('packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
<Error Condition="!Exists('packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets'))" />
</Target> </Target>
<Import Project="packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets" Condition="Exists('packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">

Binary file not shown.

View File

@ -4,8 +4,9 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:enictrl="clr-namespace:ENI2.Controls" xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:p="clr-namespace:ENI2.Properties"
mc:Ignorable="d" mc:Ignorable="d"
Title="Change password" Height="215" Width="400" Loaded="EditWindowBase_Loaded" Background="AliceBlue"> Title="Change password" Height="243" Width="400" Loaded="EditWindowBase_Loaded" Background="AliceBlue">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="28" /> <RowDefinition Height="28" />
@ -13,6 +14,7 @@
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width=".4*" /> <ColumnDefinition Width=".4*" />
@ -20,14 +22,16 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="Name" /> <Label Grid.Row="0" Grid.Column="0" Content="Name" />
<Label Grid.Row="1" Grid.Column="0" Content="Old password" /> <Label Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textOldPassword}" />
<Label Grid.Row="2" Grid.Column="0" Content="New password" /> <Label Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textNewPassword}" />
<Label Grid.Row="3" Grid.Column="0" Content="Repeat new password" /> <Label Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textRepeatNewPassword}" />
<TextBlock Grid.Row="0" Grid.Column="1" x:Name="textBlockName" VerticalAlignment="Center" FontWeight="DemiBold"/> <TextBlock Grid.Row="0" Grid.Column="1" x:Name="textBlockName" VerticalAlignment="Center" FontWeight="DemiBold"/>
<PasswordBox Grid.Row="1" Grid.Column="1" x:Name="textBoxOldPassword" Margin="2" VerticalContentAlignment="Center" /> <PasswordBox Grid.Row="1" Grid.Column="1" x:Name="textBoxOldPassword" Margin="2" VerticalContentAlignment="Center" />
<PasswordBox Grid.Row="2" Grid.Column="1" x:Name="textBoxNew1Password" Margin="2" VerticalContentAlignment="Center" /> <PasswordBox Grid.Row="2" Grid.Column="1" x:Name="textBoxNew1Password" Margin="2" VerticalContentAlignment="Center" />
<PasswordBox Grid.Row="3" Grid.Column="1" x:Name="textBoxNew2Password" Margin="2" VerticalContentAlignment="Center" /> <PasswordBox Grid.Row="3" Grid.Column="1" x:Name="textBoxNew2Password" Margin="2" VerticalContentAlignment="Center" />
<Button Grid.Row="4" Grid.Column="1" Content="Change" Name="buttonChangePassword" Margin="2" Width="80" HorizontalAlignment="Left" Click="buttonChangePassword_Click"/> <Label Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textDefaultDisplay}" />
<ComboBox x:Name="comboBoxDefaultDisplay" Grid.Column="1" Grid.Row="4" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" IsEditable="False" />
<Button Grid.Row="5" Grid.Column="1" Content="Change" Name="buttonChangePassword" Margin="2" Width="80" HorizontalAlignment="Left" Click="buttonChangePassword_Click"/>
</Grid> </Grid>
</enictrl:EditWindowBase> </enictrl:EditWindowBase>

View File

@ -4,6 +4,7 @@
using bsmd.database; using bsmd.database;
using ENI2.Controls; using ENI2.Controls;
using System;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
@ -36,43 +37,48 @@ namespace ENI2.EditControls
{ {
bool success = false; bool success = false;
string message = ""; string message = "";
if(!textBoxOldPassword.Password.IsNullOrEmpty()) if (!textBoxOldPassword.Password.IsNullOrEmpty() || !textBoxNew1Password.Password.IsNullOrEmpty() || !textBoxNew2Password.Password.IsNullOrEmpty())
{ {
if(CurrentUser.GetHash(textBoxOldPassword.Password).Equals(CurrentUser.PasswordHash)) if (!textBoxOldPassword.Password.IsNullOrEmpty())
{ {
if(textBoxNew1Password.Password.IsNullOrEmpty() || if (CurrentUser.GetHash(textBoxOldPassword.Password).Equals(CurrentUser.PasswordHash))
textBoxNew2Password.Password.IsNullOrEmpty() ||
!textBoxNew1Password.Password.Equals(textBoxNew2Password.Password))
{ {
message = "New passwords are empty or do not match"; if (textBoxNew1Password.Password.IsNullOrEmpty() ||
} textBoxNew2Password.Password.IsNullOrEmpty() ||
else !textBoxNew1Password.Password.Equals(textBoxNew2Password.Password))
{
if (textBoxOldPassword.Password.Equals(textBoxNew1Password.Password))
{ {
message = "Old and new password are the same"; message = "New passwords are empty or do not match";
} }
else else
{ {
CurrentUser.SetPassword(textBoxNew1Password.Password); if (textBoxOldPassword.Password.Equals(textBoxNew1Password.Password))
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(CurrentUser); {
success = true; message = "Old and new password are the same";
}
else
{
CurrentUser.SetPassword(textBoxNew1Password.Password);
success = true;
}
} }
} }
else
{
message = "Old password is not correct";
}
} }
else else
{ {
message = "Old password is not correct"; message = "Old password empty";
} }
if (!success)
MessageBox.Show(message, "Changing password failed", MessageBoxButton.OK, MessageBoxImage.Error);
else
MessageBox.Show("Password successfully changed.", "Password changed", MessageBoxButton.OK, MessageBoxImage.Information);
} }
else // user may have changed combobox default display value so we are saving anyway here
{ this.CurrentUser.ShipcallDisplayMode = (ReportingParty.ShipcallDisplayModeEnum)Enum.Parse(typeof(ReportingParty.ShipcallDisplayModeEnum), (string)this.comboBoxDefaultDisplay.SelectedValue);
message = "Old password empty"; DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(CurrentUser);
}
if (!success)
MessageBox.Show(message, "Changing password failed", MessageBoxButton.OK, MessageBoxImage.Error);
else
MessageBox.Show("Password successfully changed.", "Password changed", MessageBoxButton.OK, MessageBoxImage.Information);
} }
private void EditWindowBase_Loaded(object sender, RoutedEventArgs e) private void EditWindowBase_Loaded(object sender, RoutedEventArgs e)
@ -82,6 +88,8 @@ namespace ENI2.EditControls
this.OkVisible = false; this.OkVisible = false;
var cancelButton = (Button)Template.FindName("buttonCancel", this); var cancelButton = (Button)Template.FindName("buttonCancel", this);
cancelButton.Content = "Close"; cancelButton.Content = "Close";
this.comboBoxDefaultDisplay.ItemsSource = Util.EnumHelper.GetAllValuesAndDescription(typeof(ReportingParty.ShipcallDisplayModeEnum));
this.comboBoxDefaultDisplay.SelectedValue = this.CurrentUser.ShipcallDisplayMode;
} }
#endregion #endregion

View File

@ -60,7 +60,7 @@
ButtonSpinnerLocation="Right" ButtonSpinnerLocation="Right"
ParsingNumberStyle="Integer" ParsingNumberStyle="Integer"
Watermark="Enter ENI" ValueChanged="doubleUpDownENI_ValueChanged" TextAlignment="Left"/> Watermark="Enter ENI" ValueChanged="doubleUpDownENI_ValueChanged" TextAlignment="Left"/>
<enictrl:LocodeControl Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="2" Width="Auto" x:Name="locodePoC" /> <enictrl:LocodeControl Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="2" Width="Auto" x:Name="locodePoC" LocodeSource="OLD" />
<DatePicker Name="datePickerETA" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" SelectedDateChanged="datePickerETA_SelectedDateChanged" DisplayDateStart="1/1/1900" DisplayDateEnd="12/31/2199"> <DatePicker Name="datePickerETA" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" SelectedDateChanged="datePickerETA_SelectedDateChanged" DisplayDateStart="1/1/1900" DisplayDateEnd="12/31/2199">
<DatePicker.BlackoutDates> <DatePicker.BlackoutDates>
<CalendarDateRange Start="1/1/0001" End="12/31/1799"/> <CalendarDateRange Start="1/1/0001" End="12/31/1799"/>

View File

@ -57,7 +57,7 @@ namespace ENI2.EditControls
isComplete &= imo_OR_eni; isComplete &= imo_OR_eni;
string locode = this.locodePoC.LocodeValue; string locode = this.locodePoC.LocodeValue;
bool validLocode = (locode?.Length == 5) && (locode.StartsWith("DE") || locode.StartsWith("DK") || locode.Equals("ZZNOK")); bool validLocode = (locode?.Length == 5) && (locode.StartsWith("DE") || locode.StartsWith("DK") || locode.Equals("ZZNOK") || locode.Equals("DEWHV"));
isComplete &= validLocode; isComplete &= validLocode;

View File

@ -19,7 +19,7 @@
<ColumnDefinition Width="3*" /> <ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label Content="{x:Static p:Resources.textBunkerType}" Grid.Row="0" Grid.Column="0" /> <Label Content="{x:Static p:Resources.textBunkerType}" Grid.Row="0" Grid.Column="0" />
<TextBox Grid.Row="0" Grid.Column="1" Width="auto" Name="textBoxBunkerType" Margin="2" MaxLength="100" VerticalContentAlignment="Center"/> <TextBox Grid.Row="0" Grid.Column="1" Width="auto" Name="textBoxBunkerType" Margin="2" MaxLength="25" VerticalContentAlignment="Center"/>
<Label Content="{x:Static p:Resources.textBunkerQuantity}" Grid.Row="1" Grid.Column="0" /> <Label Content="{x:Static p:Resources.textBunkerQuantity}" Grid.Row="1" Grid.Column="0" />
<xctk:DoubleUpDown Grid.Row="1" Grid.Column="1" Name="doubleUpDownBunkerQuantity" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2,2,2,2" FormatString="N1" TextAlignment="Left" /> <xctk:DoubleUpDown Grid.Row="1" Grid.Column="1" Name="doubleUpDownBunkerQuantity" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2,2,2,2" FormatString="N1" TextAlignment="Left" />
</Grid> </Grid>

View File

@ -79,6 +79,7 @@ namespace ENI2.EditControls
{ {
// copy back // copy back
this.CREW.CrewMemberDuty = this.textBoxDuty.Text.Trim(); this.CREW.CrewMemberDuty = this.textBoxDuty.Text.Trim();
if (this.CREW.CrewMemberDuty.IsNullOrEmpty()) this.CREW.CrewMemberDuty = "unknown";
this.CREW.CrewMemberLastName = this.textBoxLastName.Text.Trim(); this.CREW.CrewMemberLastName = this.textBoxLastName.Text.Trim();
this.CREW.CrewMemberFirstName = this.textBoxFirstName.Text.Trim(); this.CREW.CrewMemberFirstName = this.textBoxFirstName.Text.Trim();
this.CREW.CrewMemberGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?) byte.Parse((string) this.comboBoxGender.SelectedValue); this.CREW.CrewMemberGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?) byte.Parse((string) this.comboBoxGender.SelectedValue);

View File

@ -8,7 +8,7 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:p="clr-namespace:ENI2.Properties" xmlns:p="clr-namespace:ENI2.Properties"
mc:Ignorable="d" mc:Ignorable="d"
Title="{x:Static p:Resources.textReportingParty}" Height="350" Width="800" WindowStyle="SingleBorderWindow" Background="AliceBlue"> Title="{x:Static p:Resources.textReportingParty}" Height="378" Width="800" WindowStyle="SingleBorderWindow" Background="AliceBlue">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="28" /> <RowDefinition Height="28" />
@ -21,6 +21,7 @@
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" /> <ColumnDefinition Width="2*" />
@ -46,10 +47,11 @@
<Label Name="labelUserEMail" Grid.Row="7" Grid.Column="0" Content="{x:Static p:Resources.textEMail}" HorizontalContentAlignment="Right" /> <Label Name="labelUserEMail" Grid.Row="7" Grid.Column="0" Content="{x:Static p:Resources.textEMail}" HorizontalContentAlignment="Right" />
<Label Name="labelAdmin" Grid.Row="7" Grid.Column="2" Content="{x:Static p:Resources.textAdministrator}" HorizontalContentAlignment="Right" /> <Label Name="labelAdmin" Grid.Row="7" Grid.Column="2" Content="{x:Static p:Resources.textAdministrator}" HorizontalContentAlignment="Right" />
<Label Name="labelArchived" Grid.Row="8" Grid.Column="0" Content="{x:Static p:Resources.textArchived}" HorizontalContentAlignment="Right" /> <Label Name="labelArchived" Grid.Row="8" Grid.Column="0" Content="{x:Static p:Resources.textArchived}" HorizontalContentAlignment="Right" />
<Label Name="labelCreated" Grid.Row="9" Grid.Column="0" Content="{x:Static p:Resources.textCreated}" HorizontalContentAlignment="Right" />
<Label Name="labelChanged" Grid.Row="9" Grid.Column="2" Content="{x:Static p:Resources.textChanged}" HorizontalContentAlignment="Right" />
<Label Name="labelEditor" Grid.Row="8" Grid.Column="2" Content="{x:Static p:Resources.textEditor}" HorizontalContentAlignment="Right" /> <Label Name="labelEditor" Grid.Row="8" Grid.Column="2" Content="{x:Static p:Resources.textEditor}" HorizontalContentAlignment="Right" />
<Label Name="labelCreated" Grid.Row="10" Grid.Column="0" Content="{x:Static p:Resources.textCreated}" HorizontalContentAlignment="Right" />
<Label Name="labelChanged" Grid.Row="10" Grid.Column="2" Content="{x:Static p:Resources.textChanged}" HorizontalContentAlignment="Right" />
<TextBox Grid.Row="0" Grid.Column="1" Width="auto" Name="textBoxName" Margin="2" MaxLength="100" VerticalContentAlignment="Center" /> <TextBox Grid.Row="0" Grid.Column="1" Width="auto" Name="textBoxName" Margin="2" MaxLength="100" VerticalContentAlignment="Center" />
<TextBox Grid.Row="0" Grid.Column="3" Width="auto" Name="textBoxEMail" Margin="2" MaxLength="100" VerticalContentAlignment="Center" /> <TextBox Grid.Row="0" Grid.Column="3" Width="auto" Name="textBoxEMail" Margin="2" MaxLength="100" VerticalContentAlignment="Center" />
<TextBox Grid.Row="1" Grid.Column="1" Width="auto" Name="textBoxFirstName" Margin="2" MaxLength="100" VerticalContentAlignment="Center" /> <TextBox Grid.Row="1" Grid.Column="1" Width="auto" Name="textBoxFirstName" Margin="2" MaxLength="100" VerticalContentAlignment="Center" />
@ -67,9 +69,8 @@
<CheckBox Grid.Row="7" Grid.Column="3" VerticalAlignment="Center" Name="checkBoxAdministrator" Margin="2" /> <CheckBox Grid.Row="7" Grid.Column="3" VerticalAlignment="Center" Name="checkBoxAdministrator" Margin="2" />
<CheckBox Grid.Row="8" Grid.Column="3" VerticalAlignment="Center" Name="checkBoxEditor" Margin="2" /> <CheckBox Grid.Row="8" Grid.Column="3" VerticalAlignment="Center" Name="checkBoxEditor" Margin="2" />
<CheckBox Grid.Row="8" Grid.Column="1" VerticalAlignment="Center" Name="checkBoxArchived" Margin="2" /> <CheckBox Grid.Row="8" Grid.Column="1" VerticalAlignment="Center" Name="checkBoxArchived" Margin="2" />
<Label Grid.Row="10" Grid.Column="1" Name="dateTimePickerCreated" FontStyle="Italic" />
<Label Grid.Row="9" Grid.Column="1" Name="dateTimePickerCreated" FontStyle="Italic" /> <Label Grid.Row="10" Grid.Column="3" Name="dateTimePickerChanged" FontStyle="Italic" />
<Label Grid.Row="9" Grid.Column="3" Name="dateTimePickerChanged" FontStyle="Italic" />
</Grid> </Grid>
</enictrl:EditWindowBase> </enictrl:EditWindowBase>

View File

@ -2,6 +2,7 @@
// Description: Reporting party Bearbeitungsdialog // Description: Reporting party Bearbeitungsdialog
// //
using System;
using System.Windows; using System.Windows;
using bsmd.database; using bsmd.database;
@ -24,6 +25,7 @@ namespace ENI2.EditControls
private void EditReportingPartyDialog_Loaded(object sender, RoutedEventArgs e) private void EditReportingPartyDialog_Loaded(object sender, RoutedEventArgs e)
{ {
this.textBoxCity.Text = this.ReportingParty.City; this.textBoxCity.Text = this.ReportingParty.City;
this.textBoxCountry.Text = this.ReportingParty.Country; this.textBoxCountry.Text = this.ReportingParty.Country;
this.textBoxEMail.Text = this.ReportingParty.EMail; this.textBoxEMail.Text = this.ReportingParty.EMail;
@ -41,6 +43,7 @@ namespace ENI2.EditControls
this.checkBoxArchived.IsChecked = this.ReportingParty.IsArchived; this.checkBoxArchived.IsChecked = this.ReportingParty.IsArchived;
this.checkBoxEditor.IsChecked = this.ReportingParty.IsEditor; this.checkBoxEditor.IsChecked = this.ReportingParty.IsEditor;
this.dateTimePickerChanged.Content = this.ReportingParty.Changed.HasValue ? this.ReportingParty.Changed.ToString() : ""; this.dateTimePickerChanged.Content = this.ReportingParty.Changed.HasValue ? this.ReportingParty.Changed.ToString() : "";
this.dateTimePickerCreated.Content = this.ReportingParty.Created.HasValue ? this.ReportingParty.Created.ToString() : ""; this.dateTimePickerCreated.Content = this.ReportingParty.Created.HasValue ? this.ReportingParty.Created.ToString() : "";

View File

@ -1,5 +1,5 @@
// Copyright (c) 2017 schick Informatik // Copyright (c) 2017 schick Informatik
// Description: // Description: Edit SERV and SERV_template entities
// //
using System.Windows; using System.Windows;
@ -14,36 +14,78 @@ namespace ENI2.EditControls
/// </summary> /// </summary>
public partial class EditSERVDialog : EditWindowBase public partial class EditSERVDialog : EditWindowBase
{ {
#region Construction
public EditSERVDialog() public EditSERVDialog()
{ {
InitializeComponent(); InitializeComponent();
Loaded += EditSERVDialog_Loaded; Loaded += EditSERVDialog_Loaded;
} }
#endregion
#region Properties
public SERV SERV { get; set; }
public SERV_Template SERV_Template { get; set; }
#endregion
#region event handler
private void EditSERVDialog_Loaded(object sender, RoutedEventArgs e) private void EditSERVDialog_Loaded(object sender, RoutedEventArgs e)
{ {
this.OKClicked += EditSERVDialog_OKClicked; this.OKClicked += EditSERVDialog_OKClicked;
// copy into fields // copy into fields
this.textBoxServiceName.Text = this.SERV.ServiceName; if (this.SERV != null)
this.textBoxServiceBeneficiary.Text = this.SERV.ServiceBeneficiary; {
this.textBoxServiceInvoiceRecipient.Text = this.SERV.ServiceInvoiceRecipient; this.textBoxServiceName.Text = this.SERV.ServiceName;
this.AddVisible = true; this.textBoxServiceBeneficiary.Text = this.SERV.ServiceBeneficiary;
} this.textBoxServiceInvoiceRecipient.Text = this.SERV.ServiceInvoiceRecipient;
this.AddVisible = true;
}
public void CopyValuesToEntity() if (this.SERV_Template != null)
{ {
// copy back this.textBoxServiceName.Text = this.SERV_Template.ServiceName;
this.SERV.ServiceName = this.textBoxServiceName.Text.Trim(); this.textBoxServiceBeneficiary.Text = this.SERV_Template.ServiceBeneficiary;
this.SERV.ServiceBeneficiary = this.textBoxServiceBeneficiary.Text.Trim(); this.textBoxServiceInvoiceRecipient.Text = this.SERV_Template.ServiceInvoiceRecipient;
this.SERV.ServiceInvoiceRecipient = this.textBoxServiceInvoiceRecipient.Text.Trim(); }
} }
private void EditSERVDialog_OKClicked() private void EditSERVDialog_OKClicked()
{ {
this.CopyValuesToEntity(); this.CopyValuesToEntity();
} }
public SERV SERV { get; set; } #endregion
#region public methods
public void CopyValuesToEntity()
{
if (this.SERV != null)
{
// copy back
this.SERV.ServiceName = this.textBoxServiceName.Text.Trim();
this.SERV.ServiceBeneficiary = this.textBoxServiceBeneficiary.Text.Trim();
this.SERV.ServiceInvoiceRecipient = this.textBoxServiceInvoiceRecipient.Text.Trim();
}
if (this.SERV_Template != null)
{
// copy back
this.SERV_Template.ServiceName = this.textBoxServiceName.Text.Trim();
this.SERV_Template.ServiceBeneficiary = this.textBoxServiceBeneficiary.Text.Trim();
this.SERV_Template.ServiceInvoiceRecipient = this.textBoxServiceInvoiceRecipient.Text.Trim();
}
}
#endregion
} }
} }

View File

@ -38,11 +38,11 @@
<Label Name="labelWasteCodeText" Grid.Row="0" Grid.Column="2" /> <Label Name="labelWasteCodeText" Grid.Row="0" Grid.Column="2" />
<TextBox Name="textBoxDescription" Grid.Row="1" Grid.Column="1" Margin="2" Grid.ColumnSpan="2" Width="auto" MaxLength="99" TextWrapping="Wrap" /> <TextBox Name="textBoxDescription" Grid.Row="1" Grid.Column="1" Margin="2" Grid.ColumnSpan="2" Width="auto" MaxLength="99" TextWrapping="Wrap" />
<xctk:DoubleUpDown Grid.Row="2" Grid.Column="1" Name="doubleUpDownAmountDisposed" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2" FormatString="N3" TextAlignment="Left"/> <xctk:DoubleUpDown Grid.Row="2" Grid.Column="1" Name="doubleUpDownAmountDisposed" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2" FormatString="N3" TextAlignment="Left" Maximum="9999.999" />
<xctk:DoubleUpDown Grid.Row="3" Grid.Column="1" Name="doubleUpDownMaxCapacity" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2" FormatString="N3" TextAlignment="Left"/> <xctk:DoubleUpDown Grid.Row="3" Grid.Column="1" Name="doubleUpDownMaxCapacity" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2" FormatString="N3" TextAlignment="Left" Maximum="9999.999"/>
<xctk:DoubleUpDown Grid.Row="4" Grid.Column="1" Name="doubleUpDownAmountRetained" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2" FormatString="N3" TextAlignment="Left"/> <xctk:DoubleUpDown Grid.Row="4" Grid.Column="1" Name="doubleUpDownAmountRetained" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2" FormatString="N3" TextAlignment="Left" Maximum="9999.999"/>
<enictrl:LocodeControl Grid.Row="5" Grid.Column="1" x:Name="locodePortOfDeliveryRemainingWaste" LocodeSource="SSN" /> <enictrl:LocodeControl Grid.Row="5" Grid.Column="1" x:Name="locodePortOfDeliveryRemainingWaste" LocodeSource="SSN" />
<xctk:DoubleUpDown Grid.Row="6" Grid.Column="1" Name="doubleUpDownAmountGeneratedTilNextPort" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2" FormatString="N3" TextAlignment="Left"/> <xctk:DoubleUpDown Grid.Row="6" Grid.Column="1" Name="doubleUpDownAmountGeneratedTilNextPort" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2" FormatString="N3" TextAlignment="Left" Maximum="9999.999"/>
<Label Content="{x:Static p:Resources.textCubicMeters}" Grid.Row = "2" Grid.Column="2" /> <Label Content="{x:Static p:Resources.textCubicMeters}" Grid.Row = "2" Grid.Column="2" />
<Label Content="{x:Static p:Resources.textCubicMeters}" Grid.Row = "3" Grid.Column="2" /> <Label Content="{x:Static p:Resources.textCubicMeters}" Grid.Row = "3" Grid.Column="2" />

View File

@ -14,6 +14,7 @@
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="56" /> <RowDefinition Height="56" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
@ -30,16 +31,48 @@
<Label Name="labelIdentificationNumber" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textIdentificationNumber}" /> <Label Name="labelIdentificationNumber" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textIdentificationNumber}" />
<Label Name="labelPortReceptionFacilityName" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textPortReceptionFacilityName}" /> <Label Name="labelPortReceptionFacilityName" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textPortReceptionFacilityName}" />
<Label Name="labelPortReceptionFacilityProviderName" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textPortReceptionFacilityProviderName}" /> <Label Name="labelPortReceptionFacilityProviderName" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textPortReceptionFacilityProviderName}" />
<Label Name="labelTreatmentFacilityProvider" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textTreatmentFacilityProviderDisplay}" /> <Label Name="labelTemplate" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textAgentTemplate}" />
<Label Name="labelWasteDeliveryDateFrom" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textWasteDeliveryDateFrom}" /> <Label Name="labelTreatmentFacilityProvider" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textTreatmentFacilityProviderDisplay}" />
<Label Name="labelWasteDeliveryDateTo" Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textWasteDeliveryDateTo}" /> <Label Name="labelWasteDeliveryDateFrom" Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textWasteDeliveryDateFrom}" />
<Label Name="labelWasteDeliveryDateTo" Grid.Row="6" Grid.Column="0" Content="{x:Static p:Resources.textWasteDeliveryDateTo}" />
<TextBox Name="textIdentificationNumber" Grid.Row="0" Grid.Column="1" Width="auto" MaxLength="20" TextWrapping="Wrap" Margin="2" VerticalContentAlignment="Center"/> <TextBox Name="textIdentificationNumber" Grid.Row="0" Grid.Column="1" Width="auto" MaxLength="20" TextWrapping="Wrap" Margin="2" VerticalContentAlignment="Center"/>
<TextBox Name="textBoxPortReceptionFacilityName" Grid.Row="1" Grid.Column="1" Width="auto" MaxLength="70" TextWrapping="Wrap" Margin="2" VerticalContentAlignment="Center"/> <TextBox Name="textBoxPortReceptionFacilityName" Grid.Row="1" Grid.Column="1" Width="auto" MaxLength="70" TextWrapping="Wrap" Margin="2" VerticalContentAlignment="Center"/>
<TextBox Name="textBoxPortReceptionFacilityProviderName" Grid.Row="2" Grid.Column="1" Width="auto" MaxLength="70" TextWrapping="Wrap" Margin="2" VerticalContentAlignment="Center"/> <TextBox Name="textBoxPortReceptionFacilityProviderName" Grid.Row="2" Grid.Column="1" Width="auto" MaxLength="70" TextWrapping="Wrap" Margin="2" VerticalContentAlignment="Center"/>
<TextBox Name="textBoxTreatmentFacilityProvider" Grid.Row="3" Grid.Column="1" Height="56" VerticalContentAlignment="Top" Margin="2"/> <Grid Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="1" Name="gridTemplateControls" Visibility="Visible">
<xctk:DateTimePicker Grid.Row="4" Grid.Column="1" Name="dateTimePickerWasteDeliveryDateFrom" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00" PreviewKeyUp="DateTimePicker_PreviewKeyUp"/> <Grid.ColumnDefinitions>
<xctk:DateTimePicker Grid.Row="5" Grid.Column="1" Name="dateTimePickerWasteDeliveryDateTo" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00" PreviewKeyUp="DateTimePicker_PreviewKeyUp"/> <ColumnDefinition Width=".5*"/>
<ColumnDefinition Width=".5*"/>
<!-- Name -->
<ColumnDefinition Width="26"/>
<!-- Save button -->
<ColumnDefinition Width="26"/>
<!-- Delete button -->
<ColumnDefinition Width="52"/>
<!-- Undo button -->
</Grid.ColumnDefinitions>
<ComboBox Grid.Column="0" Name="comboBox_WSDPTemplate" Margin="2" SelectedValuePath="Id" DisplayMemberPath="Remark" SelectionChanged="comboBox_WSDPTemplate_SelectionChanged" />
<TextBox Grid.Column="1" Margin="2" Name="textBoxTemplateTitle" VerticalContentAlignment="Center"/>
<Button Name="buttonSaveTemplate" Grid.Column="2" Grid.Row="0" Margin="2" Click="buttonSaveTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Save template">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/floppy_disk_blue.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonDeleteTemplate" Grid.Column="3" Grid.Row="0" Margin="2" Click="buttonDeleteTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Delete template" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/delete.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonUndoTemplate" Grid.Column="4" Grid.Row="0" Margin="22,2,2,2" Click="buttonUndoTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Undo last overwrite" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/undo.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
</Grid>
<TextBox Name="textBoxTreatmentFacilityProvider" Grid.Row="4" Grid.Column="1" Height="56" VerticalContentAlignment="Top" Margin="2"/>
<xctk:DateTimePicker Grid.Row="5" Grid.Column="1" Name="dateTimePickerWasteDeliveryDateFrom" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00" PreviewKeyUp="DateTimePicker_PreviewKeyUp"/>
<xctk:DateTimePicker Grid.Row="6" Grid.Column="1" Name="dateTimePickerWasteDeliveryDateTo" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00" PreviewKeyUp="DateTimePicker_PreviewKeyUp"/>
<!--Button x:Name="buttonAddEntries" Grid.Column="1" Grid.Row="7" Margin="2" Click="buttonAddEntries_Click" Width="170" Content="Add waste received entries" HorizontalAlignment="Left"/--> <!--Button x:Name="buttonAddEntries" Grid.Column="1" Grid.Row="7" Margin="2" Click="buttonAddEntries_Click" Width="170" Content="Add waste received entries" HorizontalAlignment="Left"/-->

View File

@ -3,6 +3,8 @@
// //
using System; using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows; using System.Windows;
using bsmd.database; using bsmd.database;
@ -15,6 +17,13 @@ namespace ENI2.EditControls
/// </summary> /// </summary>
public partial class EditWasteReceiptDialog : EditWindowBase public partial class EditWasteReceiptDialog : EditWindowBase
{ {
// TODO: "unstatic" the templates and take care they are synchronized between controls
private List<WasteDisposalServiceProvider_Template> _wsdpTemplates = null;
private WasteDisposalServiceProvider_Template _currentTemplate;
private string _undoTemplate;
public EditWasteReceiptDialog() public EditWasteReceiptDialog()
{ {
InitializeComponent(); InitializeComponent();
@ -24,7 +33,7 @@ namespace ENI2.EditControls
public WAS_RCPT WAS_RCPT { get; set; } public WAS_RCPT WAS_RCPT { get; set; }
private void EditWasteReceiptDialog_Loaded(object sender, RoutedEventArgs e) private async void EditWasteReceiptDialog_Loaded(object sender, RoutedEventArgs e)
{ {
this.textIdentificationNumber.Text = this.WAS_RCPT.IdentificationNumber; this.textIdentificationNumber.Text = this.WAS_RCPT.IdentificationNumber;
this.textBoxPortReceptionFacilityName.Text = this.WAS_RCPT.PortReceptionFacilityName; this.textBoxPortReceptionFacilityName.Text = this.WAS_RCPT.PortReceptionFacilityName;
@ -35,6 +44,12 @@ namespace ENI2.EditControls
OKClicked += EditWasteReceiptDialog_OKClicked; OKClicked += EditWasteReceiptDialog_OKClicked;
this.AddVisible = true; this.AddVisible = true;
_wsdpTemplates = await DBManagerAsync.GetWasteDisposalServiceProviderTemplatesAsync();
_wsdpTemplates.Sort();
Trace.WriteLine($"{_wsdpTemplates.Count} WSDP templates loaded");
this.comboBox_WSDPTemplate.ItemsSource = _wsdpTemplates;
} }
public void CopyValuesToEntity() public void CopyValuesToEntity()
{ {
@ -52,10 +67,87 @@ namespace ENI2.EditControls
this.CopyValuesToEntity(); this.CopyValuesToEntity();
} }
private void comboBox_WSDPTemplate_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
Trace.WriteLine("WSDP combo selection changed");
if (this.comboBox_WSDPTemplate.SelectedItem is WasteDisposalServiceProvider_Template wdsp_t)
{
this.textBoxTemplateTitle.Text = wdsp_t.Remark;
this.buttonDeleteTemplate.IsEnabled = true;
this._currentTemplate = wdsp_t;
this._undoTemplate = this.textBoxPortReceptionFacilityProviderName.Text.Trim();
this.buttonUndoTemplate.IsEnabled = this._undoTemplate.Length > 0;
this.textBoxPortReceptionFacilityProviderName.Text = wdsp_t.WasteDisposalServiceProviderName;
}
}
private async void buttonSaveTemplate_Click(object sender, RoutedEventArgs e)
{
string currentWSDPProviderName = this.textBoxPortReceptionFacilityProviderName.Text.Trim();
string currentRemark = this.textBoxTemplateTitle.Text.Trim();
if ((currentWSDPProviderName.Length == 0) || (currentRemark.Length == 0)) return;
WasteDisposalServiceProvider_Template existingTemplate = null;
foreach (WasteDisposalServiceProvider_Template wdsp_template in _wsdpTemplates)
{
// bei gefundenem Match wird ggf. der Remark überschrieben
if (wdsp_template.Remark.Equals(currentRemark))
{
existingTemplate = wdsp_template;
break;
}
}
if (existingTemplate != null)
{
if (MessageBox.Show("A template with this name already exists, overwrite?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
return;
existingTemplate.WasteDisposalServiceProviderName = currentWSDPProviderName;
await DBManagerAsync.SaveAsync(existingTemplate);
return;
}
WasteDisposalServiceProvider_Template newTemplate = new WasteDisposalServiceProvider_Template();
newTemplate.WasteDisposalServiceProviderName = currentWSDPProviderName;
newTemplate.Remark = currentRemark;
await DBManagerAsync.SaveAsync(newTemplate);
comboBox_WSDPTemplate.ItemsSource = null;
_wsdpTemplates.Add(newTemplate);
_wsdpTemplates.Sort();
comboBox_WSDPTemplate.ItemsSource = _wsdpTemplates;
MessageBox.Show("Template saved", "OK", MessageBoxButton.OK, MessageBoxImage.Information);
}
private void buttonDeleteTemplate_Click(object sender, RoutedEventArgs e)
{
if (_currentTemplate != null)
{
if (MessageBox.Show("Delete this template?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
this.comboBox_WSDPTemplate.SelectedItem = null;
this.comboBox_WSDPTemplate.ItemsSource = null;
DBManager.Instance.Delete(_currentTemplate);
_wsdpTemplates.Remove(_currentTemplate);
this.textBoxTemplateTitle.Text = null;
this.buttonDeleteTemplate.IsEnabled = false;
this.comboBox_WSDPTemplate.ItemsSource = _wsdpTemplates;
}
}
}
private void buttonUndoTemplate_Click(object sender, RoutedEventArgs e)
{
if (this._undoTemplate != null)
{
this.textBoxPortReceptionFacilityProviderName.Text = this._undoTemplate;
this.buttonUndoTemplate.IsEnabled = false;
this._undoTemplate = null;
this.comboBox_WSDPTemplate.SelectedItem = null;
}
}
// private void buttonAddEntries_Click(object sender, RoutedEventArgs e)
// {
// this.WAS_RCPT.AddMissingWasteReceived();
// }
} }
} }

View File

@ -26,7 +26,7 @@
<ComboBox Name="comboBoxWasteCode" Grid.Row="0" Grid.Column="1" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" /> <ComboBox Name="comboBoxWasteCode" Grid.Row="0" Grid.Column="1" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" />
<TextBox Name="textBoxDescription" Grid.Row="1" Margin="2" Grid.Column="1" Width="auto" MaxLength="99" TextWrapping="Wrap" /> <TextBox Name="textBoxDescription" Grid.Row="1" Margin="2" Grid.Column="1" Width="auto" MaxLength="99" TextWrapping="Wrap" />
<xctk:DoubleUpDown Grid.Row="2" Grid.Column="1" Name="doubleUpDownAmountReceived" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2" FormatString="N3" TextAlignment="Left"/> <xctk:DoubleUpDown Grid.Row="2" Grid.Column="1" Name="doubleUpDownAmountReceived" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2" FormatString="N3" TextAlignment="Left" Maximum="9999.999"/>
</Grid> </Grid>
</enictrl:EditWindowBase> </enictrl:EditWindowBase>

View File

@ -0,0 +1,32 @@
<enictrl:EditWindowBase x:Class="ENI2.EditControls.SelectCrewMemberDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ENI2.EditControls"
xmlns:p="clr-namespace:ENI2.Properties"
mc:Ignorable="d"
Title="{x:Static p:Resources.textSelectCrewMember}" Height="160" Width="400" Background="AliceBlue">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".5*" />
<ColumnDefinition Width=".5*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textLastName}" />
<Label Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textFirstName}" />
<Label Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textCrewFunctionOnBoard}" />
<TextBlock Text="{Binding CrewMemberLastName}" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" />
<TextBlock Text="{Binding CrewMemberFirstName}" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" />
<TextBlock Text="{Binding CrewMemberDuty}" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" />
</Grid>
</enictrl:EditWindowBase>

View File

@ -0,0 +1,41 @@
// Copyright (c) 2017- schick Informatik
// Description:
//
using bsmd.database;
using ENI2.Controls;
using System.Windows;
namespace ENI2.EditControls
{
/// <summary>
/// Interaction logic for SelectCrewMemberDialog.xaml
/// </summary>
public partial class SelectCrewMemberDialog : EditWindowBase
{
public SelectCrewMemberDialog()
{
InitializeComponent();
Loaded += SelectCrewMemberDialog_Loaded;
}
#region Properties
public CREW CREW { get; set; }
#endregion
#region event handler
private void SelectCrewMemberDialog_Loaded(object sender, RoutedEventArgs e)
{
if (CREW != null)
{
this.DataContext = CREW;
}
}
#endregion
}
}

View File

@ -8,7 +8,7 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:p="clr-namespace:ENI2.Properties" xmlns:p="clr-namespace:ENI2.Properties"
mc:Ignorable="d" mc:Ignorable="d"
Title="{x:Static p:Resources.textSelectImportClasses}" Height="600" Width="250" Background="AliceBlue"> Title="{x:Static p:Resources.textSelectImportClasses}" Height="660" Width="250" Background="AliceBlue">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="1*" /> <RowDefinition Height="1*" />

View File

@ -1,14 +1,13 @@
// Copyright (c) 2017-today schick Informatik // Copyright (c) 2017-today schick Informatik
// Description: Select classes for import // Description: Select classes for import via Excel or for sending them once completed
// Returns: Array of selected classes as property // Returns: Array of selected classes as property
using bsmd.database;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Windows; using System.Windows;
using bsmd.database;
namespace ENI2.EditControls namespace ENI2.EditControls
{ {
/// <summary> /// <summary>
@ -17,7 +16,8 @@ namespace ENI2.EditControls
public partial class SelectImportClassesDialog : ENI2.Controls.EditWindowBase public partial class SelectImportClassesDialog : ENI2.Controls.EditWindowBase
{ {
private readonly List<SelectClass> _selectClasses = new List<SelectClass>(); private readonly List<SelectClass> _selectClasses = new List<SelectClass>();
private readonly List<bsmd.database.Message.NotificationClass> _selectedClasses = new List<Message.NotificationClass>(); private readonly List<Message.NotificationClass> _selectedClasses = new List<Message.NotificationClass>();
private readonly List<Message.NotificationClass> _preselectedClasses = new List<Message.NotificationClass>();
public SelectImportClassesDialog() public SelectImportClassesDialog()
{ {
@ -25,33 +25,61 @@ namespace ENI2.EditControls
this.Loaded += SelectImportClassesDialog_Loaded; this.Loaded += SelectImportClassesDialog_Loaded;
} }
/// <summary>
/// List of all message classes that are available for selection
/// </summary>
public List<Message.NotificationClass> SelectedClasses public List<Message.NotificationClass> SelectedClasses
{ {
get { return _selectedClasses; } get { return _selectedClasses; }
} }
/// <summary>
/// Classes that should be checked already when the dialog is opened (relevant for send mode)
/// </summary>
public List<Message.NotificationClass > PreselectedClasses
{
get { return _preselectedClasses; }
}
/// <summary> /// <summary>
/// These messages are needed to derive message classes from, already sorted in the right manner /// These messages are needed to derive message classes from, already sorted in the right manner
/// </summary> /// </summary>
public List<Message> Messages { get; set; } public List<Message> Messages { get; set; }
/// <summary>
/// Flag to reduce selection amount in case of transit
/// </summary>
public bool IsTransit { get; set; } public bool IsTransit { get; set; }
/// <summary>
/// Flag if dialog is used in import mode (default true). Set false for send all mode.
/// </summary>
public bool IsImportMode { get; set; } = true;
private void SelectImportClassesDialog_Loaded(object sender, RoutedEventArgs e) private void SelectImportClassesDialog_Loaded(object sender, RoutedEventArgs e)
{ {
foreach(Message aMessage in this.Messages)
foreach (Message aMessage in this.Messages)
{ {
// these are of no interest
if ((aMessage.MessageNotificationClass == Message.NotificationClass.VISIT) || if ((aMessage.MessageNotificationClass == Message.NotificationClass.VISIT) ||
(aMessage.MessageNotificationClass == Message.NotificationClass.TRANSIT) || (aMessage.MessageNotificationClass == Message.NotificationClass.TRANSIT) ||
(aMessage.MessageNotificationClass == Message.NotificationClass.STO))
continue;
// these are neither imported nor sent by the Send all function
if ((aMessage.MessageNotificationClass == Message.NotificationClass.ATA) ||
(aMessage.MessageNotificationClass == Message.NotificationClass.ATD))
continue;
// filter out messages not relevant for transit
if (IsTransit && (
(aMessage.MessageNotificationClass == Message.NotificationClass.ATA) || (aMessage.MessageNotificationClass == Message.NotificationClass.ATA) ||
(aMessage.MessageNotificationClass == Message.NotificationClass.ATD) || (aMessage.MessageNotificationClass == Message.NotificationClass.ATD) ||
(aMessage.MessageNotificationClass == Message.NotificationClass.STO) (aMessage.MessageNotificationClass == Message.NotificationClass.BKRD) ||
) continue;
if (IsTransit &&
((aMessage.MessageNotificationClass == Message.NotificationClass.BKRD) ||
(aMessage.MessageNotificationClass == Message.NotificationClass.BPOL) ||
(aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) || (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) ||
(aMessage.MessageNotificationClass == Message.NotificationClass.INFO) || (aMessage.MessageNotificationClass == Message.NotificationClass.INFO) ||
(aMessage.MessageNotificationClass == Message.NotificationClass.LADG) || (aMessage.MessageNotificationClass == Message.NotificationClass.LADG) ||
@ -65,12 +93,13 @@ namespace ENI2.EditControls
)) continue; )) continue;
SelectClass sc = new SelectClass(); SelectClass sc = new SelectClass();
sc.Name = Enum.GetName(typeof(bsmd.database.Message.NotificationClass), aMessage.MessageNotificationClass); sc.Name = Enum.GetName(typeof(Message.NotificationClass), aMessage.MessageNotificationClass);
sc.Class = aMessage.MessageNotificationClass; sc.Class = aMessage.MessageNotificationClass;
sc.IsSelected = false; sc.IsSelected = this._preselectedClasses.Contains(sc.Class);
_selectClasses.Add(sc); _selectClasses.Add(sc);
} }
this.checkListBoxClasses.ItemsSource = _selectClasses; this.checkListBoxClasses.ItemsSource = _selectClasses;
this.OKClicked += SelectImportClassesDialog_OKClicked; this.OKClicked += SelectImportClassesDialog_OKClicked;
} }

View File

@ -44,7 +44,8 @@ namespace ENI2.EditControls
private void Window_Loaded(object sender, RoutedEventArgs e) private void Window_Loaded(object sender, RoutedEventArgs e)
{ {
_portAreas = LocalizedLookup.getPortAreaInfos()[this._poc]; if(LocalizedLookup.getPortAreaInfos().ContainsKey(this._poc))
_portAreas = LocalizedLookup.getPortAreaInfos()[this._poc];
this.labelLocode.Content = this._poc; this.labelLocode.Content = this._poc;
} }
@ -64,7 +65,7 @@ namespace ENI2.EditControls
private void textBoxSearchDescription_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) private void textBoxSearchDescription_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{ {
string searchText = this.textBoxSearchDescription.Text.Trim(); string searchText = this.textBoxSearchDescription.Text.Trim();
if (_portAreas == null) return;
lock (filterLock) lock (filterLock)
{ {
IEnumerable<PortAreaInfo> filtered = _portAreas; IEnumerable<PortAreaInfo> filtered = _portAreas;

View File

@ -52,7 +52,7 @@
ButtonSpinnerLocation="Right" ButtonSpinnerLocation="Right"
ParsingNumberStyle="Integer" ParsingNumberStyle="Integer"
Watermark="Enter ENI" ValueChanged="doubleUpDownENI_ValueChanged" TextAlignment="Left"/> Watermark="Enter ENI" ValueChanged="doubleUpDownENI_ValueChanged" TextAlignment="Left"/>
<enictrl:LocodeControl Grid.Column="1" Grid.Row="2" Width="Auto" x:Name="locodePoC" LocodeValue="{Binding PoC, Mode=TwoWay}" /> <enictrl:LocodeControl Grid.Column="1" Grid.Row="2" Width="Auto" x:Name="locodePoC" LocodeValue="{Binding PoC, Mode=TwoWay}" LocodeSource="OLD" />
<DatePicker Name="datePickerETA" Grid.Row="3" Grid.Column="1" Margin="2" SelectedDateChanged="datePickerETA_SelectedDateChanged" DisplayDateStart="1/1/1900" DisplayDateEnd="12/31/2199" PreviewKeyUp="DateTimePicker_PreviewKeyUpDate"> <DatePicker Name="datePickerETA" Grid.Row="3" Grid.Column="1" Margin="2" SelectedDateChanged="datePickerETA_SelectedDateChanged" DisplayDateStart="1/1/1900" DisplayDateEnd="12/31/2199" PreviewKeyUp="DateTimePicker_PreviewKeyUpDate">
<DatePicker.BlackoutDates> <DatePicker.BlackoutDates>
<CalendarDateRange Start="1/1/0001" End="12/31/1799"/> <CalendarDateRange Start="1/1/0001" End="12/31/1799"/>

View File

@ -133,7 +133,7 @@ namespace ENI2.EditControls
isComplete &= imo_OR_eni; isComplete &= imo_OR_eni;
string locode = this.locodePoC.LocodeValue; string locode = this.locodePoC.LocodeValue;
bool validLocode = (locode != null) && (locode.Length == 5) && (locode.StartsWith("DE") || locode.StartsWith("DK") || locode.Equals("ZZNOK")); bool validLocode = (locode != null) && (locode.Length == 5) && (locode.StartsWith("DE") || locode.StartsWith("DK") || locode.Equals("ZZNOK") || locode.Equals("DEWHV"));
isComplete &= validLocode; isComplete &= validLocode;

View File

@ -83,7 +83,7 @@ namespace ENI2.Excel
if ((message.MessageNotificationClass == Message.NotificationClass.HAZD) && notificationClasses.Contains(Message.NotificationClass.HAZD)) if ((message.MessageNotificationClass == Message.NotificationClass.HAZD) && notificationClasses.Contains(Message.NotificationClass.HAZD))
{ if (ScanHAZD(message, reader)) ExcelReader.SaveMessage(message); continue; } { if (ScanHAZD(message, reader)) ExcelReader.SaveMessage(message); continue; }
if ((message.MessageNotificationClass == Message.NotificationClass.INFO) && notificationClasses.Contains(Message.NotificationClass.INFO)) if ((message.MessageNotificationClass == Message.NotificationClass.INFO) && notificationClasses.Contains(Message.NotificationClass.INFO))
{ if (ScanINFO(message, reader)) ExcelReader.SaveMessage(message); continue; } { if (ScanINFO(message, messageCore, reader)) ExcelReader.SaveMessage(message); continue; }
if ((message.MessageNotificationClass == Message.NotificationClass.LADG) && notificationClasses.Contains(Message.NotificationClass.LADG)) if ((message.MessageNotificationClass == Message.NotificationClass.LADG) && notificationClasses.Contains(Message.NotificationClass.LADG))
{ if (ScanLADG(message, reader)) ExcelReader.SaveMessage(message); continue; } { if (ScanLADG(message, reader)) ExcelReader.SaveMessage(message); continue; }
if ((message.MessageNotificationClass == Message.NotificationClass.MDH) && notificationClasses.Contains(Message.NotificationClass.MDH)) if ((message.MessageNotificationClass == Message.NotificationClass.MDH) && notificationClasses.Contains(Message.NotificationClass.MDH))
@ -740,7 +740,7 @@ namespace ENI2.Excel
pas.PassengerLastName = lastName; pas.PassengerLastName = lastName;
pas.PassengerFirstName = reader.ReadCellAsText("passenger departure", string.Format("C{0}", i + 16)); pas.PassengerFirstName = reader.ReadCellAsText("passenger departure", string.Format("C{0}", i + 16));
pas.PassengerPlaceOfBirth = reader.ReadCellAsText("passenger departure", string.Format("D{0}", i + 16)); pas.PassengerPlaceOfBirth = reader.ReadCellAsText("passenger departure", string.Format("D{0}", i + 16));
pas.PassengerCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger departure", string.Format("E{0}", i + 16)), out bool canceled); pas.PassengerCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger departure", string.Format("E{0}", i + 16)), out bool canceled, false);
if (canceled) return false; if (canceled) return false;
pas.PassengerDateOfBirth = reader.ReadCellAsDateTime("passenger departure", string.Format("F{0}", i + 16)); pas.PassengerDateOfBirth = reader.ReadCellAsDateTime("passenger departure", string.Format("F{0}", i + 16));
pas.PassengerGender = ParseGender(reader.ReadCellAsText("passenger departure", string.Format("G{0}", i + 16))); pas.PassengerGender = ParseGender(reader.ReadCellAsText("passenger departure", string.Format("G{0}", i + 16)));
@ -802,7 +802,7 @@ namespace ENI2.Excel
pas.PassengerLastName = lastName; pas.PassengerLastName = lastName;
pas.PassengerFirstName = reader.ReadCellAsText("passenger arrival", string.Format("C{0}", i + 16)); pas.PassengerFirstName = reader.ReadCellAsText("passenger arrival", string.Format("C{0}", i + 16));
pas.PassengerPlaceOfBirth = reader.ReadCellAsText("passenger arrival", string.Format("D{0}", i + 16)); pas.PassengerPlaceOfBirth = reader.ReadCellAsText("passenger arrival", string.Format("D{0}", i + 16));
pas.PassengerCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger arrival", string.Format("E{0}", i + 16)), out bool canceled); pas.PassengerCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger arrival", string.Format("E{0}", i + 16)), out bool canceled, false);
if (canceled) return false; if (canceled) return false;
pas.PassengerDateOfBirth = reader.ReadCellAsDateTime("passenger arrival", string.Format("F{0}", i + 16)); pas.PassengerDateOfBirth = reader.ReadCellAsDateTime("passenger arrival", string.Format("F{0}", i + 16));
pas.PassengerGender = ParseGender(reader.ReadCellAsText("passenger arrival", string.Format("G{0}", i + 16))); pas.PassengerGender = ParseGender(reader.ReadCellAsText("passenger arrival", string.Format("G{0}", i + 16)));
@ -1117,7 +1117,7 @@ namespace ENI2.Excel
#region INFO #region INFO
private static bool ScanINFO(Message infoMessage, ExcelReader reader) private static bool ScanINFO(Message infoMessage, MessageCore core, ExcelReader reader)
{ {
if (infoMessage.Elements.Count == 0) if (infoMessage.Elements.Count == 0)
{ {
@ -1144,6 +1144,25 @@ namespace ENI2.Excel
else else
info.PortArea = ""; info.PortArea = "";
// März 2024: Spezialfall für Abrechnungsabteilung Bremenports: Feld wird markiert (falls genügend Platz)
// falls das Schiff nach DEBRE oder DEBHV geht:
if (core.PoC.Equals("DEBRE") || core.PoC.Equals("DEBRV"))
{
if (info.SpecialRequirementsOfShipAtBerth == null)
{
info.SpecialRequirementsOfShipAtBerth = "NSW by BSMD";
}
else if (info.SpecialRequirementsOfShipAtBerth.Length <= 241) // we have enough space
{
if (info.SpecialRequirementsOfShipAtBerth.Length > 0) // if there is text already add a separator
{
info.SpecialRequirementsOfShipAtBerth += " | ";
}
info.SpecialRequirementsOfShipAtBerth += "NSW by BSMD";
}
}
return true; return true;
} }
@ -1188,7 +1207,7 @@ namespace ENI2.Excel
crew.CrewMemberLastName = lastName; crew.CrewMemberLastName = lastName;
crew.CrewMemberFirstName = reader.ReadCellAsText("crew departure", string.Format("C{0}", i + 15)); crew.CrewMemberFirstName = reader.ReadCellAsText("crew departure", string.Format("C{0}", i + 15));
crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText("crew departure", string.Format("D{0}", i + 15)); crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText("crew departure", string.Format("D{0}", i + 15));
crew.CrewMemberCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("crew departure", string.Format("E{0}", i + 15)), out bool canceled); crew.CrewMemberCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("crew departure", string.Format("E{0}", i + 15)), out bool canceled, false);
if (canceled) return false; if (canceled) return false;
crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime("crew departure", string.Format("F{0}", i + 15)); crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime("crew departure", string.Format("F{0}", i + 15));
string gender = reader.ReadCellAsText("crew departure", string.Format("G{0}", i + 15)); string gender = reader.ReadCellAsText("crew departure", string.Format("G{0}", i + 15));
@ -1205,6 +1224,7 @@ namespace ENI2.Excel
crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime("crew departure", string.Format("N{0}", i + 15)); crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime("crew departure", string.Format("N{0}", i + 15));
crew.CrewMemberDuty = reader.ReadCellAsText("crew departure", string.Format("L{0}", i + 15)); crew.CrewMemberDuty = reader.ReadCellAsText("crew departure", string.Format("L{0}", i + 15));
if (crew.CrewMemberDuty.IsNullOrEmpty()) crew.CrewMemberDuty = "unknown";
result = true; result = true;
} }
@ -1237,7 +1257,7 @@ namespace ENI2.Excel
crew.CrewMemberLastName = lastName; crew.CrewMemberLastName = lastName;
crew.CrewMemberFirstName = reader.ReadCellAsText("crew arrival", string.Format("C{0}", i + 15)); crew.CrewMemberFirstName = reader.ReadCellAsText("crew arrival", string.Format("C{0}", i + 15));
crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText("crew arrival", string.Format("D{0}", i + 15)); crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText("crew arrival", string.Format("D{0}", i + 15));
crew.CrewMemberCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("crew arrival", string.Format("E{0}", i + 15)), out bool canceled); crew.CrewMemberCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("crew arrival", string.Format("E{0}", i + 15)), out bool canceled, false);
if (canceled) return false; if (canceled) return false;
crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime("crew arrival", string.Format("F{0}", i + 15)); crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime("crew arrival", string.Format("F{0}", i + 15));
string gender = reader.ReadCellAsText("crew arrival", string.Format("G{0}", i + 15)); string gender = reader.ReadCellAsText("crew arrival", string.Format("G{0}", i + 15));
@ -1254,6 +1274,7 @@ namespace ENI2.Excel
crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime("crew arrival", string.Format("N{0}", i + 15)); crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime("crew arrival", string.Format("N{0}", i + 15));
crew.CrewMemberDuty = reader.ReadCellAsText("crew arrival", string.Format("L{0}", i + 15)); crew.CrewMemberDuty = reader.ReadCellAsText("crew arrival", string.Format("L{0}", i + 15));
if (crew.CrewMemberDuty.IsNullOrEmpty()) crew.CrewMemberDuty = "unknown";
result = true; result = true;
} }

View File

@ -1,12 +1,15 @@
// Copyright (c) 2017-today Informatikbüro Daniel Schick // Copyright (c) 2017-today Informatikbüro Daniel Schick
// Base class excel (writer not yet implemented but eventually..) // Base class excel access (named ranges, colorizing, etc.)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Office.Interop.Excel; using ClosedXML.Excel;
using System.Runtime.InteropServices;
using log4net; using log4net;
using System.Globalization; using System.Globalization;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Linq;
using System.IO;
namespace ENI2.Excel namespace ENI2.Excel
{ {
@ -19,10 +22,9 @@ namespace ENI2.Excel
protected CountryMode _countryMode = CountryMode.DE; protected CountryMode _countryMode = CountryMode.DE;
protected Workbooks _excelWorkbooks; protected XLWorkbook _workBook;
protected Workbook _workBook; protected FileStream _workBookStream;
protected Application _excelApp; protected Dictionary<string, IXLDefinedName> _nameDict;
protected Dictionary<string, Name> _nameDict;
protected ILog _log; protected ILog _log;
#endregion Fields #endregion Fields
@ -31,12 +33,7 @@ namespace ENI2.Excel
public ExcelBase() public ExcelBase()
{ {
_log = LogManager.GetLogger(this.GetType().Name); _log = LogManager.GetLogger(this.GetType().Name);
this._excelApp = new Application();
this._excelApp.DisplayAlerts = false;
this._excelWorkbooks = _excelApp.Workbooks;
} }
#endregion Construction #endregion Construction
@ -45,9 +42,9 @@ namespace ENI2.Excel
internal CountryMode Mode { get { return _countryMode; } } internal CountryMode Mode { get { return _countryMode; } }
internal Dictionary<string, Name> NameDict { get { return _nameDict; } } internal Dictionary<string, IXLDefinedName> NameDict { get { return _nameDict; } }
internal Sheets Worksheets { get { return _workBook.Worksheets; } } internal IXLWorksheets Worksheets { get { return _workBook?.Worksheets; } }
#endregion #endregion
@ -55,17 +52,17 @@ namespace ENI2.Excel
protected void InitNameFields() protected void InitNameFields()
{ {
_nameDict = new Dictionary<string, Name>(); _nameDict = new Dictionary<string, IXLDefinedName>();
int bookCnt = 0; int bookCnt = 0;
foreach (Name name in _workBook.Names)
{
string theValue = name.Value;
// Namensbezug: =SheetZelle. Leere Referenzen überspringen (kommt immer mal wieder vor!)
string nameKey = name.Name; // Get workbook-level defined names
foreach (var definedName in _workBook.DefinedNames)
{
string nameKey = definedName.Name;
try try
{ {
// Handle sheet-scoped names (Sheet1!Name format)
if (nameKey.Contains("!")) if (nameKey.Contains("!"))
nameKey = nameKey.Substring(nameKey.IndexOf('!') + 1); nameKey = nameKey.Substring(nameKey.IndexOf('!') + 1);
} }
@ -75,36 +72,57 @@ namespace ENI2.Excel
continue; continue;
} }
if ((theValue != "=#REF!#REF!") && (theValue != "=#BEZUG!#BEZUG!")) // Check if the defined name is valid (not a broken reference)
if (definedName.IsValid)
{ {
_nameDict[nameKey] = name; _nameDict[nameKey] = definedName;
bookCnt++; bookCnt++;
} }
} }
_log.DebugFormat("{0} named ranges found at Workbook level", bookCnt); _log.DebugFormat("{0} defined names found at Workbook level", bookCnt);
// Get worksheet-level defined names
foreach (Worksheet ws in _workBook.Worksheets) foreach (var ws in _workBook.Worksheets)
{ {
int wsCnt = 0; int wsCnt = 0;
foreach (Name name in ws.Names) foreach (var definedName in ws.DefinedNames)
{ {
string theValue = name.Value; string nameKey = definedName.Name;
// Namensbezug: =SheetZelle. Leere Referenzen überspringen (kommt immer mal wieder vor!)
if (!_nameDict.ContainsKey(name.Name)) if (!_nameDict.ContainsKey(nameKey))
{ {
if ((theValue != "=#REF!#REF!") && (theValue != "=#BEZUG!#BEZUG!")) if (definedName.IsValid)
{ {
_nameDict[name.Name] = name; _nameDict[nameKey] = definedName;
wsCnt++; wsCnt++;
} }
} }
} }
if (wsCnt > 0) if (wsCnt > 0)
_log.DebugFormat("{0} named ranges found in Worksheet {1}", wsCnt, ws.Name); _log.DebugFormat("{0} defined names found in Worksheet {1}", wsCnt, ws.Name);
} }
} }
protected void OpenWorkbookReadOnly(string path)
{
_workBookStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
_workBook = new XLWorkbook(_workBookStream);
}
private static double? ParseAnyDouble(string val)
{
double? result = null;
if (double.TryParse(val, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite,
CultureInfo.InvariantCulture, out double tmpDouble))
result = tmpDouble;
if (result == null)
{
if (double.TryParse(val, out tmpDouble)) // current language style (==GER, mit , statt .)
result = tmpDouble;
}
return result;
}
internal double? ReadNumber(string lookup) internal double? ReadNumber(string lookup)
{ {
double? result = null; double? result = null;
@ -112,24 +130,39 @@ namespace ENI2.Excel
{ {
if (_nameDict.ContainsKey(lookup)) if (_nameDict.ContainsKey(lookup))
{ {
var val = _nameDict[lookup].RefersToRange.Value; var definedName = _nameDict[lookup];
if (val is double) result = val; var ranges = definedName.Ranges;
if (val is string) var range = ranges.FirstOrDefault();
{
if (double.TryParse(val, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite,
CultureInfo.InvariantCulture, out double tmpDouble))
result = tmpDouble;
if (result == null)
{
if (double.TryParse(val, out tmpDouble)) // current language style (==GER, mit , statt .)
result = tmpDouble;
}
}
if ((result == null) && (val != null)) if (range != null)
{ {
double tmpDouble2 = val[1, 1]; var cell = range.FirstCell();
result = tmpDouble2; if (cell != null)
{
var cellValue = cell.Value;
if (cellValue.IsNumber)
{
result = cellValue.GetNumber();
}
else if (cellValue.IsText)
{
string textVal = cellValue.GetText();
if (!string.IsNullOrEmpty(textVal))
{
result = ParseAnyDouble(textVal);
if (result == null)
{
Match m = Regex.Match(textVal, "([0-9\\.\\,]+)([a-zA-Z]*)");
if (m.Success)
{
result = ParseAnyDouble(m.Groups[1].Value);
}
}
}
}
}
} }
} }
} }
@ -142,17 +175,26 @@ namespace ENI2.Excel
internal void Colorize(string lookup, int color) internal void Colorize(string lookup, int color)
{ {
if(_nameDict.ContainsKey(lookup)) if (_nameDict.ContainsKey(lookup))
{ {
var range = _nameDict[lookup].RefersToRange; var definedName = _nameDict[lookup];
Colorize(range, color); var ranges = definedName.Ranges;
var range = ranges.FirstOrDefault();
if (range != null)
{
Colorize(range, color);
}
} }
} }
internal void Colorize(Range range, int color) internal void Colorize(IXLRange range, int color)
{ {
range.Interior.Color = color; // Convert int color to Color object
range.Worksheet.Tab.Color = color; Color backgroundColor = Color.FromArgb(color);
range.Style.Fill.BackgroundColor = XLColor.FromColor(backgroundColor);
// Set worksheet tab color
range.Worksheet.SetTabColor(XLColor.FromColor(backgroundColor));
} }
#endregion #endregion
@ -161,9 +203,7 @@ namespace ENI2.Excel
public void Save(string path) public void Save(string path)
{ {
this._workBook.SaveAs(path, XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, _workBook.SaveAs(path);
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
this._workBook.Saved = true;
} }
#endregion #endregion
@ -174,29 +214,21 @@ namespace ENI2.Excel
{ {
try try
{ {
if (this._workBook != null) if (_workBook != null)
{ {
this._workBook.Close(0); _log.Debug("Disposing Workbook");
_log.Debug("Close Worksheet"); _workBook.Dispose();
Marshal.ReleaseComObject(this._workBook); _workBook = null;
} }
if (_workBookStream != null)
if (this._excelWorkbooks != null)
{ {
this._excelWorkbooks.Close(); _workBookStream.Dispose();
_log.Debug("Close Workbooks"); _workBookStream = null;
Marshal.ReleaseComObject(this._excelWorkbooks);
}
if (this._excelApp != null)
{
_log.Debug("Quit Excel");
this._excelApp.Quit();
Marshal.ReleaseComObject(this._excelApp);
} }
} }
catch(Exception ex) catch (Exception ex)
{ {
_log.ErrorFormat("Exception disposing ExcelReader: {0}", ex.Message); _log.ErrorFormat("Exception disposing ExcelBase: {0}", ex.Message);
} }
} }

View File

@ -4,8 +4,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Drawing; using ClosedXML.Excel;
using Microsoft.Office.Interop.Excel;
namespace ENI2.Excel namespace ENI2.Excel
{ {
@ -17,29 +16,27 @@ namespace ENI2.Excel
/// </summary> /// </summary>
public static class ExcelComparer public static class ExcelComparer
{ {
private static readonly int diffColor = ColorTranslator.ToOle(Color.FromArgb(150, 150, 255)); // blue private static readonly XLColor diffColor = XLColor.FromArgb(150, 150, 255); // blue
private static bool GetSheetRange(Worksheet sheet, out int lastUsedRow, out int lastUsedColumn) private static bool GetSheetRange(IXLWorksheet sheet, out int lastUsedRow, out int lastUsedColumn)
{ {
try try
{ {
// sheet.Columns.ClearFormats(); var usedRange = sheet.RangeUsed();
// sheet.Rows.ClearFormats(); if (usedRange != null)
Range usedRange = sheet.UsedRange; {
lastUsedRow = usedRange.Rows.Count; lastUsedRow = usedRange.RowCount();
lastUsedColumn = usedRange.Columns.Count; lastUsedColumn = usedRange.ColumnCount();
return true;
/* }
Range last = sheet.Cells.SpecialCells(XlCellType.xlCellTypeLastCell, Type.Missing); else
Range range = sheet.get_Range("A1", last); {
lastUsedColumn = 0;
lastUsedRow = last.Row; lastUsedRow = 0;
lastUsedColumn = last.Column; return false;
*/ }
return true;
} }
catch(Exception) catch (Exception)
{ {
lastUsedColumn = 0; lastUsedColumn = 0;
lastUsedRow = 0; lastUsedRow = 0;
@ -47,20 +44,6 @@ namespace ENI2.Excel
} }
} }
private static string GetExcelColumnName(int columnNumber)
{
string columnName = "";
while (columnNumber > 0)
{
int modulo = (columnNumber - 1) % 26;
columnName = Convert.ToChar('A' + modulo) + columnName;
columnNumber = (columnNumber - modulo) / 26;
}
return columnName;
}
public static string Compare(string sourcePath, string targetPath, string comparisonFileName, out string errorMessage) public static string Compare(string sourcePath, string targetPath, string comparisonFileName, out string errorMessage)
{ {
errorMessage = ""; errorMessage = "";
@ -68,122 +51,107 @@ namespace ENI2.Excel
try try
{ {
File.Copy(targetPath, comparisonFileName); File.Copy(targetPath, comparisonFileName, true);
ExcelReader source = new ExcelReader(sourcePath, true, false);
ExcelReader comparison = new ExcelReader(comparisonFileName, false, false);
/* erste Variante Vergleich über Namen der Zellen using (var sourceStream = new FileStream(sourcePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var sourceWorkbook = new XLWorkbook(sourceStream))
// loop through named cells using (var comparisonWorkbook = new XLWorkbook(comparisonFileName))
foreach (string name in comparison.NameDict.Keys)
{ {
if (!source.NameDict.ContainsKey(name)) continue; // Es werden Zellen der "used range" miteinander verglichen
string sourceText = source.ReadText(name); foreach (var sourceSheet in sourceWorkbook.Worksheets)
string targetText = comparison.ReadText(name);
if (sourceText == null)
{ {
if (targetText != null) IXLWorksheet targetSheet = null;
foreach (var sheet in comparisonWorkbook.Worksheets)
{ {
comparison.Colorize(name, diffColor); if (sourceSheet.Name.Equals(sheet.Name))
counter++;
}
}
else if (targetText == null)
{
if (sourceText != null)
{
comparison.Colorize(name, diffColor);
counter++;
}
}
else if ((sourceText != null) && (targetText != null))
{
if (!sourceText.Equals(targetText))
{
// turn cell blue
comparison.Colorize(name, diffColor);
counter++;
}
}
}
*/
// Zweite Version durch alle Sheets werden Zellen der "used range" miteinander verglichen
foreach(Worksheet sourceSheet in source.Worksheets)
{
Worksheet targetSheet = null;
foreach(Worksheet sheet in comparison.Worksheets)
{
if (sourceSheet.Name.Equals(sheet.Name))
{
targetSheet = sheet;
break;
}
}
if (targetSheet == null) continue;
System.Diagnostics.Trace.WriteLine(string.Format("Processing sheet {0}", targetSheet.Name));
if(GetSheetRange(sourceSheet, out int sourceRows, out int sourceCols) && GetSheetRange(targetSheet, out int targetRows, out int targetCols))
{
// read source into 2 dim array
string rangeString = string.Format("A1:{0}{1}", GetExcelColumnName(Math.Max(sourceCols, targetCols)), Math.Max(sourceRows, targetRows));
object[,] sourceArray = sourceSheet.get_Range(rangeString).Value;
// read target into 2 dim array
object[,] targetArray = targetSheet.get_Range(rangeString).Value;
for (int rowidx = 1; rowidx <= Math.Max(sourceRows, targetRows); rowidx++)
{
for( int colidx = 1; colidx <= Math.Max(sourceCols, targetCols); colidx++)
{ {
string sourceText = null; targetSheet = sheet;
if(sourceArray[rowidx,colidx] != null) sourceText = sourceArray[rowidx,colidx].ToString(); break;
string targetText = null;
if(targetArray[rowidx,colidx] != null) targetText = targetArray[rowidx, colidx].ToString();
if (sourceText == null)
{
if (targetText != null)
{
string targetRangeName = string.Format("{0}{1}", GetExcelColumnName(colidx), rowidx);
comparison.Colorize(targetSheet.Range[targetRangeName], diffColor);
counter++;
}
}
else if (targetText == null)
{
if (sourceText != null)
{
string targetRangeName = string.Format("{0}{1}", GetExcelColumnName(colidx), rowidx);
comparison.Colorize(targetSheet.Range[targetRangeName], diffColor);
counter++;
}
}
else if ((sourceText != null) && (targetText != null))
{
if (!sourceText.Equals(targetText))
{
string targetRangeName = string.Format("{0}{1}", GetExcelColumnName(colidx), rowidx);
// turn cell blue
comparison.Colorize(targetSheet.Range[targetRangeName], diffColor);
counter++;
}
}
} }
} }
}
else
{
errorMessage = "failed to get sheet ranges";
}
}
comparison.Save(comparisonFileName); if (targetSheet == null) continue;
source.Dispose(); System.Diagnostics.Trace.WriteLine(string.Format("Processing sheet {0}", targetSheet.Name));
comparison.Dispose();
if (GetSheetRange(sourceSheet, out int sourceRows, out int sourceCols) && GetSheetRange(targetSheet, out int targetRows, out int targetCols))
{
int maxRows = Math.Max(sourceRows, targetRows);
int maxCols = Math.Max(sourceCols, targetCols);
bool sheetHasDiffs = false;
for (int rowidx = 1; rowidx <= maxRows; rowidx++)
{
for (int colidx = 1; colidx <= maxCols; colidx++)
{
string sourceText = null;
string targetText = null;
// Get source cell value
if (rowidx <= sourceRows && colidx <= sourceCols)
{
var sourceCell = sourceSheet.Cell(rowidx, colidx);
if (!sourceCell.IsEmpty())
{
sourceText = sourceCell.GetString();
}
}
// Get target cell value
if (rowidx <= targetRows && colidx <= targetCols)
{
var targetCell = targetSheet.Cell(rowidx, colidx);
if (!targetCell.IsEmpty())
{
targetText = targetCell.GetString();
}
}
if (sourceText == null)
{
if (targetText != null)
{
var cellToHighlight = targetSheet.Cell(rowidx, colidx);
cellToHighlight.Style.Fill.BackgroundColor = diffColor;
counter++;
sheetHasDiffs = true;
}
}
else if (targetText == null)
{
if (sourceText != null)
{
var cellToHighlight = targetSheet.Cell(rowidx, colidx);
cellToHighlight.Style.Fill.BackgroundColor = diffColor;
counter++;
sheetHasDiffs = true;
}
}
else if ((sourceText != null) && (targetText != null))
{
if (!sourceText.Equals(targetText))
{
var cellToHighlight = targetSheet.Cell(rowidx, colidx);
cellToHighlight.Style.Fill.BackgroundColor = diffColor;
counter++;
sheetHasDiffs = true;
}
}
}
}
if (sheetHasDiffs)
{
targetSheet.SetTabColor(diffColor);
}
}
else
{
errorMessage = "failed to get sheet ranges";
}
}
comparisonWorkbook.SaveAs(comparisonFileName);
}
errorMessage = string.Format("{0} differences found", counter); errorMessage = string.Format("{0} differences found", counter);
} }
catch (Exception ex) catch (Exception ex)
@ -193,6 +161,5 @@ namespace ENI2.Excel
return comparisonFileName; return comparisonFileName;
} }
} }
} }

View File

@ -0,0 +1,333 @@
using bsmd.database;
using ClosedXML.Excel;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
namespace ENI2.Excel
{
internal static class ExcelLocalImportHelper
{
#region Last 10 Port Facilities Called Import from Excel
public static int ImportLast10PortFacilities(SEC sec)
{
int cnt = 0;
OpenFileDialog ofd = new OpenFileDialog
{
Filter = "Excel Files|*.xls;*.xlsx"
};
if (ofd.ShowDialog() ?? false)
{
try
{
using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var workbook = new XLWorkbook(stream))
{
var worksheet = workbook.Worksheet(1);
var rows = worksheet.RangeUsed().RowsUsed();
int columnCount = worksheet.RangeUsed().ColumnCount();
// Check minimum columns upfront
if (columnCount < 8)
{
throw new InvalidDataException("Sheet must have at least 8 Columns of data");
}
List<LastTenPortFacilitiesCalled> importL10C = new List<LastTenPortFacilitiesCalled>();
foreach (var row in rows)
{
if (cnt >= 10) break; // Maximum 10 rows
// Skip empty rows
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
LastTenPortFacilitiesCalled l10c = new LastTenPortFacilitiesCalled();
try
{
// Column 1: Port Name
if (!row.Cell(1).IsEmpty())
l10c.PortFacilityPortName = row.Cell(1).GetString();
// Column 3: Country
if (!row.Cell(3).IsEmpty())
l10c.PortFacilityPortCountry = row.Cell(3).GetString();
// Column 4: Locode
if (!row.Cell(4).IsEmpty())
l10c.PortFacilityPortLoCode = row.Cell(4).GetString();
// Column 5: Arrival Date
if (!row.Cell(5).IsEmpty())
{
l10c.PortFacilityDateOfArrival = row.Cell(5).GetDateTime();
}
// Column 6: Departure Date
if (!row.Cell(6).IsEmpty())
{
l10c.PortFacilityDateOfDeparture = row.Cell(6).GetDateTime();
}
// Column 7: Security Level (byte)
if (!row.Cell(7).IsEmpty())
{
l10c.PortFacilityShipSecurityLevel = row.Cell(7).GetValue<byte>();
}
// Column 8: GISIS Code
if (!row.Cell(8).IsEmpty())
{
int gisis = row.Cell(8).GetValue<int>();
l10c.PortFacilityGISISCode = gisis.ToString().PadLeft(4, '0');
}
// Column 9: Security Matters (optional, can be beyond minimum columns)
if (columnCount >= 9 && !row.Cell(9).IsEmpty())
{
l10c.PortFacilitySecurityMattersToReport = row.Cell(9).GetString();
if (l10c.PortFacilitySecurityMattersToReport?.Equals("nil", StringComparison.OrdinalIgnoreCase) == true)
l10c.PortFacilitySecurityMattersToReport = null;
}
// Column 10: GISIS Code Locode (optional, can be beyond minimum columns)
if (columnCount >= 10 && !row.Cell(10).IsEmpty())
{
l10c.PortFacilityGISISCodeLocode = row.Cell(10).GetString();
}
l10c.SEC = sec;
l10c.IsDirty = true;
l10c.Identifier = LastTenPortFacilitiesCalled.GetNewIdentifier(sec.LastTenPortFacilitesCalled);
sec.LastTenPortFacilitesCalled.Add(l10c);
importL10C.Add(l10c);
cnt++;
}
catch (Exception ex)
{
throw new InvalidDataException($"Error processing row {row.RowNumber()}: {ex.Message}", ex);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError,
MessageBoxButton.OK, MessageBoxImage.Error);
}
}
return cnt;
}
#endregion
#region Last 30 days Import from Excel
public static int ImportLast30Days(MDH mdh)
{
int cnt = 0;
OpenFileDialog ofd = new OpenFileDialog
{
Filter = "Excel Files|*.xls;*.xlsx"
};
if (ofd.ShowDialog() ?? false)
{
try
{
using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var workbook = new XLWorkbook(stream))
{
var worksheet = workbook.Worksheet(1);
var rows = worksheet.RangeUsed().RowsUsed();
int columnCount = worksheet.RangeUsed().ColumnCount();
List<PortOfCallLast30Days> importPoC30 = new List<PortOfCallLast30Days>();
foreach (var row in rows)
{
if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
if (columnCount < 3)
{
throw new InvalidDataException("Sheet must have at least 3 Columns of data");
}
PortOfCallLast30Days poc30 = new PortOfCallLast30Days();
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
// Safer locode extraction
if (!row.Cell(1).IsEmpty())
{
try
{
poc30.PortOfCallLast30DaysLocode = row.Cell(1).GetString();
}
catch (Exception ex)
{
throw new InvalidDataException($"Invalid locode in row {row.RowNumber()}: {ex.Message}");
}
}
// Safer date extraction
if (!row.Cell(2).IsEmpty())
{
try
{
poc30.PortOfCallLast30DaysDateOfDeparture = row.Cell(2).GetDateTime();
}
catch (Exception ex)
{
throw new InvalidDataException($"Invalid date in row {row.RowNumber()}: {ex.Message}");
}
}
// Safer boolean extraction
string boolString = "";
if (!row.Cell(3).IsEmpty())
{
boolString = row.Cell(3).GetString()?.Trim() ?? "";
}
poc30.PortOfCallLast30DaysCrewMembersJoined = (
boolString.Equals("y", StringComparison.OrdinalIgnoreCase) ||
boolString.Equals("yes", StringComparison.OrdinalIgnoreCase) ||
boolString.Equals("j", StringComparison.OrdinalIgnoreCase));
// FIX: Check column count before accessing column 4
if (columnCount >= 4)
{
string allNewCrew = row.Cell(4).IsEmpty() ? null : row.Cell(4).GetString()?.Trim();
if (!allNewCrew.IsNullOrEmpty())
{
string[] crewNames = allNewCrew.Split(',', ';');
foreach (string crewName in crewNames)
{
string trimmedName = crewName.Trim();
if (trimmedName.IsNullOrEmpty()) continue;
PortOfCallLast30DaysCrewJoinedShip poc30Crew = new PortOfCallLast30DaysCrewJoinedShip
{
PortOfCallLast30DaysCrewJoinedShipName = trimmedName,
PortOfCallLast30Days = poc30
};
poc30.CrewJoinedShip.Add(poc30Crew);
}
}
}
poc30.MDH = mdh;
mdh.PortOfCallLast30Days.Add(poc30);
importPoC30.Add(poc30);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError,
MessageBoxButton.OK, MessageBoxImage.Error);
}
}
return cnt;
}
#endregion
#region Waste from Excel
public static int ImportWaste(WAS was)
{
int cnt = 0;
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Excel Files|*.xls;*.xlsx";
if (ofd.ShowDialog() ?? false)
{
try
{
using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var workbook = new XLWorkbook(stream))
{
var worksheet = workbook.Worksheet(1); // Get first worksheet
var rows = worksheet.RangeUsed().RowsUsed().Skip(3); // Skip first three rows
List<Waste> importWasteList = new List<Waste>();
object o = null;
// Diese Funktion kann das "alte" Sheet Format nicht mehr einlesen!
foreach (var row in rows)
{
if (cnt >= 35) break; // Maximum 35 rows
if (worksheet.RangeUsed().ColumnCount() < 9)
{
throw new InvalidDataException("Sheet must have 9 Columns of data");
}
if (!row.Cell(2).IsEmpty()) o = row.Cell(2).Value; else o = null;
if ((o != null) && Int32.TryParse(o.ToString(), out int wasteType))
{
Waste waste = was.GetWasteForType(wasteType);
if (waste == null)
{
waste = new Waste();
waste.WasteType = wasteType;
waste.WAS = was;
waste.IsDirty = true;
waste.Identifier = Waste.GetNewIdentifier(was.Waste);
was.Waste.Add(waste);
}
else
{
waste.IsDirty = true;
}
if (!row.Cell(5).IsEmpty()) waste.WasteDescription = row.Cell(5).GetString();
if (waste.WasteDescription.IsNullOrEmpty())
waste.WasteDescription = "-";
if (!row.Cell(6).IsEmpty())
waste.WasteDisposalAmount_MTQ = row.Cell(6).GetDouble();
if (!row.Cell(7).IsEmpty())
waste.WasteCapacity_MTQ = row.Cell(7).GetDouble();
if (!row.Cell(8).IsEmpty()) waste.WasteAmountRetained_MTQ = row.Cell(8).GetDouble();
if (!row.Cell(9).IsEmpty())
waste.WasteDisposalPort = row.Cell(9).GetString().ToUpper();
if (!row.Cell(10).IsEmpty())
waste.WasteAmountGeneratedTillNextPort_MTQ = row.Cell(10).GetDouble();
importWasteList.Add(waste);
cnt++;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
}
return cnt;
}
#endregion
}
}

View File

@ -9,13 +9,12 @@
using bsmd.database; using bsmd.database;
using ENI2.Locode; using ENI2.Locode;
using Microsoft.Office.Interop.Excel; using ClosedXML.Excel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
namespace ENI2.Excel namespace ENI2.Excel
{ {
@ -31,9 +30,9 @@ namespace ENI2.Excel
internal Dictionary<string, string> ImportValues { get; } = new Dictionary<string, string>(); internal Dictionary<string, string> ImportValues { get; } = new Dictionary<string, string>();
public ExcelReader(string filePath, bool openReadonly = true, bool createNameFields = true) public ExcelReader(string filePath, bool createNameFields = true)
{ {
this._workBook = _excelWorkbooks.Open(filePath, 0, openReadonly, 5, "", "", false, XlPlatform.xlWindows, "", false, false, 0, false, false, false); this.OpenWorkbookReadOnly(filePath);
if (createNameFields) if (createNameFields)
this.InitNameFields(); this.InitNameFields();
@ -69,16 +68,20 @@ namespace ENI2.Excel
{ {
try try
{ {
var val = _nameDict[lookup].RefersToRange.Value; var definedName = _nameDict[lookup];
var val2 = _nameDict[lookup].RefersToRange.Value2; var range = definedName.Ranges.FirstOrDefault();
if (val != null) if (range != null)
result = val.ToString().Trim(); {
else if (val2 != null) var cell = range.FirstCell();
result = val2.ToString().Trim(); if (cell != null && !cell.Value.IsBlank)
{
result = cell.Value.ToString().Trim();
}
}
} }
catch (COMException ex) catch (Exception ex)
{ {
_log.WarnFormat("COMException reading field {0}: {1}", lookup, ex.ErrorCode); _log.WarnFormat("Exception reading field {0}: {1}", lookup, ex.Message);
} }
} }
if (result != null) if (result != null)
@ -128,7 +131,7 @@ namespace ENI2.Excel
if (portName.IsNullOrEmpty()) if (portName.IsNullOrEmpty())
{ {
_log.WarnFormat("unknown Locode {0}", val); _log.WarnFormat("unknown Locode {0}", val);
val = ""; val = null;
} }
} }
return val; return val;
@ -441,47 +444,61 @@ namespace ENI2.Excel
if (_nameDict.ContainsKey(lookup)) if (_nameDict.ContainsKey(lookup))
{ {
var val = _nameDict[lookup].RefersToRange.Value; var definedName = _nameDict[lookup];
if (val is DateTime) var range = definedName.Ranges.FirstOrDefault();
if (range != null)
{ {
date = val; var cell = range.FirstCell();
} if (cell != null && !cell.Value.IsBlank)
else if (val is double)
{
try
{ {
date = DateTime.FromOADate(val); var cellValue = cell.Value;
if (cellValue.IsDateTime)
{
date = cellValue.GetDateTime();
}
else if (cellValue.IsNumber)
{
double numValue = 0;
try
{
numValue = cellValue.GetNumber();
date = DateTime.FromOADate(numValue);
}
catch (ArgumentException) { /* .. */ }
if (date == null)
{
CultureInfo provider = CultureInfo.InvariantCulture;
string dateString = numValue.ToString();
const string format = "yyyyMMdd";
if (DateTime.TryParseExact(dateString, format, provider, DateTimeStyles.None, out DateTime tmpDate))
date = tmpDate;
}
}
else if (cellValue.IsText)
{
string textValue = cellValue.GetText();
if (DateTime.TryParse(textValue, out DateTime tmpDate))
date = tmpDate;
if (date == null)
{
string[] formats = { "d/M/yyyy", "dd/M/yyyy", "d/MM/yyyy", "dd/MM/yyyy", "d/MMM/yyyy", "dd/MMM/yyyy", "yyyy-MM-dd", "yyyy-mm-d", "dd-MM-yyyy" };
if (DateTime.TryParseExact(textValue, formats, NumberFormatInfo.InvariantInfo, DateTimeStyles.None, out DateTime tmpDate2))
date = tmpDate2;
}
if (date == null)
{
CultureInfo en = CultureInfo.CreateSpecificCulture("en-US");
string[] formats = { "d/M/yyyy", "dd/M/yyyy", "d/MM/yyyy", "dd/MM/yyyy", "d/MMM/yyyy", "dd/MMM/yyyy", "yyyy-MM-dd", "yyyy-mm-d", "dd-MM-yyyy" };
if (DateTime.TryParseExact(textValue, formats, en, DateTimeStyles.None, out DateTime tmpDate3))
date = tmpDate3;
}
}
} }
catch (ArgumentException) { /* .. */ }
if (date == null)
{
CultureInfo provider = CultureInfo.InvariantCulture;
string dateString = val.ToString();
const string format = "yyyyMMdd";
if (DateTime.TryParseExact(dateString, format, provider, DateTimeStyles.None, out DateTime tmpDate))
date = tmpDate;
}
}
if (date == null)
{
if (DateTime.TryParse(val, out DateTime tmpDate))
date = tmpDate;
}
if (date == null)
{
string[] formats = { "d/M/yyyy", "dd/M/yyyy", "d/MM/yyyy", "dd/MM/yyyy", "d/MMM/yyyy", "dd/MMM/yyyy", "yyyy-MM-dd", "yyyy-mm-d", "dd-MM-yyyy" };
if (DateTime.TryParseExact(val, formats, NumberFormatInfo.InvariantInfo, DateTimeStyles.None, out DateTime tmpDate))
date = tmpDate;
}
if (date == null)
{
CultureInfo en = CultureInfo.CreateSpecificCulture("en-US");
string[] formats = { "d/M/yyyy", "dd/M/yyyy", "d/MM/yyyy", "dd/MM/yyyy", "d/MMM/yyyy", "dd/MMM/yyyy", "yyyy-MM-dd", "yyyy-mm-d", "dd-MM-yyyy" };
if (DateTime.TryParseExact(val, formats, en, DateTimeStyles.None, out DateTime tmpDate))
return tmpDate;
} }
if (date != null) if (date != null)
@ -532,61 +549,72 @@ namespace ENI2.Excel
{ {
if (_nameDict.ContainsKey(lookup)) if (_nameDict.ContainsKey(lookup))
{ {
var val = _nameDict[lookup].RefersToRange.Value; var definedName = _nameDict[lookup];
if (val is DateTime) var range = definedName.Ranges.FirstOrDefault();
if (range != null)
{ {
result = val; var cell = range.FirstCell();
} if (cell != null && !cell.Value.IsBlank)
if (val is double)
{
try
{ {
result = DateTime.FromOADate(val); var cellValue = cell.Value;
}
catch (ArgumentException) { }
if (result == null) if (cellValue.IsDateTime)
{
CultureInfo provider = CultureInfo.InvariantCulture;
string dateString = val.ToString();
if (!dateString.Contains(":"))
{ {
const string format = "HHmm"; result = cellValue.GetDateTime();
if (DateTime.TryParseExact(dateString, format, provider, DateTimeStyles.None, out DateTime tmpDate))
result = tmpDate;
} }
} else if (cellValue.IsTimeSpan)
} {
TimeSpan timespan = cellValue.GetTimeSpan();
result = new DateTime(timespan.Ticks);
}
else if (cellValue.IsNumber)
{
double numValue = 0;
try
{
numValue = cellValue.GetNumber();
result = DateTime.FromOADate(numValue);
}
catch (ArgumentException) { }
if (val is string @string) if (result == null)
{ {
if (@string.EndsWith("lt", StringComparison.OrdinalIgnoreCase)) CultureInfo provider = CultureInfo.InvariantCulture;
val = @string.Substring(0, @string.Length - 2).Trim(); string dateString = numValue.ToString();
else if (!dateString.Contains(":"))
val = @string.Trim(); {
} const string format = "HHmm";
if (DateTime.TryParseExact(dateString, format, provider, DateTimeStyles.None, out DateTime tmpDate))
result = tmpDate;
}
}
}
else if (cellValue.IsText)
{
string textValue = cellValue.GetText();
if (result == null) if (textValue.EndsWith("lt", StringComparison.OrdinalIgnoreCase))
{ textValue = textValue.Substring(0, textValue.Length - 2).Trim();
if (DateTime.TryParseExact(val, "HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault, out DateTime date)) else
result = date; textValue = textValue.Trim();
}
if (result == null) if (DateTime.TryParseExact(textValue, "HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault, out DateTime date))
{ result = date;
if (DateTime.TryParseExact(val, "HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault, out DateTime date))
result = date;
}
if ((result == null) && (val != null)) if (result == null)
{ {
CultureInfo provider = CultureInfo.InvariantCulture; if (DateTime.TryParseExact(textValue, "HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault, out DateTime date2))
string dateString = val.ToString(); result = date2;
if (!dateString.Contains(":")) }
{
const string format = "HHmm"; if (result == null && !textValue.Contains(":"))
if (DateTime.TryParseExact(dateString, format, provider, DateTimeStyles.None, out DateTime tmpDate)) {
result = tmpDate; CultureInfo provider = CultureInfo.InvariantCulture;
const string format = "HHmm";
if (DateTime.TryParseExact(textValue, format, provider, DateTimeStyles.None, out DateTime tmpDate))
result = tmpDate;
}
}
} }
} }
} }
@ -627,7 +655,7 @@ namespace ENI2.Excel
{ {
try try
{ {
Worksheet theWorkSheet = _workBook.Worksheets[sheetName]; var theWorkSheet = _workBook.Worksheets.Worksheet(sheetName);
return theWorkSheet != null; return theWorkSheet != null;
} }
catch (Exception) catch (Exception)
@ -640,12 +668,13 @@ namespace ENI2.Excel
{ {
try try
{ {
Worksheet workSheet = (Worksheet)_workBook.Worksheets[sheetName]; var workSheet = _workBook.Worksheets.Worksheet(sheetName);
string result = workSheet.Range[range].Text.ToString(); var cell = workSheet.Range(range).FirstCell();
string result = cell.Value.ToString();
if (!result.IsNullOrEmpty()) if (!result.IsNullOrEmpty())
{ {
result = result.Trim().Clean(); result = result.Trim().Clean();
if(maxLength.HasValue && result.Length > maxLength.Value) if (maxLength.HasValue && result.Length > maxLength.Value)
{ {
result = result.Substring(0, maxLength.Value); result = result.Substring(0, maxLength.Value);
} }
@ -663,8 +692,9 @@ namespace ENI2.Excel
{ {
try try
{ {
Worksheet workSheet = (Worksheet)_workBook.Worksheets[sheetName]; var workSheet = _workBook.Worksheets.Worksheet(sheetName);
string result = workSheet.Range[row, col].Text.ToString(); var cell = workSheet.Cell(row, col);
string result = cell.Value.ToString();
if (!result.IsNullOrEmpty()) if (!result.IsNullOrEmpty())
result = result.Trim().Clean(); result = result.Trim().Clean();
return result; return result;
@ -681,10 +711,11 @@ namespace ENI2.Excel
{ {
try try
{ {
Worksheet workSheet = (Worksheet)_workBook.Worksheets[sheetName]; var workSheet = _workBook.Worksheets.Worksheet(sheetName);
Range aRange = workSheet.Range[range]; var aRange = workSheet.Range(range);
if (aRange != null) if (aRange != null)
{ {
// TODO: Implement dropdown reading logic for ClosedXML
} }
} }
catch (Exception e) catch (Exception e)
@ -713,26 +744,27 @@ namespace ENI2.Excel
try try
{ {
double? result = null; double? result = null;
Worksheet workSheet = (Worksheet)_workBook.Worksheets[sheetName]; var workSheet = _workBook.Worksheets.Worksheet(sheetName);
var val = workSheet.Range[range].Value; var cell = workSheet.Range(range).FirstCell();
if (val is double) result = val; var cellValue = cell.Value;
if (val is string)
if (cellValue.IsNumber)
{ {
if (double.TryParse(val, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, result = cellValue.GetNumber();
}
else if (cellValue.IsText)
{
string textValue = cellValue.GetText();
if (double.TryParse(textValue, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite,
CultureInfo.InvariantCulture, out double tmpDouble)) CultureInfo.InvariantCulture, out double tmpDouble))
result = tmpDouble; result = tmpDouble;
if (result == null) if (result == null)
{ {
if (double.TryParse(val, out tmpDouble)) // current language style (==GER, mit , statt .) if (double.TryParse(textValue, out tmpDouble)) // current language style (==GER, mit , statt .)
result = tmpDouble; result = tmpDouble;
} }
} }
if ((result == null) && (val != null))
{
double tmpDouble2 = val[1, 1];
result = tmpDouble2;
}
return result; return result;
} }
catch (Exception e) catch (Exception e)
@ -747,7 +779,7 @@ namespace ENI2.Excel
string dateString = ReadCellAsText(sheetName, range); string dateString = ReadCellAsText(sheetName, range);
if (dateString != null) if (dateString != null)
{ {
string[] formats = { "yyyy/MM/dd HH:mm", "yyyy/MM/dd", "dd.MM.yyyy", "dd-MM-yyyy", "d/M/yyyy", "dd/M/yyyy", "d/MM/yyyy", "dd/MM/yyyy", "d/MMM/yyyy", "dd/MMM/yyyy", "yyyy-MM-dd", "yyyy-mm-d" }; string[] formats = { "yyyy/MM/dd HH:mm", "yyyy/MM/dd", "dd.MM.yyyy", "dd-MM-yyyy", "d/M/yyyy", "dd/M/yyyy", "d/MM/yyyy", "dd/MM/yyyy", "d/MMM/yyyy", "dd/MMM/yyyy", "yyyy-MM-dd", "yyyy-MM-d", "dd.MM.yyyy HH:mm:ss", "dd.MM.yyyy HH:mm" };
if (DateTime.TryParseExact(dateString, formats, NumberFormatInfo.InvariantInfo, DateTimeStyles.None, out DateTime tmpDate)) if (DateTime.TryParseExact(dateString, formats, NumberFormatInfo.InvariantInfo, DateTimeStyles.None, out DateTime tmpDate))
return tmpDate; return tmpDate;
CultureInfo en = CultureInfo.CreateSpecificCulture("en-US"); CultureInfo en = CultureInfo.CreateSpecificCulture("en-US");
@ -759,7 +791,6 @@ namespace ENI2.Excel
return null; return null;
} }
#endregion Dakosy-specific functions #endregion Dakosy-specific functions
} }
} }

View File

@ -1,12 +1,10 @@
using System; // Copyright (c) 2017- schick Informatik
// Description: Dumps Maersk data into a simple Excel file
//
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using ClosedXML.Excel;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Office.Interop.Excel;
using System.Runtime.InteropServices;
using bsmd.database; using bsmd.database;
namespace ENI2.Excel namespace ENI2.Excel
@ -17,68 +15,58 @@ namespace ENI2.Excel
{ {
data.Sort(); data.Sort();
Application excelApp = new Application(); using (var workbook = new XLWorkbook())
excelApp.DisplayAlerts = false;
excelApp.Visible = false;
Workbook wb = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
Worksheet ws = wb.Worksheets[1];
// Überschriften erste Zeile
ws.Cells[1, 1] = "ETA";
ws.Cells[1, 2] = "ETD";
ws.Cells[1, 3] = "Rotation name";
ws.Cells[1, 4] = "Vessel code";
ws.Cells[1, 5] = "Vessel name";
ws.Cells[1, 6] = "IMO";
ws.Cells[1, 7] = "Arr voy";
ws.Cells[1, 8] = "Dep voy";
ws.Cells[1, 9] = "Terminal name";
ws.Cells[1, 10] = "Operator code";
ws.Cells[1, 11] = "Pro arr";
ws.Cells[1, 12] = "Pro dep";
ws.Cells[1, 13] = "ID";
ws.Cells[1, 14] = "Remark";
for (int i = 0; i < data.Count; i++)
{ {
MaerskData md = data[i]; var worksheet = workbook.Worksheets.Add("Sheet1");
ws.Cells[i + 2, 1].NumberFormat = "TT/hh:mm"; // Headers in first row
ws.Cells[i + 2, 1] = md.ColA; worksheet.Cell(1, 1).Value = "ETA";
ws.Cells[i + 2, 2].NumberFormat = "TT/hh:mm"; worksheet.Cell(1, 2).Value = "ETD";
ws.Cells[i + 2, 2] = md.ColB; worksheet.Cell(1, 3).Value = "Rotation name";
ws.Cells[i + 2, 3] = md.ColC; worksheet.Cell(1, 4).Value = "Vessel code";
ws.Cells[i + 2, 4] = md.ColD; worksheet.Cell(1, 5).Value = "Vessel name";
ws.Cells[i + 2, 5] = md.ColE; worksheet.Cell(1, 6).Value = "IMO";
ws.Cells[i + 2, 6] = md.ColF; worksheet.Cell(1, 7).Value = "Arr voy";
ws.Cells[i + 2, 7] = md.ColG; worksheet.Cell(1, 8).Value = "Dep voy";
ws.Cells[i + 2, 8] = md.ColH; worksheet.Cell(1, 9).Value = "Terminal name";
ws.Cells[i + 2, 9] = md.ColI; worksheet.Cell(1, 10).Value = "Operator code";
ws.Cells[i + 2, 10] = md.ColJ; worksheet.Cell(1, 11).Value = "Pro arr";
ws.Cells[i + 2, 11] = md.ColK; worksheet.Cell(1, 12).Value = "Pro dep";
ws.Cells[i + 2, 12] = md.ColL; worksheet.Cell(1, 13).Value = "ID";
ws.Cells[i + 2, 13] = md.ColM ; worksheet.Cell(1, 14).Value = "Remark";
ws.Cells[i + 2, 14] = md.Remark;
if((md.MessageCore != null) && (md.MessageCore.Cancelled ?? false)) for (int i = 0; i < data.Count; i++)
{ {
ws.Rows[i + 2].Font.Strikethrough = true; MaerskData md = data[i];
int row = i + 2; // Data starts from row 2
worksheet.Cell(row, 1).Value = md.ColA;
worksheet.Cell(row, 1).Style.NumberFormat.Format = "dd/hh:mm";
worksheet.Cell(row, 2).Value = md.ColB;
worksheet.Cell(row, 2).Style.NumberFormat.Format = "dd/hh:mm";
worksheet.Cell(row, 3).Value = md.ColC;
worksheet.Cell(row, 4).Value = md.ColD;
worksheet.Cell(row, 5).Value = md.ColE;
worksheet.Cell(row, 6).Value = md.ColF;
worksheet.Cell(row, 7).Value = md.ColG;
worksheet.Cell(row, 8).Value = md.ColH;
worksheet.Cell(row, 9).Value = md.ColI;
worksheet.Cell(row, 10).Value = md.ColJ;
worksheet.Cell(row, 11).Value = md.ColK;
worksheet.Cell(row, 12).Value = md.ColL;
worksheet.Cell(row, 13).Value = md.ColM;
worksheet.Cell(row, 14).Value = md.Remark;
if ((md.MessageCore != null) && (md.MessageCore.Cancelled ?? false))
{
worksheet.Row(row).Style.Font.Strikethrough = true;
}
} }
workbook.SaveAs(filename);
} }
wb.SaveAs(filename, XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
wb.Saved = true;
wb.Close(0);
Marshal.ReleaseComObject(ws);
Marshal.ReleaseComObject(wb);
excelApp.Quit();
Marshal.ReleaseComObject(excelApp);
} }
} }
} }

View File

@ -15,6 +15,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ENI2.Excel namespace ENI2.Excel
@ -57,7 +58,7 @@ namespace ENI2.Excel
return false; return false;
} }
ValueMapping.LoadDicts(); // reload all messaging dicts (also removes "temporary" entries from last run) Task.Run(async () => await ValueMapping.LoadDicts()); // reload all messaging dicts (also removes "temporary" entries from last run)
// load messages if already present // load messages if already present
List<Message> messages = DBManager.Instance.GetMessagesForCore(messageCore, DBManager.MessageLoad.ALL); List<Message> messages = DBManager.Instance.GetMessagesForCore(messageCore, DBManager.MessageLoad.ALL);
@ -93,7 +94,7 @@ namespace ENI2.Excel
if ((message.MessageNotificationClass == Message.NotificationClass.HAZD) && notificationClasses.Contains(Message.NotificationClass.HAZD)) if ((message.MessageNotificationClass == Message.NotificationClass.HAZD) && notificationClasses.Contains(Message.NotificationClass.HAZD))
{ if (ScanHAZD(message, reader)) ExcelReader.SaveMessage(message); continue; } { if (ScanHAZD(message, reader)) ExcelReader.SaveMessage(message); continue; }
if ((message.MessageNotificationClass == Message.NotificationClass.INFO) && notificationClasses.Contains(Message.NotificationClass.INFO)) if ((message.MessageNotificationClass == Message.NotificationClass.INFO) && notificationClasses.Contains(Message.NotificationClass.INFO))
{ if (ScanINFO(message, reader)) ExcelReader.SaveMessage(message); continue; } { if (ScanINFO(message, messageCore, reader)) ExcelReader.SaveMessage(message); continue; }
if ((message.MessageNotificationClass == Message.NotificationClass.LADG) && notificationClasses.Contains(Message.NotificationClass.LADG)) if ((message.MessageNotificationClass == Message.NotificationClass.LADG) && notificationClasses.Contains(Message.NotificationClass.LADG))
{ if (ScanLADG(message, reader)) ExcelReader.SaveMessage(message); continue; } { if (ScanLADG(message, reader)) ExcelReader.SaveMessage(message); continue; }
if ((message.MessageNotificationClass == Message.NotificationClass.MDH) && notificationClasses.Contains(Message.NotificationClass.MDH)) if ((message.MessageNotificationClass == Message.NotificationClass.MDH) && notificationClasses.Contains(Message.NotificationClass.MDH))
@ -943,7 +944,7 @@ namespace ENI2.Excel
#region INFO #region INFO
private static bool ScanINFO(Message infoMessage, ExcelReader reader) private static bool ScanINFO(Message infoMessage, MessageCore core, ExcelReader reader)
{ {
if (infoMessage.Elements.Count == 0) if (infoMessage.Elements.Count == 0)
{ {
@ -970,6 +971,25 @@ namespace ENI2.Excel
bool? fumigatedBulkCargo = reader.ReadBoolean("INFO.FumigatedBulkCargo"); bool? fumigatedBulkCargo = reader.ReadBoolean("INFO.FumigatedBulkCargo");
info.FumigatedBulkCargo = (byte)((fumigatedBulkCargo ?? false) ? 1 : 0); info.FumigatedBulkCargo = (byte)((fumigatedBulkCargo ?? false) ? 1 : 0);
// März 2024: Spezialfall für Abrechnungsabteilung Bremenports: Feld wird markiert (falls genügend Platz)
// falls das Schiff nach DEBRE oder DEBHV geht:
if(core.PoC.Equals("DEBRE") || core.PoC.Equals("DEBRV"))
{
if(info.SpecialRequirementsOfShipAtBerth == null)
{
info.SpecialRequirementsOfShipAtBerth = "NSW by BSMD";
}
else if(info.SpecialRequirementsOfShipAtBerth.Length <= 241) // we have enough space
{
if(info.SpecialRequirementsOfShipAtBerth.Length > 0) // if there is text already add a separator
{
info.SpecialRequirementsOfShipAtBerth += " | ";
}
info.SpecialRequirementsOfShipAtBerth += "NSW by BSMD";
}
}
return true; return true;
} }
@ -988,15 +1008,18 @@ namespace ENI2.Excel
STAT stat = statMessage.Elements[0] as STAT; STAT stat = statMessage.Elements[0] as STAT;
ScanMessage(stat, reader); ScanMessage(stat, reader);
foreach (Message preMessage in messages) if (!messageCore.IsTransit) // let's not do this for transit messages
{ {
if (preMessage.MessageNotificationClass == Message.NotificationClass.PRE72H) foreach (Message preMessage in messages)
{ {
if (preMessage.Elements.Count > 0) if (preMessage.MessageNotificationClass == Message.NotificationClass.PRE72H)
{ {
PRE72H pre72h = preMessage.Elements[0] as PRE72H; if (preMessage.Elements.Count > 0)
pre72h.Tanker = stat.IsTanker; {
ExcelReader.SaveMessage(preMessage); PRE72H pre72h = preMessage.Elements[0] as PRE72H;
pre72h.Tanker = stat.IsTanker;
ExcelReader.SaveMessage(preMessage);
}
} }
} }
} }
@ -1221,6 +1244,7 @@ namespace ENI2.Excel
if ((reader.Mode == ExcelReader.CountryMode.DE) && waste.IsDashWasteCode) if ((reader.Mode == ExcelReader.CountryMode.DE) && waste.IsDashWasteCode)
{ {
waste.WasteDescription = "-"; waste.WasteDescription = "-";
// NOP
} }
else if (reader.Mode == ExcelReader.CountryMode.DK) else if (reader.Mode == ExcelReader.CountryMode.DK)
{ {
@ -1260,18 +1284,19 @@ namespace ENI2.Excel
if (waste.WasteType == 2309) waste.WasteType = 507; if (waste.WasteType == 2309) waste.WasteType = 507;
if (waste.WasteType == 3000) waste.WasteType = 401; if (waste.WasteType == 3000) waste.WasteType = 401;
waste.WasteDisposalAmount_MTQ = reader.ReadNumberDefaultZero(wasteAmount); waste.WasteDisposalAmount_MTQ = reader.ReadNumber(wasteAmount);
waste.WasteCapacity_MTQ = reader.ReadNumberDefaultZero(wasteCapacity); if (!waste.WasteDisposalAmount_MTQ.HasValue && reader.ReadText(wasteAmount).IsNullOrEmpty()) waste.WasteDisposalAmount_MTQ = 0;
waste.WasteAmountRetained_MTQ = reader.ReadNumberDefaultZero(wasteRetained); waste.WasteCapacity_MTQ = reader.ReadNumber(wasteCapacity);
if (!waste.WasteCapacity_MTQ.HasValue && reader.ReadText(wasteCapacity).IsNullOrEmpty()) waste.WasteCapacity_MTQ = 0;
waste.WasteAmountRetained_MTQ = reader.ReadNumber(wasteRetained);
if (!waste.WasteAmountRetained_MTQ.HasValue && reader.ReadText(wasteRetained).IsNullOrEmpty()) waste.WasteAmountRetained_MTQ = 0;
waste.WasteDisposalPort = reader.ReadSSNLocode(wastePort); // aka RemainingWasteDisposalPort waste.WasteDisposalPort = reader.ReadSSNLocode(wastePort); // aka RemainingWasteDisposalPort
if (waste.WasteDisposalPort.IsNullOrEmpty()) if ((waste.WasteDisposalPort == null) && reader.ReadText(wastePort).IsNullOrEmpty()) waste.WasteDisposalPort = "ZZUKN";
{
waste.WasteDisposalPort = "ZZUKN";
}
waste.WasteAmountGeneratedTillNextPort_MTQ = reader.ReadNumberDefaultZero(amountGen); waste.WasteAmountGeneratedTillNextPort_MTQ = reader.ReadNumber(amountGen);
if (!waste.WasteAmountGeneratedTillNextPort_MTQ.HasValue && reader.ReadText(amountGen).IsNullOrEmpty()) waste.WasteAmountGeneratedTillNextPort_MTQ = 0;
if (!waste.WasteType.HasValue || (waste.WasteType > 999)) if (!waste.WasteType.HasValue || (waste.WasteType > 999))
{ {
@ -1279,7 +1304,8 @@ namespace ENI2.Excel
} }
} }
was.AddMissingWaste(); was.AddMissingWaste(false);
return true; return true;
} }
@ -1349,7 +1375,7 @@ namespace ENI2.Excel
wr.WasteCode.Equals("204") || wr.WasteCode.Equals("510") || wr.WasteCode.Equals("511")) wr.WasteCode.Equals("204") || wr.WasteCode.Equals("510") || wr.WasteCode.Equals("511"))
wr.WasteDescription = "-"; wr.WasteDescription = "-";
} }
wr.AmountWasteReceived_MTQ = reader.ReadNumber(wAmount) ?? (double?)0; // Default ist 0, nicht nix ;-) wr.AmountWasteReceived_MTQ = reader.ReadNumber(wAmount); // ?? (double?)0; // Default ist 0, nicht nix ;-) // Update: wir wollen doch einen Fehler
} }
// only add message when an identification number was given // only add message when an identification number was given
@ -1399,10 +1425,10 @@ namespace ENI2.Excel
int i = 1; int i = 1;
foreach (LastTenPortFacilitiesCalled ltpfc in sec.LastTenPortFacilitesCalled) foreach (LastTenPortFacilitiesCalled ltpfc in sec.LastTenPortFacilitesCalled)
{ {
if (!(mdh.GetSublistElementWithIdentifier((i + 1).ToString()) is PortOfCallLast30Days poc30d)) if (!(mdh.GetSublistElementWithIdentifier((i).ToString()) is PortOfCallLast30Days poc30d))
{ {
poc30d = new PortOfCallLast30Days(); poc30d = new PortOfCallLast30Days();
poc30d.Identifier = (i + 1).ToString(); poc30d.Identifier = (i).ToString();
poc30d.MDH = mdh; poc30d.MDH = mdh;
mdh.PortOfCallLast30Days.Add(poc30d); mdh.PortOfCallLast30Days.Add(poc30d);
} }
@ -1416,64 +1442,66 @@ namespace ENI2.Excel
} }
else // "normal mode", aus den Zellen lesen else // "normal mode", aus den Zellen lesen
{ {
// POC last 30 days
for (int i = 0; i < mdh.NumberOfExcelRows; i++) string sheetTitle = "1. VOYAGE";
// 4.8.25: Changed this area to work like reading from a Dakosy Sheet (by values in rows, not cell names)
if (reader.HasWorksheetNamed(sheetTitle))
{ {
string portName = string.Format("MDH.PortOfCallLast30DaysPort_{0}", i + 1);
string portCountry = string.Format("MDH.PortOfCallLast30DaysCountry_{0}", i + 1);
string locode = string.Format("MDH.PortOfCallLast30DaysLocode_{0}", i + 1);
string crewJoined = string.Format("MDH.PortOfCallLast30DaysCrewMembersJoined_{0}", i + 1);
string crewName = string.Format("MDH.PortOfCallLast30DaysCrewJoinedShipName_{0}", i + 1);
string depDate = string.Format("MDH.PortOfCallLast30DaysDateOfDeparture_{0}", i + 1);
if (!(mdh.GetSublistElementWithIdentifier((i + 1).ToString()) is PortOfCallLast30Days poc30d)) // POC last 30 days
for (int i = 0; i < mdh.NumberOfExcelRows; i++)
{ {
poc30d = new PortOfCallLast30Days();
poc30d.Identifier = (i + 1).ToString();
poc30d.MDH = mdh;
mdh.PortOfCallLast30Days.Add(poc30d);
}
string pName = reader.ReadText(portName); if (!(mdh.GetSublistElementWithIdentifier((i + 1).ToString()) is PortOfCallLast30Days poc30d))
string pCountry = reader.ReadText(portCountry);
poc30d.PortOfCallLast30DaysDateOfDeparture = reader.ReadDate(depDate);
poc30d.PortOfCallLast30DaysLocode = reader.ReadLoCode(locode);
// Verbesserungsvorschlag Jul/21: CrewMembersJoined Häkchen abhängig von den Namen in der Spalte
bool? PortOfCallLast30DaysCrewMembersJoinedFlag = reader.ReadBoolean(crewJoined);
string crewNameString = reader.ReadText(crewName);
poc30d.PortOfCallLast30DaysCrewMembersJoined = !crewNameString.IsNullOrEmpty();
// if crew members joined is set explicitly to true and the name is empty, still set the field to true
if (!(poc30d.PortOfCallLast30DaysCrewMembersJoined ?? false) && (PortOfCallLast30DaysCrewMembersJoinedFlag ?? false))
poc30d.PortOfCallLast30DaysCrewMembersJoined = true;
if (!crewNameString.IsNullOrEmpty() && (poc30d.PortOfCallLast30DaysCrewMembersJoined ?? false))
{
// try different separators
string[] crew = crewNameString.Split(';');
if (crew.Length == 1)
crew = crewNameString.Split(',');
for (int j = 0; j < crew.Length; j++)
{ {
if (!(poc30d.GetSublistElementWithIdentifier((j + 1).ToString()) is PortOfCallLast30DaysCrewJoinedShip poc30dCrew)) poc30d = new PortOfCallLast30Days();
{ poc30d.Identifier = (i + 1).ToString();
poc30dCrew = new PortOfCallLast30DaysCrewJoinedShip(); poc30d.MDH = mdh;
poc30dCrew.Identifier = (j + 1).ToString(); mdh.PortOfCallLast30Days.Add(poc30d);
poc30dCrew.PortOfCallLast30Days = poc30d;
poc30d.CrewJoinedShip.Add(poc30dCrew);
}
poc30dCrew.PortOfCallLast30DaysCrewJoinedShipName = crew[j];
} }
}
// Leer/def. Zeilen entfernen string pName = reader.ReadCellAsText(sheetTitle, string.Format("C{0}", 82 + i));
if (!poc30d.PortOfCallLast30DaysDateOfDeparture.HasValue && (poc30d.PortOfCallLast30DaysLocode == null)) string pCountry = reader.ReadCellAsText(sheetTitle, string.Format("E{0}", 82 + i));
mdh.PortOfCallLast30Days.Remove(poc30d);
poc30d.PortOfCallLast30DaysDateOfDeparture = reader.ReadCellAsDateTime(sheetTitle, string.Format("G{0}", 82 + i));
poc30d.PortOfCallLast30DaysLocode = reader.ReadCellAsText(sheetTitle, string.Format("F{0}", 82 + i));
if (LocodeDB.PortNameFromLocode(poc30d.PortOfCallLast30DaysLocode).IsNullOrEmpty()) poc30d.PortOfCallLast30DaysLocode = "";
// Verbesserungsvorschlag Jul/21: CrewMembersJoined Häkchen abhängig von den Namen in der Spalte
bool? PortOfCallLast30DaysCrewMembersJoinedFlag = reader.ReadCellAsBool(sheetTitle, string.Format("H{0}", 82 + i));
string crewNameString = reader.ReadCellAsText(sheetTitle, string.Format("I{0}", 82 + i));
poc30d.PortOfCallLast30DaysCrewMembersJoined = !crewNameString.IsNullOrEmpty() && (crewNameString.Length > 1);
// if crew members joined is set explicitly to true and the name is empty, still set the field to true
if (!(poc30d.PortOfCallLast30DaysCrewMembersJoined ?? false) && (PortOfCallLast30DaysCrewMembersJoinedFlag ?? false))
poc30d.PortOfCallLast30DaysCrewMembersJoined = true;
if (!crewNameString.IsNullOrEmpty() && (poc30d.PortOfCallLast30DaysCrewMembersJoined ?? false))
{
// try different separators
string[] crew = crewNameString.Split(';');
if (crew.Length == 1)
crew = crewNameString.Split(',');
for (int j = 0; j < crew.Length; j++)
{
if (!(poc30d.GetSublistElementWithIdentifier((j + 1).ToString()) is PortOfCallLast30DaysCrewJoinedShip poc30dCrew))
{
poc30dCrew = new PortOfCallLast30DaysCrewJoinedShip();
poc30dCrew.Identifier = (j + 1).ToString();
poc30dCrew.PortOfCallLast30Days = poc30d;
poc30d.CrewJoinedShip.Add(poc30dCrew);
}
poc30dCrew.PortOfCallLast30DaysCrewJoinedShipName = crew[j];
}
}
// Leer/def. Zeilen entfernen
if (!poc30d.PortOfCallLast30DaysDateOfDeparture.HasValue && (poc30d.PortOfCallLast30DaysLocode.IsNullOrEmpty()))
mdh.PortOfCallLast30Days.Remove(poc30d);
}
} }
} }
@ -1586,6 +1614,9 @@ namespace ENI2.Excel
} }
SEC sec = secMessage.Elements[0] as SEC; SEC sec = secMessage.Elements[0] as SEC;
((ISublistContainer)sec).DeleteElements();
ScanMessage(sec, reader); ScanMessage(sec, reader);
reader.ReadBoolean("SEC.AreMatterToReport"); // das berücksichtigen wir derzeit nicht in der DB (implizit) reader.ReadBoolean("SEC.AreMatterToReport"); // das berücksichtigen wir derzeit nicht in der DB (implizit)
@ -1636,97 +1667,84 @@ namespace ENI2.Excel
if (!sec.KielCanalPassagePlannedIncomming.HasValue && !sec.KielCanalPassagePlannedOutgoing.HasValue) if (!sec.KielCanalPassagePlannedIncomming.HasValue && !sec.KielCanalPassagePlannedOutgoing.HasValue)
sec.KielCanalPassagePlanned = false; sec.KielCanalPassagePlanned = false;
// Last10PortFacilitesCalled
for (int i = 1; i <= 10; i++)
string sheetTitle = "1. VOYAGE";
// 4.8.25: Changed this area to work like reading from a Dakosy Sheet (by values in rows, not cell names)
if (reader.HasWorksheetNamed(sheetTitle))
{ {
string portName = string.Format("SEC.PortFacilityPortName_{0}", i); // Last10PortFacilitesCalled
string portCountry = string.Format("SEC.PortFacilityPortCountry_{0}", i); for (int i = 0; i < 10; i++)
string portLocode = string.Format("SEC.PortFacilityPortLoCode_{0}", i);
string portDateOfArrival = string.Format("SEC.PortFacilityDateOfArrival_{0}", i);
string portDateOfDeparture = string.Format("SEC.PortFacilityDateOfDeparture_{0}", i);
string portShipSecLevel = string.Format("SEC.PortFacilityShipSecurityLevel_{0}", i);
string portGISISCode = string.Format("SEC.PortFacilityGISISCode_{0}", i);
string portSecMatters = string.Format("SEC.PortFacilitySecurityMattersToReport_{0}", i);
if (!(sec.GetPortFacilityWithIdentifier(i.ToString()) is LastTenPortFacilitiesCalled l10fc))
{ {
l10fc = new LastTenPortFacilitiesCalled();
l10fc.Identifier = i.ToString(); if (!(sec.GetPortFacilityWithIdentifier((i + 1).ToString()) is LastTenPortFacilitiesCalled l10fc))
l10fc.SEC = sec; {
sec.LastTenPortFacilitesCalled.Add(l10fc); l10fc = new LastTenPortFacilitiesCalled();
l10fc.Identifier = (i + 1).ToString();
l10fc.SEC = sec;
sec.LastTenPortFacilitesCalled.Add(l10fc);
}
l10fc.PortFacilityPortName = reader.ReadCellAsText(sheetTitle, string.Format("C{0}", 54 + i), 99);
l10fc.PortFacilityPortCountry = reader.ReadCellAsText(sheetTitle, string.Format("E{0}", 54 + i), 99);
l10fc.PortFacilityPortLoCode = reader.ReadCellAsText(sheetTitle, string.Format("F{0}", 54 + i), 5);
if (LocodeDB.PortNameFromLocode(l10fc.PortFacilityPortLoCode).IsNullOrEmpty()) l10fc.PortFacilityPortLoCode = "";
l10fc.PortFacilityDateOfArrival = reader.ReadCellAsDateTime(sheetTitle, string.Format("G{0}", 54 + i));
l10fc.PortFacilityDateOfDeparture = reader.ReadCellAsDateTime(sheetTitle, string.Format("H{0}", 54 + i));
string sLevel = reader.ReadCellAsText(sheetTitle, string.Format("I{0}", 54 + i));
if (!sLevel.IsNullOrEmpty())
{
if (sLevel.Contains('1')) l10fc.PortFacilityShipSecurityLevel = 1;
if (sLevel.Contains('2')) l10fc.PortFacilityShipSecurityLevel = 2;
if (sLevel.Contains('3')) l10fc.PortFacilityShipSecurityLevel = 3;
}
string s = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", 54 + i));
// All invalid codes become "0000", Oct/25
l10fc.PortFacilityGISISCode = (s != null) && Regex.IsMatch(s.Trim(), @"^\d{1,4}$") ? s.Trim().PadLeft(4, '0') : "0000";
l10fc.PortFacilitySecurityMattersToReport = reader.ReadCellAsText(sheetTitle, string.Format("K{0}", 54 + i), 255);
// keinen "leeren" Hafen anlegen, wenn der Eintrag leer war (trifft anscheinend bei Neubauten zu, siehe E-Mail Christin vom 20./22.6.17
if (l10fc.PortFacilityPortName.IsNullOrEmpty() && l10fc.PortFacilityPortLoCode.IsNullOrEmpty() && l10fc.PortFacilityPortCountry.IsNullOrEmpty())
sec.LastTenPortFacilitesCalled.Remove(l10fc);
} }
l10fc.PortFacilityPortName = reader.ReadText(portName); // Ship2ShipActivities
l10fc.PortFacilityPortCountry = reader.ReadText(portCountry); for (int i = 0; i < 10; i++)
l10fc.PortFacilityPortLoCode = reader.ReadLoCode(portLocode);
l10fc.PortFacilityDateOfArrival = reader.ReadDate(portDateOfArrival);
l10fc.PortFacilityDateOfDeparture = reader.ReadDate(portDateOfDeparture);
string sLevel = reader.ReadText(portShipSecLevel);
if (!sLevel.IsNullOrEmpty())
{ {
if (sLevel.Contains('1')) l10fc.PortFacilityShipSecurityLevel = 1;
if (sLevel.Contains('2')) l10fc.PortFacilityShipSecurityLevel = 2; if (!(sec.GetShipToShipWithIdentifier((i + 1).ToString()) is ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2sActivity))
if (sLevel.Contains('3')) l10fc.PortFacilityShipSecurityLevel = 3; {
s2sActivity = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled();
s2sActivity.Identifier = (i + 1).ToString();
s2sActivity.SEC = sec;
sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Add(s2sActivity);
}
s2sActivity.ShipToShipActivityLocationName = reader.ReadCellAsText(sheetTitle, string.Format("C{0}", 68 + i), 255);
if (s2sActivity.ShipToShipActivityLocationName.IsNullOrEmpty())
{
sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Remove(s2sActivity);
continue;
}
s2sActivity.ShipToShipActivityLocationLoCode = reader.ReadCellAsText(sheetTitle, string.Format("E{0}", 68 + i), 5);
if (LocodeDB.PortNameFromLocode(s2sActivity.ShipToShipActivityLocationLoCode).IsNullOrEmpty()) s2sActivity.ShipToShipActivityLocationLoCode = "";
s2sActivity.ShipToShipActivityLocationCoordinatesLatitude = (int?) reader.ReadCellAsDecimal(sheetTitle, string.Format("F{0}", 68 + i));
// keine "0" (d.h. fehlerhafte Koordinaten) ins ANSW übergeben falls im Sheet nichts ist aber der Reader das aus irgendeinem Grund liest
if (s2sActivity.ShipToShipActivityLocationCoordinatesLatitude == 0)
s2sActivity.ShipToShipActivityLocationCoordinatesLatitude = null;
s2sActivity.ShipToShipActivityLocationCoordinatesLongitude = (int?)reader.ReadCellAsDecimal(sheetTitle, string.Format("G{0}", 68 + i));
if (s2sActivity.ShipToShipActivityLocationCoordinatesLongitude == 0)
s2sActivity.ShipToShipActivityLocationCoordinatesLongitude = null;
s2sActivity.ShipToShipActivityDateFrom = reader.ReadCellAsDateTime(sheetTitle, string.Format("H{0}", 68 + i));
s2sActivity.ShipToShipActivityDateTo = reader.ReadCellAsDateTime(sheetTitle, string.Format("I{0}", 68 + i));
s2sActivity.ShipToShipActivityTypeCode = (int?)reader.ReadCellAsDecimal(sheetTitle, string.Format("J{0}", 68 + i));
s2sActivity.ShipToShipActivitySecurityMattersToReport = reader.ReadCellAsText(sheetTitle, string.Format("K{0}", 68 + i), 255);
} }
l10fc.PortFacilityGISISCode = reader.ReadTextNoWhitespace(portGISISCode);
if (l10fc.PortFacilityGISISCode.IsNullOrEmpty() || l10fc.PortFacilityGISISCode == "0")
l10fc.PortFacilityGISISCode = "0000";
if (l10fc.PortFacilityGISISCode?.Length < 4)
{
while (l10fc.PortFacilityGISISCode.Length < 4) l10fc.PortFacilityGISISCode = "0" + l10fc.PortFacilityGISISCode;
}
l10fc.PortFacilitySecurityMattersToReport = reader.ReadText(portSecMatters);
// keinen "leeren" Hafen anlegen, wenn der Eintrag leer war (trifft anscheinend bei Neubauten zu, siehe E-Mail Christin vom 20./22.6.17
if (l10fc.PortFacilityPortName.IsNullOrEmpty() && l10fc.PortFacilityPortLoCode.IsNullOrEmpty() && l10fc.PortFacilityPortCountry.IsNullOrEmpty())
sec.LastTenPortFacilitesCalled.Remove(l10fc);
}
// Ship2ShipActivities
for (int i = 1; i <= 10; i++)
{
string s2sName = string.Format("SEC.ShipToShipActivityLocationName_{0}", i);
string s2sLocode = string.Format("SEC.ShipToShipActivityLocationLoCode_{0}", i);
string s2sLatitude = string.Format("SEC.ShipToShipActivityLocationCoordinatesLatitude_{0}", i);
string s2sLongitude = string.Format("SEC.ShipToShipActivityLocationCoordinatesLongitude_{0}", i);
string s2sFromDate = string.Format("SEC.ShipToShipActivityDateFrom_{0}", i);
string s2sToDate = string.Format("SEC.ShipToShipActivityDateTo_{0}", i);
string s2sSec = string.Format("SEC.ShipToShipActivitySecurityMattersToReport_{0}", i);
string s2sActivityString = string.Format("SEC.ShipToShipActivityType_{0}", i);
if (!(sec.GetShipToShipWithIdentifier(i.ToString()) is ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2sActivity))
{
s2sActivity = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled();
s2sActivity.Identifier = i.ToString();
s2sActivity.SEC = sec;
sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Add(s2sActivity);
}
s2sActivity.ShipToShipActivityLocationName = reader.ReadText(s2sName);
if (s2sActivity.ShipToShipActivityLocationName.IsNullOrEmpty())
{
sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Remove(s2sActivity);
continue;
}
s2sActivity.ShipToShipActivityLocationLoCode = reader.ReadLoCode(s2sLocode);
s2sActivity.ShipToShipActivityLocationCoordinatesLatitude = (int?)reader.ReadNumber(s2sLatitude);
// keine "0" (d.h. fehlerhafte Koordinaten) ins ANSW übergeben falls im Sheet nichts ist aber der Reader das aus irgendeinem Grund liest
if (s2sActivity.ShipToShipActivityLocationCoordinatesLatitude == 0)
s2sActivity.ShipToShipActivityLocationCoordinatesLatitude = null;
s2sActivity.ShipToShipActivityLocationCoordinatesLongitude = (int?)reader.ReadNumber(s2sLongitude);
if (s2sActivity.ShipToShipActivityLocationCoordinatesLongitude == 0)
s2sActivity.ShipToShipActivityLocationCoordinatesLongitude = null;
s2sActivity.ShipToShipActivityDateFrom = reader.ReadDate(s2sFromDate);
s2sActivity.ShipToShipActivityDateTo = reader.ReadDate(s2sToDate);
s2sActivity.ShipToShipActivityTypeCode = (int?)reader.ReadNumber(s2sActivityString);
reader.ReadShip2ShipActivityType(s2sActivityString); // 24.8.21 nicht Code dem Klartext zuordnen, nur das Feld kolorieren
s2sActivity.ShipToShipActivitySecurityMattersToReport = reader.ReadText(s2sSec);
} }
return true; return true;
@ -1879,8 +1897,6 @@ namespace ENI2.Excel
string tLen = string.Format("TOWD.TowageOnDepartureLengthOverall_MTR_{0}", i); string tLen = string.Format("TOWD.TowageOnDepartureLengthOverall_MTR_{0}", i);
string tBeam = string.Format("TOWD.TowageOnDepartureBeam_MTR_{0}", i); string tBeam = string.Format("TOWD.TowageOnDepartureBeam_MTR_{0}", i);
string tOp = string.Format("TOWD.TowageOnDepartureOperatorCompanyName_{0}", i); string tOp = string.Format("TOWD.TowageOnDepartureOperatorCompanyName_{0}", i);
string tPoc = string.Format("TOWD.TowageOnArrivalPurposeOfCall_{0}", i);
string tgt = string.Format("TOWD.TowageOnArrivalGrossTonnage_{0}", i);
string towageName = reader.ReadText(tName); string towageName = reader.ReadText(tName);
if (towageName.IsNullOrEmpty()) continue; if (towageName.IsNullOrEmpty()) continue;
@ -2112,10 +2128,11 @@ namespace ENI2.Excel
if (canceled) return true; if (canceled) return true;
crew.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 18), 100); crew.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 18), 100);
if (crew.CrewMemberDuty.IsNullOrEmpty()) crew.CrewMemberDuty = "unknown";
crew.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18)), out canceled); crew.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18)), out canceled);
if (canceled) return true; if (canceled) return true;
crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 18), 100); crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 18), 100);
crew.CrewMemberCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("I{0}", i + 18)), out _); crew.CrewMemberCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("I{0}", i + 18)), out _, false);
crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("J{0}", i + 18)); crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("J{0}", i + 18));
@ -2128,7 +2145,7 @@ namespace ENI2.Excel
if (canceled) return true; if (canceled) return true;
if (crew.CrewMemberIdentityDocumentIssuingState.IsNullOrEmpty() && isOldVersion) if (crew.CrewMemberIdentityDocumentIssuingState.IsNullOrEmpty() && isOldVersion)
crew.CrewMemberIdentityDocumentIssuingState = "XX"; crew.CrewMemberIdentityDocumentIssuingState = "XX";
crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime(sheetTitle, string.Format("N{0}", i + 18)); crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime(sheetTitle, string.Format("N{0}", i + 18)) ?? (DateTime?)new DateTime(2100, 12, 31);
if (!crew.CrewMemberIdentityDocumentExpiryDate.HasValue && isOldVersion) if (!crew.CrewMemberIdentityDocumentExpiryDate.HasValue && isOldVersion)
crew.CrewMemberIdentityDocumentExpiryDate = new DateTime(2100, 12, 31); crew.CrewMemberIdentityDocumentExpiryDate = new DateTime(2100, 12, 31);
@ -2166,6 +2183,7 @@ namespace ENI2.Excel
if (canceled) return true; if (canceled) return true;
crew.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 13)); crew.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 13));
if (crew.CrewMemberDuty.IsNullOrEmpty()) crew.CrewMemberDuty = "unknown";
crew.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 13)), out canceled); crew.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 13)), out canceled);
if (canceled) return true; if (canceled) return true;
crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 13)); crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 13));
@ -2208,7 +2226,8 @@ namespace ENI2.Excel
for (int i = 0; i < 5000; i++) for (int i = 0; i < 5000; i++)
{ {
string lastName = reader.ReadCellAsText(sheetTitle, string.Format("C{0}", i + 18), 100); string lastName = reader.ReadCellAsText(sheetTitle, string.Format("C{0}", i + 18), 100);
if (lastName.IsNullOrEmpty()) break; string firstName = reader.ReadCellAsText(sheetTitle, string.Format("D{0}", i + 18), 100);
if (lastName.IsNullOrEmpty() && firstName.IsNullOrEmpty()) break;
if (!(crewdMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is CREWD crewd)) if (!(crewdMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is CREWD crewd))
{ {
@ -2222,16 +2241,17 @@ namespace ENI2.Excel
crewd.NotificationSchengen = true; crewd.NotificationSchengen = true;
crewd.NotificationPAX = notificationPax ?? false; crewd.NotificationPAX = notificationPax ?? false;
crewd.CrewMemberLastName = lastName; crewd.CrewMemberLastName = lastName;
crewd.CrewMemberFirstName = reader.ReadCellAsText(sheetTitle, string.Format("D{0}", i + 18), 100); crewd.CrewMemberFirstName = firstName;
crewd.CrewMemberGender = ReadGender(reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 18)), out bool canceled); crewd.CrewMemberGender = ReadGender(reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 18)), out bool canceled);
if (canceled) return true; if (canceled) return true;
crewd.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 18), 100); crewd.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 18), 100);
if (crewd.CrewMemberDuty.IsNullOrEmpty()) crewd.CrewMemberDuty = "unknown";
crewd.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18)), out canceled); crewd.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18)), out canceled);
if (canceled) return true; if (canceled) return true;
crewd.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 18), 100); crewd.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 18), 100);
crewd.CrewMemberCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("I{0}", i + 18)), out _); crewd.CrewMemberCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("I{0}", i + 18)), out _, false);
crewd.CrewMemberDateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("J{0}", i + 18)); crewd.CrewMemberDateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("J{0}", i + 18));
crewd.CrewMemberIdentityDocumentType = ReadDocumentType(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 18)), out canceled); crewd.CrewMemberIdentityDocumentType = ReadDocumentType(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 18)), out canceled);
@ -2279,6 +2299,7 @@ namespace ENI2.Excel
if (canceled) return true; if (canceled) return true;
crewd.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 14)); crewd.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 14));
if (crewd.CrewMemberDuty.IsNullOrEmpty()) crewd.CrewMemberDuty = "unknown";
crewd.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 14)), out canceled); crewd.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 14)), out canceled);
if (canceled) return true; if (canceled) return true;
crewd.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 14)); crewd.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 14));
@ -2352,7 +2373,7 @@ namespace ENI2.Excel
pas.PassengerInTransit = reader.ReadCellAsBool(sheetTitle, string.Format("H{0}", i + 17)); pas.PassengerInTransit = reader.ReadCellAsBool(sheetTitle, string.Format("H{0}", i + 17));
pas.PassengerPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", i + 17), 100); pas.PassengerPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", i + 17), 100);
pas.PassengerCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 17)), out _); pas.PassengerCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 17)), out _, false);
if (canceled) return true; if (canceled) return true;
DateTime? dateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("L{0}", i + 17)); DateTime? dateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("L{0}", i + 17));
@ -2493,7 +2514,7 @@ namespace ENI2.Excel
pas.PassengerInTransit = reader.ReadCellAsBool(sheetTitle, string.Format("H{0}", i + 18)); pas.PassengerInTransit = reader.ReadCellAsBool(sheetTitle, string.Format("H{0}", i + 18));
pas.PassengerPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", i + 18), 100); pas.PassengerPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", i + 18), 100);
pas.PassengerCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 18)), out _); pas.PassengerCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 18)), out _, false);
if (canceled) return true; if (canceled) return true;
DateTime? dateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("L{0}", i + 18)); DateTime? dateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("L{0}", i + 18));
@ -2503,7 +2524,7 @@ namespace ENI2.Excel
if (canceled) return true; if (canceled) return true;
pas.PassengerIdentityDocumentId = reader.ReadCellAsText(sheetTitle, string.Format("N{0}", i + 18), 100); pas.PassengerIdentityDocumentId = reader.ReadCellAsText(sheetTitle, string.Format("N{0}", i + 18), 100);
pas.PassengerIdentityDocumentExpiryDate = reader.ReadCellAsDateTime(sheetTitle, string.Format("P{0}", i + 18)) ?? (DateTime?)new DateTime(2100, 12, 31); pas.PassengerIdentityDocumentExpiryDate = reader.ReadCellAsDateTime(sheetTitle, string.Format("P{0}", i + 18)) ?? (DateTime?)new DateTime(2100, 12, 31); ;
pas.PassengerVisaNumber = reader.ReadCellAsText(sheetTitle, string.Format("Q{0}", i + 18), 100); pas.PassengerVisaNumber = reader.ReadCellAsText(sheetTitle, string.Format("Q{0}", i + 18), 100);
pas.EmergencyCare = reader.ReadCellAsText(sheetTitle, string.Format("R{0}", i + 18), 255); pas.EmergencyCare = reader.ReadCellAsText(sheetTitle, string.Format("R{0}", i + 18), 255);
@ -2826,12 +2847,12 @@ namespace ENI2.Excel
return result; return result;
} }
public static string ReadNationality(string nationality, out bool canceled) public static string ReadNationality(string nationality, out bool canceled, bool setPlaceHolder = true)
{ {
string result = null; string result = null;
canceled = false; canceled = false;
nationality = nationality.Trim(); nationality = nationality.Trim();
if (nationality.IsNullOrEmpty()) if (nationality.IsNullOrEmpty() && setPlaceHolder)
{ {
result = "XX"; result = "XX";
} }
@ -2849,35 +2870,38 @@ namespace ENI2.Excel
} }
else // we cannot find whatever this is.. else // we cannot find whatever this is..
{ {
FixImportDialog fid = new FixImportDialog(); if (setPlaceHolder) // only show import dialog if this is a required field..
fid.Value = nationality;
fid.ValueType = "Nationality";
fid.SelectionValues = CREW.NationalityDict;
if (fid.ShowDialog() ?? false)
{ {
if (!fid.SelectedValue.IsNullOrEmpty()) FixImportDialog fid = new FixImportDialog();
fid.Value = nationality;
fid.ValueType = "Nationality";
fid.SelectionValues = CREW.NationalityDict;
if (fid.ShowDialog() ?? false)
{ {
if(!ValueMapping.InvalidKeys[ValueMapping.MappingType.COUNTRY].Contains(nationality)) if (!fid.SelectedValue.IsNullOrEmpty())
{ {
string selectedValue = fid.SelectedValue; if (!ValueMapping.InvalidKeys[ValueMapping.MappingType.COUNTRY].Contains(nationality))
Task<bool> createResult = Task.Run(async () => await ValueMapping.Create(ValueMapping.MappingType.COUNTRY, nationality, selectedValue)); {
if(!createResult.Result) string selectedValue = fid.SelectedValue;
_log.WarnFormat("Error saving nationality value mapping {0} -> {1}", nationality, selectedValue); Task<bool> createResult = Task.Run(async () => await ValueMapping.Create(ValueMapping.MappingType.COUNTRY, nationality, selectedValue));
if (!createResult.Result)
_log.WarnFormat("Error saving nationality value mapping {0} -> {1}", nationality, selectedValue);
}
else
{
// add temporary
ValueMapping vm = ValueMapping.Create(ValueMapping.MappingType.COUNTRY);
vm.Key = nationality;
vm.Value = fid.SelectedValue;
ValueMapping.Dicts[ValueMapping.MappingType.COUNTRY].Add(nationality, vm);
}
result = fid.SelectedValue.Substring(0, 2); // attention manual entry
} }
else
{
// add temporary
ValueMapping vm = ValueMapping.Create(ValueMapping.MappingType.COUNTRY);
vm.Key = nationality;
vm.Value = fid.SelectedValue;
ValueMapping.Dicts[ValueMapping.MappingType.COUNTRY].Add(nationality, vm);
}
result = fid.SelectedValue.Substring(0, 2); // attention manual entry
} }
} else
else {
{ canceled = true;
canceled = true; }
} }
} }

View File

@ -1,8 +1,8 @@
// Copyright (c) 2017- schick Informatik // Copyright (c) 2017- schick Informatik
// Description: // Description: Writing excel files
// //
using Microsoft.Office.Interop.Excel; using ClosedXML.Excel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
@ -26,10 +26,9 @@ namespace ENI2.Excel
if (isRefSheet) filename = @"Excel\Reference_Sheet_DE.xlsx"; if (isRefSheet) filename = @"Excel\Reference_Sheet_DE.xlsx";
string refFilePath = System.IO.Path.Combine(Environment.CurrentDirectory, filename); string refFilePath = System.IO.Path.Combine(Environment.CurrentDirectory, filename);
this._workBook = _excelWorkbooks.Open(refFilePath, 0, true, 5, "", "", false, XlPlatform.xlWindows, "", false, false, 0, false, false, false); this.OpenWorkbookReadOnly(refFilePath);
this.InitNameFields(); this.InitNameFields();
} }
#endregion #endregion
@ -44,7 +43,7 @@ namespace ENI2.Excel
{ {
try try
{ {
switch(message.MessageNotificationClass) switch (message.MessageNotificationClass)
{ {
case Message.NotificationClass.AGNT: case Message.NotificationClass.AGNT:
if (message.Elements[0] is AGNT agnt) this.WriteMessage(agnt); if (message.Elements[0] is AGNT agnt) this.WriteMessage(agnt);
@ -84,10 +83,10 @@ namespace ENI2.Excel
break; break;
case Message.NotificationClass.HAZA: case Message.NotificationClass.HAZA:
this.WriteHAZ(message, true); this.WriteHAZ(message, true);
break; break;
case Message.NotificationClass.HAZD: case Message.NotificationClass.HAZD:
this.WriteHAZ(message, false); this.WriteHAZ(message, false);
break; break;
case Message.NotificationClass.INFO: case Message.NotificationClass.INFO:
if (message.Elements[0] is INFO info) if (message.Elements[0] is INFO info)
{ {
@ -192,11 +191,6 @@ namespace ENI2.Excel
} }
public void WriteMaerskList(List<MaerskData> maerskList)
{
}
#endregion #endregion
#region private excel field writing #region private excel field writing
@ -242,7 +236,7 @@ namespace ENI2.Excel
else if (property.PropertyType == typeof(Boolean?)) else if (property.PropertyType == typeof(Boolean?))
{ {
object boolVal = property.GetValue(dbEntity); object boolVal = property.GetValue(dbEntity);
if(boolVal != null) if (boolVal != null)
success = this.WriteBoolean(lookupNameAttribute.LookupName, boolVal); success = this.WriteBoolean(lookupNameAttribute.LookupName, boolVal);
} }
else else
@ -374,6 +368,9 @@ namespace ENI2.Excel
#endregion #endregion
// [Rest of the methods remain exactly the same as they only call the base class methods]
// I'll include a few key ones to show the pattern, but the rest are identical...
#region CREW #region CREW
private void WriteCREW(Message crewMessage, bool isArrival, bool isRefSheet) private void WriteCREW(Message crewMessage, bool isArrival, bool isRefSheet)
@ -385,7 +382,7 @@ namespace ENI2.Excel
WriteBoolean(string.Format("CREW{0}.NotificationPAX", isArrival ? "" : "D"), ((CREW)crewMessage.Elements[0]).NotificationPAX); WriteBoolean(string.Format("CREW{0}.NotificationPAX", isArrival ? "" : "D"), ((CREW)crewMessage.Elements[0]).NotificationPAX);
} }
for(int i = 0; i<Math.Min(crewMessage.NumberOfExcelRows, crewMessage.Elements.Count); i++) for (int i = 0; i < Math.Min(crewMessage.NumberOfExcelRows, crewMessage.Elements.Count); i++)
{ {
string crewLastName = string.Format("CREW{1}.CrewMemberLastName_{0}", i + 1, isArrival ? "" : "D"); string crewLastName = string.Format("CREW{1}.CrewMemberLastName_{0}", i + 1, isArrival ? "" : "D");
string crewFirstName = string.Format("CREW{1}.CrewMemberFirstName_{0}", i + 1, isArrival ? "" : "D"); string crewFirstName = string.Format("CREW{1}.CrewMemberFirstName_{0}", i + 1, isArrival ? "" : "D");
@ -413,7 +410,7 @@ namespace ENI2.Excel
WriteText(crewNationality, crew.CrewMemberNationality); WriteText(crewNationality, crew.CrewMemberNationality);
WriteText(crewDuty, crew.CrewMemberDuty); WriteText(crewDuty, crew.CrewMemberDuty);
WriteText(crewPlaceOfBirth, crew.CrewMemberPlaceOfBirth); WriteText(crewPlaceOfBirth, crew.CrewMemberPlaceOfBirth);
if(crew.CrewMemberDateOfBirth.HasValue) if (crew.CrewMemberDateOfBirth.HasValue)
WriteDate(crewDateOfBirth, crew.CrewMemberDateOfBirth.Value); WriteDate(crewDateOfBirth, crew.CrewMemberDateOfBirth.Value);
WriteText(crewIdentDocType, crew.CrewMemberIdentityDocumentTypeDisplay); WriteText(crewIdentDocType, crew.CrewMemberIdentityDocumentTypeDisplay);
WriteText(crewIdentDocId, crew.CrewMemberIdentityDocumentId); WriteText(crewIdentDocId, crew.CrewMemberIdentityDocumentId);
@ -424,16 +421,16 @@ namespace ENI2.Excel
} }
else else
{ {
if(!crew.CrewMemberIdentityDocumentIssuingState.IsNullOrEmpty() && !crew.CrewMemberIdentityDocumentIssuingState.Equals("XX")) if (!crew.CrewMemberIdentityDocumentIssuingState.IsNullOrEmpty() && !crew.CrewMemberIdentityDocumentIssuingState.Equals("XX"))
WriteText(crewIssuingState, crew.CrewMemberIdentityDocumentIssuingState); WriteText(crewIssuingState, crew.CrewMemberIdentityDocumentIssuingState);
} }
if(isRefSheet) if (isRefSheet)
{ {
WriteDate(crewExpiry, crew.CrewMemberIdentityDocumentExpiryDate); WriteDate(crewExpiry, crew.CrewMemberIdentityDocumentExpiryDate);
} }
else else
{ {
if(crew.CrewMemberIdentityDocumentExpiryDate != new DateTime(2100, 12, 31)) if (crew.CrewMemberIdentityDocumentExpiryDate != new DateTime(2100, 12, 31))
WriteDate(crewExpiry, crew.CrewMemberIdentityDocumentExpiryDate); WriteDate(crewExpiry, crew.CrewMemberIdentityDocumentExpiryDate);
} }
@ -1066,7 +1063,7 @@ namespace ENI2.Excel
string tLen = string.Format("TOWD.TowageOnDepartureLengthOverall_MTR_{0}", i + 1); string tLen = string.Format("TOWD.TowageOnDepartureLengthOverall_MTR_{0}", i + 1);
string tBeam = string.Format("TOWD.TowageOnDepartureBeam_MTR_{0}", i + 1); string tBeam = string.Format("TOWD.TowageOnDepartureBeam_MTR_{0}", i + 1);
string tOp = string.Format("TOWD.TowageOnDepartureOperatorCompanyName_{0}", i + 1); string tOp = string.Format("TOWD.TowageOnDepartureOperatorCompanyName_{0}", i + 1);
string tPoc = string.Format("TOWD.TowageOnDeparturePurposeOfCall_{0}", i + 1); // string tPoc = string.Format("TOWD.TowageOnDeparturePurposeOfCall_{0}", i + 1);
TOWD towd = towdMessage.Elements[i] as TOWD; TOWD towd = towdMessage.Elements[i] as TOWD;
@ -1276,7 +1273,7 @@ namespace ENI2.Excel
private void WriteGenderCode(string label, byte? gender) private void WriteGenderCode(string label, byte? gender)
{ {
if(gender.HasValue) if (gender.HasValue)
{ {
if (gender == 0) WriteText(label, "not known"); if (gender == 0) WriteText(label, "not known");
if (gender == 1) WriteText(label, "m"); if (gender == 1) WriteText(label, "m");
@ -1303,15 +1300,24 @@ namespace ENI2.Excel
private bool WriteBoolean(string lookupName, object v) private bool WriteBoolean(string lookupName, object v)
{ {
bool result = _nameDict.ContainsKey(lookupName); bool result = _nameDict.ContainsKey(lookupName);
bool? b = (bool?) v; bool? b = (bool?)v;
try try
{ {
if (result && b.HasValue) if (result && b.HasValue)
{ {
_nameDict[lookupName].RefersToRange.Value = b.Value ? "Y" : "N"; var definedName = _nameDict[lookupName];
var range = definedName.Ranges.FirstOrDefault();
if (range != null)
{
var cell = range.FirstCell();
if (cell != null)
{
cell.Value = b.Value ? "Y" : "N";
}
}
} }
} }
catch(Exception) catch (Exception)
{ {
System.Diagnostics.Trace.WriteLine(string.Format("Error writing {0} to excel, field missing", lookupName)); System.Diagnostics.Trace.WriteLine(string.Format("Error writing {0} to excel, field missing", lookupName));
} }
@ -1326,10 +1332,19 @@ namespace ENI2.Excel
{ {
if (result) if (result)
{ {
_nameDict[lookupName].RefersToRange.Value = v; var definedName = _nameDict[lookupName];
var range = definedName.Ranges.FirstOrDefault();
if (range != null)
{
var cell = range.FirstCell();
if (cell != null)
{
cell.Value = ClosedXML.Excel.XLCellValue.FromObject(v);
}
}
} }
} }
catch(Exception) catch (Exception)
{ {
System.Diagnostics.Trace.WriteLine(string.Format("Error writing {0} to excel, field missing", lookupName)); System.Diagnostics.Trace.WriteLine(string.Format("Error writing {0} to excel, field missing", lookupName));
} }
@ -1343,7 +1358,16 @@ namespace ENI2.Excel
if (result) if (result)
{ {
_nameDict[lookupName].RefersToRange.Value = v; var definedName = _nameDict[lookupName];
var range = definedName.Ranges.FirstOrDefault();
if (range != null)
{
var cell = range.FirstCell();
if (cell != null)
{
cell.Value = ClosedXML.Excel.XLCellValue.FromObject(v);
}
}
} }
return result; return result;
@ -1355,11 +1379,19 @@ namespace ENI2.Excel
if (result) if (result)
{ {
if(v != null) if (v != null)
{ {
_nameDict[lookupName].RefersToRange.Value = ((DateTime) v).ToLocalTime().ToOADate(); var definedName = _nameDict[lookupName];
var range = definedName.Ranges.FirstOrDefault();
if (range != null)
{
var cell = range.FirstCell();
if (cell != null)
{
cell.Value = ClosedXML.Excel.XLCellValue.FromObject(((DateTime)v).ToLocalTime());
}
}
} }
} }
return result; return result;
@ -1373,9 +1405,17 @@ namespace ENI2.Excel
{ {
if (v != null) if (v != null)
{ {
_nameDict[lookupName].RefersToRange.Value = ((DateTime)v).ToLocalTime().ToShortTimeString(); var definedName = _nameDict[lookupName];
var range = definedName.Ranges.FirstOrDefault();
if (range != null)
{
var cell = range.FirstCell();
if (cell != null)
{
cell.Value = ((DateTime)v).ToLocalTime().ToString("HH:mm");
}
}
} }
} }
return result; return result;

View File

@ -310,7 +310,8 @@ namespace ENI2
public static Dictionary<string, List<PortAreaInfo>> getPortAreaInfos() public static Dictionary<string, List<PortAreaInfo>> getPortAreaInfos()
{ {
if(_portAreaInfos == null) int cnt = 0;
if (_portAreaInfos == null)
{ {
_portAreaInfos = new Dictionary<string, List<PortAreaInfo>>(); _portAreaInfos = new Dictionary<string, List<PortAreaInfo>>();
string query = @"SELECT Locode, Agentur, Schiffe, Liegeplatz, Hafengebiet, `Hafengebiet-Code`, Bemerkungen from INFO_PortArea_Helper"; string query = @"SELECT Locode, Agentur, Schiffe, Liegeplatz, Hafengebiet, `Hafengebiet-Code`, Bemerkungen from INFO_PortArea_Helper";
@ -338,6 +339,7 @@ namespace ENI2
_portAreaInfos[pai.Locode] = new List<PortAreaInfo>(); _portAreaInfos[pai.Locode] = new List<PortAreaInfo>();
} }
_portAreaInfos[pai.Locode].Add(pai); _portAreaInfos[pai.Locode].Add(pai);
cnt++;
} }
} }
return _portAreaInfos; return _portAreaInfos;

View File

@ -95,6 +95,7 @@
<MenuItem x:Name="menuItemUserAdministration" Header="{x:Static p:Resources.textUserAdministration}" Click="radioButton_Click" Visibility="Hidden"/> <MenuItem x:Name="menuItemUserAdministration" Header="{x:Static p:Resources.textUserAdministration}" Click="radioButton_Click" Visibility="Hidden"/>
<MenuItem x:Name="menuItemMaersk" Header="{x:Static p:Resources.textPOLists}" Click="radioButton_Click" Visibility="Hidden" /> <MenuItem x:Name="menuItemMaersk" Header="{x:Static p:Resources.textPOLists}" Click="radioButton_Click" Visibility="Hidden" />
<MenuItem x:Name="menuItemValueMappings" Header="{x:Static p:Resources.textExcelValueMappings}" Click="radioButton_Click" Visibility="Hidden" /> <MenuItem x:Name="menuItemValueMappings" Header="{x:Static p:Resources.textExcelValueMappings}" Click="radioButton_Click" Visibility="Hidden" />
<MenuItem x:Name="menuItemEasyPeasy" Header="{x:Static p:Resources.textEasyPeasy}" Click="radioButton_Click" Visibility="Hidden" />
<MenuItem x:Name="labelStatusId" /> <MenuItem x:Name="labelStatusId" />
<MenuItem Header="Help" HorizontalAlignment="Right"> <MenuItem Header="Help" HorizontalAlignment="Right">
<MenuItem Header="Change Password" Click="buttonChangePassword_Click"> <MenuItem Header="Change Password" Click="buttonChangePassword_Click">

View File

@ -39,6 +39,7 @@ namespace ENI2
private ServerStatusControl statusControl; private ServerStatusControl statusControl;
private readonly SucheControl sucheControl; private readonly SucheControl sucheControl;
private CompareExcelDialog compareExcelDialog; private CompareExcelDialog compareExcelDialog;
private EasyPeasyControl easyPeasyControl;
private bool dbConnected; private bool dbConnected;
private readonly ScaleTransform _transform = new ScaleTransform(1.0, 1.0); private readonly ScaleTransform _transform = new ScaleTransform(1.0, 1.0);
@ -79,7 +80,7 @@ namespace ENI2
#region Search related event handler #region Search related event handler
private void AnmeldungenControl_MessageCoreSelected(MessageCore aMessageCore) private void AnmeldungenControl_MessageCoreSelected(MessageCore aMessageCore, ReportingParty.ShipcallDisplayModeEnum displayMode = ReportingParty.ShipcallDisplayModeEnum.CLASSIC)
{ {
if(aMessageCore != null) if(aMessageCore != null)
{ {
@ -120,7 +121,7 @@ namespace ENI2
iDidLockIt); iDidLockIt);
searchResultItem.IsCancelled = aMessageCore.Cancelled ?? false; searchResultItem.IsCancelled = aMessageCore.Cancelled ?? false;
DetailRootControl drc = new DetailRootControl(aMessageCore); DetailRootControl drc = new DetailRootControl(aMessageCore, displayMode);
drc.LockedByOtherUser = !iDidLockIt; drc.LockedByOtherUser = !iDidLockIt;
if (!(aMessageCore.Cancelled ?? false)) if (!(aMessageCore.Cancelled ?? false))
@ -135,7 +136,7 @@ namespace ENI2
this._dbWatchDog.Register(aMessageCore); this._dbWatchDog.Register(aMessageCore);
drc.HighlightReset += Drc_HighlightReset; drc.HighlightReset += Drc_HighlightReset;
drc.OpenNewCoreRequested += (core) => this.AnmeldungenControl_MessageCoreSelected(core); drc.OpenNewCoreRequested += (core) => this.AnmeldungenControl_MessageCoreSelected(core, DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].ShipcallDisplayMode);
drc.ReloadCoreRequested += Drc_ReloadCoreRequested; drc.ReloadCoreRequested += Drc_ReloadCoreRequested;
} }
@ -218,15 +219,26 @@ namespace ENI2
// Dez.22: Special case for BRE/BRV: Warning if some messages are not "confirmed" // Dez.22: Special case for BRE/BRV: Warning if some messages are not "confirmed"
if(drc.Core.PoC.Equals("DEBRE")||drc.Core.PoC.Equals("DEBRV")) if(drc.Core.PoC.Equals("DEBRE")||drc.Core.PoC.Equals("DEBRV"))
{ {
if(drc.HasCriticalInfoMissing(out string missingClass)) if(drc.HasCriticalInfoMissing(out string missingClass, drc.Core.PoC))
{ {
_log.WarnFormat("set close warning because at least {0} is missing from BRE/BRV arrival", missingClass); // _log.WarnFormat("set close warning because at least {0} is missing from BRE/BRV/HAM arrival", missingClass);
if (MessageBox.Show(string.Format(Properties.Resources.textSpecialCaseBREBRV, missingClass), Properties.Resources.textConfirmation, MessageBoxButton.YesNo, if (MessageBox.Show(string.Format(Properties.Resources.textSpecialCaseBREBRV, missingClass), Properties.Resources.textConfirmation, MessageBoxButton.YesNo,
MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No) MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
e.Cancel = true; e.Cancel = true;
} }
} }
// Jul.24: Special case HAM extended (from above)
if (drc.Core.PoC.Equals("DEHAM"))
{
if (drc.HasCriticalInfoMissing(out string missingClass, drc.Core.PoC))
{
if (MessageBox.Show(string.Format(Properties.Resources.textSpecialCaseDEHAM, missingClass), Properties.Resources.textConfirmation, MessageBoxButton.YesNo,
MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
e.Cancel = true;
}
}
if (!e.Cancel) if (!e.Cancel)
{ {
if (lockedCores.ContainsKey(tabItem)) if (lockedCores.ContainsKey(tabItem))
@ -313,6 +325,14 @@ namespace ENI2
} }
this.rootContainer.Children.Add(this.vmControl); this.rootContainer.Children.Add(this.vmControl);
} }
else if(sender == this.menuItemEasyPeasy)
{
if(this.easyPeasyControl == null)
{
this.easyPeasyControl = new EasyPeasyControl();
}
this.rootContainer.Children.Add(this.easyPeasyControl);
}
} }
private void buttonCompareSheets_Click(object sender, RoutedEventArgs ev) private void buttonCompareSheets_Click(object sender, RoutedEventArgs ev)
@ -366,6 +386,8 @@ namespace ENI2
Properties.Settings.Default.MainWindowPlacement = this.GetPlacement(); Properties.Settings.Default.MainWindowPlacement = this.GetPlacement();
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
Microsoft.Win32.SystemEvents.SessionEnded -= SystemEvents_SessionEnded; Microsoft.Win32.SystemEvents.SessionEnded -= SystemEvents_SessionEnded;
if (easyPeasyControl != null)
easyPeasyControl.SaveState();
} }
private void Window_SourceInitialized(object sender, EventArgs e) private void Window_SourceInitialized(object sender, EventArgs e)
@ -461,7 +483,7 @@ namespace ENI2
if (((ShowIdDialog)sid).OpenCore) if (((ShowIdDialog)sid).OpenCore)
{ {
Dispatcher.BeginInvoke((Action)(() => { Dispatcher.BeginInvoke((Action)(() => {
this.AnmeldungenControl_MessageCoreSelected(closedDialog.Core); // in einem neuen Reiter öffnen this.AnmeldungenControl_MessageCoreSelected(closedDialog.Core, DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].ShipcallDisplayMode); // in einem neuen Reiter öffnen
})); }));
} }
@ -529,7 +551,7 @@ namespace ENI2
// Meldeklassen für neuen Anlauf erzeugen: // Meldeklassen für neuen Anlauf erzeugen:
bsmd.database.Util.CreateMessagesForCore(newCore, null, userEntity); bsmd.database.Util.CreateMessagesForCore(newCore, null, userEntity);
this.AnmeldungenControl_MessageCoreSelected(newCore); // in einem neuen Reiter öffnen this.AnmeldungenControl_MessageCoreSelected(newCore, DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].ShipcallDisplayMode); // in einem neuen Reiter öffnen
// watchdog registrieren, damit die "grüne" Markierung erscheint, sobald die Anmeldung durch den Excel-Prozess gelaufen ist. // watchdog registrieren, damit die "grüne" Markierung erscheint, sobald die Anmeldung durch den Excel-Prozess gelaufen ist.
this._dbWatchDog.Register(newCore); this._dbWatchDog.Register(newCore);
@ -601,7 +623,7 @@ namespace ENI2
showIdDialog.Closed += (sid, showIdArgs) => showIdDialog.Closed += (sid, showIdArgs) =>
{ {
if (((ShowIdDialog)sid).OpenCore) if (((ShowIdDialog)sid).OpenCore)
this.AnmeldungenControl_MessageCoreSelected(changedCore); this.AnmeldungenControl_MessageCoreSelected(changedCore, DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].ShipcallDisplayMode);
}; };
showIdDialog.Show(); showIdDialog.Show();
showIdDialog.Activate(); showIdDialog.Activate();
@ -679,6 +701,7 @@ namespace ENI2
ReportingParty.CurrentReportingParty = this.userEntity; ReportingParty.CurrentReportingParty = this.userEntity;
this.menuItemMaersk.Visibility = Visibility.Visible; this.menuItemMaersk.Visibility = Visibility.Visible;
this.menuItemValueMappings.Visibility = Visibility.Visible; this.menuItemValueMappings.Visibility = Visibility.Visible;
this.menuItemEasyPeasy.Visibility = Visibility.Visible;
if (this.userEntity.IsAdmin) if (this.userEntity.IsAdmin)
{ {
this.menuItemUserAdministration.Visibility = Visibility.Visible; this.menuItemUserAdministration.Visibility = Visibility.Visible;
@ -742,5 +765,6 @@ namespace ENI2
#endregion #endregion
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -586,6 +586,18 @@
<data name="user_edit" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="user_edit" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\user_edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\user_edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="user_edit4" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\user_edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="user_edit3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\user_edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="user_edit2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\user_edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="user_edit1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\user_edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="textSave" xml:space="preserve"> <data name="textSave" xml:space="preserve">
<value>Save</value> <value>Save</value>
</data> </data>
@ -1172,7 +1184,7 @@
<value>Category</value> <value>Category</value>
</data> </data>
<data name="textColumsOfIBC" xml:space="preserve"> <data name="textColumsOfIBC" xml:space="preserve">
<value>Columns "o" of OBC Code (value 15.19)</value> <value>Columns "o" of IBC Code (value 15.19)</value>
</data> </data>
<data name="textContainerNo" xml:space="preserve"> <data name="textContainerNo" xml:space="preserve">
<value>Container No.</value> <value>Container No.</value>
@ -1606,6 +1618,9 @@
<data name="textCopyClip" xml:space="preserve"> <data name="textCopyClip" xml:space="preserve">
<value>Copy Id to clipboard</value> <value>Copy Id to clipboard</value>
</data> </data>
<data name="textCopyShipnameClip" xml:space="preserve">
<value>Copy ship name to clipboard</value>
</data>
<data name="textUpdateStatus" xml:space="preserve"> <data name="textUpdateStatus" xml:space="preserve">
<value>Server status update</value> <value>Server status update</value>
</data> </data>
@ -1742,7 +1757,7 @@
<value>Select all</value> <value>Select all</value>
</data> </data>
<data name="textSelectImportClasses" xml:space="preserve"> <data name="textSelectImportClasses" xml:space="preserve">
<value>Select classes to import</value> <value>Select message classes</value>
</data> </data>
<data name="textSelectNone" xml:space="preserve"> <data name="textSelectNone" xml:space="preserve">
<value>Select none</value> <value>Select none</value>
@ -1859,7 +1874,7 @@
<value>Search NST2007 list</value> <value>Search NST2007 list</value>
</data> </data>
<data name="textSpecialCaseBREBRV" xml:space="preserve"> <data name="textSpecialCaseBREBRV" xml:space="preserve">
<value>At least one of NOA_NOD, AGNT, INFO, SEC, TIEFA hasn't been sent for DEBRE/DEBRV: ({0}) Close anyway?</value> <value>At least one of NOA_NOD, AGNT, INFO, SEC, TIEFA, SERV hasn't been sent for DEBRE/DEBRV/DEHAM: ({0}) Close anyway?</value>
</data> </data>
<data name="about" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="about" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\about.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\about.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
@ -1900,4 +1915,357 @@
<data name="textCopyToPASD" xml:space="preserve"> <data name="textCopyToPASD" xml:space="preserve">
<value>Copy to PASD</value> <value>Copy to PASD</value>
</data> </data>
<data name="textSpecialCaseDEHAM" xml:space="preserve">
<value>{0} has not been sent for DEHAM. Close anyway?</value>
</data>
<data name="textDeleteAllEntries" xml:space="preserve">
<value>Delete all entries</value>
</data>
<data name="textConfimDeleteAllEntries" xml:space="preserve">
<value>This will delete all entries. Are you sure?</value>
</data>
<data name="textVoyage" xml:space="preserve">
<value>1. Voyage</value>
</data>
<data name="text11PreviousPort" xml:space="preserve">
<value>1.1 Previous port</value>
</data>
<data name="text12IncomingVoyage" xml:space="preserve">
<value>1.2 Incoming voyage</value>
</data>
<data name="text13RelevantPortcall" xml:space="preserve">
<value>1.3 Relevant Portcall (port of call) / Kiel-Canal-Transit</value>
</data>
<data name="text14OutgoingVoyage" xml:space="preserve">
<value>1.4 Outgoing voyage</value>
</data>
<data name="text15NextPort" xml:space="preserve">
<value>1.5 Next port</value>
</data>
<data name="text16Voyage" xml:space="preserve">
<value>1.5 Voyage</value>
</data>
<data name="text17Last10PortFacilitiesCalled" xml:space="preserve">
<value>1.7 Last 10 port facilities called</value>
</data>
<data name="text18ShipToShip" xml:space="preserve">
<value>1.8 Ship to ship activities during last 10 port facilities called</value>
</data>
<data name="text19PortsCalled30days" xml:space="preserve">
<value>1.9 Ports called during the last 30 days</value>
</data>
<data name="text110MaritimeHealthData" xml:space="preserve">
<value>1.10 Maritime health data</value>
</data>
<data name="text111PortOfItinerary" xml:space="preserve">
<value>1.11 Port of itinerary</value>
</data>
<data name="textDefaultDisplay" xml:space="preserve">
<value>Default display</value>
</data>
<data name="textOpenClassic" xml:space="preserve">
<value>Open in classic display mode</value>
</data>
<data name="textOpenFormsheet" xml:space="preserve">
<value>Open in form sheet display mode</value>
</data>
<data name="text1Voyage" xml:space="preserve">
<value>1. Voyage</value>
</data>
<data name="text2PortCall" xml:space="preserve">
<value>2. Port call</value>
</data>
<data name="text21ReferenceNumbers" xml:space="preserve">
<value>2.1 Reference numbers</value>
</data>
<data name="text22PortOperations" xml:space="preserve">
<value>2.2 Port operations</value>
</data>
<data name="text23Agency" xml:space="preserve">
<value>2.3 Agency</value>
</data>
<data name="text24Invoice" xml:space="preserve">
<value>2.4 Invoice (concerning mooring fees, disposal costs etc.)</value>
</data>
<data name="text25CargeOnBoard" xml:space="preserve">
<value>2.5 Cargo on board related to incoming journey</value>
</data>
<data name="text26CargoPort" xml:space="preserve">
<value>2.6 Cargo handled in port of call (cargo to discharge / load / transiting)</value>
</data>
<data name="text27Waste" xml:space="preserve">
<value>2.7 Waste (MARPOL) data</value>
</data>
<data name="text28Store" xml:space="preserve">
<value>2.8 Store information</value>
</data>
<data name="text29CrewEffects" xml:space="preserve">
<value>2.9 IMO crew effects declaration (IMO FAL form 4)</value>
</data>
<data name="textStore" xml:space="preserve">
<value>Store</value>
</data>
<data name="textQuantityUnit" xml:space="preserve">
<value>Quantity unit</value>
</data>
<data name="textLocationOnBoard" xml:space="preserve">
<value>Location on board</value>
</data>
<data name="textOfficialUse" xml:space="preserve">
<value>Official use</value>
</data>
<data name="text3PreArrival" xml:space="preserve">
<value>3. Pre-arrival</value>
</data>
<data name="text31General" xml:space="preserve">
<value>3.1 General</value>
</data>
<data name="text32PersonsOnBoard" xml:space="preserve">
<value>3.2 Persons on board on arrival</value>
</data>
<data name="text33BunkerOnArrival" xml:space="preserve">
<value>3.3 Bunker on arrival</value>
</data>
<data name="text34DangerousCargo" xml:space="preserve">
<value>3.4 Dangerous cargo on board on arrival</value>
</data>
<data name="text36TowOnArrival" xml:space="preserve">
<value>3.5 Tow (barge, pontoon, etc.) on arrival</value>
</data>
<data name="textAreMatterToReport" xml:space="preserve">
<value>Are any security-related matters to report?</value>
</data>
<data name="textMatterToReport" xml:space="preserve">
<value>if yes, description of matters to report</value>
</data>
<data name="text4PreDeparture" xml:space="preserve">
<value>4. Pre-departure</value>
</data>
<data name="text42PersonsOnBoard" xml:space="preserve">
<value>4.2 Persons on board on departure</value>
</data>
<data name="text43BunkerOnDeparture" xml:space="preserve">
<value>4.3 Bunker on departure</value>
</data>
<data name="text44DangerousCargo" xml:space="preserve">
<value>4.4 Dangerous cargo on board on departure</value>
</data>
<data name="text45TowOnDeparture" xml:space="preserve">
<value>4.5 Tow (barge, pontoon etc.) on departure</value>
</data>
<data name="text41General" xml:space="preserve">
<value>4.1 General</value>
</data>
<data name="text5ShipData" xml:space="preserve">
<value>5. Ship data</value>
</data>
<data name="text51General" xml:space="preserve">
<value>5.1 General</value>
</data>
<data name="text52SSCEC" xml:space="preserve">
<value>5.2 SSCEC</value>
</data>
<data name="text53ISPS" xml:space="preserve">
<value>5.3 ISPS</value>
</data>
<data name="text54TankerDetails" xml:space="preserve">
<value>5.4 Tanker details</value>
</data>
<data name="textNetTonnage" xml:space="preserve">
<value>Net tonnage</value>
</data>
<data name="textRegistryDate" xml:space="preserve">
<value>Registry date</value>
</data>
<data name="textCertificateOfRegistryNumber" xml:space="preserve">
<value>Certificate of registry number</value>
</data>
<data name="textIsDueToInspection" xml:space="preserve">
<value>Is due to inspection?</value>
</data>
<data name="textPossibleAnchorage" xml:space="preserve">
<value>Possible anchorage?</value>
</data>
<data name="textShipEmail" xml:space="preserve">
<value>Ship e-mail</value>
</data>
<data name="text6CrewDataOnArrival" xml:space="preserve">
<value>6. Crew data on arrival</value>
</data>
<data name="text7CrewDeparture" xml:space="preserve">
<value>7. Crew data on departure</value>
</data>
<data name="text8PassengerArrival" xml:space="preserve">
<value>8. Passenger data on arrival</value>
</data>
<data name="text9PassengerDeparture" xml:space="preserve">
<value>9. Passenger data on departure</value>
</data>
<data name="text10DangerousCargoArrival" xml:space="preserve">
<value>10. Dangerous cargo data on arrival</value>
</data>
<data name="text11DangerousCargoDeparture" xml:space="preserve">
<value>11. Dangerous cargo data on departure</value>
</data>
<data name="text12ATAATD" xml:space="preserve">
<value>12. Actual time of arrival / departure</value>
</data>
<data name="text13WasteReceipts" xml:space="preserve">
<value>13. Waste receipts</value>
</data>
<data name="textDGContactFamilyName" xml:space="preserve">
<value>DG manifest contact - family name</value>
</data>
<data name="textDGContactPhone" xml:space="preserve">
<value>DG manifest contact - phone</value>
</data>
<data name="text102IBCData" xml:space="preserve">
<value>10.2 IBC data (on arrival), if applicable</value>
</data>
<data name="text10.3IGCData" xml:space="preserve">
<value>10.3 IGC data (on arrival), if applicable</value>
</data>
<data name="text104IMSBCData" xml:space="preserve">
<value>10.4 IMSBC data (on arrival), if applicable</value>
</data>
<data name="text103IGCData" xml:space="preserve">
<value>10.3 IGC data (on arrival), if applicable</value>
</data>
<data name="text105MARPOLData" xml:space="preserve">
<value>10.5 MARPOL I data (on arrival), if applicable</value>
</data>
<data name="text106IMDGData" xml:space="preserve">
<value>10.6 IMDG data (on arrival), if applicable</value>
</data>
<data name="text101General" xml:space="preserve">
<value>10.1 General</value>
</data>
<data name="text111General" xml:space="preserve">
<value>11.1 General</value>
</data>
<data name="text112IBCData" xml:space="preserve">
<value>11.2 IBC data (on departure), if applicable</value>
</data>
<data name="text113IGCData" xml:space="preserve">
<value>11.3 IGC data (on departure), if applicable</value>
</data>
<data name="text114IMSBCData" xml:space="preserve">
<value>11.4 IMSBC data (on departure), if applicable</value>
</data>
<data name="text115MARPOLData" xml:space="preserve">
<value>11.5 MARPOL I data (on departure), if applicable</value>
</data>
<data name="text116IMDGData" xml:space="preserve">
<value>11.6 IMDG data (on departure), if applicable</value>
</data>
<data name="text121ATA" xml:space="preserve">
<value>12.1 Actual time of arrival</value>
</data>
<data name="text122ATD" xml:space="preserve">
<value>12.2 Actual time of departure</value>
</data>
<data name="text131WasteReceipt" xml:space="preserve">
<value>13.1 Waste receipt</value>
</data>
<data name="clock" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\clock.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="text102" xml:space="preserve">
<value>2 IBC</value>
</data>
<data name="text103" xml:space="preserve">
<value>3 IGC</value>
</data>
<data name="text104" xml:space="preserve">
<value>4 IMSBC</value>
</data>
<data name="text105" xml:space="preserve">
<value>5 MARPOL I</value>
</data>
<data name="text106" xml:space="preserve">
<value>6 IMDG</value>
</data>
<data name="textTab11" xml:space="preserve">
<value>1-6 Actual</value>
</data>
<data name="textTab12" xml:space="preserve">
<value>7-9 Tables</value>
</data>
<data name="textTab13" xml:space="preserve">
<value>10 MDH</value>
</data>
<data name="textTab14" xml:space="preserve">
<value>11 Cruise</value>
</data>
<data name="textTab21" xml:space="preserve">
<value>1-2 Berth</value>
</data>
<data name="textTab22" xml:space="preserve">
<value>3-4 Contact</value>
</data>
<data name="textTab23" xml:space="preserve">
<value>5-6 Cargo</value>
</data>
<data name="textTab24" xml:space="preserve">
<value>7 Waste</value>
</data>
<data name="textTab51" xml:space="preserve">
<value>1 General</value>
</data>
<data name="textTab52" xml:space="preserve">
<value>2-3 MDH / SEC</value>
</data>
<data name="textTab53" xml:space="preserve">
<value>4 Tanker</value>
</data>
<data name="textNewPassword" xml:space="preserve">
<value>New password</value>
</data>
<data name="textOldPassword" xml:space="preserve">
<value>Old password</value>
</data>
<data name="textRepeatNewPassword" xml:space="preserve">
<value>Repeat new password</value>
</data>
<data name="textMDHSimplification" xml:space="preserve">
<value>MDH simplification available</value>
</data>
<data name="textSECSimplification" xml:space="preserve">
<value>SEC simplification available</value>
</data>
<data name="textCopyFromCREWA" xml:space="preserve">
<value>Copy from CREWA</value>
</data>
<data name="textSelectCrewMember" xml:space="preserve">
<value>Select crew member</value>
</data>
<data name="textSERVTemplate" xml:space="preserve">
<value>SERV-Template</value>
</data>
<data name="pencil" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\pencil.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="textWasteDisposalServiceProvider" xml:space="preserve">
<value>Waste disposal service provider</value>
</data>
<data name="textSendAll" xml:space="preserve">
<value>Send all</value>
</data>
<data name="textENIStatus" xml:space="preserve">
<value>ENI-Status</value>
</data>
<data name="textNSWStatus" xml:space="preserve">
<value>NSW-Status</value>
</data>
<data name="textConfirmWSDPOverwrite" xml:space="preserve">
<value>The existing value for the waste disposal service provider will be overwritten.
Current entry: {0}
New entry: {1}
Proceed?</value>
</data>
<data name="textEasyPeasy" xml:space="preserve">
<value>Easy Peasy 🍋</value>
</data>
</root> </root>

View File

@ -12,7 +12,7 @@ namespace ENI2.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -161,5 +161,29 @@ namespace ENI2.Properties {
this["W2Top"] = value; this["W2Top"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public string W3Left {
get {
return ((string)(this["W3Left"]));
}
set {
this["W3Left"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public string W3Top {
get {
return ((string)(this["W3Top"]));
}
set {
this["W3Top"] = value;
}
}
} }
} }

View File

@ -41,5 +41,11 @@
<Setting Name="W2Top" Type="System.String" Scope="User"> <Setting Name="W2Top" Type="System.String" Scope="User">
<Value Profile="(Default)">0</Value> <Value Profile="(Default)">0</Value>
</Setting> </Setting>
<Setting Name="W3Left" Type="System.String" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="W3Top" Type="System.String" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

BIN
ENI2/Report/Logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -101,7 +101,7 @@ namespace ENI2.Report
string migraTempFile = string.Format("{1}\\{0}.mdddl", filenameCore, Path.GetDirectoryName(filename)); string migraTempFile = string.Format("{1}\\{0}.mdddl", filenameCore, Path.GetDirectoryName(filename));
MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, migraTempFile); MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, migraTempFile);
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true); PdfDocumentRenderer renderer = new PdfDocumentRenderer();
renderer.Document = document; renderer.Document = document;
renderer.RenderDocument(); renderer.RenderDocument();
@ -254,7 +254,7 @@ namespace ENI2.Report
table.AddColumn(140); table.AddColumn(140);
Row row = table.AddRow(); Row row = table.AddRow();
Image logoImage = row.Cells[0].AddImage(@"Report\Logo.gif"); // kann man offenbar nur von einem Pfad laden Image logoImage = row.Cells[0].AddImage(@"Report\Logo.png"); // kann man offenbar nur von einem Pfad laden
logoImage.Width = 80; logoImage.Width = 80;
row.Cells[0].MergeDown = 6; row.Cells[0].MergeDown = 6;
@ -1250,8 +1250,9 @@ namespace ENI2.Report
private static void CreateWAS_RCPTTable(Document document, Message message) private static void CreateWAS_RCPTTable(Document document, Message message)
{ {
foreach (WAS_RCPT was_rpct in message.Elements) for (int i = 0; i < message.Elements.Count; i++)
{ {
WAS_RCPT was_rpct = (WAS_RCPT)message.Elements[i];
document.LastSection.AddParagraph(""); document.LastSection.AddParagraph("");
Table table = AddGrayTable(document); Table table = AddGrayTable(document);

BIN
ENI2/Resources/Logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
ENI2/Resources/clock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
ENI2/Resources/pencil.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -117,7 +117,7 @@ namespace ENI2.LockingServiceReference {
return this.CORRUPTFilesField; return this.CORRUPTFilesField;
} }
set { set {
if ((ReferenceEquals(this.CORRUPTFilesField, value) != true)) { if ((object.ReferenceEquals(this.CORRUPTFilesField, value) != true)) {
this.CORRUPTFilesField = value; this.CORRUPTFilesField = value;
this.RaisePropertyChanged("CORRUPTFiles"); this.RaisePropertyChanged("CORRUPTFiles");
} }
@ -143,7 +143,7 @@ namespace ENI2.LockingServiceReference {
return this.IMPFilesField; return this.IMPFilesField;
} }
set { set {
if ((ReferenceEquals(this.IMPFilesField, value) != true)) { if ((object.ReferenceEquals(this.IMPFilesField, value) != true)) {
this.IMPFilesField = value; this.IMPFilesField = value;
this.RaisePropertyChanged("IMPFiles"); this.RaisePropertyChanged("IMPFiles");
} }
@ -156,7 +156,7 @@ namespace ENI2.LockingServiceReference {
return this.READYFilesField; return this.READYFilesField;
} }
set { set {
if ((ReferenceEquals(this.READYFilesField, value) != true)) { if ((object.ReferenceEquals(this.READYFilesField, value) != true)) {
this.READYFilesField = value; this.READYFilesField = value;
this.RaisePropertyChanged("READYFiles"); this.RaisePropertyChanged("READYFiles");
} }

View File

@ -0,0 +1,46 @@
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
x:Class="ENI2.SheetDisplayControls.ATAControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:util="clr-namespace:ENI2.Util"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:ENI2.SheetDisplayControls"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="800">
<GroupBox Name="portCallGroupBox" Header="{x:Static p:Resources.text12ATAATD}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width=".3*" />
<ColumnDefinition Width=".3*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="36" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text121ATA}" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"/>
<Label Content="ATA" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<xctk:DateTimePicker Grid.Column="1" Grid.Row="1" Value="{Binding ATAPortOfCall, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePickerATA" Format="Custom"
FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}"
TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00" PreviewKeyUp="DateTimePicker_PreviewKeyUp" ValueChanged="dateTimePickerATA_ValueChanged" />
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text122ATD}" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"/>
<Label Content="ATD" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<xctk:DateTimePicker Grid.Column="1" Grid.Row="3" Value="{Binding ATDPortOfCall, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePickerATD" Format="Custom"
FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}"
TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00" PreviewKeyUp="DateTimePicker_PreviewKeyUp" ValueChanged="dateTimePickerATD_ValueChanged"/>
</Grid>
</ScrollViewer>
</GroupBox>
</src:DetailBaseControl>

View File

@ -0,0 +1,113 @@
// Copyright (c) 2025- schick Informatik
// Description: Display control of formsheet Tab 12. ATA ATD
//
using bsmd.database;
using System;
using System.Windows;
namespace ENI2.SheetDisplayControls
{
/// <summary>
/// Interaction logic for ATAControl.xaml
/// </summary>
public partial class ATAControl : DetailBaseControl
{
#region Fields
ATA _ata;
ATD _atd;
bool startupComplete = false;
#endregion
#region Fields
public ATAControl()
{
InitializeComponent();
Loaded += ATAControl_Loaded;
}
#endregion
#region public overrides
public override void Initialize()
{
base.Initialize();
foreach (Message aMessage in this.Messages)
{
if (aMessage.MessageNotificationClass == Message.NotificationClass.ATA)
{
this.ControlMessages.Add(aMessage);
if (aMessage.Elements.Count > 0)
_ata = aMessage.Elements[0] as ATA;
if (_ata == null)
{
_ata = new ATA();
_ata.MessageCore = this.Core;
_ata.MessageHeader = aMessage;
aMessage.Elements.Add(_ata);
}
this.dateTimePickerATA.DataContext = _ata;
}
if (aMessage.MessageNotificationClass == Message.NotificationClass.ATD)
{
this.ControlMessages.Add(aMessage);
if (aMessage.Elements.Count > 0)
_atd = aMessage.Elements[0] as ATD;
if (_atd == null)
{
_atd = new ATD();
_atd.MessageCore = this.Core;
_atd.MessageHeader = aMessage;
aMessage.Elements.Add(_atd);
}
this.dateTimePickerATD.DataContext = _atd;
}
}
}
public override void SetEnabled(bool enabled)
{
base.SetEnabled(enabled);
this.portCallGroupBox.IsEnabled = enabled;
}
#endregion
#region event handler
private void ATAControl_Loaded(object sender, RoutedEventArgs e)
{
this.RegisterDateTimePickerChange(this.dateTimePickerATA, Message.NotificationClass.ATA);
this.RegisterDateTimePickerChange(this.dateTimePickerATD, Message.NotificationClass.ATD);
startupComplete = true;
}
private void dateTimePickerATD_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
if (startupComplete && this.dateTimePickerATD.Value.HasValue)
{
DateTime setTime = this.dateTimePickerATD.Value.Value;
if ((setTime > DateTime.Now.AddDays(14)) || (setTime < DateTime.Now.AddDays(-14)))
MessageBox.Show("ATD value may be invalid", "Date implausible", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
private void dateTimePickerATA_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
if (startupComplete && this.dateTimePickerATA.Value.HasValue)
{
DateTime setTime = this.dateTimePickerATA.Value.Value;
if ((setTime > DateTime.Now.AddDays(14)) || (setTime < DateTime.Now.AddDays(-14)))
MessageBox.Show("ATA value may be invalid", "Date implausible", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
#endregion
}
}

View File

@ -0,0 +1,64 @@
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
x:Class="ENI2.SheetDisplayControls.CrewDepartureControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:util="clr-namespace:ENI2.Util"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:ENI2.SheetDisplayControls"
mc:Ignorable="d"
d:DesignHeight="1450" d:DesignWidth="800">
<GroupBox Name="crewDepartureGroupBox" Header="{x:Static p:Resources.text7CrewDeparture}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220"/>
<ColumnDefinition Width=".65*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="8" />
<RowDefinition Height="28" />
<RowDefinition Height="640" />
</Grid.RowDefinitions>
<Label Name="labelCrewNotificationSchengenDeparture" Content="{x:Static p:Resources.textNotificationSchengen}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right"/>
<CheckBox Name="checkBoxCrewNotificationSchengenDeparture" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationSchengenDeparture_Click" Grid.Row="0" Grid.Column="1"/>
<Label Name="labelCrewNotificationPAXDeparture" Content="{x:Static p:Resources.textNotificationPAX}" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right"/>
<CheckBox Name="checkBoxCrewNotificationPAXDeparture" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationPAXDeparture_Click" Grid.Row="1" Grid.Column="1" />
<Button Grid.Row="3" Grid.Column="0" Name="buttonImportExcelCrewDeparture" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Width="120" HorizontalAlignment="Right" VerticalAlignment="Center" Background="Transparent" Click="buttonImportExcelCrewDeparture_Click" />
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal">
<TextBlock Margin="20, 0, 0, 0" Name="textBlockNumCrewEntriesDeparture" FontWeight="Bold" Text="{Binding Elements.Count}" VerticalAlignment="Center"/>
<Label Name="labelCrewEntryCountDeparture" Content="{x:Static p:Resources.textEntries}" />
<Button Name="buttonDeleteAllCrewD" Margin="2" Content="{x:Static p:Resources.textDeleteAllEntries}" Background="Transparent" Click="buttonDeleteAllCrewD_Click"/>
</StackPanel>
<enictrl:ENIDataGrid Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" x:Name="dataGridCrewListDeparture" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textLastName}" Binding="{Binding CrewMemberLastName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textFirstName}" Binding="{Binding CrewMemberFirstName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textGender}" Binding="{Binding CrewMemberGenderDisplay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCrewFunctionOnBoard}" Binding="{Binding CrewMemberDuty, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textNationality}" Binding="{Binding CrewMemberNationality, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textPlaceOfBirth}" Binding="{Binding CrewMemberPlaceOfBirth, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCountryOfBirth}" Binding="{Binding CrewMemberCountryOfBirth, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDateOfBirth}" Binding="{Binding CrewMemberDateOfBirth, Mode=TwoWay, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocType}" Binding="{Binding CrewMemberIdentityDocumentTypeDisplay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocNumber}" Binding="{Binding CrewMemberIdentityDocumentId, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentIssuingState}" Binding="{Binding CrewMemberIdentityDocumentIssuingState, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentExpiryDate}" Binding="{Binding CrewMemberIdentityDocumentExpiryDate, Mode=TwoWay, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textVisaNumber}" Binding="{Binding CrewMemberVisaNumber, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</ScrollViewer>
</GroupBox>
</src:DetailBaseControl>

View File

@ -0,0 +1,376 @@
// Copyright (c) 2025 - schick Informatik
// Description: Display control of formsheet Tab 7. Crew data departure
//
using bsmd.database;
using ClosedXML.Excel;
using ENI2.EditControls;
using ENI2.Util;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace ENI2.SheetDisplayControls
{
/// <summary>
/// Interaction logic for CrewDepartureControl.xaml
/// </summary>
public partial class CrewDepartureControl : DetailBaseControl
{
#region Fields
private Message _crewaMessage;
private Message _crewdMessage;
#endregion
#region Construction
public CrewDepartureControl()
{
InitializeComponent();
}
#endregion
#region public overrides
public override void Initialize()
{
base.Initialize();
foreach (Message aMessage in this.Messages)
{
if (aMessage.MessageNotificationClass == Message.NotificationClass.CREWA) { this._crewaMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.CREWD) { this._crewdMessage = aMessage; this.ControlMessages.Add(aMessage); }
}
#region init CREWD
if (this._crewdMessage == null)
{
this._crewdMessage = this.Core.CreateMessage(Message.NotificationClass.CREWD);
this.Messages.Add(this._crewdMessage);
}
this.dataGridCrewListDeparture.Initialize();
this.dataGridCrewListDeparture.ItemsSource = this._crewdMessage.Elements;
this.dataGridCrewListDeparture.AddingNewItem += DataGridCrewListDeparture_AddingNewItem;
this.dataGridCrewListDeparture.EditRequested += DataGridCrewListDeparture_EditRequested;
this.dataGridCrewListDeparture.DeleteRequested += DataGridCrewListDeparture_DeleteRequested;
this.dataGridCrewListDeparture.CreateRequested += DataGridCrewListDeparture_CreateRequested;
this.dataGridCrewListDeparture.RefreshGrid += DataGridCrewListDeparture_RefreshGrid;
this.dataGridCrewListDeparture.MultiEditRequested += DataGridCrewListDeparture_MultiEditRequested;
if (this._crewdMessage.Elements.Count > 0)
{
this.checkBoxCrewNotificationSchengenDeparture.IsChecked = ((CREWD)this._crewdMessage.Elements[0]).NotificationSchengen;
this.checkBoxCrewNotificationPAXDeparture.IsChecked = ((CREWD)this._crewdMessage.Elements[0]).NotificationPAX;
}
this.textBlockNumCrewEntriesDeparture.DataContext = this._crewdMessage;
// extra menu copy to CREWA
{
this.dataGridCrewListDeparture.ContextMenu.Items.Add(new Separator());
MenuItem copyCREWDItem = new MenuItem();
copyCREWDItem.Header = Properties.Resources.textCopyToCREWA;
copyCREWDItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
copyCREWDItem.Click += CopyCREWDItem_Click; ;
this.dataGridCrewListDeparture.ContextMenu.Items.Add(copyCREWDItem);
}
#endregion
}
public override void SetEnabled(bool enabled)
{
base.SetEnabled(enabled);
this.crewDepartureGroupBox.IsEnabled = enabled;
}
#endregion
#region event handler
private void checkBoxCrewNotificationSchengenDeparture_Click(object sender, RoutedEventArgs e)
{
foreach (CREWD crewd in _crewdMessage.Elements.Cast<CREWD>())
{
crewd.NotificationSchengen = checkBoxCrewNotificationSchengenDeparture.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
private void checkBoxCrewNotificationPAXDeparture_Click(object sender, RoutedEventArgs e)
{
foreach (CREWD crewd in _crewdMessage.Elements.Cast<CREWD>())
{
crewd.NotificationSchengen = checkBoxCrewNotificationSchengenDeparture.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
private void buttonImportExcelCrewDeparture_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog
{
Filter = "Excel Files|*.xls;*.xlsx"
};
if (ofd.ShowDialog() ?? false)
{
try
{
using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var workbook = new XLWorkbook(stream))
{
var worksheet = workbook.Worksheet(1); // Get first worksheet
var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
List<CREWD> importCrew = new List<CREWD>();
foreach (var row in rows)
{
if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
// Check if we have at least 13 columns
if (worksheet.RangeUsed().ColumnCount() < 13)
{
throw new InvalidDataException("Sheet must have 13 columns of data");
}
CREWD crew = new CREWD();
crew.IsDeparture = true;
// Check if first two cells are empty
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (!row.Cell(1).IsEmpty()) crew.CrewMemberLastName = row.Cell(1).GetString().Clean();
if (crew.CrewMemberLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(crew.CrewMemberLastName)) continue;
if (!row.Cell(2).IsEmpty()) crew.CrewMemberFirstName = row.Cell(2).GetString().Clean();
if (!row.Cell(3).IsEmpty()) crew.CrewMemberGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
if (!row.Cell(4).IsEmpty()) crew.CrewMemberDuty = row.Cell(4).GetString().Clean();
if (!row.Cell(5).IsEmpty()) crew.CrewMemberNationality = row.Cell(5).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(6).IsEmpty()) crew.CrewMemberPlaceOfBirth = row.Cell(6).GetString().Clean();
if (!row.Cell(7).IsEmpty()) crew.CrewMemberCountryOfBirth = row.Cell(7).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(8).IsEmpty()) crew.CrewMemberDateOfBirth = row.Cell(8).GetDateTime();
if (!row.Cell(9).IsEmpty()) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(9).GetString());
if (!row.Cell(10).IsEmpty()) crew.CrewMemberIdentityDocumentId = row.Cell(10).GetString().Clean();
if (!row.Cell(11).IsEmpty()) crew.CrewMemberIdentityDocumentIssuingState = row.Cell(11).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(12).IsEmpty()) crew.CrewMemberIdentityDocumentExpiryDate = row.Cell(12).GetDateTime();
if (!row.Cell(13).IsEmpty()) crew.CrewMemberVisaNumber = row.Cell(13).GetString().Clean();
crew.MessageHeader = this._crewdMessage;
crew.IsDirty = true;
crew.Identifier = CREWD.GetNewIdentifier(this._crewdMessage.Elements);
this._crewdMessage.Elements.Add(crew);
importCrew.Add(crew);
}
if (importCrew.Count > 0)
{
this.dataGridCrewListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWD);
MessageBox.Show(String.Format(Properties.Resources.textCrewImported, importCrew.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
private async void buttonDeleteAllCrewD_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show(Properties.Resources.textConfimDeleteAllEntries, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
foreach (CREWD crewd in this._crewdMessage.Elements.Cast<CREWD>())
{
await DBManagerAsync.DeleteAsync(crewd);
}
this._crewdMessage.Elements.Clear();
this.dataGridCrewListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
}
private void CopyCREWDItem_Click(object sender, RoutedEventArgs e)
{
if (this.dataGridCrewListDeparture.SelectedItems != null)
{
foreach (CREWD crewd in this.dataGridCrewListDeparture.SelectedItems)
{
CREW crewa = new CREW();
crewa.MessageHeader = this._crewaMessage;
crewa.CopyFromCREW(crewd);
crewa.IsDeparture = false;
crewa.Identifier = DatabaseEntity.GetNewIdentifier(this._crewaMessage.Elements);
this._crewaMessage.Elements.Add(crewa);
this.SublistElementChanged(Message.NotificationClass.CREWA);
}
}
}
#endregion
#region crew grid departure
private void DataGridCrewListDeparture_CreateRequested()
{
EditCREWDialog ecd = new EditCREWDialog
{
CREW = new CREWD()
};
ecd.CREW.IsDeparture = true;
ecd.CREW.Identifier = CREWD.GetNewIdentifier(_crewdMessage.Elements);
ecd.CREW.MessageHeader = this._crewdMessage;
ecd.AddClicked += () =>
{
ecd.CopyValuesToEntity();
if (!this._crewdMessage.Elements.Contains(ecd.CREW))
{
this._crewdMessage.Elements.Add(ecd.CREW);
this.CheckCREWD();
}
this.dataGridCrewListDeparture.Items.Refresh();
ecd.CREW = new CREWD
{
IsDeparture = true,
MessageHeader = this._crewdMessage,
Identifier = CREWD.GetNewIdentifier(_crewdMessage.Elements)
};
this.SublistElementChanged(Message.NotificationClass.CREWD);
};
if (ecd.ShowDialog() ?? false)
{
if (!this._crewdMessage.Elements.Contains(ecd.CREW))
{
_crewdMessage.Elements.Add(ecd.CREW);
this.CheckCREWD();
}
this.dataGridCrewListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
}
private void DataGridCrewListDeparture_DeleteRequested(DatabaseEntity obj)
{
if (obj is CREWD crewd)
{
// are you sure dialog is in base class
_crewdMessage.Elements.Remove(crewd);
DBManager.Instance.Delete(crewd);
}
}
private void DataGridCrewListDeparture_RefreshGrid()
{
DatabaseEntity.ResetIdentifiers(_crewdMessage.Elements);
this.SublistElementChanged(Message.NotificationClass.CREWD);
this.dataGridCrewListDeparture.Items.Refresh();
}
private void DataGridCrewListDeparture_EditRequested(DatabaseEntity obj)
{
EditCREWDialog ecd = new EditCREWDialog
{
CREW = obj as CREWD
};
ecd.AddClicked += () =>
{
ecd.CopyValuesToEntity();
if (!_crewdMessage.Elements.Contains(ecd.CREW))
{
_crewdMessage.Elements.Add(ecd.CREW);
this.CheckCREWD();
}
this.dataGridCrewListDeparture.Items.Refresh();
ecd.CREW = new CREWD
{
IsDeparture = true,
Identifier = CREWD.GetNewIdentifier(_crewdMessage.Elements),
MessageHeader = _crewdMessage
};
this.SublistElementChanged(Message.NotificationClass.CREWD);
};
if (ecd.ShowDialog() ?? false)
{
if (!_crewdMessage.Elements.Contains(ecd.CREW))
{
_crewdMessage.Elements.Add(ecd.CREW);
this.CheckCREWD();
}
ecd.CREW.IsDirty = true;
this.dataGridCrewListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
}
private void DataGridCrewListDeparture_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
this.DataGridCrewListDeparture_CreateRequested();
}
private void DataGridCrewListDeparture_MultiEditRequested(List<DatabaseEntity> databaseEntities)
{
List<CREW> crewList = new List<CREW>();
foreach (CREW acrew in databaseEntities.Cast<CREW>())
crewList.Add(acrew);
// write common values of all CREW entities to template entity
CREW crew = CREW.CreateCommon(crewList);
EditCREWDialog dialog = new EditCREWDialog();
dialog.CREW = crew;
dialog.AddVisible = false;
if (dialog.ShowDialog() ?? false)
{
// write back changed values from crew to all entities and mark them as changed
CREW.WriteTemplateToList(crew, crewList);
this.SublistElementChanged(Message.NotificationClass.CREWD);
this.dataGridCrewListDeparture.Items.Refresh();
}
}
#endregion
#region private methods
private void CheckCREWD()
{
if (this._crewdMessage.Elements.Count == 0) return;
CREWD firstCREW = this._crewdMessage.Elements[0] as CREWD;
if (this._crewdMessage.Elements.Count == 1)
{
firstCREW.NotificationSchengen = true;
this.checkBoxCrewNotificationSchengenDeparture.IsChecked = true;
}
else
{
for (int i = 1; i < this._crewdMessage.Elements.Count; i++)
{
((CREWD)this._crewdMessage.Elements[i]).NotificationSchengen = firstCREW.NotificationSchengen;
}
}
}
#endregion
}
}

View File

@ -0,0 +1,68 @@
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
x:Class="ENI2.SheetDisplayControls.CrewPreArrivalControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:util="clr-namespace:ENI2.Util"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:ENI2.SheetDisplayControls"
mc:Ignorable="d"
d:DesignHeight="1450" d:DesignWidth="800">
<GroupBox Name="crewPreArrivalGroupBox" Header="{x:Static p:Resources.text6CrewDataOnArrival}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220"/>
<ColumnDefinition Width=".3*" />
<ColumnDefinition Width=".3*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="8" />
<RowDefinition Height="28" />
<RowDefinition Height="640" />
</Grid.RowDefinitions>
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textNameMaster}" Name="label_nameMaster" Margin="0,0,10,0"/>
<TextBox Grid.Row="0" Grid.Column="1" Name="textBox_NameMaster" MaxLength="100" Margin="2" Text="{Binding NameOfMaster, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center" />
<Button Grid.Row="0" Grid.Column="2" Content="{x:Static p:Resources.textCopyFromCREWA}" Margin="2" Width="120" HorizontalAlignment="Left" x:Name="buttonCopyFromCrewA" Click="buttonCopyFromCrewA_Click" />
<Label Name="labelCrewNotificationSchengen" Content="{x:Static p:Resources.textNotificationSchengen}" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right"/>
<CheckBox Name="checkBoxCrewNotificationSchengen" Grid.Row="1" Grid.Column="1" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationSchengen_Click"/>
<Label Name="labelCrewNotificationPAX" Content="{x:Static p:Resources.textNotificationPAX}" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" />
<CheckBox Name="checkBoxCrewNotificationPAX" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationPAX_Click" Grid.Row="2" Grid.Column="1"/>
<Button Name="buttonImportExcelCrew" Grid.Row="4" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2,2,10,2" Width="120" HorizontalAlignment="Right" VerticalAlignment="Center" Background="Transparent" Click="buttonImportExcelCrew_Click" />
<StackPanel Grid.Row="4" Grid.Column="1" Orientation="Horizontal">
<TextBlock Margin="20, 0, 0, 0" Name="textBlockNumCrewEntries" FontWeight="Bold" Text="{Binding Elements.Count}" VerticalAlignment="Center"/>
<Label Name="labelCrewEntryCount" Content="{x:Static p:Resources.textEntries}" />
<Button Name="buttonDeleteAllCrewA" Margin="2" Content="{x:Static p:Resources.textDeleteAllEntries}" Background="Transparent" Click="buttonDeleteAllCrewA_Click"/>
</StackPanel>
<enictrl:ENIDataGrid Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="3" x:Name="dataGridCrewList" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textLastName}" Binding="{Binding CrewMemberLastName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textFirstName}" Binding="{Binding CrewMemberFirstName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textGender}" Binding="{Binding CrewMemberGenderDisplay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCrewFunctionOnBoard}" Binding="{Binding CrewMemberDuty, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textNationality}" Binding="{Binding CrewMemberNationality, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textPlaceOfBirth}" Binding="{Binding CrewMemberPlaceOfBirth, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCountryOfBirth}" Binding="{Binding CrewMemberCountryOfBirth, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDateOfBirth}" Binding="{Binding CrewMemberDateOfBirth, Mode=TwoWay, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocType}" Binding="{Binding CrewMemberIdentityDocumentTypeDisplay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocNumber}" Binding="{Binding CrewMemberIdentityDocumentId, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentIssuingState}" Binding="{Binding CrewMemberIdentityDocumentIssuingState, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentExpiryDate}" Binding="{Binding CrewMemberIdentityDocumentExpiryDate, Mode=TwoWay, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textVisaNumber}" Binding="{Binding CrewMemberVisaNumber, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<!--<DataGridTextColumn Header="{x:Static p:Resources.textEffects}" Binding="{Binding Effects, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />-->
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</ScrollViewer>
</GroupBox>
</src:DetailBaseControl>

View File

@ -0,0 +1,405 @@
// Copyright (c) 2025 - schick Informatik
// Description: Display control of formsheet Tab 6. Crew data arrival
//
using bsmd.database;
using ClosedXML.Excel;
using ENI2.EditControls;
using ENI2.Util;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace ENI2.SheetDisplayControls
{
/// <summary>
/// Interaction logic for CrewPreArrivalControl.xaml
/// </summary>
public partial class CrewPreArrivalControl : DetailBaseControl
{
#region Fields
private NAME _name;
private Message _crewaMessage;
private Message _crewdMessage;
#endregion
#region Construction
public CrewPreArrivalControl()
{
InitializeComponent();
this.Loaded += CrewPreArrivalControl_Loaded;
}
#endregion
#region public override
public override void Initialize()
{
base.Initialize();
foreach (Message aMessage in this.Messages)
{
if (aMessage.MessageNotificationClass == Message.NotificationClass.NAME) { this._name = aMessage.Elements[0] as NAME; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.CREWA) { this._crewaMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.CREWD) { this._crewdMessage = aMessage; this.ControlMessages.Add(aMessage); }
}
this.textBox_NameMaster.DataContext = _name;
this.textBlockNumCrewEntries.DataContext = _crewaMessage;
#region init CREWA
if (this._crewaMessage == null)
{
this._crewaMessage = this.Core.CreateMessage(Message.NotificationClass.CREWA);
this.Messages.Add(this._crewaMessage);
}
this.dataGridCrewList.Initialize();
this.dataGridCrewList.ItemsSource = this._crewaMessage.Elements;
this.dataGridCrewList.AddingNewItem += DataGridCrewList_AddingNewItem;
this.dataGridCrewList.EditRequested += DataGridCrewList_EditRequested;
this.dataGridCrewList.DeleteRequested += DataGridCrewList_DeleteRequested;
this.dataGridCrewList.CreateRequested += DataGridCrewList_CreateRequested;
this.dataGridCrewList.RefreshGrid += DataGridCrewList_RefreshGrid;
this.dataGridCrewList.MultiEditRequested += DataGridCrewList_MultiEditRequested;
if (this._crewaMessage.Elements.Count > 0)
{
this.checkBoxCrewNotificationSchengen.IsChecked = ((CREW)this._crewaMessage.Elements[0]).NotificationSchengen;
this.checkBoxCrewNotificationPAX.IsChecked = ((CREW)this._crewaMessage.Elements[0]).NotificationPAX;
}
// extra menu copy to CREWD
{
this.dataGridCrewList.ContextMenu.Items.Add(new Separator());
MenuItem copyCREWAItem = new MenuItem();
copyCREWAItem.Header = Properties.Resources.textCopyToCREWD;
copyCREWAItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
copyCREWAItem.Click += CopyCREWAItem_Click;
this.dataGridCrewList.ContextMenu.Items.Add(copyCREWAItem);
}
#endregion
}
public override void SetEnabled(bool enabled)
{
base.SetEnabled(enabled);
this.crewPreArrivalGroupBox.IsEnabled = enabled;
}
#endregion
#region event handler
private void CopyCREWAItem_Click(object sender, RoutedEventArgs e)
{
if (this.dataGridCrewList.SelectedItems != null)
{
foreach (CREW crewa in this.dataGridCrewList.SelectedItems)
{
CREWD crewd = new CREWD();
crewd.MessageHeader = this._crewdMessage;
crewd.CopyFromCREW(crewa);
crewd.IsDeparture = true;
crewd.Identifier = DatabaseEntity.GetNewIdentifier(this._crewdMessage.Elements);
this._crewdMessage.Elements.Add(crewd);
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
}
}
private void CrewPreArrivalControl_Loaded(object sender, RoutedEventArgs e)
{
this.RegisterTextboxChange(this.textBox_NameMaster, Message.NotificationClass.NAME);
}
private async void buttonDeleteAllCrewA_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show(Properties.Resources.textConfimDeleteAllEntries, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
foreach (CREW crewa in this._crewaMessage.Elements.Cast<CREW>())
{
await DBManagerAsync.DeleteAsync(crewa);
}
this._crewaMessage.Elements.Clear();
this.dataGridCrewList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWA);
}
}
private void checkBoxCrewNotificationSchengen_Click(object sender, RoutedEventArgs e)
{
foreach (CREW crew in _crewaMessage.Elements.Cast<CREW>())
{
crew.NotificationSchengen = checkBoxCrewNotificationSchengen.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.CREWA);
}
private void checkBoxCrewNotificationPAX_Click(object sender, RoutedEventArgs e)
{
foreach (CREW crew in _crewaMessage.Elements.Cast<CREW>())
{
crew.NotificationPAX = checkBoxCrewNotificationPAX.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.CREWA);
}
private void buttonImportExcelCrew_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog
{
Filter = "Excel Files|*.xls;*.xlsx"
};
if (ofd.ShowDialog() ?? false)
{
try
{
using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var workbook = new XLWorkbook(stream))
{
var worksheet = workbook.Worksheet(1); // Get first worksheet
var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
List<CREW> importCrew = new List<CREW>();
foreach (var row in rows)
{
if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
// Check if we have at least 13 columns
if (worksheet.RangeUsed().ColumnCount() < 13)
{
throw new InvalidDataException("Sheet must have 13 columns of data");
}
CREW crew = new CREW();
// Check if first two cells are empty
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (!row.Cell(1).IsEmpty()) crew.CrewMemberLastName = row.Cell(1).GetString().Clean();
if (crew.CrewMemberLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(crew.CrewMemberLastName)) continue;
if (!row.Cell(2).IsEmpty()) crew.CrewMemberFirstName = row.Cell(2).GetString().Clean();
if (!row.Cell(3).IsEmpty()) crew.CrewMemberGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
if (!row.Cell(4).IsEmpty()) crew.CrewMemberDuty = row.Cell(4).GetString().Clean();
if (!row.Cell(5).IsEmpty()) crew.CrewMemberNationality = row.Cell(5).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(6).IsEmpty()) crew.CrewMemberPlaceOfBirth = row.Cell(6).GetString().Clean();
if (!row.Cell(7).IsEmpty()) crew.CrewMemberCountryOfBirth = row.Cell(7).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(8).IsEmpty()) crew.CrewMemberDateOfBirth = row.Cell(8).GetDateTime();
if (!row.Cell(9).IsEmpty()) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(9).GetString());
if (!row.Cell(10).IsEmpty()) crew.CrewMemberIdentityDocumentId = row.Cell(10).GetString().Clean();
if (!row.Cell(11).IsEmpty()) crew.CrewMemberIdentityDocumentIssuingState = row.Cell(11).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(12).IsEmpty()) crew.CrewMemberIdentityDocumentExpiryDate = row.Cell(12).GetDateTime();
if (!row.Cell(13).IsEmpty()) crew.CrewMemberVisaNumber = row.Cell(13).GetString().Clean();
crew.MessageHeader = this._crewaMessage;
crew.IsDirty = true;
crew.Identifier = CREW.GetNewIdentifier(this._crewaMessage.Elements);
this._crewaMessage.Elements.Add(crew);
importCrew.Add(crew);
}
if (importCrew.Count > 0)
{
this.dataGridCrewList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWA);
MessageBox.Show(String.Format(Properties.Resources.textCrewImported, importCrew.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
private void buttonCopyFromCrewA_Click(object sender, RoutedEventArgs e)
{
CREW crewA = null;
if (this._crewaMessage.Elements.Count > 0)
{
crewA = this._crewaMessage.Elements[0] as CREW;
}
SelectCrewMemberDialog scmd = new SelectCrewMemberDialog();
scmd.CREW = crewA;
scmd.AddVisible = false;
if (scmd.ShowDialog() ?? false)
{
this.textBox_NameMaster.Text = $"{crewA.CrewMemberFirstName} {crewA.CrewMemberLastName}";
this.SublistElementChanged(Message.NotificationClass.NAME);
var binding = textBox_NameMaster.GetBindingExpression(TextBox.TextProperty);
binding?.UpdateSource();
}
}
#endregion
#region crew grid arrival
private void DataGridCrewList_CreateRequested()
{
EditCREWDialog ecd = new EditCREWDialog
{
CREW = new CREW()
};
ecd.CREW.Identifier = CREW.GetNewIdentifier(_crewaMessage.Elements);
ecd.CREW.MessageHeader = this._crewaMessage;
ecd.AddClicked += () =>
{
ecd.CopyValuesToEntity();
if (!this._crewaMessage.Elements.Contains(ecd.CREW))
{
this._crewaMessage.Elements.Add(ecd.CREW);
this.CheckCREWA();
}
this.dataGridCrewList.Items.Refresh();
ecd.CREW = new CREW
{
MessageHeader = this._crewaMessage,
Identifier = CREW.GetNewIdentifier(_crewaMessage.Elements)
};
this.SublistElementChanged(Message.NotificationClass.CREWA);
};
if (ecd.ShowDialog() ?? false)
{
if (!this._crewaMessage.Elements.Contains(ecd.CREW))
{
_crewaMessage.Elements.Add(ecd.CREW);
this.CheckCREWA();
}
this.dataGridCrewList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWA);
}
}
private void DataGridCrewList_DeleteRequested(DatabaseEntity obj)
{
if (obj is CREW crew)
{
// are you sure dialog is in base class
_crewaMessage.Elements.Remove(crew);
DBManager.Instance.Delete(crew);
}
}
private void DataGridCrewList_RefreshGrid()
{
DatabaseEntity.ResetIdentifiers(_crewaMessage.Elements);
this.SublistElementChanged(Message.NotificationClass.CREWA);
this.dataGridCrewList.Items.Refresh();
}
private void DataGridCrewList_EditRequested(DatabaseEntity obj)
{
EditCREWDialog ecd = new EditCREWDialog
{
CREW = obj as CREW
};
ecd.AddClicked += () =>
{
ecd.CopyValuesToEntity();
if (!_crewaMessage.Elements.Contains(ecd.CREW))
{
_crewaMessage.Elements.Add(ecd.CREW);
this.CheckCREWA();
}
this.dataGridCrewList.Items.Refresh();
ecd.CREW = new CREW
{
Identifier = CREW.GetNewIdentifier(_crewaMessage.Elements),
MessageHeader = _crewaMessage
};
this.SublistElementChanged(Message.NotificationClass.CREWA);
};
if (ecd.ShowDialog() ?? false)
{
if (!_crewaMessage.Elements.Contains(ecd.CREW))
{
_crewaMessage.Elements.Add(ecd.CREW);
this.CheckCREWA();
}
ecd.CREW.IsDirty = true;
this.dataGridCrewList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWA);
}
}
private void DataGridCrewList_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
this.DataGridCrewList_CreateRequested();
}
private void DataGridCrewList_MultiEditRequested(List<DatabaseEntity> databaseEntities)
{
List<CREW> crewList = new List<CREW>();
foreach (CREW acrew in databaseEntities.Cast<CREW>())
crewList.Add(acrew);
// write common values of all CREW entities to template entity
CREW crew = CREW.CreateCommon(crewList);
EditCREWDialog dialog = new EditCREWDialog();
dialog.CREW = crew;
dialog.AddVisible = false;
if (dialog.ShowDialog() ?? false)
{
// write back changed values from crew to all entities and mark them as changed
CREW.WriteTemplateToList(crew, crewList);
this.SublistElementChanged(Message.NotificationClass.CREWA);
this.dataGridCrewList.Items.Refresh();
}
}
#endregion
#region private methods
private void CheckCREWA()
{
if (this._crewaMessage.Elements.Count == 0) return;
CREW firstCREW = this._crewaMessage.Elements[0] as CREW;
if (this._crewaMessage.Elements.Count == 1)
{
firstCREW.NotificationSchengen = true;
this.checkBoxCrewNotificationSchengen.IsChecked = true;
}
else
{
for (int i = 1; i < this._crewaMessage.Elements.Count; i++)
{
((CREW)this._crewaMessage.Elements[i]).NotificationSchengen = firstCREW.NotificationSchengen;
}
}
}
#endregion
}
}

View File

@ -0,0 +1,209 @@
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
x:Class="ENI2.SheetDisplayControls.DangerousCargoControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:util="clr-namespace:ENI2.Util"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:ENI2.SheetDisplayControls"
mc:Ignorable="d"
d:DesignHeight="1550" d:DesignWidth="800">
<GroupBox Name="dangerousCargoGroupBox" Header="{x:Static p:Resources.text10DangerousCargoArrival}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="290"/>
<ColumnDefinition Width=".3*" />
<ColumnDefinition Width=".3*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock x:Name="textBlock101" FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text101General}" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"/>
<Label Content="{x:Static p:Resources.textDGManifestOnBoard}" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<Label Content="{x:Static p:Resources.textDGContactFamilyName}" Grid.Column="0" Grid.Row="2" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<Label Content="{x:Static p:Resources.textDGContactPhone}" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<Label Content="{x:Static p:Resources.textMoUBalticRoRo}" Grid.Column="0" Grid.Row="4" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<Label Content="{x:Static p:Resources.textVesselClass}" Grid.Column="0" Grid.Row="5" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<CheckBox Name="checkBoxDGManifestOnBoard" IsChecked="{Binding DPGManifestOnBoardOnArrival}" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="2"/>
<TextBox Grid.Row="2" Grid.Column="1" Name="textBoxDGManifestContactFamilyName" MaxLength="99" Margin="2" Text="{Binding DPGContactFamilyName, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center" />
<TextBox Grid.Row="3" Grid.Column="1" Name="textBoxDGManifestContactPhone" MaxLength="99" Margin="2" Text="{Binding DPGContactPhone, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center" />
<CheckBox Name="checkBoxMoUBaltic" IsChecked="{Binding MOUBaltic}" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="2"/>
<ComboBox x:Name="comboBoxVesselClass" Grid.Row="5" Grid.Column="1" Margin="2" SelectedIndex="{Binding INFShipClass, Converter={util:ByteConverter}}" ContextMenu="{DynamicResource ClearContextMenu}" />
<TextBlock Name="textBlockMessageClass" FontWeight="DemiBold" Grid.Row="6" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0" />
<Button Content="{x:Static p:Resources.textNewDGItem}" Name="buttonNewItem" Margin="2" Click="buttonNewItem_Click" Grid.Row="6" Grid.Column="1" Background="Transparent" />
<TabControl Grid.Row="7" Grid.ColumnSpan="3">
<TabItem Header="{x:Static p:Resources.text102}" x:Name="tabIBCItems">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="36"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock x:Name="textBlock102" FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text102IBCData}" Grid.Column="0" Grid.Row="0"/>
<enictrl:ENIDataGrid x:Name="dataGridIBCItems" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" AutoGenerateColumns="False" Margin="0,5,0,0" Grid.Row="1">
<DataGrid.Columns>
<DataGridTextColumn Header="{x:Static p:Resources.textIdentifier}" Binding="{Binding Identifier}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textProductName}" Binding="{Binding ProductName}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPollutionCategory}" Binding="{Binding PollutionCategoryDisplay}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textRisks}" Binding="{Binding HazardsDisplay}" IsReadOnly="True" Width="auto" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textColumsOfIBC}" Binding="{Binding SpecRef15_19}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textFlashpointInformation}" Binding="{Binding FlashpointInformationDisplay}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textFlashpoint}" Binding="{Binding Flashpoint_CEL}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textQuantity}" Binding="{Binding Quantity_KGM, StringFormat={}{0:N3}}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textStowagePosition}" Binding="{Binding StowagePosition}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfLoading}" Binding="{Binding PortOfLoading}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfDischarge}" Binding="{Binding PortOfDischarge}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textRemarks}" Binding="{Binding Remarks}" IsReadOnly="True" Width="auto" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</TabItem>
<TabItem Header="{x:Static p:Resources.text103}" x:Name="tabIGCItems">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="36"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock x:Name="textBlock103" FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text103IGCData}" Grid.Row="0" />
<enictrl:ENIDataGrid x:Name="dataGridIGCItems" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Grid.Row="1" AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="{x:Static p:Resources.textIdentifier}" Binding="{Binding Identifier}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textProductName}" Binding="{Binding ProductName}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textUNNumber}" Binding="{Binding UNNumber}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textIMOClassSubclass}" Binding="{Binding IMOClass}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textQuantity}" Binding="{Binding Quantity_KGM, StringFormat={}{0:N3}}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textStowagePosition}" Binding="{Binding StowagePosition}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfLoading}" Binding="{Binding PortOfLoading}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfDischarge}" Binding="{Binding PortOfDischarge}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textRemarks}" Binding="{Binding Remarks}" IsReadOnly="True" Width="auto" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</TabItem>
<TabItem Header="{x:Static p:Resources.text104}" x:Name="tabIMSBCItems">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="36"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock x:Name="textBlock104" FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text104IMSBCData}" Grid.Row="0" />
<enictrl:ENIDataGrid x:Name="dataGridIMSBCItems" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Grid.Row="1" AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="{x:Static p:Resources.textIdentifier}" Binding="{Binding Identifier}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textBulkCargoShippingName}" Binding="{Binding BulkCargoShippingName}" IsReadOnly="True" Width="auto" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textMaterialHazard}" Binding="{Binding MHB}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textUNNumber}" Binding="{Binding UNNumber}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textIMOClassSubclass}" Binding="{Binding IMOClass}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textQuantity}" Binding="{Binding Quantity_KGM, StringFormat={}{0:N3}}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textStowagePosition}" Binding="{Binding StowagePosition}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfLoading}" Binding="{Binding PortOfLoading}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfDischarge}" Binding="{Binding PortOfDischarge}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textRemarks}" Binding="{Binding Remarks}" IsReadOnly="True" Width="auto" />
<DataGridComboBoxColumn Header="{x:Static p:Resources.textIMOHazardClass}" ItemsSource="{x:Static util:GlobalStructures.imoHazardClasses}" IsReadOnly="True" Width="auto">
<DataGridComboBoxColumn.ElementStyle>
<Style TargetType="ComboBox">
<Setter Property="SelectedIndex" Value="{Binding IMOHazardClass, UpdateSourceTrigger=PropertyChanged}" />
</Style>
</DataGridComboBoxColumn.ElementStyle>
</DataGridComboBoxColumn>
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</TabItem>
<TabItem Header="{x:Static p:Resources.text105}" x:Name="tabMARPOLItems">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="36"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock x:Name="textBlock105" FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text105MARPOLData}" Grid.Row="0" />
<enictrl:ENIDataGrid x:Name="dataGridMARPOLItems" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Grid.Row="1" AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="{x:Static p:Resources.textIdentifier}" Binding="{Binding Identifier}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textName}" Binding="{Binding Name}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textFlashpointInformation}" Binding="{Binding FlashpointInformationDisplay}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textFlashpoint}" Binding="{Binding Flashpoint_CEL}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textQuantity}" Binding="{Binding Quantity_KGM, StringFormat={}{0:N3}}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textStowagePosition}" Binding="{Binding StowagePosition}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfLoading}" Binding="{Binding PortOfLoading}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfDischarge}" Binding="{Binding PortOfDischarge}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textRemarks}" Binding="{Binding Remarks}" IsReadOnly="True" Width="auto" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</TabItem>
<TabItem Header="{x:Static p:Resources.text106}" x:Name="tabIMDGItems">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="36"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock x:Name="textBlock106" FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text106IMDGData}" Grid.Row="0"/>
<enictrl:ENIDataGrid x:Name="dataGridIMDGItems" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Grid.Row="1" AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="{x:Static p:Resources.textIdentifier}" Binding="{Binding Identifier}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textUNNumber}" Binding="{Binding UNNumber}" IsReadOnly="True" Width="auto" />
<DataGridComboBoxColumn Header="{x:Static p:Resources.textPackingGroup}" ItemsSource="{x:Static util:GlobalStructures.PackingGroups}" IsReadOnly="True" Width="auto">
<DataGridComboBoxColumn.ElementStyle>
<Style TargetType="ComboBox">
<Setter Property="SelectedIndex" Value="{Binding PackingGroup, UpdateSourceTrigger=PropertyChanged}" />
</Style>
</DataGridComboBoxColumn.ElementStyle>
</DataGridComboBoxColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textProperShippingName}" Binding="{Binding ProperShippingName}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textIMOClassDivision}" Binding="{Binding IMOClass}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textTechnicalName}" Binding="{Binding TechnicalName}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textNetExplosiveMass}" Binding="{Binding NetExplosiveMass_KGM, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textFlashpoint}" Binding="{Binding Flashpoint_CEL}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textRadioNuclideName}" Binding="{Binding Class7NuclideName}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textMaxActivity}" Binding="{Binding Class7MaxActivity_BQL, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textCategory}" Binding="{Binding Class7Category}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textTransportIndex}" Binding="{Binding Class7TransportIndex}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textCriticalSafetyIndex}" Binding="{Binding Class7CSI}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textSubsidiaryRisk}" Binding="{Binding SubsidiaryRiskText}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textControlTemperature}" Binding="{Binding ControlTemperature_CEL, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textEmergencyTemperature}" Binding="{Binding EmergencyTemperature_CEL, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textMarinePollutant}" Binding="{Binding MarinePollutant}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textNumberOfPackages}" Binding="{Binding NumberOfPackages}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPackageType}" Binding="{Binding PackageType}" IsReadOnly="True" Width="auto" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textLimitedQuantity}" Binding="{Binding LimitedQuantities}" IsReadOnly="True" Width="auto" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textExceptedQuantities}" Binding="{Binding ExceptedQuantities}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textNetQuantity}" Binding="{Binding NetQuantity_KGM, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textGrossQuantity}" Binding="{Binding GrossQuantity_KGM, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" />
<!--DataGridTextColumn Header="{x:Static p:Resources.textExceptedQuantities}" Binding="{Binding ExceptedQuantities, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" /-->
<DataGridTextColumn Header="{x:Static p:Resources.textCargoVolume}" Binding="{Binding Volume_MTQ, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textGeneralCargo}" Binding="{Binding GeneralCargoIBC}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textContainerNo}" Binding="{Binding ContainerNumber}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textVehicleLicensePlate}" Binding="{Binding VehicleLicenseNumber}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textStowagePosition}" Binding="{Binding StowagePosition}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textSubsidiaryRisk}" Binding="{Binding SubsidiaryRiskText}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textContainerPositionBay}" Binding="{Binding Bay}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textContainerPositionRow}" Binding="{Binding Row}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textContainerPositionTier}" Binding="{Binding Tier}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfLoading}" Binding="{Binding PortOfLoading}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfDischarge}" Binding="{Binding PortOfDischarge}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textRemarks}" Binding="{Binding Remarks}" IsReadOnly="True" Width="auto" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</TabItem>
</TabControl>
</Grid>
</ScrollViewer>
</GroupBox>
</src:DetailBaseControl>

View File

@ -0,0 +1,882 @@
// Copyright (c) 2025- schick Informatik
// Description: Display control of formsheet Tab 10. Dangerous cargo arrival
//
using bsmd.database;
using ENI2.EditControls;
using ENI2.Util;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media.Imaging;
namespace ENI2.SheetDisplayControls
{
/// <summary>
/// Interaction logic for DangerousCargoArrivalControl.xaml
/// </summary>
public partial class DangerousCargoControl : DetailBaseControl
{
#region Fields
private HAZ haza;
private HAZ hazd;
private NewDGItemDialog newDGDialog = null;
#endregion
#region Construction
public DangerousCargoControl()
{
InitializeComponent();
Loaded += DangerousCargoArrivalControl_Loaded;
}
#endregion
#region public override
public override void Initialize()
{
base.Initialize();
foreach (Message aMessage in this.Messages)
{
if (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD)
{
this.hazd = aMessage.Elements[0] as HAZ;
this.ControlMessages.Add(aMessage);
}
if (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA)
{
this.haza = aMessage.Elements[0] as HAZ;
this.ControlMessages.Add(aMessage);
}
this.textBlockMessageClass.Text = IsDeparture ? "HAZD" : "HAZA";
}
this.comboBoxVesselClass.ItemsSource = GlobalStructures.vesselClasses;
this.checkBoxDGManifestOnBoard.DataContext = this.IsDeparture ? hazd : haza;
this.textBoxDGManifestContactFamilyName.DataContext = this.IsDeparture ? hazd : haza;
this.textBoxDGManifestContactPhone.DataContext = this.IsDeparture ? hazd : haza;
this.checkBoxMoUBaltic.DataContext = this.IsDeparture ? hazd : haza;
this.comboBoxVesselClass.DataContext = this.IsDeparture ? hazd : haza;
#region init grids
this.dataGridIMDGItems.Initialize();
this.dataGridIMDGItems.ItemsSource = this.IsDeparture ? this.hazd.IMDGPositions : this.haza.IMDGPositions;
CollectionView myCollectionView = (CollectionView)CollectionViewSource.GetDefaultView(dataGridIMDGItems.Items);
((INotifyCollectionChanged)myCollectionView).CollectionChanged += DangerousGoodsDetailControl_CollectionChanged;
this.dataGridIMDGItems.CreateRequested += DataGridIMDGItems_CreateRequested;
this.dataGridIMDGItems.AddingNewItem += DataGridIMDGItems_AddingNewItem;
this.dataGridIMDGItems.EditRequested += DataGridIMDGItems_EditRequested;
this.dataGridIMDGItems.DeleteRequested += DataGridIMDGItems_DeleteRequested;
this.dataGridIBCItems.Initialize();
this.dataGridIBCItems.ItemsSource = this.IsDeparture ? this.hazd.IBCPositions : this.haza.IBCPositions;
myCollectionView = (CollectionView)CollectionViewSource.GetDefaultView(dataGridIBCItems.Items);
((INotifyCollectionChanged)myCollectionView).CollectionChanged += DangerousGoodsDetailControl_CollectionChanged;
this.dataGridIBCItems.CreateRequested += DataGridIBCItems_CreateRequested;
this.dataGridIBCItems.AddingNewItem += DataGridIBCItems_AddingNewItem;
this.dataGridIBCItems.EditRequested += DataGridIBCItems_EditRequested;
this.dataGridIBCItems.DeleteRequested += DataGridIBCItems_DeleteRequested;
this.dataGridIGCItems.Initialize();
this.dataGridIGCItems.ItemsSource = this.IsDeparture ? this.hazd.IGCPositions : this.haza.IGCPositions;
((INotifyCollectionChanged)myCollectionView).CollectionChanged += DangerousGoodsDetailControl_CollectionChanged;
this.dataGridIGCItems.CreateRequested += DataGridIGCItems_CreateRequested;
this.dataGridIGCItems.CreateRequested += DataGridIGCItems_CreateRequested;
this.dataGridIGCItems.AddingNewItem += DataGridIGCItems_AddingNewItem;
this.dataGridIGCItems.EditRequested += DataGridIGCItems_EditRequested;
this.dataGridIGCItems.DeleteRequested += DataGridIGCItems_DeleteRequested;
this.dataGridIMSBCItems.Initialize();
this.dataGridIMSBCItems.ItemsSource = this.IsDeparture ? this.hazd.IMSBCPositions : this.haza.IMSBCPositions;
myCollectionView = (CollectionView)CollectionViewSource.GetDefaultView(dataGridIMSBCItems.Items);
((INotifyCollectionChanged)myCollectionView).CollectionChanged += DangerousGoodsDetailControl_CollectionChanged;
this.dataGridIMSBCItems.CreateRequested += DataGridIMSBCItems_CreateRequested;
this.dataGridIMSBCItems.AddingNewItem += DataGridIMSBCItems_AddingNewItem;
this.dataGridIMSBCItems.EditRequested += DataGridIMSBCItems_EditRequested;
this.dataGridIMSBCItems.DeleteRequested += DataGridIMSBCItems_DeleteRequested;
this.dataGridMARPOLItems.Initialize();
this.dataGridMARPOLItems.ItemsSource = this.IsDeparture ? this.hazd.MARPOLPositions : this.haza.MARPOLPositions;
myCollectionView = (CollectionView)CollectionViewSource.GetDefaultView(dataGridMARPOLItems.Items);
((INotifyCollectionChanged)myCollectionView).CollectionChanged += DangerousGoodsDetailControl_CollectionChanged;
this.dataGridMARPOLItems.CreateRequested += DataGridMARPOLItems_CreateRequested;
this.dataGridMARPOLItems.AddingNewItem += DataGridMARPOLItems_AddingNewItem;
this.dataGridMARPOLItems.EditRequested += DataGridMARPOLItems_EditRequested;
this.dataGridMARPOLItems.DeleteRequested += DataGridMARPOLItems_DeleteRequested;
this.RefreshTabHeaders();
#endregion
#region Extra Menüpunkte um Positionen zwischen HAZA / HAZD zu kopieren
this.dataGridIBCItems.ContextMenu.Items.Add(new Separator());
MenuItem copyIBCItem = new MenuItem();
copyIBCItem.Header = string.Format(Properties.Resources.textCopyTo, this.IsDeparture ? "HAZA" : "HAZD");
copyIBCItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
copyIBCItem.Click += new RoutedEventHandler(this.copyIBC);
this.dataGridIBCItems.ContextMenu.Items.Add(copyIBCItem);
this.dataGridIGCItems.ContextMenu.Items.Add(new Separator());
MenuItem copyItemIGC = new MenuItem();
copyItemIGC.Header = string.Format(Properties.Resources.textCopyTo, this.IsDeparture ? "HAZA" : "HAZD");
copyItemIGC.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
copyItemIGC.Click += new RoutedEventHandler(this.copyIGC);
this.dataGridIGCItems.ContextMenu.Items.Add(copyItemIGC);
this.dataGridIMDGItems.ContextMenu.Items.Add(new Separator());
MenuItem copyItemIMDG = new MenuItem();
copyItemIMDG.Header = string.Format(Properties.Resources.textCopyTo, this.IsDeparture ? "HAZA" : "HAZD");
copyItemIMDG.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
copyItemIMDG.Click += new RoutedEventHandler(this.copyIMDG);
this.dataGridIMDGItems.ContextMenu.Items.Add(copyItemIMDG);
this.dataGridIMSBCItems.ContextMenu.Items.Add(new Separator());
MenuItem copyItemIMSBC = new MenuItem();
copyItemIMSBC.Header = string.Format(Properties.Resources.textCopyTo, this.IsDeparture ? "HAZA" : "HAZD");
copyItemIMSBC.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
copyItemIMSBC.Click += new RoutedEventHandler(this.copyIMSBC);
this.dataGridIMSBCItems.ContextMenu.Items.Add(copyItemIMSBC);
this.dataGridMARPOLItems.ContextMenu.Items.Add(new Separator());
MenuItem copyItemMARPOL = new MenuItem();
copyItemMARPOL.Header = string.Format(Properties.Resources.textCopyTo, this.IsDeparture ? "HAZA" : "HAZD");
copyItemMARPOL.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
copyItemMARPOL.Click += new RoutedEventHandler(this.copyMARPOL);
this.dataGridMARPOLItems.ContextMenu.Items.Add(copyItemMARPOL);
#endregion
this._initialized = true;
}
#region SetEnabled
public override void SetEnabled(bool enabled)
{
this.dangerousCargoGroupBox.IsEnabled = enabled;
this.dataGridIBCItems.IsEnabled = enabled;
// this.checkBoxDangerousGoodsOnBoard.IsEnabled = enabled;
this.checkBoxDGManifestOnBoard.IsEnabled = enabled;
this.checkBoxMoUBaltic.IsEnabled = enabled;
this.dataGridIBCItems.IsEnabled = enabled;
this.dataGridIMDGItems.IsEnabled = enabled;
this.dataGridIGCItems.IsEnabled = enabled;
this.dataGridIMSBCItems.IsEnabled = enabled;
this.dataGridMARPOLItems.IsEnabled = enabled;
}
#endregion
#endregion
#region Properties
public bool IsDeparture { get; set; }
#endregion
#region event handler
private void DangerousCargoArrivalControl_Loaded(object sender, RoutedEventArgs e)
{
// this.RegisterCheckboxChange(this.checkBoxDangerousGoodsOnBoard, this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.RegisterCheckboxChange(this.checkBoxDGManifestOnBoard, this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.RegisterCheckboxChange(this.checkBoxMoUBaltic, this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.RegisterComboboxIndexChange(this.comboBoxVesselClass, this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.RegisterTextboxChange(this.textBoxDGManifestContactFamilyName, this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.RegisterTextboxChange(this.textBoxDGManifestContactPhone, this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
if(this.IsDeparture)
{
this.dangerousCargoGroupBox.Header = Properties.Resources.text11DangerousCargoDeparture;
this.textBlock101.Text = Properties.Resources.text111General;
this.textBlock102.Text = Properties.Resources.text112IBCData;
this.textBlock103.Text = Properties.Resources.text113IGCData;
this.textBlock104.Text = Properties.Resources.text114IMSBCData;
this.textBlock105.Text = Properties.Resources.text115MARPOLData;
this.textBlock106.Text = Properties.Resources.text116IMDGData;
}
}
private void DangerousGoodsDetailControl_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
this.RefreshTabHeaders();
}
#endregion
#region Copy event handler
private void copyMARPOL(object sender, RoutedEventArgs e)
{
// aus dem aktuell selektierten MARPOL Element ein neues MARPOL Element machen und nach HAZD kopieren
if (this.dataGridMARPOLItems.SelectedItems != null)
{
HAZ target_haz = this.IsDeparture ? this.haza : this.hazd;
foreach (MARPOL_Annex_I_Position selectedMARPOL in this.dataGridMARPOLItems.SelectedItems)
{
MARPOL_Annex_I_Position copyMARPOL = new MARPOL_Annex_I_Position();
copyMARPOL.MessageHeader = target_haz.MessageHeader;
copyMARPOL.HAZ = target_haz;
copyMARPOL.CopyFromMARPOL(selectedMARPOL);
copyMARPOL.Identifier = DatabaseEntity.GetNewIdentifier(target_haz.MARPOLPositions, "MARPOL-");
target_haz.MARPOLPositions.Add(copyMARPOL);
target_haz.NoDPGOnBoardOnArrival = false;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZA : Message.NotificationClass.HAZD);
this.OnControlCacheReset(this.IsDeparture ? Properties.Resources.textDGArrival : Properties.Resources.textDGDeparture);
}
}
}
private void copyIMSBC(object sender, RoutedEventArgs e)
{
// aus dem aktuell selektierten IMBSC Element ein neues IMBSC Element machen und nach HAZD kopieren
if (this.dataGridIMSBCItems.SelectedItems != null)
{
HAZ target_haz = this.IsDeparture ? this.haza : this.hazd;
foreach (IMSBCPosition selectedIMSBC in this.dataGridIMSBCItems.SelectedItems)
{
IMSBCPosition copyIMSBC = new IMSBCPosition();
copyIMSBC.MessageHeader = target_haz.MessageHeader;
copyIMSBC.HAZ = target_haz;
copyIMSBC.CopyFromIMSBC(selectedIMSBC);
copyIMSBC.Identifier = DatabaseEntity.GetNewIdentifier(target_haz.IMSBCPositions, "IMSBC-");
target_haz.IMSBCPositions.Add(copyIMSBC);
target_haz.NoDPGOnBoardOnArrival = false;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZA : Message.NotificationClass.HAZD);
this.OnControlCacheReset(this.IsDeparture ? Properties.Resources.textDGArrival : Properties.Resources.textDGDeparture);
}
}
}
private void copyIMDG(object sender, RoutedEventArgs e)
{
// aus dem aktuell selektierten IMDG Element ein neues IMDG Element machen und nach HAZD kopieren
if (this.dataGridIMDGItems.SelectedItems != null)
{
HAZ target_haz = this.IsDeparture ? this.haza : this.hazd;
foreach (IMDGPosition selectedIMDG in this.dataGridIMDGItems.SelectedItems)
{
IMDGPosition copyIMDG = new IMDGPosition();
copyIMDG.MessageHeader = target_haz.MessageHeader;
copyIMDG.HAZ = target_haz;
copyIMDG.CopyFromIMDG(selectedIMDG);
copyIMDG.Identifier = DatabaseEntity.GetNewIdentifier(target_haz.IMDGPositions, "IMDG-");
target_haz.IMDGPositions.Add(copyIMDG);
target_haz.NoDPGOnBoardOnArrival = false;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZA : Message.NotificationClass.HAZD);
this.OnControlCacheReset(this.IsDeparture ? Properties.Resources.textDGArrival : Properties.Resources.textDGDeparture);
}
}
}
private void copyIGC(object sender, RoutedEventArgs e)
{
// aus dem aktuell selektierten IGC Element ein neues IGC Element machen und nach HAZD kopieren
if (this.dataGridIGCItems.SelectedItems != null)
{
HAZ target_haz = this.IsDeparture ? this.haza : this.hazd;
foreach (IGCPosition selectedIGC in this.dataGridIGCItems.SelectedItems)
{
IGCPosition copyIGC = new IGCPosition();
copyIGC.MessageHeader = target_haz.MessageHeader;
copyIGC.HAZ = target_haz;
copyIGC.CopyFromIGC(selectedIGC);
copyIGC.Identifier = DatabaseEntity.GetNewIdentifier(target_haz.IGCPositions, "IGC-");
target_haz.IGCPositions.Add(copyIGC);
target_haz.NoDPGOnBoardOnArrival = false;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZA : Message.NotificationClass.HAZD);
this.OnControlCacheReset(this.IsDeparture ? Properties.Resources.textDGArrival : Properties.Resources.textDGDeparture);
}
}
}
private void copyIBC(object sender, RoutedEventArgs e)
{
// aus dem aktuell selektierten IBC Element ein neues IBC Element machen und nach HAZD kopieren
if (this.dataGridIBCItems.SelectedItems != null)
{
HAZ target_haz = this.IsDeparture ? this.haza : this.hazd;
foreach (IBCPosition selectedIBC in this.dataGridIBCItems.SelectedItems)
{
if (selectedIBC != null)
{
IBCPosition copyIBC = new IBCPosition();
copyIBC.MessageHeader = target_haz.MessageHeader;
copyIBC.HAZ = target_haz;
copyIBC.CopyFromIBC(selectedIBC);
copyIBC.Identifier = DatabaseEntity.GetNewIdentifier(target_haz.IBCPositions, "IBC-");
target_haz.IBCPositions.Add(copyIBC);
target_haz.NoDPGOnBoardOnArrival = false;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZA : Message.NotificationClass.HAZD);
this.OnControlCacheReset(this.IsDeparture ? Properties.Resources.textDGArrival : Properties.Resources.textDGDeparture);
}
}
}
}
#endregion
#region new sublist item button handler
private void buttonNewItem_Click(object sender, RoutedEventArgs e)
{
if (newDGDialog != null)
{
newDGDialog.Activate();
}
else
{
newDGDialog = new NewDGItemDialog();
newDGDialog.Closed += NewDGDialog_Closed;
newDGDialog.OKClicked += NewDGDialog_OKClicked;
newDGDialog.AddClicked += NewDGDialog_OKClicked;
newDGDialog.Show();
}
}
private void NewDGDialog_Closed(object sender, EventArgs e)
{
newDGDialog = null;
}
private void NewDGDialog_OKClicked()
{
HAZ haz = this.IsDeparture ? hazd : haza;
HAZPosTemplate selectedTemplate = this.newDGDialog.SelectedTemplate;
if (selectedTemplate != null)
{
// create new DG position based on template
switch (selectedTemplate.TemplateType)
{
case HAZPosTemplate.SublistType.IBC:
IBCPosition ibcPos = new IBCPosition();
ibcPos.FlashpointInformation = selectedTemplate.Flashpoint;
ibcPos.Flashpoint_CEL = selectedTemplate.FP_IBC;
ibcPos.SpecRef15_19 = selectedTemplate.SpecRef15_19;
ibcPos.Hazards = selectedTemplate.Hazard;
ibcPos.Identifier = DatabaseEntity.GetNewIdentifier(haz.IBCPositions, "IBC-");
ibcPos.PollutionCategory = selectedTemplate.PollutionCategory;
ibcPos.HAZ = haz;
haz.IBCPositions.Add(ibcPos);
this.dataGridIBCItems.Items.Refresh();
this.DataGridIBCItems_EditRequested(ibcPos);
break;
case HAZPosTemplate.SublistType.IGC:
IGCPosition igcPos = new IGCPosition();
igcPos.Identifier = DatabaseEntity.GetNewIdentifier(haz.IGCPositions, "IGC-");
igcPos.UNNumber = selectedTemplate.UNNr;
igcPos.IMOClass = selectedTemplate.IMOClass;
igcPos.HAZ = haz;
haz.IGCPositions.Add(igcPos);
this.dataGridIGCItems.Items.Refresh();
this.DataGridIGCItems_EditRequested(igcPos);
break;
case HAZPosTemplate.SublistType.IMSBC:
IMSBCPosition imsbcPos = new IMSBCPosition();
imsbcPos.Identifier = DatabaseEntity.GetNewIdentifier(haz.IMSBCPositions, "IMSBC-");
imsbcPos.IMOHazardClass = selectedTemplate.IMSBC_HAZ;
imsbcPos.UNNumber = selectedTemplate.UNNr;
imsbcPos.IMOClass = selectedTemplate.IMOClass;
imsbcPos.MHB = selectedTemplate.MHB ?? false;
imsbcPos.HAZ = haz;
haz.IMSBCPositions.Add(imsbcPos);
this.dataGridIMSBCItems.Items.Refresh();
this.DataGridIMSBCItems_EditRequested(imsbcPos);
break;
case HAZPosTemplate.SublistType.MARPOL:
MARPOL_Annex_I_Position marpolPos = new MARPOL_Annex_I_Position();
marpolPos.FlashpointInformation = selectedTemplate.Flashpoint;
marpolPos.Identifier = DatabaseEntity.GetNewIdentifier(haz.MARPOLPositions, "MARPOL-");
marpolPos.HAZ = haz;
haz.MARPOLPositions.Add(marpolPos);
this.dataGridMARPOLItems.Items.Refresh();
this.DataGridMARPOLItems_EditRequested(marpolPos);
break;
}
this.SetHAZGlobalFlags();
}
}
#endregion
#region MARPOL datagrid handlers
private void DataGridMARPOLItems_DeleteRequested(DatabaseEntity obj)
{
HAZ haz = this.IsDeparture ? hazd : haza;
if (obj is MARPOL_Annex_I_Position marpol)
{
// are you sure dialog is in base class
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(marpol);
haz.MARPOLPositions.Remove(marpol);
DatabaseEntity.ResetIdentifiers(new List<DatabaseEntity>(haz.MARPOLPositions));
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.dataGridMARPOLItems.Items.Refresh();
}
}
private void DataGridMARPOLItems_EditRequested(DatabaseEntity obj)
{
EditMarpolDialog eld = new EditMarpolDialog();
eld.MARPOL = obj as MARPOL_Annex_I_Position;
HAZ haz = this.IsDeparture ? hazd : haza;
eld.AddClicked += () =>
{
eld.CopyValuesToEntity();
if (!haz.MARPOLPositions.Contains(eld.MARPOL))
haz.MARPOLPositions.Add(eld.MARPOL);
this.dataGridMARPOLItems.Items.Refresh();
eld.MARPOL = new MARPOL_Annex_I_Position();
eld.Identifier = DatabaseEntity.GetNewIdentifier(haz.MARPOLPositions, "MARPOL-");
eld.MARPOL.HAZ = haz;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.SetHAZGlobalFlags();
};
if (eld.ShowDialog() ?? false)
{
if (!haz.MARPOLPositions.Contains(eld.MARPOL))
haz.MARPOLPositions.Add(eld.MARPOL);
this.dataGridMARPOLItems.Items.Refresh();
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
}
}
private void DataGridMARPOLItems_AddingNewItem(object sender, System.Windows.Controls.AddingNewItemEventArgs e)
{
this.DataGridMARPOLItems_CreateRequested();
}
private void DataGridMARPOLItems_CreateRequested()
{
HAZ haz = this.IsDeparture ? hazd : haza;
EditMarpolDialog ebd = new EditMarpolDialog();
ebd.MARPOL = new MARPOL_Annex_I_Position();
ebd.MARPOL.Identifier = DatabaseEntity.GetNewIdentifier(haz.MARPOLPositions, "MARPOL-");
ebd.MARPOL.HAZ = haz;
ebd.AddClicked += () =>
{
ebd.CopyValuesToEntity();
if (!haz.MARPOLPositions.Contains(ebd.MARPOL))
haz.MARPOLPositions.Add(ebd.MARPOL);
this.dataGridMARPOLItems.Items.Refresh();
ebd.MARPOL = new MARPOL_Annex_I_Position();
ebd.MARPOL.HAZ = haz;
ebd.Identifier = DatabaseEntity.GetNewIdentifier(haz.MARPOLPositions, "MARPOL-");
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.SetHAZGlobalFlags();
};
if (ebd.ShowDialog() ?? false)
{
if (!haz.MARPOLPositions.Contains(ebd.MARPOL))
haz.MARPOLPositions.Add(ebd.MARPOL);
this.dataGridMARPOLItems.Items.Refresh();
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.SetHAZGlobalFlags();
}
}
#endregion
#region IMSBC datagrid handlers
private void DataGridIMSBCItems_DeleteRequested(DatabaseEntity obj)
{
HAZ haz = this.IsDeparture ? hazd : haza;
if (obj is IMSBCPosition imsbc)
{
// are you sure dialog is in base class
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(imsbc);
haz.IMSBCPositions.Remove(imsbc);
DatabaseEntity.ResetIdentifiers(new List<DatabaseEntity>(haz.IMSBCPositions));
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.dataGridIMSBCItems.Items.Refresh();
}
}
private void DataGridIMSBCItems_EditRequested(DatabaseEntity obj)
{
HAZ haz = this.IsDeparture ? hazd : haza;
EditIMSBCDialog eld = new EditIMSBCDialog();
eld.IMSBC = obj as IMSBCPosition;
eld.AddClicked += () =>
{
eld.CopyValuesToEntity();
if (!haz.IMSBCPositions.Contains(eld.IMSBC))
haz.IMSBCPositions.Add(eld.IMSBC);
this.dataGridIMSBCItems.Items.Refresh();
eld.IMSBC = new IMSBCPosition();
eld.Identifier = DatabaseEntity.GetNewIdentifier(haz.IMSBCPositions, "IMSBC-");
eld.IMSBC.HAZ = haz;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.SetHAZGlobalFlags();
};
if (eld.ShowDialog() ?? false)
{
if (!haz.IMSBCPositions.Contains(eld.IMSBC))
haz.IMSBCPositions.Add(eld.IMSBC);
this.dataGridIMSBCItems.Items.Refresh();
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
}
}
private void DataGridIMSBCItems_AddingNewItem(object sender, System.Windows.Controls.AddingNewItemEventArgs e)
{
this.DataGridIMSBCItems_CreateRequested();
}
private void DataGridIMSBCItems_CreateRequested()
{
HAZ haz = this.IsDeparture ? hazd : haza;
EditIMSBCDialog ebd = new EditIMSBCDialog();
ebd.IMSBC = new IMSBCPosition();
ebd.IMSBC.Identifier = DatabaseEntity.GetNewIdentifier(haz.IMSBCPositions, "IMSBC-");
ebd.IMSBC.HAZ = haz;
ebd.AddClicked += () =>
{
ebd.CopyValuesToEntity();
if (!haz.IMSBCPositions.Contains(ebd.IMSBC))
haz.IMSBCPositions.Add(ebd.IMSBC);
this.dataGridIMSBCItems.Items.Refresh();
ebd.IMSBC = new IMSBCPosition();
ebd.IMSBC.HAZ = haz;
ebd.Identifier = DatabaseEntity.GetNewIdentifier(haz.IMSBCPositions, "IMSBC-");
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.SetHAZGlobalFlags();
};
if (ebd.ShowDialog() ?? false)
{
if (!haz.IMSBCPositions.Contains(ebd.IMSBC))
haz.IMSBCPositions.Add(ebd.IMSBC);
this.dataGridIMSBCItems.Items.Refresh();
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.SetHAZGlobalFlags();
}
}
#endregion
#region IGC datagrid handlers
private void DataGridIGCItems_DeleteRequested(DatabaseEntity obj)
{
HAZ haz = this.IsDeparture ? hazd : haza;
if (obj is IGCPosition igc)
{
// are you sure dialog is in base class
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(igc);
haz.IGCPositions.Remove(igc);
DatabaseEntity.ResetIdentifiers(new List<DatabaseEntity>(haz.IGCPositions));
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.dataGridIGCItems.Items.Refresh();
}
}
private void DataGridIGCItems_EditRequested(DatabaseEntity obj)
{
HAZ haz = this.IsDeparture ? hazd : haza;
EditIGCDialog eld = new EditIGCDialog();
eld.IGC = obj as IGCPosition;
eld.AddClicked += () =>
{
eld.CopyValuesToEntity();
if (!haz.IGCPositions.Contains(eld.IGC))
haz.IGCPositions.Add(eld.IGC);
this.dataGridIGCItems.Items.Refresh();
eld.IGC = new IGCPosition();
eld.Identifier = DatabaseEntity.GetNewIdentifier(haz.IGCPositions, "IGC-");
eld.IGC.HAZ = haz;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.SetHAZGlobalFlags();
};
if (eld.ShowDialog() ?? false)
{
if (!haz.IGCPositions.Contains(eld.IGC))
haz.IGCPositions.Add(eld.IGC);
this.dataGridIGCItems.Items.Refresh();
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
}
}
private void DataGridIGCItems_AddingNewItem(object sender, System.Windows.Controls.AddingNewItemEventArgs e)
{
this.DataGridIGCItems_CreateRequested();
}
private void DataGridIGCItems_CreateRequested()
{
HAZ haz = this.IsDeparture ? hazd : haza;
EditIGCDialog ebd = new EditIGCDialog();
ebd.IGC = new IGCPosition();
ebd.IGC.Identifier = DatabaseEntity.GetNewIdentifier(haz.IGCPositions, "IGC-");
ebd.IGC.HAZ = haz;
ebd.AddClicked += () =>
{
ebd.CopyValuesToEntity();
if (!haz.IGCPositions.Contains(ebd.IGC))
haz.IGCPositions.Add(ebd.IGC);
this.dataGridIGCItems.Items.Refresh();
ebd.IGC = new IGCPosition();
ebd.IGC.HAZ = haz;
ebd.Identifier = DatabaseEntity.GetNewIdentifier(haz.IGCPositions, "IGC-");
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
};
if (ebd.ShowDialog() ?? false)
{
if (!haz.IGCPositions.Contains(ebd.IGC))
haz.IGCPositions.Add(ebd.IGC);
this.dataGridIGCItems.Items.Refresh();
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.SetHAZGlobalFlags();
}
}
#endregion
#region IBC datagrid handlers
private void DataGridIBCItems_DeleteRequested(DatabaseEntity obj)
{
HAZ haz = this.IsDeparture ? hazd : haza;
if (obj is IBCPosition ibc)
{
// are you sure dialog is in base class
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(ibc);
haz.IBCPositions.Remove(ibc);
DatabaseEntity.ResetIdentifiers(new List<DatabaseEntity>(haz.IBCPositions));
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.dataGridIBCItems.Items.Refresh();
}
}
private void DataGridIBCItems_EditRequested(DatabaseEntity obj)
{
HAZ haz = this.IsDeparture ? hazd : haza;
EditIBCDialog eld = new EditIBCDialog();
eld.IBC = obj as IBCPosition;
eld.AddClicked += () =>
{
eld.CopyValuesToEntity();
if (!haz.IBCPositions.Contains(eld.IBC))
haz.IBCPositions.Add(eld.IBC);
this.dataGridIBCItems.Items.Refresh();
eld.IBC = new IBCPosition();
eld.Identifier = DatabaseEntity.GetNewIdentifier(haz.IBCPositions, "IBC-");
eld.IBC.HAZ = haz;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.SetHAZGlobalFlags();
};
if (eld.ShowDialog() ?? false)
{
if (!haz.IBCPositions.Contains(eld.IBC))
haz.IBCPositions.Add(eld.IBC);
this.dataGridIBCItems.Items.Refresh();
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
}
}
private void DataGridIBCItems_AddingNewItem(object sender, System.Windows.Controls.AddingNewItemEventArgs e)
{
this.DataGridIBCItems_CreateRequested();
}
private void DataGridIBCItems_CreateRequested()
{
HAZ haz = this.IsDeparture ? hazd : haza;
EditIBCDialog ebd = new EditIBCDialog();
ebd.IBC = new IBCPosition();
ebd.IBC.Identifier = DatabaseEntity.GetNewIdentifier(haz.IBCPositions, "IBC-");
ebd.IBC.HAZ = haz;
ebd.AddClicked += () =>
{
ebd.CopyValuesToEntity();
if (!haz.IBCPositions.Contains(ebd.IBC))
haz.IBCPositions.Add(ebd.IBC);
this.dataGridIBCItems.Items.Refresh();
ebd.IBC = new IBCPosition();
ebd.IBC.HAZ = haz;
ebd.Identifier = DatabaseEntity.GetNewIdentifier(haz.IBCPositions, "IBC-");
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
};
if (ebd.ShowDialog() ?? false)
{
if (!haz.IBCPositions.Contains(ebd.IBC))
haz.IBCPositions.Add(ebd.IBC);
this.dataGridIBCItems.Items.Refresh();
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.SetHAZGlobalFlags();
}
}
#endregion
#region IMDG datagrid handlers
private void DataGridIMDGItems_DeleteRequested(DatabaseEntity obj)
{
HAZ haz = this.IsDeparture ? hazd : haza;
if (obj is IMDGPosition imdg)
{
// are you sure dialog is in base class
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(imdg);
haz.IMDGPositions.Remove(imdg);
DatabaseEntity.ResetIdentifiers(new List<DatabaseEntity>(haz.IMDGPositions));
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.dataGridIMDGItems.Items.Refresh();
}
}
private void DataGridIMDGItems_EditRequested(DatabaseEntity obj)
{
HAZ haz = this.IsDeparture ? hazd : haza;
EditIMDGDialog eld = new EditIMDGDialog();
eld.IMDG = obj as IMDGPosition;
eld.AddClicked += () =>
{
eld.CopyValuesToEntity();
if (!haz.IMDGPositions.Contains(eld.IMDG))
haz.IMDGPositions.Add(eld.IMDG);
this.dataGridIMDGItems.Items.Refresh();
eld.IMDG = new IMDGPosition();
eld.Identifier = DatabaseEntity.GetNewIdentifier(haz.IMDGPositions, "IMDG-");
eld.IMDG.HAZ = haz;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
};
if (eld.ShowDialog() ?? false)
{
if (!haz.IMDGPositions.Contains(eld.IMDG))
haz.IMDGPositions.Add(eld.IMDG);
this.dataGridIMDGItems.Items.Refresh();
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.SetHAZGlobalFlags();
}
}
private void DataGridIMDGItems_AddingNewItem(object sender, System.Windows.Controls.AddingNewItemEventArgs e)
{
this.DataGridIMDGItems_CreateRequested();
}
private void DataGridIMDGItems_CreateRequested()
{
HAZ haz = this.IsDeparture ? hazd : haza;
EditIMDGDialog ebd = new EditIMDGDialog();
ebd.IMDG = new IMDGPosition();
ebd.IMDG.Identifier = DatabaseEntity.GetNewIdentifier(haz.IMDGPositions, "IMDG-");
ebd.IMDG.HAZ = haz;
ebd.AddClicked += () =>
{
ebd.CopyValuesToEntity();
if (!haz.IMDGPositions.Contains(ebd.IMDG))
haz.IMDGPositions.Add(ebd.IMDG);
this.dataGridIMDGItems.Items.Refresh();
ebd.IMDG = new IMDGPosition();
ebd.IMDG.HAZ = haz;
ebd.Identifier = DatabaseEntity.GetNewIdentifier(haz.IMDGPositions, "IMDG-");
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
};
if (ebd.ShowDialog() ?? false)
{
if (!haz.IMDGPositions.Contains(ebd.IMDG))
haz.IMDGPositions.Add(ebd.IMDG);
this.dataGridIMDGItems.Items.Refresh();
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA);
this.SetHAZGlobalFlags();
}
}
#endregion
#region private methods
/// <summary>
/// Beim Hinzufügen der allerersten Gefahrgutposition sollen die Flags vorbelegt werden
/// </summary>
void SetHAZGlobalFlags()
{
HAZ haz = this.IsDeparture ? this.hazd : this.haza;
int totalCount = haz.MARPOLPositions.Count + haz.IMDGPositions.Count + haz.IGCPositions.Count + haz.IBCPositions.Count + haz.IMSBCPositions.Count;
if (totalCount == 1)
{
// if (!(this.checkBoxDangerousGoodsOnBoard.IsChecked ?? false)) this.checkBoxDangerousGoodsOnBoard.IsChecked = true;
if (this.checkBoxMoUBaltic.IsChecked ?? true) this.checkBoxMoUBaltic.IsChecked = false;
haz.NoDPGOnBoardOnArrival = false;
haz.MOUBaltic = false;
}
}
/// <summary>
/// The tab headers include an info on how many DG items there are
/// </summary>
private void RefreshTabHeaders()
{
HAZ haz = this.IsDeparture ? hazd : haza;
if (haz.IMDGPositions.Count > 0)
this.tabIMDGItems.Header = string.Format("{0} ({1})", Properties.Resources.textIMDGItems, haz.IMDGPositions.Count);
else
this.tabIMDGItems.Header = Properties.Resources.textIMDGItems;
if (haz.IBCPositions.Count > 0)
this.tabIBCItems.Header = string.Format("{0} ({1})", Properties.Resources.textIBCItems, haz.IBCPositions.Count);
else
this.tabIBCItems.Header = Properties.Resources.textIBCItems;
if (haz.IGCPositions.Count > 0)
this.tabIGCItems.Header = string.Format("{0} ({1})", Properties.Resources.textIGCItems, haz.IGCPositions.Count);
else
this.tabIGCItems.Header = Properties.Resources.textIGCItems;
if (haz.IMSBCPositions.Count > 0)
this.tabIMSBCItems.Header = string.Format("{0} ({1})", Properties.Resources.textIMSBCItems, haz.IMSBCPositions.Count);
else
this.tabIMSBCItems.Header = Properties.Resources.textIMSBCItems;
if (haz.MARPOLPositions.Count > 0)
this.tabMARPOLItems.Header = string.Format("{0} ({1})", Properties.Resources.textMARPOLItems, haz.MARPOLPositions.Count);
else
this.tabMARPOLItems.Header = Properties.Resources.textMARPOLItems;
}
#endregion
}
}

View File

@ -0,0 +1,70 @@
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
x:Class="ENI2.SheetDisplayControls.PassengerDepartureControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:util="clr-namespace:ENI2.Util"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:ENI2.SheetDisplayControls"
mc:Ignorable="d"
d:DesignHeight="1450" d:DesignWidth="800">
<GroupBox Name="passengerDepartureGroupBox" Header="{x:Static p:Resources.text9PassengerDeparture}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220"/>
<ColumnDefinition Width=".65*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="8" />
<RowDefinition Height="28" />
<RowDefinition Height="640" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Name="labelPasNotificationSchengenDeparture" Content="{x:Static p:Resources.textNotificationSchengen}" HorizontalAlignment="Right" />
<CheckBox Grid.Row="0" Grid.Column="1" Name="checkBoxPasNotificationSchengenDeparture" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationSchengenDeparture_Click"/>
<Label Grid.Row="1" Grid.Column="0" Name="labelPasNotificationPAXDeparture" Content="{x:Static p:Resources.textNotificationPAX}" HorizontalAlignment="Right"/>
<CheckBox Grid.Row="1" Grid.Column="1" Name="checkBoxPasNotificationPAXDeparture" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationPAXDeparture_Click"/>
<Button Name="buttonImportExcelPassengerDeparture" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Width="120" HorizontalAlignment="Right" VerticalAlignment="Center" Background="Transparent" Click="buttonImportExcelPassengerDeparture_Click" />
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal">
<TextBlock Margin="20, 0, 0, 0" Name="textBlockNumPasEntriesDeparture" FontWeight="Bold" Text="{Binding Elements.Count}" VerticalAlignment="Center"/>
<Label Name="labelPasEntryCountDeparture" Content="{x:Static p:Resources.textEntries}" />
<Button Name="buttonDeleteAllPasD" Margin="2" Content="{x:Static p:Resources.textDeleteAllEntries}" Background="Transparent" Click="buttonDeleteAllPasD_Click"/>
</StackPanel>
<enictrl:ENIDataGrid Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" x:Name="dataGridPassengerListDeparture" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textLastName}" Binding="{Binding PassengerLastName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textFirstName}" Binding="{Binding PassengerFirstName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textGender}" Binding="{Binding PassengerGenderDisplay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfEmbarkation}" Binding="{Binding PassengerPortOfEmbarkation}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfDisembarkation}" Binding="{Binding PassengerPortOfDisembarkation}" IsReadOnly="True" Width="0.1*" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textTransitPassenger}" Binding="{Binding PassengerInTransit}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textNationality}" Binding="{Binding PassengerNationality}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textPlaceOfBirth}" Binding="{Binding PassengerPlaceOfBirth}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCountryOfBirth}" Binding="{Binding PassengerCountryOfBirth, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDateOfBirth}" Binding="{Binding PassengerDateOfBirth, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocType}" Binding="{Binding PassengerIdentityDocumentTypeDisplay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocNumber}" Binding="{Binding PassengerIdentityDocumentId}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentIssuingState}" Binding="{Binding PassengerIdentityDocumentIssuingState}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentExpiryDate}" Binding="{Binding PassengerIdentityDocumentExpiryDate, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textVisaNumber}" Binding="{Binding PassengerVisaNumber}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textEmergencyCare}" Binding="{Binding EmergencyCare, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textEmergencyContactNumber}" Binding="{Binding EmergencyContactNumber, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</ScrollViewer>
</GroupBox>
</src:DetailBaseControl>

View File

@ -0,0 +1,381 @@
// Copyright (c) 2025 - schick Informatik
// Description: Display control of formsheet Tab 9. Pas data departure
//
using bsmd.database;
using ClosedXML.Excel;
using ENI2.EditControls;
using ENI2.Locode;
using ENI2.Util;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace ENI2.SheetDisplayControls
{
/// <summary>
/// Interaction logic for PassengerDepartureControl.xaml
/// </summary>
public partial class PassengerDepartureControl : DetailBaseControl
{
#region Fields
private Message _pasMessage;
private Message _pasdMessage;
#endregion
#region Construction
public PassengerDepartureControl()
{
InitializeComponent();
}
#endregion
#region public override
public override void Initialize()
{
base.Initialize();
foreach (Message aMessage in this.Messages)
{
if (aMessage.MessageNotificationClass == Message.NotificationClass.PASA) { this._pasMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.PASD) { this._pasdMessage = aMessage; this.ControlMessages.Add(aMessage); }
}
#region init PASD
if (this._pasdMessage == null)
{
this._pasdMessage = this.Core.CreateMessage(Message.NotificationClass.PASD);
this.Messages.Add(this._pasdMessage);
}
this.dataGridPassengerListDeparture.Initialize();
this.dataGridPassengerListDeparture.ItemsSource = this._pasdMessage.Elements;
this.dataGridPassengerListDeparture.AddingNewItem += DataGridPassengerListDeparture_AddingNewItem;
this.dataGridPassengerListDeparture.EditRequested += DataGridPassengerListDeparture_EditRequested;
this.dataGridPassengerListDeparture.DeleteRequested += DataGridPassengerListDeparture_DeleteRequested;
this.dataGridPassengerListDeparture.CreateRequested += DataGridPassengerListDeparture_CreateRequested;
this.dataGridPassengerListDeparture.RefreshGrid += DataGridPassengerListDeparture_RefreshGrid;
this.dataGridPassengerListDeparture.MultiEditRequested += DataGridPassengerListDeparture_MultiEditRequested;
if (this._pasdMessage.Elements.Count > 0)
{
this.checkBoxPasNotificationSchengenDeparture.IsChecked = ((PASD)this._pasdMessage.Elements[0]).NotificationSchengen;
this.checkBoxPasNotificationPAXDeparture.IsChecked = ((PASD)this._pasdMessage.Elements[0]).NotificationPAX;
}
this.textBlockNumPasEntriesDeparture.DataContext = this._pasdMessage;
// extra menu copy to PASA
{
this.dataGridPassengerListDeparture.ContextMenu.Items.Add(new Separator());
MenuItem copyPASDItem = new MenuItem();
copyPASDItem.Header = Properties.Resources.textCopyToPASA;
copyPASDItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
copyPASDItem.Click += CopyPASDItem_Click;
this.dataGridPassengerListDeparture.ContextMenu.Items.Add(copyPASDItem);
}
#endregion
}
public override void SetEnabled(bool enabled)
{
base.SetEnabled(enabled);
this.passengerDepartureGroupBox.IsEnabled = enabled;
}
#endregion
#region event handler
private void CopyPASDItem_Click(object sender, RoutedEventArgs e)
{
if (this.dataGridPassengerListDeparture.SelectedItems != null)
{
foreach (PASD pasd in this.dataGridPassengerListDeparture.SelectedItems)
{
PAS pasa = new PAS();
pasa.MessageHeader = this._pasMessage;
pasa.CopyFromPAS(pasd);
pasa.IsDeparture = false;
pasa.Identifier = DatabaseEntity.GetNewIdentifier(this._pasMessage.Elements);
this._pasMessage.Elements.Add(pasa);
this.SublistElementChanged(Message.NotificationClass.PASA);
}
}
}
private void checkBoxPasNotificationSchengenDeparture_Click(object sender, RoutedEventArgs e)
{
foreach (PASD pasd in _pasdMessage.Elements.Cast<PASD>())
{
pasd.NotificationSchengen = checkBoxPasNotificationSchengenDeparture.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.PASD);
}
private void checkBoxPasNotificationPAXDeparture_Click(object sender, RoutedEventArgs e)
{
foreach (PASD pasd in _pasdMessage.Elements.Cast<PASD>())
{
pasd.NotificationPAX = checkBoxPasNotificationPAXDeparture.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.PASD);
}
private void buttonImportExcelPassengerDeparture_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog
{
Filter = "Excel Files|*.xls;*.xlsx"
};
if (ofd.ShowDialog() ?? false)
{
try
{
using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var workbook = new XLWorkbook(stream))
{
var worksheet = workbook.Worksheet(1); // Get first worksheet
var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
List<PASD> importPassenger = new List<PASD>();
foreach (var row in rows)
{
if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
if (worksheet.RangeUsed().ColumnCount() < 17)
{
throw new InvalidDataException("Sheet must have 17 columns of data");
}
PASD pas = new PASD();
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (!row.Cell(1).IsEmpty()) pas.PassengerLastName = row.Cell(1).GetString().Clean();
if (pas.PassengerLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(pas.PassengerLastName)) continue;
if (!row.Cell(2).IsEmpty()) pas.PassengerFirstName = row.Cell(2).GetString().Clean();
if (!row.Cell(3).IsEmpty()) pas.PassengerGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
if (!row.Cell(4).IsEmpty()) pas.PassengerPortOfEmbarkation = row.Cell(4).GetString().Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
pas.PassengerPortOfEmbarkation = null;
if (!row.Cell(5).IsEmpty()) pas.PassengerPortOfDisembarkation = row.Cell(5).GetString().Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
pas.PassengerPortOfDisembarkation = null;
if (!row.Cell(6).IsEmpty()) pas.PassengerInTransit = GlobalStructures.ReadBoolean(row.Cell(6).GetString());
if (!row.Cell(7).IsEmpty()) pas.PassengerNationality = row.Cell(7).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(8).IsEmpty()) pas.PassengerPlaceOfBirth = row.Cell(8).GetString().Clean();
if (!row.Cell(9).IsEmpty()) pas.PassengerCountryOfBirth = row.Cell(9).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(10).IsEmpty()) pas.PassengerDateOfBirth = row.Cell(10).GetDateTime();
if (!row.Cell(11).IsEmpty()) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(11).GetString());
if (!row.Cell(12).IsEmpty()) pas.PassengerIdentityDocumentId = row.Cell(12).GetString().Clean();
if (!row.Cell(13).IsEmpty()) pas.PassengerIdentityDocumentIssuingState = row.Cell(13).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(14).IsEmpty()) pas.PassengerIdentityDocumentExpiryDate = row.Cell(14).GetDateTime();
if (!row.Cell(15).IsEmpty()) pas.PassengerVisaNumber = row.Cell(15).GetString().Clean();
if (!row.Cell(16).IsEmpty()) pas.EmergencyCare = row.Cell(16).GetString().Clean();
if (!row.Cell(17).IsEmpty()) pas.EmergencyContactNumber = row.Cell(17).GetString().Clean();
pas.MessageHeader = this._pasdMessage;
pas.IsDirty = true;
pas.Identifier = PASD.GetNewIdentifier(this._pasdMessage.Elements);
this._pasdMessage.Elements.Add(pas);
importPassenger.Add(pas);
}
if (importPassenger.Count > 0)
{
this.dataGridPassengerListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASD);
MessageBox.Show(String.Format(Properties.Resources.textPassengerImported, importPassenger.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
private async void buttonDeleteAllPasD_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show(Properties.Resources.textConfimDeleteAllEntries, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
foreach (PASD pasd in this._pasdMessage.Elements.Cast<PASD>())
{
await DBManagerAsync.DeleteAsync(pasd);
}
this._pasdMessage.Elements.Clear();
this.dataGridPassengerListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASD);
}
}
#endregion
#region passenger grid departure
private void DataGridPassengerListDeparture_CreateRequested()
{
EditPASDialog epd = new EditPASDialog
{
PAS = new PASD()
};
epd.PAS.IsDeparture = true;
epd.PAS.Identifier = PASD.GetNewIdentifier(_pasdMessage.Elements);
epd.PAS.MessageHeader = this._pasdMessage;
epd.AddClicked += () =>
{
epd.CopyValuesToEntity();
if (!this._pasdMessage.Elements.Contains(epd.PAS))
{
this._pasdMessage.Elements.Add(epd.PAS);
this.CheckPASD();
}
this.dataGridPassengerListDeparture.Items.Refresh();
epd.PAS = new PASD
{
IsDeparture = true,
MessageHeader = this._pasdMessage,
Identifier = PASD.GetNewIdentifier(_pasdMessage.Elements)
};
this.SublistElementChanged(Message.NotificationClass.PASD);
};
if (epd.ShowDialog() ?? false)
{
if (!this._pasdMessage.Elements.Contains(epd.PAS))
{
_pasdMessage.Elements.Add(epd.PAS);
this.CheckPASD();
}
this.dataGridPassengerListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASD);
}
}
private void DataGridPassengerListDeparture_DeleteRequested(DatabaseEntity obj)
{
if (obj is PASD pasd)
{
// are you sure dialog is in base class
_pasdMessage.Elements.Remove(pasd);
DBManager.Instance.Delete(pasd);
}
}
private void DataGridPassengerListDeparture_RefreshGrid()
{
DatabaseEntity.ResetIdentifiers(_pasdMessage.Elements);
this.SublistElementChanged(Message.NotificationClass.PASD);
this.dataGridPassengerListDeparture.Items.Refresh();
}
private void DataGridPassengerListDeparture_EditRequested(DatabaseEntity obj)
{
EditPASDialog epd = new EditPASDialog
{
PAS = obj as PASD
};
epd.AddClicked += () =>
{
epd.CopyValuesToEntity();
if (!_pasMessage.Elements.Contains(epd.PAS))
{
_pasMessage.Elements.Add(epd.PAS);
this.CheckPASD();
}
this.dataGridPassengerListDeparture.Items.Refresh();
epd.PAS = new PASD
{
IsDeparture = true,
Identifier = PASD.GetNewIdentifier(_pasdMessage.Elements),
MessageHeader = _pasdMessage
};
this.SublistElementChanged(Message.NotificationClass.PASD);
};
if (epd.ShowDialog() ?? false)
{
if (!_pasdMessage.Elements.Contains(epd.PAS))
{
_pasdMessage.Elements.Add(epd.PAS);
this.CheckPASD();
}
epd.PAS.IsDirty = true;
this.dataGridPassengerListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASD);
}
}
private void DataGridPassengerListDeparture_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
this.DataGridPassengerListDeparture_CreateRequested();
}
private void DataGridPassengerListDeparture_MultiEditRequested(List<DatabaseEntity> databaseEntities)
{
List<PAS> pasList = new List<PAS>();
foreach (PAS apas in databaseEntities.Cast<PAS>())
pasList.Add(apas);
// write common values of all PAS entities to template entity
PAS pas = PAS.CreateCommon(pasList);
EditPASDialog dialog = new EditPASDialog();
dialog.PAS = pas;
dialog.AddVisible = false;
if (dialog.ShowDialog() ?? false)
{
// write back changed values from pas to all entities and mark them as changed
PAS.WriteTemplateToList(pas, pasList);
this.SublistElementChanged(Message.NotificationClass.PASD);
this.dataGridPassengerListDeparture.Items.Refresh();
}
}
#endregion
#region private methods
private void CheckPASD()
{
if (this._pasdMessage.Elements.Count == 0) return;
PASD firstPAS = this._pasdMessage.Elements[0] as PASD;
if (this._pasdMessage.Elements.Count == 1)
{
firstPAS.NotificationSchengen = true;
this.checkBoxPasNotificationSchengenDeparture.IsChecked = true;
}
else
{
for (int i = 1; i < this._pasdMessage.Elements.Count; i++)
{
((PASD)this._pasdMessage.Elements[i]).NotificationSchengen = firstPAS.NotificationSchengen;
}
}
}
#endregion
}
}

View File

@ -0,0 +1,69 @@
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
x:Class="ENI2.SheetDisplayControls.PassengerPreArrivalControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:util="clr-namespace:ENI2.Util"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:ENI2.SheetDisplayControls"
mc:Ignorable="d"
d:DesignHeight="1450" d:DesignWidth="800">
<GroupBox Name="passengerArrivalGroupBox" Header="{x:Static p:Resources.text8PassengerArrival}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220"/>
<ColumnDefinition Width=".65*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="8" />
<RowDefinition Height="28" />
<RowDefinition Height="640" />
</Grid.RowDefinitions>
<CheckBox Grid.Column="1" Name="checkBoxPasNotificationSchengen" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationSchengen_Click" />
<Label Name="labelPasNotificationSchengen" Content="{x:Static p:Resources.textNotificationSchengen}" HorizontalAlignment="Right" />
<CheckBox Grid.Column="1" Grid.Row="1" Name="checkBoxPasNotificationPAX" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationPAX_Click"/>
<Label Grid.Column="0" Grid.Row="1" Name="labelPasNotificationPAX" Content="{x:Static p:Resources.textNotificationPAX}" HorizontalAlignment="Right" />
<Button Grid.Column="0" Grid.Row="3" Name="buttonImportExcelPassenger" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Width="120" HorizontalAlignment="Right" VerticalAlignment="Center" Background="Transparent" Click="buttonImportExcelPassenger_Click" />
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal">
<TextBlock Margin="20, 0, 0, 0" Name="textBlockNumPasEntries" FontWeight="Bold" Text="{Binding Elements.Count}" VerticalAlignment="Center"/>
<Label Name="labelPasEntryCount" Content="{x:Static p:Resources.textEntries}" />
<Button Name="buttonDeleteAllPasA" Margin="2" Content="{x:Static p:Resources.textDeleteAllEntries}" Background="Transparent" Click="buttonDeleteAllPasA_Click"/>
</StackPanel>
<enictrl:ENIDataGrid Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" x:Name="dataGridPassengerList" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textLastName}" Binding="{Binding PassengerLastName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textFirstName}" Binding="{Binding PassengerFirstName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textGender}" Binding="{Binding PassengerGenderDisplay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfEmbarkation}" Binding="{Binding PassengerPortOfEmbarkation}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfDisembarkation}" Binding="{Binding PassengerPortOfDisembarkation}" IsReadOnly="True" Width="0.1*" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textTransitPassenger}" Binding="{Binding PassengerInTransit}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textNationality}" Binding="{Binding PassengerNationality}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textPlaceOfBirth}" Binding="{Binding PassengerPlaceOfBirth}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCountryOfBirth}" Binding="{Binding PassengerCountryOfBirth, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDateOfBirth}" Binding="{Binding PassengerDateOfBirth, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocType}" Binding="{Binding PassengerIdentityDocumentTypeDisplay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocNumber}" Binding="{Binding PassengerIdentityDocumentId}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentIssuingState}" Binding="{Binding PassengerIdentityDocumentIssuingState}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentExpiryDate}" Binding="{Binding PassengerIdentityDocumentExpiryDate, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textVisaNumber}" Binding="{Binding PassengerVisaNumber}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textEmergencyCare}" Binding="{Binding EmergencyCare, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textEmergencyContactNumber}" Binding="{Binding EmergencyContactNumber, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</ScrollViewer>
</GroupBox>
</src:DetailBaseControl>

View File

@ -0,0 +1,378 @@
// Copyright (c) 2025 - schick Informatik
// Description: Display control of formsheet Tab 8. Pas data arrival
//
//
using bsmd.database;
using ClosedXML.Excel;
using ENI2.EditControls;
using ENI2.Locode;
using ENI2.Util;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace ENI2.SheetDisplayControls
{
/// <summary>
/// Interaction logic for PassengerPreArrivalControl.xaml
/// </summary>
public partial class PassengerPreArrivalControl : DetailBaseControl
{
#region Fields
private Message _pasMessage;
private Message _pasdMessage;
#endregion
#region Construction
public PassengerPreArrivalControl()
{
InitializeComponent();
}
#endregion
#region public overrides
public override void Initialize()
{
base.Initialize();
foreach (Message aMessage in this.Messages)
{
if (aMessage.MessageNotificationClass == Message.NotificationClass.PASA) { this._pasMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.PASD) { this._pasdMessage = aMessage; this.ControlMessages.Add(aMessage); }
}
#region init PASA
if (this._pasMessage == null)
{
this._pasMessage = this.Core.CreateMessage(Message.NotificationClass.PASA);
this.Messages.Add(this._pasMessage);
}
this.textBlockNumPasEntries.DataContext = this._pasMessage;
this.dataGridPassengerList.Initialize();
this.dataGridPassengerList.ItemsSource = this._pasMessage.Elements;
this.dataGridPassengerList.AddingNewItem += DataGridPassengerList_AddingNewItem;
this.dataGridPassengerList.EditRequested += DataGridPassengerList_EditRequested;
this.dataGridPassengerList.DeleteRequested += DataGridPassengerList_DeleteRequested;
this.dataGridPassengerList.CreateRequested += DataGridPassengerList_CreateRequested;
this.dataGridPassengerList.RefreshGrid += DataGridPassengerList_RefreshGrid;
this.dataGridPassengerList.MultiEditRequested += DataGridPassengerList_MultiEditRequested;
if (this._pasMessage.Elements.Count > 0)
{
this.checkBoxPasNotificationSchengen.IsChecked = ((PAS)this._pasMessage.Elements[0]).NotificationSchengen;
this.checkBoxPasNotificationPAX.IsChecked = ((PAS)this._pasMessage.Elements[0]).NotificationPAX;
}
// extra menu copy to PASD
{
this.dataGridPassengerList.ContextMenu.Items.Add(new Separator());
MenuItem copyPASAItem = new MenuItem();
copyPASAItem.Header = Properties.Resources.textCopyToPASD;
copyPASAItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
copyPASAItem.Click += CopyPASAItem_Click; ;
this.dataGridPassengerList.ContextMenu.Items.Add(copyPASAItem);
}
#endregion
}
public override void SetEnabled(bool enabled)
{
base.SetEnabled(enabled);
this.passengerArrivalGroupBox.IsEnabled = enabled;
}
#endregion
#region event handler
private void CopyPASAItem_Click(object sender, RoutedEventArgs e)
{
if (this.dataGridPassengerList.SelectedItems != null)
{
foreach (PAS pasa in this.dataGridPassengerList.SelectedItems)
{
PASD pasd = new PASD();
pasd.MessageHeader = this._pasdMessage;
pasd.CopyFromPAS(pasa);
pasd.IsDeparture = true;
pasd.Identifier = DatabaseEntity.GetNewIdentifier(this._pasdMessage.Elements);
this._pasdMessage.Elements.Add(pasd);
this.SublistElementChanged(Message.NotificationClass.PASD);
}
}
}
private void buttonImportExcelPassenger_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog
{
Filter = "Excel Files|*.xls;*.xlsx"
};
if (ofd.ShowDialog() ?? false)
{
try
{
using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var workbook = new XLWorkbook(stream))
{
var worksheet = workbook.Worksheet(1); // Get first worksheet
var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
List<PAS> importPassenger = new List<PAS>();
foreach (var row in rows)
{
if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
if (worksheet.RangeUsed().ColumnCount() < 17)
{
throw new InvalidDataException("Sheet must have 17 columns of data");
}
PAS pas = new PAS();
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (!row.Cell(1).IsEmpty()) pas.PassengerLastName = row.Cell(1).GetString().Clean();
if (pas.PassengerLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(pas.PassengerLastName)) continue;
if (!row.Cell(2).IsEmpty()) pas.PassengerFirstName = row.Cell(2).GetString().Clean();
if (!row.Cell(3).IsEmpty()) pas.PassengerGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
if (!row.Cell(4).IsEmpty()) pas.PassengerPortOfEmbarkation = row.Cell(4).GetString().Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
pas.PassengerPortOfEmbarkation = null;
if (!row.Cell(5).IsEmpty()) pas.PassengerPortOfDisembarkation = row.Cell(5).GetString().Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
pas.PassengerPortOfDisembarkation = null;
if (!row.Cell(6).IsEmpty()) pas.PassengerInTransit = GlobalStructures.ReadBoolean(row.Cell(6).GetString());
if (!row.Cell(7).IsEmpty()) pas.PassengerNationality = row.Cell(7).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(8).IsEmpty()) pas.PassengerPlaceOfBirth = row.Cell(8).GetString().Clean();
if (!row.Cell(9).IsEmpty()) pas.PassengerCountryOfBirth = row.Cell(9).GetString().Substring(0, 2).ToUpper().Clean();
if (!row.Cell(10).IsEmpty()) pas.PassengerDateOfBirth = row.Cell(10).GetDateTime();
if (!row.Cell(11).IsEmpty()) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(11).GetString());
if (!row.Cell(12).IsEmpty()) pas.PassengerIdentityDocumentId = row.Cell(12).GetString().Clean();
if (!row.Cell(13).IsEmpty()) pas.PassengerIdentityDocumentIssuingState = row.Cell(13).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(14).IsEmpty()) pas.PassengerIdentityDocumentExpiryDate = row.Cell(14).GetDateTime();
if (!row.Cell(15).IsEmpty()) pas.PassengerVisaNumber = row.Cell(15).GetString().Clean();
if (!row.Cell(16).IsEmpty()) pas.EmergencyCare = row.Cell(16).GetString().Clean();
if (!row.Cell(17).IsEmpty()) pas.EmergencyContactNumber = row.Cell(17).GetString().Clean();
pas.MessageHeader = this._pasMessage;
pas.IsDirty = true;
pas.Identifier = PAS.GetNewIdentifier(this._pasMessage.Elements);
this._pasMessage.Elements.Add(pas);
importPassenger.Add(pas);
}
if (importPassenger.Count > 0)
{
this.dataGridPassengerList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASA);
MessageBox.Show(String.Format(Properties.Resources.textPassengerImported, importPassenger.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
private void checkBoxPasNotificationSchengen_Click(object sender, RoutedEventArgs e)
{
foreach (PAS pas in _pasMessage.Elements.Cast<PAS>())
{
pas.NotificationSchengen = checkBoxPasNotificationSchengen.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.PASA);
}
private void checkBoxPasNotificationPAX_Click(object sender, RoutedEventArgs e)
{
foreach (PAS pas in _pasMessage.Elements.Cast<PAS>())
{
pas.NotificationPAX = checkBoxPasNotificationPAX.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.PASA);
}
private async void buttonDeleteAllPasA_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show(Properties.Resources.textConfimDeleteAllEntries, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
foreach (PAS pasa in this._pasMessage.Elements.Cast<PAS>())
{
await DBManagerAsync.DeleteAsync(pasa);
}
this._pasMessage.Elements.Clear();
this.dataGridPassengerList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASA);
}
}
#endregion
#region passenger grid arrival
private void DataGridPassengerList_CreateRequested()
{
EditPASDialog epd = new EditPASDialog
{
PAS = new PAS()
};
epd.PAS.Identifier = PAS.GetNewIdentifier(_pasMessage.Elements);
epd.PAS.MessageHeader = this._pasMessage;
epd.AddClicked += () =>
{
epd.CopyValuesToEntity();
if (!this._pasMessage.Elements.Contains(epd.PAS))
{
this._pasMessage.Elements.Add(epd.PAS);
this.CheckPASA();
}
this.dataGridPassengerList.Items.Refresh();
epd.PAS = new PAS
{
MessageHeader = this._pasMessage,
Identifier = PAS.GetNewIdentifier(_pasMessage.Elements)
};
this.SublistElementChanged(Message.NotificationClass.PASA);
};
if (epd.ShowDialog() ?? false)
{
if (!this._pasMessage.Elements.Contains(epd.PAS))
{
_pasMessage.Elements.Add(epd.PAS);
this.CheckPASA();
}
this.dataGridPassengerList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASA);
}
}
private void DataGridPassengerList_DeleteRequested(DatabaseEntity obj)
{
if (obj is PAS pas)
{
// are you sure dialog is in base class
_pasMessage.Elements.Remove(pas);
DBManager.Instance.Delete(pas);
}
}
private void DataGridPassengerList_RefreshGrid()
{
DatabaseEntity.ResetIdentifiers(_pasMessage.Elements);
this.SublistElementChanged(Message.NotificationClass.PASA);
this.dataGridPassengerList.Items.Refresh();
}
private void DataGridPassengerList_EditRequested(DatabaseEntity obj)
{
EditPASDialog epd = new EditPASDialog
{
PAS = obj as PAS
};
epd.AddClicked += () =>
{
epd.CopyValuesToEntity();
if (!_pasMessage.Elements.Contains(epd.PAS))
{
_pasMessage.Elements.Add(epd.PAS);
this.CheckPASA();
}
this.dataGridPassengerList.Items.Refresh();
epd.PAS = new PAS
{
Identifier = PAS.GetNewIdentifier(_pasMessage.Elements),
MessageHeader = _pasMessage
};
this.SublistElementChanged(Message.NotificationClass.PASA);
};
if (epd.ShowDialog() ?? false)
{
if (!_pasMessage.Elements.Contains(epd.PAS))
{
_pasMessage.Elements.Add(epd.PAS);
this.CheckPASA();
}
epd.PAS.IsDirty = true;
this.dataGridPassengerList.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASA);
}
}
private void DataGridPassengerList_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
this.DataGridPassengerList_CreateRequested();
}
private void DataGridPassengerList_MultiEditRequested(List<DatabaseEntity> databaseEntities)
{
List<PAS> pasList = new List<PAS>();
foreach (PAS apas in databaseEntities.Cast<PAS>())
pasList.Add(apas);
// write common values of all PAS entities to template entity
PAS pas = PAS.CreateCommon(pasList);
EditPASDialog dialog = new EditPASDialog();
dialog.PAS = pas;
dialog.AddVisible = false;
if (dialog.ShowDialog() ?? false)
{
// write back changed values from pas to all entities and mark them as changed
PAS.WriteTemplateToList(pas, pasList);
this.SublistElementChanged(Message.NotificationClass.PASA);
this.dataGridPassengerList.Items.Refresh();
}
}
#endregion
#region private methods
private void CheckPASA()
{
if (this._pasMessage.Elements.Count == 0) return;
PAS firstPAS = this._pasMessage.Elements[0] as PAS;
if (this._pasMessage.Elements.Count == 1)
{
firstPAS.NotificationSchengen = true;
this.checkBoxPasNotificationSchengen.IsChecked = true;
}
else
{
for (int i = 1; i < this._pasMessage.Elements.Count; i++)
{
((PAS)this._pasMessage.Elements[i]).NotificationSchengen = firstPAS.NotificationSchengen;
}
}
}
#endregion
}
}

View File

@ -0,0 +1,472 @@
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
x:Class="ENI2.SheetDisplayControls.PortControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:util="clr-namespace:ENI2.Util"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:col="clr-namespace:System.Collections;assembly=mscorlib"
xmlns:local="clr-namespace:ENI2.SheetDisplayControls"
mc:Ignorable="d"
d:DesignHeight="1050" d:DesignWidth="800">
<UserControl.Resources>
<col:ArrayList x:Key="arrList">
<col:DictionaryEntry Key="None" Value="0" />
<col:DictionaryEntry Key="Maersk BHV" Value="1" />
<col:DictionaryEntry Key="SeaGo BHV" Value="2" />
<col:DictionaryEntry Key="SeaGo WHV" Value="4" />
<col:DictionaryEntry Key="Hoegh BHV" Value="8" />
<col:DictionaryEntry Key="Elbe Bulk" Value="16" />
<col:DictionaryEntry Key="Fct Junge" Value="32" />
</col:ArrayList>
</UserControl.Resources>
<GroupBox Name="portCallGroupBox" Header="{x:Static p:Resources.text2PortCall}">
<TabControl x:Name="mainTabControl">
<TabItem Header="{x:Static p:Resources.textTab21}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220"/>
<ColumnDefinition Width=".3*" />
<ColumnDefinition Width=".3*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="36" />
<RowDefinition Height="120" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text21ReferenceNumbers}" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"/>
<Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textVisitTransitId}" Margin="0,0,10,0" />
<TextBox Name="textBoxDisplayId" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="1" IsReadOnly="True" Margin="2" VerticalContentAlignment="Center" />
<Label HorizontalAlignment="Right" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textTicketNo}" Margin="0,0,10,0" />
<TextBox Name="textBoxTicketNo" Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="1" Text="{Binding TicketNo, Mode=TwoWay, Converter={util:TrimStringConverter}}" Margin="2" VerticalContentAlignment="Center" MaxLength="50"/>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text22PortOperations}" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"/>
<GroupBox Grid.Row="4" Grid.ColumnSpan="3" Name="groupBoxCallPurpose" Header="{x:Static p:Resources.textCallPurposes}" >
<enictrl:ENIDataGrid x:Name="dataGridCallPurposes" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
SelectionMode="Single" AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textCode}" Binding="{Binding CallPurposeCode, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDescription}" Binding="{Binding CallPurposeDescription, Mode=TwoWay}" IsReadOnly="True" Width="0.9*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</GroupBox>
<Label HorizontalContentAlignment="Right" Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textPortArea}" Name="label_INFOPortArea" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<Grid Grid.Row="5" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".7*" />
<ColumnDefinition Width=".3*" />
</Grid.ColumnDefinitions>
<ComboBox Grid.Row="0" Grid.Column="0" Name="comboBoxPortArea" Margin="2" SelectedValue="{Binding PortArea}" SelectedValuePath="Key" DisplayMemberPath="Value" ContextMenu="{DynamicResource ClearContextMenu}" />
<Button Grid.Row="0" Grid.Column="1" x:Name="buttonSearchPortArea" Margin="2" Content="Lookup port area" Click="buttonSearchPortArea_Click" />
</Grid>
<Label HorizontalContentAlignment="Right" Grid.Row="6" Grid.Column="0" Content="{x:Static p:Resources.textRequestedPositionInPortOfCall}" Name="label_INFORequestedBerth" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<TextBox Grid.Row="6" Grid.Column="1" Name="textRequestedPostionInPortOfCall" Margin="2" Text="{Binding RequestedPositionInPortOfCall, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<Label HorizontalContentAlignment="Right" Grid.Row="7" Grid.Column="0" Content="{x:Static p:Resources.textSpecialRequirementsOfShipAtBerth}" Name="label_INFOSpecialRequirements" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<TextBox Grid.Row="7" Grid.Column="1" Grid.RowSpan="1" Name="textSpecialRequirements" Margin="2" Text="{Binding SpecialRequirementsOfShipAtBerth, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center" />
<Label HorizontalContentAlignment="Right" Grid.Row="8" Grid.Column="0" Content="{x:Static p:Resources.textConstructionCharacteristics}" Name="label_INFOConstructionCharacteristics" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<TextBox Grid.Row="8" Grid.Column="1" Grid.RowSpan="1" Name="textConstructionCharacteristics" Margin="2" Text="{Binding ConstructionCharacteristicsOfShip, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<Label Content="{x:Static p:Resources.textPlannedOperations}" Grid.Column="0" Grid.Row="9" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<TextBox Text="{Binding PlannedOperations, Mode=TwoWay, Converter={util:TrimStringConverter}}" Name="textBoxPlannedOperations" Grid.Column="1" Grid.Row="9" Margin="2,2,2,2" VerticalContentAlignment="Center" MaxLength="99"/>
<Label Content="{x:Static p:Resources.textPlannedInspection}" Grid.Column="0" Grid.Row="10" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<TextBox Text="{Binding PlannedWorks, Mode=TwoWay, Converter={util:TrimStringConverter}}" Name="textBoxPlannedWorks" Grid.Column="1" Grid.Row="10" Margin="2,2,2,2" MaxLength="255" />
</Grid>
</TabItem>
<TabItem Header="{x:Static p:Resources.textTab22}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="190"/>
<ColumnDefinition Width=".3*" />
<ColumnDefinition Width=".3*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="1" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="140" />
</Grid.RowDefinitions>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text23Agency}" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"/>
<Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textAgentTemplate}" Name="labelAgentTemplate" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textCompanyName}" Name="label_AgentCompanyName" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textStreetNumber}" Name="label_AgentStreetAndNumber" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textPostalCode}" Name="label_AgentPostalCode" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="6" Grid.Column="0" Content="{x:Static p:Resources.textCity}" Name="label_AgentCity" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="7" Grid.Column="0" Content="{x:Static p:Resources.textCountry}" Name="label_AgentCountry" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="8" Grid.Column="0" Content="{x:Static p:Resources.textPhone}" Name="label_AgentPhone" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="9" Grid.Column="0" Content="{x:Static p:Resources.textFax}" Name="label_AgentFax" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="10" Grid.Column="0" Content="{x:Static p:Resources.textEMail}" Name="label_AgentEMail" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="11" Grid.Column="0" Content="{x:Static p:Resources.textLastName}" Name="label_AgentLastName" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="12" Grid.Column="0" Content="{x:Static p:Resources.textFirstName}" Name="label_AgentFirstName" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="13" Grid.Column="0" Content="{x:Static p:Resources.textWasteDisposalServiceProvider}" Name="label_WasteDisposalServiceProvider" Margin="0,0,10,0"/>
<ComboBox Grid.Row="1" Grid.Column="1" Name="comboBox_AgentTemplate" Margin="2" SelectedValuePath="Id" DisplayMemberPath="AgentTitle" SelectionChanged="comboBox_AgentTemplate_SelectionChanged" />
<Grid Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="26" />
</Grid.ColumnDefinitions>
</Grid>
<Grid Grid.Row="1" Grid.Column="2" Name="gridTemplateControls" Visibility="Visible">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="26" />
<ColumnDefinition Width="*"/>
<!-- Name -->
<ColumnDefinition Width="26"/>
<!-- Save button -->
<ColumnDefinition Width="26"/>
<!-- Delete button -->
<ColumnDefinition Width="52"/>
<!-- Undo button -->
</Grid.ColumnDefinitions>
<Button Name="buttonSetTemplate" Grid.Column="0" Margin="2" Click="buttonSetTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Apply template" HorizontalContentAlignment="Right" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/check.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<TextBox Grid.Column="1" Margin="2" Name="textBoxTemplateTitle" VerticalContentAlignment="Center"/>
<Button Name="buttonSaveTemplate" Grid.Column="2" Grid.Row="0" Margin="2" Click="buttonSaveTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Save template">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/floppy_disk_blue.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonDeleteTemplate" Grid.Column="3" Grid.Row="0" Margin="2" Click="buttonDeleteTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Delete template" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/delete.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonUndoTemplate" Grid.Column="4" Grid.Row="0" Margin="22,2,2,2" Click="buttonUndoTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Undo last overwrite" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/undo.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
</Grid>
<TextBox Grid.Row="3" Grid.Column="1" Name="textBox_AgentCompanyName" MaxLength="99" Margin="2" Text="{Binding AgentCompanyName, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="4" Grid.Column="1" Name="textBox_AgentStreetAndNumber" MaxLength="99" Margin="2" Text="{Binding AgentStreetAndNumber, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="5" Grid.Column="1" Name="textBox_AgentPostalCode" MaxLength="99" Margin="2" Text="{Binding AgentPostalCode, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="6" Grid.Column="1" Name="textBox_AgentCity" MaxLength="99" Margin="2" Text="{Binding AgentCity, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="7" Grid.Column="1" Name="textBox_AgentCountry" MaxLength="99" Margin="2" Text="{Binding AgentCountry, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center" />
<TextBox Grid.Row="8" Grid.Column="1" Name="textBox_AgentPhone" MaxLength="99" Margin="2" Text="{Binding AgentPhone, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="9" Grid.Column="1" Name="textBox_AgentFax" MaxLength="99" Margin="2" Text="{Binding AgentFax, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="10" Grid.Column="1" Name="textBox_AgentEMail" MaxLength="99" Margin="2" Text="{Binding AgentEMail, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="11" Grid.Column="1" Name="textBox_AgentLastName" MaxLength="99" Margin="2" Text="{Binding AgentLastName, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="12" Grid.Column="1" Name="textBox_AgentFirstName" MaxLength="99" Margin="2" Text="{Binding AgentFirstName, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="13" Grid.Column="1" Name="textBox_WasteDisposalServiceProvider" MaxLength="99" Margin="2" Text="{Binding WasteDisposalServiceProviderText, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text24Invoice}" Grid.Column="0" Grid.Row="14" Grid.ColumnSpan="3"/>
<Label HorizontalContentAlignment="Right" Grid.Row="15" Grid.Column="0" Content="{x:Static p:Resources.textSERVTemplate}" Name="label_MaerskSeaGo" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<ComboBox Grid.Row="15" Grid.Column="1" x:Name="comboBoxGroup" DisplayMemberPath="ServiceName" Margin="2" SelectionChanged="comboBoxGroup_SelectionChanged" ContextMenu="{DynamicResource ClearContextMenu}" />
<Grid Grid.Row="15" Grid.Column="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="26" />
<ColumnDefinition Width="26" />
<ColumnDefinition Width="26" />
<ColumnDefinition Width="26" />
<ColumnDefinition Width="26" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Name="buttonSetSERVTemplate" Margin="2" Click="buttonSetSERVTemplate_Click" BorderThickness="0" Background="Transparent" Grid.Column="0"
ToolTip="Apply template" HorizontalContentAlignment="Right" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/check.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonEditSERVTemplate" Grid.Column="2" Grid.Row="0" Margin="2" Click="buttonEditSERVTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Edit template">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/pencil.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonNewSERVTemplate" Grid.Column="3" Grid.Row="0" Margin="2" Click="buttonNewSERVTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="New template">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/document_plain_new.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonDeleteSERVTemplate" Grid.Column="4" Grid.Row="0" Margin="2" Click="buttonDeleteSERVTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Delete template" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/delete.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
</Grid>
<GroupBox Name="servGroupBox" Header="{x:Static p:Resources.textServ}" Grid.Row="16" Grid.Column="0" Grid.ColumnSpan="3">
<enictrl:ENIDataGrid x:Name="dataGridSERV" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textServiceName}" Binding="{Binding ServiceName, Mode=TwoWay}" IsReadOnly="True" Width="0.3*" />
<DataGridTextColumn Header="{x:Static p:Resources.textServiceBeneficiary}" Binding="{Binding ServiceBeneficiary, Mode=TwoWay}" IsReadOnly="True" Width="0.3*" />
<DataGridTextColumn Header="{x:Static p:Resources.textServiceInvoiceRecipient}" Binding="{Binding ServiceInvoiceRecipient, Mode=TwoWay}" IsReadOnly="True" Width="0.4*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</GroupBox>
</Grid>
</TabItem>
<TabItem Header="{x:Static p:Resources.textTab23}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220"/>
<ColumnDefinition Width=".3*" />
<ColumnDefinition Width=".3*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="36" />
<RowDefinition Height="180" />
</Grid.RowDefinitions>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text25CargeOnBoard}" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3"/>
<Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textGeneralCargoDescription}" Name="label_GeneralCargoDescription" Margin="0,0,10,0"/>
<ComboBox Name="comboBoxGeneralDescriptionOfCargo" Grid.Row="1" Grid.Column="1" IsEditable="False" StaysOpenOnEdit="True" SelectedIndex="{Binding GeneralDescriptionOfCargo, Converter={util:ByteConverter}}" Margin="2" IsTextSearchEnabled="True"/>
<Label HorizontalContentAlignment="Right" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textFumigatedBulkCargo}" Name="label_INFOFumigatedBulkCargo" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<CheckBox Grid.Row="2" Grid.Column="1" Name="checkBoxFumigatedBulkCargo" VerticalContentAlignment="Center" IsChecked="{Binding FumigatedBulkCargoBool, Mode=TwoWay}" Margin="2,2,2,2"/>
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textTanker}" VerticalContentAlignment="Center" Margin="0,0,10,0" />
<CheckBox Grid.Row="3" Grid.Column="1" Name="checkBoxTanker" VerticalContentAlignment="Center" IsChecked="{Binding Tanker, Mode=TwoWay}" Margin="2,2,2,2" />
<Label Content="{x:Static p:Resources.textTankerCondition}" Grid.Column="0" Grid.Row="4" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<ComboBox Grid.Row="4" Grid.Column="1" Name="comboBoxConditionCargoBallastTanks" Margin="2" SelectedIndex="{Binding ConditionCargoBallastTanks, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={util:ByteConverter}}" IsEnabled="{Binding ElementName=checkBoxTanker, Path=IsChecked}" ContextMenu="{DynamicResource ClearContextMenu}"/>
<Label Content="{x:Static p:Resources.textTankerNatureOfCargo}" Grid.Column="0" Grid.Row="5" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<TextBox Text="{Binding NatureOfCargo, Mode=TwoWay, Converter={util:TrimStringConverter}}" Name="textBoxNatureOfCargo" Grid.Column="1" Grid.Row="5" Margin="2,2,2,2" IsEnabled="{Binding ElementName=checkBoxTanker, Path=IsChecked}" VerticalContentAlignment="Center" MaxLength="99" />
<Label Content="{x:Static p:Resources.textTankerVolumeOfCargo}" Grid.Column="0" Grid.Row="6" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<xctk:DoubleUpDown Grid.Row="6" Grid.Column="1" Name="doubleUpDownVolumeOfCargo" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2,2,2,2" FormatString="N3" Value="{Binding VolumeOfCargo, Mode=TwoWay}" IsEnabled="{Binding ElementName=checkBoxTanker, Path=IsChecked}" TextAlignment="Left"/>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text26CargoPort}" Grid.Column="0" Grid.Row="7" Grid.ColumnSpan="3"/>
<GroupBox Name="ladgGroupBox" Header="{x:Static p:Resources.textLadg}" Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="3">
<enictrl:ENIDataGrid x:Name="dataGridLADG" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoHandlingType}" Binding="{Binding CargoHandlingTypeDisplay}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textLACodes}" Binding="{Binding CargoLACode, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoCodeNST}" Binding="{Binding CargoCodeNST, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoCodeNST3}" Binding="{Binding CargoCodeNST_3, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoNumberOfItems}" IsReadOnly="False" Width="0.15*">
<DataGridTextColumn.Binding>
<Binding Path="CargoNumberOfItems" Mode="TwoWay">
<Binding.ValidationRules>
<util:NumberValidationRule MaxValue="9999999" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textCargoGrossQuantity}" IsReadOnly="False" Width="0.15*">
<DataGridTextColumn.Binding>
<Binding Path="CargoGrossQuantity_TNE" Mode="TwoWay" StringFormat="N3">
<Binding.ValidationRules>
<util:NumberValidationRule MaxValue="1000000" MinValue="0" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textCargoPortOfLoading}" Binding="{Binding PortOfLoading, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoPortOfDischarge}" Binding="{Binding PortOfDischarge, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</GroupBox>
</Grid>
</TabItem>
<TabItem Header="{x:Static p:Resources.textTab24}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="320"/>
<ColumnDefinition Width=".3*" />
<ColumnDefinition Width=".3*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="56" />
<RowDefinition Height="28" />
<RowDefinition Height="530" />
<RowDefinition Height="28" />
<RowDefinition Height="36" />
<RowDefinition Height="140" />
<RowDefinition Height="36" />
<RowDefinition Height="140" />
</Grid.RowDefinitions>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text27Waste}" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"/>
<Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textValidExemption}" Name="label_ValidExemption" Margin="0,0,10,0"/>
<CheckBox Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Name="checkBoxValidExemption" IsChecked="{Binding WasteDisposalValidExemption, Mode=TwoWay}" />
<Label HorizontalContentAlignment="Right" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textAccurateDetailsGiven}" Name="label_AccurateDetailsGiven" Margin="0,0,10,0"/>
<CheckBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Name="checkBoxAccurateCorrectDetails" IsChecked="{Binding ConfirmationOfCorrectness, Mode=TwoWay}" />
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textLastPortWasteDischarge}" Name="label_WasteLastPortDischarged" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textWasteDateLastDisposal}" Name="label_DateOfLastDisposal" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textWasteDisposalServiceProviders}" Name="label_WasteDisposalServiceProviders" Margin="0,0,10,0"/>
<enictrl:LocodeControl Grid.Row="3" Grid.Column="1" x:Name="locodeCtrlLastWastePort" LocodeValue="{Binding LastWasteDisposalPort, Mode=TwoWay}" LocodeSource="SSN" />
<DatePicker Grid.Row="4" Grid.Column="1" Name="datePickerDateLastDisposal" Margin="2" SelectedDate="{Binding LastWasteDisposalDate, Mode=TwoWay}" DisplayDateStart="1/1/1800" DisplayDateEnd="12/31/2199" PreviewKeyUp="DateTimePicker_PreviewKeyUpDate">
<DatePicker.BlackoutDates>
<CalendarDateRange Start="1/1/0001" End="12/31/1799"/>
<CalendarDateRange Start="1/1/2199" End="1/1/9999"/>
</DatePicker.BlackoutDates>
</DatePicker>
<TextBox Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2" Grid.RowSpan="1" Name="textBoxWasteDisposalServiceProviders" Text="{Binding WasteDisposalServiceProviderText, Converter={util:TrimStringConverter}}" Margin="2" />
<!-- Label Grid.Row="6" Grid.Column="0" HorizontalContentAlignment="Right" Content="{x:Static p:Resources.textAgentTemplate}" Margin="0,0,10,0" / -->
<Grid Grid.Row="6" Grid.Column="1" Grid.ColumnSpan="2" x:Name="gridWasteControls">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".25*" />
<ColumnDefinition Width=".25*" />
<ColumnDefinition Width=".25*" />
<ColumnDefinition Width=".25*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<!-- RowDefinition Height="28" / -->
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<ComboBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Name="comboBox_WSDPTemplate" Margin="2" SelectedValuePath="Id" DisplayMemberPath="Remark" SelectionChanged="comboBox_WSDPTemplate_SelectionChanged" />
<Button Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="1" Name="buttonAddMissingEntries" Content="{x:Static p:Resources.textAddMissingEntries}" Margin="2" Click="buttonAddMissingEntries_Click"/>
<Button Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="1" Name="buttonImportFromExcel" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Click="buttonImportFromExcel_Click" />
</Grid>
<enictrl:ENIDataGrid x:Name="dataGridWaste" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" AutoGenerateColumns="False" Margin="0,5,0,0" Grid.Row="7" Grid.ColumnSpan="3" CanUserAddRows="False">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textCode}" Binding="{Binding WasteTypeDisplayGrid}" IsReadOnly="True" Width="0.2*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDescription}" Binding="{Binding WasteDescription}" IsReadOnly="True" Width="0.15*" />
<DataGridTemplateColumn IsReadOnly="True" Width="0.1*">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{x:Static p:Resources.textWasteAmountToBeDisposed}" FontSize="10"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" Text="{Binding WasteDisposalAmount_MTQ, StringFormat={}{0:N3}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn IsReadOnly="True" Width="0.1*">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{x:Static p:Resources.textWasteMaxCapacity}" FontSize="10"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" Text="{Binding WasteCapacity_MTQ, StringFormat={}{0:N3}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn IsReadOnly="True" Width="0.1*">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{x:Static p:Resources.textWasteRetained}" FontSize="10"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" Text="{Binding WasteAmountRetained_MTQ, StringFormat={}{0:N3}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn IsReadOnly="True" Width="0.1*">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{x:Static p:Resources.textWastePortOfDelivery}" FontSize="10"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" Text="{Binding WasteDisposalPort}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn IsReadOnly="True" Width="0.12*">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{x:Static p:Resources.textWasteGeneratedUntilNextPort}" FontSize="9"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" Text="{Binding WasteAmountGeneratedTillNextPort_MTQ, StringFormat={}{0:N3}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</enictrl:ENIDataGrid>
<Label HorizontalContentAlignment="Right" Grid.Row="8" Grid.Column="0" Content="{x:Static p:Resources.textNextWasteDisposalPort}" Name="label_NextWasteDisposalPort" Margin="0,0,10,0"/>
<enictrl:LocodeControl Grid.Row="8" Grid.Column="1" x:Name="locodeCtrlNextWastePort" LocodeValue="{Binding NextWasteDisposalPort, Mode=TwoWay}" LocodeSource="SSN" />
<!--
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text28Store}" Grid.Column="0" Grid.Row="7" Grid.ColumnSpan="2"/>
<GroupBox Name="storeGroupBox" Header="{x:Static p:Resources.textStore}" Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="2">
<enictrl:ENIDataGrid x:Name="dataGridSTO" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textName}" Binding="{Binding Name}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textQuantity}" IsReadOnly="True" Width="0.1*">
<DataGridTextColumn.Binding>
<Binding Path="Quantity" Mode="TwoWay" StringFormat="N3">
<Binding.ValidationRules>
<util:NumberValidationRule MaxValue="1000000" MinValue="0" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textQuantityUnit}" Binding="{Binding QuantityUnit, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textLocationOnBoard}" Binding="{Binding LocationOnBoard, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textOfficialUse}" Binding="{Binding OfficialUse, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</GroupBox>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text29CrewEffects}" Grid.Column="0" Grid.Row="9" Grid.ColumnSpan="2"/>
<GroupBox Name="effectsGroupBox" Header="{x:Static p:Resources.textEffects}" Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="2">
<enictrl:ENIDataGrid x:Name="dataGridEffects" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textEffects}" Binding="{Binding Effects}" IsReadOnly="True" Width="0.15*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</GroupBox>
-->
</Grid>
</TabItem>
</TabControl>
</GroupBox>
</src:DetailBaseControl>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,125 @@
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
x:Class="ENI2.SheetDisplayControls.PreArrivalControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:util="clr-namespace:ENI2.Util"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:ENI2.SheetDisplayControls"
mc:Ignorable="d"
d:DesignHeight="850" d:DesignWidth="800">
<GroupBox Name="preArrivalGroupBox" Header="{x:Static p:Resources.text3PreArrival}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="240"/>
<ColumnDefinition Width=".3*" />
<ColumnDefinition Width=".3*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="36" />
<RowDefinition Height="140" />
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="36" />
<RowDefinition Height="140" />
</Grid.RowDefinitions>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text31General}" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3"/>
<Label Grid.Row="1" Content="{x:Static p:Resources.textDraughtOnArrivalLabel}" Grid.Column="0" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<xctk:DoubleUpDown Grid.Row="1" Grid.Column="1" Name="doubleUpDownDraught" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2,2,2,2" FormatString="N1" Value="{Binding DraughtUponArrival_DMT, Mode=TwoWay}" TextAlignment="Left"/>
<Label HorizontalContentAlignment="Right" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textCurrentShipSecLevel}" Name="label_CurrentShipSecLevel" Margin="0,0,10,0"/>
<ComboBox Name="comboBoxCurrentShipSecurityLevel" Grid.Row="2" Grid.Column="1" SelectedValue="{Binding CurrentShipSecurityLevel}" Margin="2" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True" />
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textAnchored}" Name="label_IsAnchored" Margin="0,0,10,0" />
<CheckBox Grid.Column="1" Grid.Row="3" IsThreeState="False" VerticalContentAlignment="Center" Name="checkBox_IsAnchored" IsChecked="{Binding IsAnchored}"/>
<Label HorizontalContentAlignment="Right" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textAreMatterToReport}" Name="label_AreMatterToReport" Margin="0,0,10,0"/>
<CheckBox Grid.Column="1" Grid.Row="4" IsThreeState="False" VerticalContentAlignment="Center" Name="checkBox_AreMatterToReport" IsChecked="{Binding AreMatterToReport}"/>
<Label HorizontalContentAlignment="Right" Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textMatterToReport}" Name="label_MatterToReport" Margin="0,0,10,0"/>
<TextBox Name="textBoxMatterToReport" Grid.Row="5" Grid.Column="1" MaxLength="1024" Text="{Binding MatterToReport, Converter={util:TrimStringConverter}}" IsEnabled="{Binding ElementName=checkBox_AreMatterToReport, Path=IsChecked}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text32PersonsOnBoard}" Grid.Column="0" Grid.Row="6" Grid.ColumnSpan="3"/>
<Label Content="{x:Static p:Resources.textPersonsOnBoard}" Grid.Column="0" Grid.Row="7" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<xctk:IntegerUpDown Value="{Binding TotalPersonsOnBoardUponArrival, Mode=TwoWay}" Grid.Row="7" Grid.Column="1" Name="integerUpDownPersonsOnBoard" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2,2,2,2" TextAlignment="Left"/>
<Label Content="{x:Static p:Resources.textCrewMemberOnBoard}" Grid.Column="0" Grid.Row="8" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<xctk:IntegerUpDown Value="{Binding TotalCrewMembersOnBoardUponArrival, Mode=TwoWay}" Grid.Row="8" Grid.Column="1" Name="integerUpDownCrewMemberOnBoard" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2,2,2,2" TextAlignment="Left"/>
<Label Content="{x:Static p:Resources.textPassengersOnBoard}" Grid.Column="0" Grid.Row="9" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<xctk:IntegerUpDown Value="{Binding TotalPassengersOnBoardUponArrival, Mode=TwoWay}" Grid.Row="9" Grid.Column="1" Name="integerUpDownPassengersOnBoard" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2,2,2,2" TextAlignment="Left"/>
<Label Content="{x:Static p:Resources.textStowawaysOnBoard}" Grid.Column="0" Grid.Row="10" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<xctk:IntegerUpDown Value="{Binding TotalStowawaysOnBoardUponArrival, Mode=TwoWay}" Grid.Row="10" Grid.Column="1" Name="integerUpDownStowawaysOnBoard" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2,2,2,2" TextAlignment="Left"/>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text33BunkerOnArrival}" Grid.Column="0" Grid.Row="11" Grid.ColumnSpan="3"/>
<enictrl:ENIDataGrid x:Name="dataGridBKRA" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Grid.Row="12" Grid.ColumnSpan="3"
AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textBunkerType}" Width="0.2*">
<DataGridTextColumn.Binding>
<Binding Path="BunkerFuelType" Mode="TwoWay">
<Binding.ValidationRules>
<util:StringValidationRule MaxLength="25" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textBunkerQuantity}" IsReadOnly="False" Width="0.8*">
<DataGridTextColumn.Binding>
<Binding Path="BunkerFuelQuantity_TNE" Mode="TwoWay">
<Binding.ValidationRules>
<util:NumberValidationRule MaxValue="10000"/>
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
</DataGrid.Columns>
</enictrl:ENIDataGrid>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text34DangerousCargo}" Grid.Column="0" Grid.Row="13" Grid.ColumnSpan="3"/>
<Label Content="{x:Static p:Resources.textDangerousGoodsOnBoard}" Grid.Column="0" Grid.Row="14" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<CheckBox Name="checkBoxDangerousGoodsOnBoard" IsChecked="{Binding NoDPGOnBoardOnArrival, Converter={util:InverseBooleanConverter}}" Grid.Row="14" Grid.Column="1" VerticalAlignment="Center"/>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text36TowOnArrival}" Grid.Column="0" Grid.Row="15" Grid.ColumnSpan="3"/>
<enictrl:ENIDataGrid Grid.Row="16" Grid.Column="0" Grid.ColumnSpan="3" x:Name="dataGridTowageOnArrival" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textName}" Binding="{Binding TowageOnArrivalName}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPurposeOfCall}" Binding="{Binding TowageOnArrivalPurposeOfCall}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textFlag}" Binding="{Binding TowageOnArrivalFlag}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textDraughtInDecimetre}" Binding="{Binding TowageOnArrivalDraught_DMT, StringFormat={}{0:N1}}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textGrossTonnage}" Binding="{Binding TowageOnArrivalGrossTonnage}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textLengthOverAll}" Binding="{Binding TowageOnArrivalLengthOverall_MTR, StringFormat={}{0:N2}}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textBeamOverAll}" Binding="{Binding TowageOnArrivalBeam_MTR, StringFormat={}{0:N2}}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textRemarks}" Binding="{Binding TowageOnArrivalRemarks}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textCompanyName}" Binding="{Binding TowageOnArrivalOperatorCompanyName}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textStreetNumber}" Binding="{Binding TowageOnArrivalOperatorStreetNameAndNumber}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPostalCode}" Binding="{Binding TowageOnArrivalOperatorPostalCode}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textCity}" Binding="{Binding TowageOnArrivalOperatorCity}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textCountry}" Binding="{Binding TowageOnArrivalOperatorCountry}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textEMail}" Binding="{Binding TowageOnArrivalOperatorEmail}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPhone}" Binding="{Binding TowageOnArrivalOperatorPhone}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textFax}" Binding="{Binding TowageOnArrivalOperatorFax}" IsReadOnly="True" Width="Auto" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</ScrollViewer>
</GroupBox>
</src:DetailBaseControl>

Some files were not shown because too many files have changed in this diff Show More