diff --git a/ENI2/EditControls/EditCREWDialog.xaml.cs b/ENI2/EditControls/EditCREWDialog.xaml.cs index 6c1d1883..3a90a038 100644 --- a/ENI2/EditControls/EditCREWDialog.xaml.cs +++ b/ENI2/EditControls/EditCREWDialog.xaml.cs @@ -15,9 +15,7 @@ namespace ENI2.EditControls /// Interaction logic for EditCREWDialog.xaml /// public partial class EditCREWDialog : EditWindowBase - { - - private static DateTime MAXDATE = new DateTime(2198, 12, 31); + { public EditCREWDialog() { @@ -39,24 +37,35 @@ namespace ENI2.EditControls this.textBoxPlaceOfBirth.Text = this.CREW.CrewMemberPlaceOfBirth; this.comboBoxNationality.ItemsSource = bsmd.database.CREW.NationalityDict; this.comboBoxNationality.SelectedValue = this.CREW.CrewMemberNationality; - if (this.CREW.CrewMemberDateOfBirth > MAXDATE) - this.CREW.CrewMemberDateOfBirth = MAXDATE; + if (this.CREW.CrewMemberDateOfBirth > CREW.CLAMPMAXDATE) + { + this.datePickerDateOfBirth.SelectedDate = CREW.CLAMPMAXDATE; + } + else if (this.CREW.CrewMemberDateOfBirth < CREW.CLAMPMINDATE) + { + this.datePickerDateOfBirth.SelectedDate = CREW.CLAMPMINDATE; + } else + { this.datePickerDateOfBirth.SelectedDate = this.CREW.CrewMemberDateOfBirth; + } this.comboBoxIdDocType.ItemsSource = GlobalStructures.IDDocTypeDict; this.comboBoxIdDocType.SelectedValue = this.CREW.CrewMemberIdentityDocumentType?.ToString(); this.textBoxIdDocNumber.Text = this.CREW.CrewMemberIdentityDocumentId; this.textBoxVisaNumber.Text = this.CREW.CrewMemberVisaNumber; this.comboBoxIssuingState.ItemsSource = bsmd.database.CREW.NationalityDict; this.comboBoxIssuingState.SelectedValue = this.CREW.CrewMemberIdentityDocumentIssuingState; - if (this.CREW.CrewMemberIdentityDocumentExpiryDate > MAXDATE) + if (this.CREW.CrewMemberIdentityDocumentExpiryDate > CREW.CLAMPMAXDATE) { - this.datePickerExpiryDate.SelectedDate = MAXDATE; + this.datePickerExpiryDate.SelectedDate = CREW.CLAMPMAXDATE; + } + else if(this.CREW.CrewMemberDateOfBirth < CREW.CLAMPMINDATE) + { + this.datePickerExpiryDate.SelectedDate = CREW.CLAMPMINDATE; } else - { - if (this.CREW.CrewMemberIdentityDocumentExpiryDate.HasValue) - this.datePickerExpiryDate.SelectedDate = MAXDATE; + { + this.datePickerExpiryDate.SelectedDate = this.CREW.CrewMemberIdentityDocumentExpiryDate; } // this.comboBoxCountryOfBirth.ItemsSource = bsmd.database.CREW.NationalityDict; // XXX: TODO // this.comboBoxCountryOfBirth.SelectedValue = this.CREW.CrewMemberCountryOfBirth; diff --git a/ENI2/EditControls/EditPasDialog.xaml.cs b/ENI2/EditControls/EditPasDialog.xaml.cs index e5910f44..25b4dc85 100644 --- a/ENI2/EditControls/EditPasDialog.xaml.cs +++ b/ENI2/EditControls/EditPasDialog.xaml.cs @@ -15,9 +15,7 @@ namespace ENI2.EditControls /// Interaction logic for EditPasDialog.xaml /// public partial class EditPASDialog : EditWindowBase - { - - private static DateTime MAXDATE = new DateTime(2198, 12, 31); + { public EditPASDialog() { @@ -38,10 +36,18 @@ namespace ENI2.EditControls this.textBoxPlaceOfBirth.Text = this.PAS.PassengerPlaceOfBirth; this.comboBoxNationality.ItemsSource = bsmd.database.CREW.NationalityDict; this.comboBoxNationality.SelectedValue = this.PAS.PassengerNationality; - if (this.PAS.PassengerDateOfBirth > MAXDATE) - this.datePickerDateOfBirth.SelectedDate = MAXDATE; + if (this.PAS.PassengerDateOfBirth > CREW.CLAMPMAXDATE) + { + this.datePickerDateOfBirth.SelectedDate = CREW.CLAMPMAXDATE; + } + else if (this.PAS.PassengerDateOfBirth < CREW.CLAMPMINDATE) + { + this.datePickerDateOfBirth.SelectedDate = CREW.CLAMPMINDATE; + } else + { this.datePickerDateOfBirth.SelectedDate = this.PAS.PassengerDateOfBirth; + } this.comboBoxIdDocType.ItemsSource = GlobalStructures.IDDocTypeDict; this.comboBoxIdDocType.SelectedValue = this.PAS.PassengerIdentityDocumentType?.ToString(); this.textBoxIdDocNumber.Text = this.PAS.PassengerIdentityDocumentId; @@ -52,15 +58,19 @@ namespace ENI2.EditControls this.comboBoxIssuingState.ItemsSource = bsmd.database.CREW.NationalityDict; this.comboBoxIssuingState.SelectedValue = this.PAS.PassengerIdentityDocumentIssuingState; - if (this.PAS.PassengerIdentityDocumentExpiryDate > MAXDATE) + if (this.PAS.PassengerIdentityDocumentExpiryDate > CREW.CLAMPMAXDATE) { - this.datePickerExpiryDate.SelectedDate = MAXDATE; + this.datePickerExpiryDate.SelectedDate = CREW.CLAMPMAXDATE; + } + else if (this.PAS.PassengerIdentityDocumentExpiryDate < CREW.CLAMPMINDATE) + { + this.datePickerExpiryDate.SelectedDate = CREW.CLAMPMINDATE; } else { - if (this.PAS.PassengerIdentityDocumentExpiryDate.HasValue) - this.datePickerExpiryDate.SelectedDate = this.PAS.PassengerIdentityDocumentExpiryDate; + this.datePickerExpiryDate.SelectedDate = this.PAS.PassengerIdentityDocumentExpiryDate; } + // XXX : TODO //this.comboBoxCountryOfBirth.ItemsSource = bsmd.database.CREW.NationalityDict; //this.comboBoxCountryOfBirth.SelectedValue = this.PAS.PassengerCountryOfBirth; diff --git a/ENI2/Excel/ExcelUtil.cs b/ENI2/Excel/ExcelUtil.cs index fb267eeb..f8de70eb 100644 --- a/ENI2/Excel/ExcelUtil.cs +++ b/ENI2/Excel/ExcelUtil.cs @@ -1450,7 +1450,7 @@ namespace ENI2.Excel if (!(poc30d.PortOfCallLast30DaysCrewMembersJoined ?? false) && (PortOfCallLast30DaysCrewMembersJoinedFlag ?? false)) poc30d.PortOfCallLast30DaysCrewMembersJoined = true; - if (poc30d.PortOfCallLast30DaysCrewMembersJoined ?? false) + if (!crewNameString.IsNullOrEmpty() && (poc30d.PortOfCallLast30DaysCrewMembersJoined ?? false)) { // try different separators string[] crew = crewNameString.Split(';'); diff --git a/bsmd.database/CREW.cs b/bsmd.database/CREW.cs index f0dcb7d6..8179f8c4 100644 --- a/bsmd.database/CREW.cs +++ b/bsmd.database/CREW.cs @@ -17,6 +17,9 @@ namespace bsmd.database public class CREW : DatabaseEntity, ISublistElement, IBulkSaver { + public static DateTime CLAMPMAXDATE = new DateTime(2198, 12, 31); + public static DateTime CLAMPMINDATE = new DateTime(1900, 1, 1); + public CREW() { this.tablename = "[dbo].[CREW]"; @@ -297,6 +300,9 @@ namespace bsmd.database { if (this.CrewMemberIdentityDocumentExpiryDate.Equals(new DateTime(2100, 12, 31))) violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Id doc expiry date set to 31/12/2100", null, this.Title, this.Identifier, this.Tablename)); + + if ((this.CrewMemberIdentityDocumentExpiryDate >= CLAMPMAXDATE) || (this.CrewMemberIdentityDocumentExpiryDate <= CLAMPMINDATE)) + violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Check id doc expiry date", null, this.Title, this.Identifier, this.Tablename)); } if (this.CrewMemberGender.HasValue) @@ -305,8 +311,11 @@ namespace bsmd.database violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Gender set to unknown", null, this.Title, this.Identifier, this.Tablename)); } - if ((this.CrewMemberDateOfBirth.HasValue) && (this.CrewMemberDateOfBirth.Value > DateTime.Today)) - violations.Add(RuleEngine.CreateViolation(ValidationCode.TIME_IMPLAUSIBLE, "Date of birth is in the future", null, this.Title, this.Identifier, this.Tablename)); + if (this.CrewMemberDateOfBirth.HasValue && (this.CrewMemberDateOfBirth.Value > DateTime.Today)) + violations.Add(RuleEngine.CreateViolation(ValidationCode.TIME_IMPLAUSIBLE, "Date of birth is in the future", null, this.Title, this.Identifier, this.Tablename)); + + if (this.CrewMemberDateOfBirth.HasValue && (this.CrewMemberDateOfBirth.Value <= CLAMPMINDATE)) + violations.Add(RuleEngine.CreateViolation(ValidationCode.TIME_IMPLAUSIBLE, "Check date of birth", null, this.Title, this.Identifier, this.Tablename)); } diff --git a/bsmd.database/PAS.cs b/bsmd.database/PAS.cs index 31f133fb..b8d77cfa 100644 --- a/bsmd.database/PAS.cs +++ b/bsmd.database/PAS.cs @@ -354,6 +354,9 @@ namespace bsmd.database { if(this.PassengerIdentityDocumentExpiryDate.Equals(new DateTime(2100, 12, 31))) violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Id doc expiry date set to 31/12/2100", null, this.Title, this.Identifier, this.Tablename)); + + if ((this.PassengerDateOfBirth >= CREW.CLAMPMAXDATE) || (this.PassengerDateOfBirth <= CREW.CLAMPMINDATE)) + violations.Add(RuleEngine.CreateViolation(ValidationCode.TIME_IMPLAUSIBLE, "Check identity document expiry date", null, this.Title, this.Identifier, this.Tablename)); } if(this.PassengerGender.HasValue) @@ -362,8 +365,14 @@ namespace bsmd.database violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Gender set to unknown", null, this.Title, this.Identifier, this.Tablename)); } - if ((this.PassengerDateOfBirth.HasValue) && (this.PassengerDateOfBirth.Value > DateTime.Today)) - violations.Add(RuleEngine.CreateViolation(ValidationCode.TIME_IMPLAUSIBLE, "Date of birth is in the future", null, this.Title, this.Identifier, this.Tablename)); + if (this.PassengerDateOfBirth.HasValue) + { + if (this.PassengerDateOfBirth.Value > DateTime.Today) + violations.Add(RuleEngine.CreateViolation(ValidationCode.TIME_IMPLAUSIBLE, "Date of birth is in the future", null, this.Title, this.Identifier, this.Tablename)); + + if(this.PassengerDateOfBirth <= CREW.CLAMPMINDATE) + violations.Add(RuleEngine.CreateViolation(ValidationCode.TIME_IMPLAUSIBLE, "Check date of birth", null, this.Title, this.Identifier, this.Tablename)); + } }