// // Class: PAS // Current CLR: 4.0.30319.34209 // System: Microsoft Visual Studio 10.0 // Author: dani // Created: 4/2/2015 8:36:42 PM // // Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved. using System; using System.Data; using System.Data.SqlClient; using System.Collections.Generic; using System.Linq; namespace bsmd.database { public class PAS : DatabaseEntity, ISublistElement, IBulkSaver { #region Construction public PAS() { this.tablename = "[dbo].[PAS]"; } #endregion #region Properties [ShowReport] [ReportDisplayName("Last name")] [Validation(ValidationCode.NOT_NULL)] [MaxLength(100)] [ENI2Validation] public string PassengerLastName { get; set; } [ShowReport] [ReportDisplayName("First name")] [Validation(ValidationCode.NOT_NULL)] [MaxLength(100)] [ENI2Validation] public string PassengerFirstName { get; set; } [ShowReport] [ReportDisplayName("Place of birth")] [Validation(ValidationCode.NOT_NULL)] [MaxLength(100)] [ENI2Validation] public string PassengerPlaceOfBirth { get; set; } [Validation(ValidationCode.NOT_NULL)] [ENI2Validation] public DateTime? PassengerDateOfBirth { get; set; } [ShowReport] [ReportDisplayName("Date of birth")] public string PassengerDateOfBirthDisplay { get { if (this.PassengerDateOfBirth.HasValue) return this.PassengerDateOfBirth.Value.ToShortDateString(); return string.Empty; } } [ENI2Validation] public byte? PassengerGender { get; set; } [ShowReport] [ReportDisplayName("Gender")] public string PassengerGenderDisplay { get { return Util.GetGenderDisplay(this.PassengerGender); } } [ShowReport] [ReportDisplayName("Nationality")] [Validation(ValidationCode.FLAG_CODE)] [MaxLength(2)] [ENI2Validation] public string PassengerNationality { get; set; } [Validation(ValidationCode.NOT_NULL)] [ENI2Validation] public byte? PassengerIdentityDocumentType { get; set; } [ShowReport] [ReportDisplayName("Identity document type")] public string PassengerIdentityDocumentTypeDisplay { get { return Util.GetIdentityDocumentTypeDisplay(this.PassengerIdentityDocumentType); } } [ShowReport] [ReportDisplayName("Identity document id")] [Validation(ValidationCode.NOT_NULL)] [MaxLength(100)] [ENI2Validation] public string PassengerIdentityDocumentId { get; set; } [ShowReport] [ReportDisplayName("Visa number")] [MaxLength(100)] [ENI2Validation] public string PassengerVisaNumber { get; set; } [ShowReport] [ReportDisplayName("Port of embarkation")] [Validation(ValidationCode.LOCODE)] [MaxLength(5)] [ENI2Validation] public string PassengerPortOfEmbarkation { get; set; } [ShowReport] [ReportDisplayName("Port of disembarkation")] [Validation(ValidationCode.LOCODE)] [MaxLength(5)] [ENI2Validation] public string PassengerPortOfDisembarkation { get; set; } [ShowReport] [ReportDisplayName("In transit")] [Validation(ValidationCode.NOT_NULL)] [ENI2Validation] public bool? PassengerInTransit { get; set; } [ShowReport] [ReportDisplayName("Issuing state")] [Validation(ValidationCode.FLAG_CODE)] [ENI2Validation] public string PassengerIdentityDocumentIssuingState { get; set; } [ShowReport] [ReportDisplayName("Expiry date")] [Validation(ValidationCode.PAST_DATE)] [ENI2Validation] public DateTime? PassengerIdentityDocumentExpiryDate { get; set; } [ENI2Validation] public bool? NotificationSchengen { get; set; } [ENI2Validation] public bool? NotificationPAX { get; set; } [Validation(ValidationCode.FLAG_CODE)] [MaxLength(2)] [ENI2Validation] public string PassengerCountryOfBirth { get; set; } [ENI2Validation] [ReportDisplayName("Emergency care")] [MaxLength(255)] public string EmergencyCare { get; set; } [ENI2Validation] [ReportDisplayName("Emergency contact number")] [MaxLength(99)] public string EmergencyContactNumber { get; set; } /// /// Helper property for validation /// public bool HasSchengenDetails { get { return PassengerIdentityDocumentType.HasValue && !PassengerIdentityDocumentId.IsNullOrEmpty() && !PassengerIdentityDocumentIssuingState.IsNullOrEmpty() && PassengerIdentityDocumentExpiryDate.HasValue && !PassengerPortOfEmbarkation.IsNullOrEmpty() && !PassengerPortOfDisembarkation.IsNullOrEmpty(); } } /// /// Helper property for validation /// public bool HasPAXDetails { get { return !EmergencyCare.IsNullOrEmpty() && !EmergencyContactNumber.IsNullOrEmpty(); } } public string Identifier { get; set; } public string SublistCollectionKey { get { return "pas"; } } [ENI2Validation] public bool IsDeparture { get; set; } public override string Subtitle { get { return "Passenger information"; } } #endregion #region DatabaseEntity implementation public override void PrepareSave(System.Data.IDbCommand cmd) { SqlCommand scmd = cmd as SqlCommand; scmd.Parameters.AddWithValue("@P1", this.MessageHeader.Id); scmd.Parameters.AddWithNullableValue("@P2", this.PassengerLastName); scmd.Parameters.AddWithNullableValue("@P3", this.PassengerFirstName); scmd.Parameters.AddWithNullableValue("@P4", this.PassengerPlaceOfBirth); scmd.Parameters.AddWithNullableValue("@P5", this.PassengerDateOfBirth); scmd.Parameters.AddWithNullableValue("@P6", this.PassengerGender); scmd.Parameters.AddWithNullableValue("@P7", this.PassengerNationality); scmd.Parameters.AddWithNullableValue("@P8", this.PassengerIdentityDocumentType); scmd.Parameters.AddWithNullableValue("@P9", this.PassengerIdentityDocumentId); scmd.Parameters.AddWithNullableValue("@P10", this.PassengerVisaNumber); scmd.Parameters.AddWithNullableValue("@P11", this.PassengerPortOfEmbarkation); scmd.Parameters.AddWithNullableValue("@P12", this.PassengerPortOfDisembarkation); scmd.Parameters.AddWithNullableValue("@P13", this.PassengerInTransit); scmd.Parameters.AddWithNullableValue("@P14", this.Identifier); scmd.Parameters.AddWithValue("@P15", this.IsDeparture); scmd.Parameters.AddWithNullableValue("@P16", this.PassengerIdentityDocumentIssuingState); scmd.Parameters.AddWithNullableValue("@P17", this.PassengerIdentityDocumentExpiryDate); scmd.Parameters.AddWithNullableValue("@P18", this.NotificationSchengen); scmd.Parameters.AddWithNullableValue("@P19", this.NotificationPAX); scmd.Parameters.AddWithNullableValue("@P20", this.EmergencyCare); scmd.Parameters.AddWithNullableValue("@P21", this.EmergencyContactNumber); scmd.Parameters.AddWithNullableValue("@P22", this.PassengerCountryOfBirth); if (this.IsNew) { this.CreateId(); scmd.Parameters.AddWithValue("@ID", this.Id); scmd.CommandText = string.Format("INSERT INTO {0} (Id, MessageHeaderId, PassengerLastName, PassengerFirstName, " + "PassengerPlaceOfBirth, PassengerDateOfBirth, PassengerGender, PassengerNationality, PassengerIdentityDocumentType, " + "PassengerIdentityDocumentId, PassengerVisaNumber, PassengerPortOfEmbarkation, PassengerPortOfDisembarkation," + "PassengerInTransit, Identifier, IsDeparture, PassengerIdentityDocumentIssuingState, PassengerIdentityDocumentExpiryDate, " + "NotificationSchengen, NotificationPAX, EmergencyCare, EmergencyContactNumber, PassengerCountryOfBirth) " + "VALUES (@ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15, @P16, @P17, @P18, @P19, @P20, @P21, @P22 )", this.Tablename); } else { scmd.Parameters.AddWithValue("ID", this.Id); scmd.CommandText = string.Format("UPDATE {0} SET PassengerLastName = @P2, PassengerFirstName = @P3, " + "PassengerPlaceOfBirth = @P4, PassengerDateOfBirth = @P5, PassengerGender = @P6," + "PassengerNationality = @P7, PassengerIdentityDocumentType = @P8, PassengerIdentityDocumentId = @P9, " + "PassengerVisaNumber = @P10, PassengerPortOfEmbarkation = @P11, PassengerPortOfDisembarkation = @P12, " + "PassengerInTransit = @P13, IsDeparture = @P15, Identifier = @P14, PassengerIdentityDocumentIssuingState = @P16, " + "PassengerIdentityDocumentExpiryDate = @P17, NotificationSchengen = @P18, NotificationPAX = @P19, " + "EmergencyCare = @P20, EmergencyContactNumber = @P21, PassengerCountryOfBirth = @P22 WHERE Id = @ID", this.Tablename); } } public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria) { string query = string.Format("SELECT Id, PassengerLastName, PassengerFirstName, PassengerPlaceOfBirth, " + "PassengerDateOfBirth, PassengerGender, PassengerNationality, PassengerIdentityDocumentType, PassengerIdentityDocumentId, " + "PassengerVisaNumber, PassengerPortOfEmbarkation, PassengerPortOfDisembarkation, PassengerInTransit, Identifier, " + "IsDeparture, PassengerIdentityDocumentIssuingState, PassengerIdentityDocumentExpiryDate, NotificationSchengen, " + "NotificationPAX, EmergencyCare, EmergencyContactNumber, PassengerCountryOfBirth FROM {0}", this.Tablename); switch (filter) { case Message.LoadFilter.MESSAGEHEADER: query += " WHERE IsDeparture = 0 AND MessageHeaderId = @MHID"; ((SqlCommand)cmd).Parameters.AddWithValue("@MHID", criteria[0]); break; case Message.LoadFilter.ALL: default: query += " WHERE IsDeparture = 0"; break; } cmd.CommandText = query; } public override List LoadList(System.Data.IDataReader reader) { List result = new List(); while (reader.Read()) { PAS pas = new PAS(); pas.id = reader.GetGuid(0); if (!reader.IsDBNull(1)) pas.PassengerLastName = reader.GetString(1); if (!reader.IsDBNull(2)) pas.PassengerFirstName = reader.GetString(2); if (!reader.IsDBNull(3)) pas.PassengerPlaceOfBirth = reader.GetString(3); if (!reader.IsDBNull(4)) pas.PassengerDateOfBirth = reader.GetDateTime(4); if (!reader.IsDBNull(5)) pas.PassengerGender = reader.GetByte(5); if (!reader.IsDBNull(6)) pas.PassengerNationality = reader.GetString(6); if (!reader.IsDBNull(7)) pas.PassengerIdentityDocumentType = reader.GetByte(7); if (!reader.IsDBNull(8)) pas.PassengerIdentityDocumentId = reader.GetString(8); if (!reader.IsDBNull(9)) pas.PassengerVisaNumber = reader.GetString(9); if (!reader.IsDBNull(10)) pas.PassengerPortOfEmbarkation = reader.GetString(10); if (!reader.IsDBNull(11)) pas.PassengerPortOfDisembarkation = reader.GetString(11); if (!reader.IsDBNull(12)) pas.PassengerInTransit = reader.GetBoolean(12); if (!reader.IsDBNull(13)) pas.Identifier = reader.GetString(13); if (!reader.IsDBNull(14)) pas.IsDeparture = reader.GetBoolean(14); if (!reader.IsDBNull(15)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(15); if (!reader.IsDBNull(16)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(16); if (!reader.IsDBNull(17)) pas.NotificationSchengen = reader.GetBoolean(17); if (!reader.IsDBNull(18)) pas.NotificationPAX = reader.GetBoolean(18); if (!reader.IsDBNull(19)) pas.EmergencyCare = reader.GetString(19); if (!reader.IsDBNull(20)) pas.EmergencyContactNumber = reader.GetString(20); if (!reader.IsDBNull(21)) pas.PassengerCountryOfBirth = reader.GetString(21); result.Add(pas); } reader.Close(); result.Sort(); return result; } public override string Title => "PASA"; #endregion #region Validation public override void Validate(List errors, List violations) { // /* Nach RM Christin / Trello vom 27.11.17 auskommentiert // und heute (19.10.22) wieder einkommentiert if (this.PassengerPortOfDisembarkation != null) { if (this.PassengerPortOfDisembarkation.Equals("ZZUKN")) violations.Add(RuleEngine.CreateViolation(ValidationCode.NOT_NULL, "Port of disembarkation set to ZZUKN", null, this.Title, this.Identifier, this.IsDeparture ? "PASD" : "PASA")); } if (this.PassengerPortOfEmbarkation != null) { if (this.PassengerPortOfEmbarkation.Equals("ZZUKN")) violations.Add(RuleEngine.CreateViolation(ValidationCode.NOT_NULL, "Port of embarkation set to ZZUKN", null, this.Title, this.Identifier, this.IsDeparture ? "PASD" : "PASA")); } if (this.PassengerIdentityDocumentType.HasValue) { if (this.PassengerIdentityDocumentType.Value == 5) violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Doc. type set to OTHER_LEGAL_IDENTITY_DOCUMENT", null, this.Title, this.Identifier, this.IsDeparture ? "PASD" : "PASA")); } if (this.PassengerNationality != null) { if (this.PassengerNationality.Equals("XX")) violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Nationality set to XX", null, this.Title, this.Identifier, this.IsDeparture ? "PASD" : "PASA")); } if (this.PassengerIdentityDocumentIssuingState != null) { if (this.PassengerIdentityDocumentIssuingState.Equals("XX")) violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Id. doc issuing state set to XX", null, this.Title, this.Identifier, this.IsDeparture ? "PASD" : "PASA")); } if (this.PassengerIdentityDocumentExpiryDate.HasValue) { 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.IsDeparture ? "PASD" : "PASA")); if ((this.PassengerIdentityDocumentExpiryDate >= CREW.CLAMPMAXDATE) || (this.PassengerIdentityDocumentExpiryDate <= CREW.CLAMPMINDATE)) violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Check identity document expiry date", null, this.Title, this.Identifier, this.IsDeparture ? "PASD" : "PASA")); } if (this.PassengerGender.HasValue) { if (this.PassengerGender == 0) violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Gender set to unknown", null, this.Title, this.Identifier, this.IsDeparture ? "PASD" : "PASA")); } 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.IsDeparture ? "PASD" : "PASA")); if (this.PassengerDateOfBirth <= CREW.CLAMPMINDATE) violations.Add(RuleEngine.CreateViolation(ValidationCode.TIME_IMPLAUSIBLE, "Check date of birth", null, this.Title, this.Identifier, this.IsDeparture ? "PASD" : "PASA")); } // NSW 7.2 rules if ((this.NotificationSchengen ?? false) && (!this.HasSchengenDetails)) { errors.Add(RuleEngine.CreateError(ValidationCode.V202, "Schengen flag set but no data", null, this.Title, null, this.IsDeparture ? "PASD" : "PASA")); } if (!(this.NotificationSchengen ?? false) && (this.HasSchengenDetails)) { errors.Add(RuleEngine.CreateError(ValidationCode.V202, "Schengen data given but flag not set", null, this.Title, null, this.IsDeparture ? "PASD" : "PASA")); } if ((this.NotificationPAX ?? false) && (!this.HasPAXDetails)) { errors.Add(RuleEngine.CreateError(ValidationCode.V203, "PAX flag set but no data", null, this.Title, null, this.IsDeparture ? "PASD" : "PASA")); } if (!(this.NotificationPAX ?? false) && (this.HasPAXDetails)) { errors.Add(RuleEngine.CreateError(ValidationCode.V203, "PAX data given but flag not set", null, this.Title, null, this.IsDeparture ? "PASD" : "PASA")); } } #endregion #region IBulkSaver implementation public DataTable PrepareBulkInsert(List databaseEntities) { DataTable result = new DataTable(); result.Columns.Add(new DataColumn { ColumnName = "MessageHeaderId", DataType = MessageHeader.Id.GetType() }); result.Columns.Add(new DataColumn { ColumnName = "PassengerLastName", DataType = typeof(string), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerFirstName", DataType = typeof(string), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerPlaceOfBirth", DataType = typeof(string), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerDateOfBirth", DataType = typeof(DateTime), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerGender", DataType = typeof(byte), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerNationality", DataType = typeof(string), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerIdentityDocumentType", DataType = typeof(byte), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerIdentityDocumentId", DataType = typeof(string), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerVisaNumber", DataType = typeof(string), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerPortOfEmbarkation", DataType = typeof(string), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerPortOfDisembarkation", DataType = typeof(string), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerInTransit", DataType = typeof(bool), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "Identifier", DataType = typeof(string), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "IsDeparture", DataType = typeof(bool), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerIdentityDocumentIssuingState", DataType = typeof(string), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerIdentityDocumentExpiryDate", DataType = typeof(DateTime), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "NotificationSchengen", DataType = typeof(bool), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "NotificationPAX", DataType = typeof(bool), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "EmergencyCare", DataType = typeof(string), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "EmergencyContactNumber", DataType = typeof(string), AllowDBNull = true }); result.Columns.Add(new DataColumn { ColumnName = "PassengerCountryOfBirth", DataType = typeof(string), AllowDBNull = true }); foreach (PAS pas in databaseEntities.Cast()) { DataRow row = result.NewRow(); row[0] = pas.MessageHeader.Id; row[1] = pas.PassengerLastName ?? (object)DBNull.Value; row[2] = pas.PassengerFirstName ?? (object)DBNull.Value; row[3] = pas.PassengerPlaceOfBirth ?? (object)DBNull.Value; row[4] = pas.PassengerDateOfBirth ?? (object)DBNull.Value; row[5] = pas.PassengerGender ?? (object)DBNull.Value; row[6] = pas.PassengerNationality ?? (object)DBNull.Value; row[7] = pas.PassengerIdentityDocumentType ?? (object)DBNull.Value; row[8] = pas.PassengerIdentityDocumentId ?? (object)DBNull.Value; row[9] = pas.PassengerVisaNumber ?? (object)DBNull.Value; row[10] = pas.PassengerPortOfEmbarkation ?? (object)DBNull.Value; row[11] = pas.PassengerPortOfDisembarkation ?? (object)DBNull.Value; row[12] = pas.PassengerInTransit ?? (object)DBNull.Value; row[13] = pas.Identifier ?? (object)DBNull.Value; row[14] = pas.IsDeparture; row[15] = pas.PassengerIdentityDocumentIssuingState ?? (object)DBNull.Value; row[16] = pas.PassengerIdentityDocumentExpiryDate ?? (object)DBNull.Value; row[17] = pas.NotificationSchengen ?? (object)DBNull.Value; row[18] = pas.NotificationPAX ?? (object)DBNull.Value; row[19] = pas.EmergencyCare ?? (object)DBNull.Value; row[20] = pas.EmergencyContactNumber ?? (object)DBNull.Value; row[21] = pas.PassengerCountryOfBirth ?? (object)DBNull.Value; result.Rows.Add(row); } result.TableName = this.tablename; return result; } #endregion #region IComparable implementation public int CompareTo(object obj) { if (obj is null) return 1; if (!(obj is PAS)) return 1; if (Int32.TryParse(((PAS)obj).Identifier, out int i1) && Int32.TryParse(this.Identifier, out int i2)) return i2.CompareTo(i1); return this.Identifier.CompareTo(((PAS)obj).Identifier); } #endregion #region public copy func public void CopyFromPAS(PAS pas) { if (pas == null) return; this.PassengerLastName = pas.PassengerLastName; this.PassengerFirstName = pas.PassengerFirstName; this.PassengerPlaceOfBirth = pas.PassengerPlaceOfBirth; this.PassengerDateOfBirth = pas.PassengerDateOfBirth; this.PassengerGender = pas.PassengerGender; this.PassengerNationality = pas.PassengerNationality; this.PassengerIdentityDocumentType = pas.PassengerIdentityDocumentType; this.PassengerIdentityDocumentId = pas.PassengerIdentityDocumentId; this.PassengerVisaNumber = pas.PassengerVisaNumber; this.PassengerPortOfEmbarkation = pas.PassengerPortOfEmbarkation; this.PassengerPortOfDisembarkation = pas.PassengerPortOfDisembarkation; this.PassengerInTransit = pas.PassengerInTransit; this.PassengerIdentityDocumentIssuingState = pas.PassengerIdentityDocumentIssuingState; this.PassengerIdentityDocumentExpiryDate = pas.PassengerIdentityDocumentExpiryDate; this.NotificationSchengen = pas.NotificationSchengen; this.NotificationPAX = pas.NotificationPAX; this.PassengerCountryOfBirth = pas.PassengerCountryOfBirth; this.EmergencyCare = pas.EmergencyCare; this.EmergencyContactNumber = pas.EmergencyContactNumber; } #endregion } #region class PASD public class PASD : PAS { public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria) { string query = string.Format("SELECT Id, PassengerLastName, PassengerFirstName, PassengerPlaceOfBirth, " + "PassengerDateOfBirth, PassengerGender, PassengerNationality, PassengerIdentityDocumentType, PassengerIdentityDocumentId, " + "PassengerVisaNumber, PassengerPortOfEmbarkation, PassengerPortOfDisembarkation, PassengerInTransit, Identifier, IsDeparture, " + "PassengerIdentityDocumentIssuingState, PassengerIdentityDocumentExpiryDate, NotificationSchengen, NotificationPAX, " + "EmergencyCare, EmergencyContactNumber, PassengerCountryOfBirth FROM {0}", this.Tablename); switch (filter) { case Message.LoadFilter.MESSAGEHEADER: query += " WHERE IsDeparture = 1 AND MessageHeaderId = @MHID"; ((SqlCommand)cmd).Parameters.AddWithValue("@MHID", criteria[0]); break; case Message.LoadFilter.ALL: default: query += " WHERE IsDeparture = 1"; break; } cmd.CommandText = query; } public override List LoadList(System.Data.IDataReader reader) { List result = new List(); while (reader.Read()) { PASD pas = new PASD(); pas.id = reader.GetGuid(0); if (!reader.IsDBNull(1)) pas.PassengerLastName = reader.GetString(1); if (!reader.IsDBNull(2)) pas.PassengerFirstName = reader.GetString(2); if (!reader.IsDBNull(3)) pas.PassengerPlaceOfBirth = reader.GetString(3); if (!reader.IsDBNull(4)) pas.PassengerDateOfBirth = reader.GetDateTime(4); if (!reader.IsDBNull(5)) pas.PassengerGender = reader.GetByte(5); if (!reader.IsDBNull(6)) pas.PassengerNationality = reader.GetString(6); if (!reader.IsDBNull(7)) pas.PassengerIdentityDocumentType = reader.GetByte(7); if (!reader.IsDBNull(8)) pas.PassengerIdentityDocumentId = reader.GetString(8); if (!reader.IsDBNull(9)) pas.PassengerVisaNumber = reader.GetString(9); if (!reader.IsDBNull(10)) pas.PassengerPortOfEmbarkation = reader.GetString(10); if (!reader.IsDBNull(11)) pas.PassengerPortOfDisembarkation = reader.GetString(11); if (!reader.IsDBNull(12)) pas.PassengerInTransit = reader.GetBoolean(12); if (!reader.IsDBNull(13)) pas.Identifier = reader.GetString(13); if (!reader.IsDBNull(14)) pas.IsDeparture = reader.GetBoolean(14); if (!reader.IsDBNull(15)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(15); if (!reader.IsDBNull(16)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(16); if (!reader.IsDBNull(17)) pas.NotificationSchengen = reader.GetBoolean(17); if (!reader.IsDBNull(18)) pas.NotificationPAX = reader.GetBoolean(18); if (!reader.IsDBNull(19)) pas.EmergencyCare = reader.GetString(19); if (!reader.IsDBNull(20)) pas.EmergencyContactNumber = reader.GetString(20); if (!reader.IsDBNull(21)) pas.PassengerCountryOfBirth = reader.GetString(21); result.Add(pas); } reader.Close(); result.Sort(); return result; } } #endregion }