Exemplo n.º 1
0
        /// <summary>
        /// Get the passport details and estores them as parameters.
        /// If there is a passport with the MainPassport flag set, then use this passport.
        /// Otherwise use the most recent passport which has a passport number.
        /// </summary>
        /// <param name="APartnerKey">Partner key</param>
        /// <returns>true if one passport was found, otherwise false</returns>
        private bool GetPassport(Int64 APartnerKey)
        {
            PmPassportDetailsTable PassportTable = new PmPassportDetailsTable();

            PmPassportDetailsRow ResultPassportRow = GetLatestPassport(APartnerKey, situation);

            if (ResultPassportRow != null)
            {
                // add the results to the parameters
                foreach (DataColumn col in PassportTable.Columns)
                {
                    situation.GetParameters().Add(StringHelper.UpperCamelCase(col.ColumnName, true,
                                                                              true), new TVariant(ResultPassportRow[col.ColumnName]));
                }
            }
            else
            {
                // add empty results to the parameters.
                // Otherwise the old rsults from the previous calculations will be used.
                foreach (DataColumn col in PassportTable.Columns)
                {
                    situation.GetParameters().Add(StringHelper.UpperCamelCase(col.ColumnName, true,
                                                                              true), new TVariant(""));
                }
            }

            return(ResultPassportRow != null);
        }
Exemplo n.º 2
0
        private void ValidateDataDetailsManual(PmPassportDetailsRow ARow)
        {
            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            TSharedPersonnelValidation_Personnel.ValidatePassportManual(this, ARow, ref VerificationResultCollection,
                                                                        FValidationControlsDict);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Code to be run after the deletion process
 /// </summary>
 /// <param name="ARowToDelete">the row that was/was to be deleted</param>
 /// <param name="AAllowDeletion">whether or not the user was permitted to delete</param>
 /// <param name="ADeletionPerformed">whether or not the deletion was performed successfully</param>
 /// <param name="ACompletionMessage">if specified, is the deletion completion message</param>
 private void PostDeleteManual(PmPassportDetailsRow ARowToDelete,
                               bool AAllowDeletion,
                               bool ADeletionPerformed,
                               string ACompletionMessage)
 {
     if (ADeletionPerformed)
     {
         DoRecalculateScreenParts();
     }
 }
Exemplo n.º 4
0
        private void ShowDetailsManual(PmPassportDetailsRow ARow)
        {
            // always take "date of birth" field value from person record
            if (FMainDS.PPerson[0].IsDateOfBirthNull())
            {
                dtpDateOfBirth.Date = null;
            }
            else
            {
                dtpDateOfBirth.Date = FMainDS.PPerson[0].DateOfBirth;
            }

            // In theory, the next Method call could be done in Methods NewRowManual; however, NewRowManual runs before
            // the Row is actually added and this would result in the Count to be one too less, so we do the Method call here, short
            // of a non-existing 'AfterNewRowManual' Method....
            DoRecalculateScreenParts();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get the passport details and restores them as parameters.
        /// If there is a passport with the MainPassport flag set, then use this passport.
        /// Otherwise use the most recent passport which has a passport number.
        /// </summary>
        /// <param name="APartnerKey">Partner key</param>
        /// <param name="ASituation">A current Report Situation</param>
        /// <returns>true if one passport was found, otherwise false</returns>
        public static PmPassportDetailsRow GetLatestPassport(Int64 APartnerKey, TRptSituation ASituation)
        {
            PmPassportDetailsTable PassportTable     = null;
            PmPassportDetailsRow   ResultPassportRow = null;

            StringCollection PassportCollumns = new StringCollection();
            StringCollection OrderList        = new StringCollection();

            PassportCollumns.Add(PmPassportDetailsTable.GetPassportNationalityCodeDBName());
            PassportCollumns.Add(PmPassportDetailsTable.GetPassportNumberDBName());
            PassportCollumns.Add(PmPassportDetailsTable.GetDateOfExpirationDBName());
            PassportCollumns.Add(PmPassportDetailsTable.GetFullPassportNameDBName());
            OrderList.Add("ORDER BY " + PmPassportDetailsTable.GetDateOfExpirationDBName() + " DESC");

            PassportTable = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey,
                                                                   PassportCollumns, ASituation.GetDatabaseConnection().Transaction,
                                                                   OrderList, 0, 0);

            // Look for MainPassport flag
            foreach (PmPassportDetailsRow Row in PassportTable.Rows)
            {
                if (!Row.IsMainPassportNull() &&
                    Row.MainPassport)
                {
                    ResultPassportRow = Row;
                    break;
                }
            }

            // Look for the most recent passport with a passport number
            if (ResultPassportRow == null)
            {
                foreach (PmPassportDetailsRow Row in PassportTable.Rows)
                {
                    if (Row.PassportNumber.Length > 0)
                    {
                        ResultPassportRow = Row;
                        break;
                    }
                }
            }

            return(ResultPassportRow);
        }
Exemplo n.º 6
0
        private static void CreatePassport(XmlNode ANode, Int64 APartnerKey, ref PartnerImportExportTDS AMainDS)
        {
            string PassportNum = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_PASSPORTNUMBER);

            if (PassportNum.Length > 0)
            {
                PmPassportDetailsRow NewRow = AMainDS.PmPassportDetails.NewRowTyped();
                NewRow.PassportNumber          = PassportNum;
                NewRow.PassportDetailsType     = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_PASSPORTTYPE);
                NewRow.PlaceOfBirth            = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_PASSPORTPLACEOFBIRTH);
                NewRow.PassportNationalityCode = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_PASSPORTNATIONALITY);
                NewRow.PlaceOfIssue            = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_PASSPORTPLACEOFISSUE);
                NewRow.CountryOfIssue          = TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_PASSPORTCOUNTRYOFISSUE);
                NewRow.DateOfIssue             = DateTime.Parse(TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_PASSPORTDATEOFISSUE));
                NewRow.DateOfExpiration        = DateTime.Parse(TXMLParser.GetAttribute(ANode, MPartnerConstants.PARTNERIMPORT_PASSPORTDATEOFEXPIRATION));
                AMainDS.PmPassportDetails.Rows.Add(NewRow);
                AddVerificationResult("Passport Record Created.", TResultSeverity.Resv_Status);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Returns the 'nationality' of a passport and marks expired passports up.
        /// </summary>
        /// <param name="ACacheRetriever">Delegate that returns the specified DataTable from the data cache (client- or serverside).
        /// Delegate Method needs to be for the MPartner Cache (that is, it needs to work with the <see cref="TCacheableCommonTablesEnum" /> Enum!</param>
        /// <param name="APassportDR">DataRow containing information about a passport.</param>
        /// <returns>Country name that goes with the passport's Nationality Code, except for the case
        /// where no country name is found for the Nationality Code, then the Nationality Code is returned.
        /// If a passport is expired, the string " (exp.)" (potentially translated) is added as a postfix.</returns>
        public static string DeterminePassportNationality(TGetCacheableDataTableFromCache ACacheRetriever, PmPassportDetailsRow APassportDR)
        {
            string ReturnValue;

            ReturnValue = CommonCodeHelper.GetCountryName(
                @ACacheRetriever, APassportDR.PassportNationalityCode);

            // Fallback: If no country name exists in the Chacheable DataTable, use the Nationality Code.
            if (ReturnValue == String.Empty)
            {
                ReturnValue = APassportDR.PassportNationalityCode;
            }

            if ((APassportDR.DateOfExpiration.HasValue)
                && (APassportDR.DateOfExpiration.Value.Date < DateTime.Now.Date))
            {
                if ((!APassportDR.IsMainPassportNull())
                    && (APassportDR.MainPassport))
                {
                    ReturnValue += PASSPORTMAIN_EXPIRED;
                }
                else
                {
                    ReturnValue += PASSPORT_EXPIRED;
                }
            }

            return ReturnValue;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Get the missing information of a short term application partner.
        /// This could be Passport, Date of Birth, Gender, Mother Tongue, Emergency Contact, Event, Travel information
        /// </summary>
        /// <param name="APartnerKey">Partner Key</param>
        /// <param name="AApplicationKey">Application Key</param>
        /// <param name="ARegistrationOffice">Registration Office</param>
        /// <returns>String of all the missing informations for this partner and application</returns>
        private String GetMissingInfo(Int64 APartnerKey, int AApplicationKey, Int64 ARegistrationOffice)
        {
            String MissingInfo = "";
            PmPassportDetailsTable      PassportTable;
            PPersonTable                PersonTable;
            PPartnerTable               PartnerTable;
            PPartnerRelationshipTable   PartnerRelationshipTable;
            PmShortTermApplicationTable ShortTermApplicationTable;

            // Check for passport Details
            PassportTable = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey, situation.GetDatabaseConnection().Transaction);
            bool PassportDetailMissing = true;

            for (int Counter = 0; Counter < PassportTable.Rows.Count; ++Counter)
            {
                PmPassportDetailsRow row = (PmPassportDetailsRow)PassportTable.Rows[Counter];

                if (row.FullPassportName.Length > 0)
                {
                    PassportDetailMissing = false;
                }
            }

            if (PassportDetailMissing)
            {
                MissingInfo += " Passport Details,";
            }

            // Check for Date of Birth and Gender
            PersonTable = PPersonAccess.LoadByPrimaryKey(APartnerKey, situation.GetDatabaseConnection().Transaction);

            if (PassportTable.Rows.Count == 0)
            {
                MissingInfo += " Date of Birth, Gender,";
            }
            else
            {
                PPersonRow PersonRow = (PPersonRow)PersonTable.Rows[0];

                if (PersonRow.IsDateOfBirthNull())
                {
                    MissingInfo += " Date of Birth,";
                }

                if (PersonRow.Gender == "Unknown")
                {
                    MissingInfo += " Gender,";
                }
            }

            // Check for mother tongue
            PartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, situation.GetDatabaseConnection().Transaction);

            if (PassportTable.Rows.Count == 0)
            {
                MissingInfo += " Mother Tongue,";
            }
            else if (((PPartnerRow)PartnerTable.Rows[0]).LanguageCode == "99")
            {
                MissingInfo += " Mother Tongue,";
            }

            // Check for partner relationship
            PartnerRelationshipTable = PPartnerRelationshipAccess.LoadViaPPartnerRelationKey(APartnerKey,
                                                                                             situation.GetDatabaseConnection().Transaction);

            bool HasEmergencyContact = false;

            for (int Counter = 0; Counter < PartnerRelationshipTable.Rows.Count; ++Counter)
            {
                PPartnerRelationshipRow Row = (PPartnerRelationshipRow)PartnerRelationshipTable.Rows[Counter];

                if (Row.PartnerKey == 0)
                {
                    continue;
                }

                if ((Row.RelationName == "PAREND") ||
                    (Row.RelationName == "GUARDIAN") ||
                    (Row.RelationName == "RELATIVE") ||
                    (Row.RelationName == "EMER-1") ||
                    (Row.RelationName == "EMER-2") ||
                    (Row.RelationName == "NOK-OTHER"))
                {
                    HasEmergencyContact = true;
                    break;
                }
            }

            if (!HasEmergencyContact)
            {
                MissingInfo += " Emergency Contact,";
            }

            // Check for Event and Travel information
            ShortTermApplicationTable = PmShortTermApplicationAccess.LoadByPrimaryKey(APartnerKey,
                                                                                      AApplicationKey, ARegistrationOffice, situation.GetDatabaseConnection().Transaction);

            bool HasEvent      = false;
            bool HasTravelInfo = false;

            for (int Counter = 0; Counter < ShortTermApplicationTable.Rows.Count; ++Counter)
            {
                PmShortTermApplicationRow Row = (PmShortTermApplicationRow)ShortTermApplicationTable.Rows[Counter];

                if (Row.ConfirmedOptionCode != "")
                {
                    HasEvent = true;
                }

                if ((!Row.IsArrivalNull()) &&
                    (!Row.IsDepartureNull()))
                {
                    HasTravelInfo = true;
                }
            }

            if (!HasEvent)
            {
                MissingInfo += " Event,";
            }

            if (!HasTravelInfo)
            {
                MissingInfo += "Travel Information,";
            }

            // remove the last ,
            if (MissingInfo.Length > 0)
            {
                MissingInfo.Remove(MissingInfo.Length - 1);
            }

            return(MissingInfo);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Returns the 'nationality' of a passport and marks expired passports up.
        /// </summary>
        /// <param name="ACacheRetriever">Delegate that returns the specified DataTable from the data cache (client- or serverside).
        /// Delegate Method needs to be for the MPartner Cache (that is, it needs to work with the <see cref="TCacheableCommonTablesEnum" /> Enum!</param>
        /// <param name="APassportDR">DataRow containing information about a passport.</param>
        /// <returns>Country name that goes with the passport's Nationality Code, except for the case
        /// where no country name is found for the Nationality Code, then the Nationality Code is returned.
        /// If a passport is expired, the string " (exp.)" (potentially translated) is added as a postfix.</returns>
        public static string DeterminePassportNationality(TGetCacheableDataTableFromCache ACacheRetriever, PmPassportDetailsRow APassportDR)
        {
            string ReturnValue;

            ReturnValue = CommonCodeHelper.GetCountryName(
                @ACacheRetriever, APassportDR.PassportNationalityCode);

            // Fallback: If no country name exists in the Chacheable DataTable, use the Nationality Code.
            if (ReturnValue == String.Empty)
            {
                ReturnValue = APassportDR.PassportNationalityCode;
            }

            if ((APassportDR.DateOfExpiration.HasValue) &&
                (APassportDR.DateOfExpiration.Value.Date < DateTime.Now.Date))
            {
                if ((!APassportDR.IsMainPassportNull()) &&
                    (APassportDR.MainPassport))
                {
                    ReturnValue += PASSPORTMAIN_EXPIRED;
                }
                else
                {
                    ReturnValue += PASSPORT_EXPIRED;
                }
            }

            return(ReturnValue);
        }
        private void ValidateDataDetailsManual(PmPassportDetailsRow ARow)
        {
            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            TSharedPersonnelValidation_Personnel.ValidatePassportManual(this, ARow, ref VerificationResultCollection,
                FValidationControlsDict);
        }
        private void ShowDetailsManual(PmPassportDetailsRow ARow)
        {
            // always take "date of birth" field value from person record
            if (FMainDS.PPerson[0].IsDateOfBirthNull())
            {
                dtpDateOfBirth.Date = null;
            }
            else
            {
                dtpDateOfBirth.Date = FMainDS.PPerson[0].DateOfBirth;
            }

            // In theory, the next Method call could be done in Methods NewRowManual; however, NewRowManual runs before
            // the Row is actually added and this would result in the Count to be one too less, so we do the Method call here, short
            // of a non-existing 'AfterNewRowManual' Method....
            DoRecalculateScreenParts();
        }
 /// <summary>
 /// Code to be run after the deletion process
 /// </summary>
 /// <param name="ARowToDelete">the row that was/was to be deleted</param>
 /// <param name="AAllowDeletion">whether or not the user was permitted to delete</param>
 /// <param name="ADeletionPerformed">whether or not the deletion was performed successfully</param>
 /// <param name="ACompletionMessage">if specified, is the deletion completion message</param>
 private void PostDeleteManual(PmPassportDetailsRow ARowToDelete,
     bool AAllowDeletion,
     bool ADeletionPerformed,
     string ACompletionMessage)
 {
     if (ADeletionPerformed)
     {
         DoRecalculateScreenParts();
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Validates the Passport data of a Partner.
        /// </summary>
        /// <param name="AContext">Context that describes where the data validation failed.</param>
        /// <param name="ARow">The <see cref="DataRow" /> which holds the the data against which the validation is run.</param>
        /// <param name="AVerificationResultCollection">Will be filled with any <see cref="TVerificationResult" /> items if
        /// data validation errors occur.</param>
        /// <param name="AValidationControlsDict">A <see cref="TValidationControlsDict" /> containing the Controls that
        /// display data that is about to be validated.</param>
        /// <returns>void</returns>
        public static void ValidatePassportManual(object AContext, PmPassportDetailsRow ARow,
            ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict)
        {
            DataColumn ValidationColumn;
            TValidationControlsData ValidationControlsData;
            TVerificationResult VerificationResult;

            // Don't validate deleted DataRows
            if (ARow.RowState == DataRowState.Deleted)
            {
                return;
            }

            // 'Passport Number' must have a value
            ValidationColumn = ARow.Table.Columns[PmPassportDetailsTable.ColumnPassportNumberId];

            if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData))
            {
                VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.PassportNumber,
                    ValidationControlsData.ValidationControlLabel,
                    AContext, ValidationColumn, ValidationControlsData.ValidationControl);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
            }

            // 'Passport Name' must contain an opening and a closing paraenthesis
            ValidationColumn = ARow.Table.Columns[PmPassportDetailsTable.ColumnFullPassportNameId];

            if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData))
            {
                if ((!ARow.FullPassportName.Contains("("))
                    || (!ARow.FullPassportName.Contains(")")))
                {
                    VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext,
                            ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_INDIV_DATA_PASSPORT_NAME_MISSING_PARAS,
                                new string[] { ValidationControlsData.ValidationControlLabel, ARow.FullPassportName })),
                        ValidationColumn, ValidationControlsData.ValidationControl);

                    // Handle addition to/removal from TVerificationResultCollection
                    AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
                }
            }

            // 'Expiry Date' must be later than 'Issue Date'
            ValidationColumn = ARow.Table.Columns[PmPassportDetailsTable.ColumnDateOfExpirationId];

            if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData))
            {
                VerificationResult = TDateChecks.FirstGreaterOrEqualThanSecondDate(ARow.DateOfExpiration, ARow.DateOfIssue,
                    ValidationControlsData.ValidationControlLabel, ValidationControlsData.SecondValidationControlLabel,
                    AContext, ValidationColumn, ValidationControlsData.ValidationControl);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
            }

            // 'Passport Type' must not be unassignable
            ValidationColumn = ARow.Table.Columns[PmPassportDetailsTable.ColumnPassportDetailsTypeId];

            if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData))
            {
                PtPassportTypeTable TypeTable;
                PtPassportTypeRow TypeRow;

                VerificationResult = null;

                if ((!ARow.IsPassportDetailsTypeNull())
                    && (ARow.PassportDetailsType != String.Empty))
                {
                    TypeTable = (PtPassportTypeTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTable(
                        TCacheablePersonTablesEnum.PassportTypeList);
                    TypeRow = (PtPassportTypeRow)TypeTable.Rows.Find(ARow.PassportDetailsType);

                    // 'Passport Type' must not be unassignable
                    if ((TypeRow != null)
                        && TypeRow.UnassignableFlag
                        && (TypeRow.IsUnassignableDateNull()
                            || (TypeRow.UnassignableDate <= DateTime.Today)))
                    {
                        // if 'Passport Type' is unassignable then check if the value has been changed or if it is a new record
                        if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmPassportDetailsTable.GetPassportDetailsTypeDBName()))
                        {
                            VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext,
                                    ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING,
                                        new string[] { ValidationControlsData.ValidationControlLabel, ARow.PassportDetailsType })),
                                ValidationColumn, ValidationControlsData.ValidationControl);
                        }
                    }
                }

                // Handle addition/removal to/from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
            }
        }