Beispiel #1
0
        /// <summary>
        /// Returns the Languages of a Person from Personnel. It excludes the MainLanguage.
        /// </summary>
        /// <remarks>The Language Codes are sorted by Language Level so that the Language
        /// with the best level comes first, then the other Languages in descending Language
        /// Level order.</remarks>
        /// <param name="APartnerKey">PartnerKey of the PERSON.</param>
        /// <param name="AMainLanguage">MainLanguage of the PERSON.</param>
        /// <param name="AReadTransaction">Open DB Transaction.</param>
        /// <returns>A String containing all the Language Codes from Personnel, excluding the
        /// MainLanguage. The Language Codes are separated with a '|' (pipe) character.</returns>
        private static String GetPersonLanguagesFromPersonnel(Int64 APartnerKey, string AMainLanguage, TDBTransaction AReadTransaction)
        {
            const string LANG_SEPARATOR      = "|";
            String       AdditionalLanguages = "";

            PmPersonLanguageTable PersonLangDT = PmPersonLanguageAccess.LoadViaPPerson(APartnerKey, AReadTransaction);

            if (PersonLangDT != null)
            {
                // We want the list of Languages sorted by Language Level so that the Language with the
                // best level comes first, then the other Languages in descending Language Level order.
                DataView PersonLangDV = new DataView(PersonLangDT, "",
                                                     PmPersonLanguageTable.GetLanguageLevelDBName() + " DESC", DataViewRowState.CurrentRows);

                for (int Counter = 0; Counter < PersonLangDV.Count; Counter++)
                {
                    PmPersonLanguageRow PersonLangDR = (PmPersonLanguageRow)PersonLangDV[Counter].Row;

                    if (PersonLangDR.LanguageCode != AMainLanguage)
                    {
                        AdditionalLanguages = AdditionalLanguages + PersonLangDR.LanguageCode + LANG_SEPARATOR;
                    }
                }

                if (AdditionalLanguages.Length > 0)
                {
                    AdditionalLanguages = AdditionalLanguages.Substring(0, AdditionalLanguages.Length - LANG_SEPARATOR.Length);
                }
            }

            return(AdditionalLanguages);
        }
        private void ValidateDataDetailsManual(PmPersonLanguageRow ARow)
        {
            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            TSharedPersonnelValidation_Personnel.ValidatePersonalLanguageManual(this, ARow, ref VerificationResultCollection,
                                                                                FValidationControlsDict);
        }
 private void ShowDetailsManual(PmPersonLanguageRow ARow)
 {
     // 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(PmPersonLanguageRow ARowToDelete,
                               bool AAllowDeletion,
                               bool ADeletionPerformed,
                               string ACompletionMessage)
 {
     if (ADeletionPerformed)
     {
         DoRecalculateScreenParts();
     }
 }
Beispiel #5
0
        /// <summary>
        /// Gets all the languages of the person
        /// </summary>
        /// <param name="APartnerKey">Partner Key</param>
        /// <returns></returns>
        private String GetPersonLanguages(Int64 APartnerKey)
        {
            PmPersonLanguageTable LanguageTable;
            PPartnerTable         PartnerTable;
            String SpokenLanguages    = "";
            String MotherLanguageCode = "99";
            bool   MotherTongeInList  = false;

            PartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, situation.GetDatabaseConnection().Transaction);

            if (PartnerTable.Rows.Count > 0)
            {
                MotherLanguageCode = ((PPartnerRow)PartnerTable.Rows[0]).LanguageCode;
            }

            LanguageTable = PmPersonLanguageAccess.LoadViaPPerson(APartnerKey, situation.GetDatabaseConnection().Transaction);

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

                if (Row.LanguageCode == MotherLanguageCode)
                {
                    SpokenLanguages  += MotherLanguageCode + " (M";
                    MotherTongeInList = true;
                }
                else
                {
                    SpokenLanguages += Row.LanguageCode + " (" + Row.LanguageLevel;
                }

                SpokenLanguages += "), ";
            }

            if (!MotherTongeInList)
            {
                // Insert mother tongue at the first place:
                SpokenLanguages = MotherLanguageCode + " (M), " + SpokenLanguages;
            }

            // remove the last comma and space
            if (SpokenLanguages.Length > 2)
            {
                SpokenLanguages.Remove(SpokenLanguages.Length - 2);
            }

            return(SpokenLanguages);
        }
        private void ValidateDataDetailsManual(PmPersonLanguageRow ARow)
        {
            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            TSharedPersonnelValidation_Personnel.ValidatePersonalLanguageManual(this, ARow, ref VerificationResultCollection,
                FValidationControlsDict);
        }
 private void ShowDetailsManual(PmPersonLanguageRow ARow)
 {
     // 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(PmPersonLanguageRow ARowToDelete,
     bool AAllowDeletion,
     bool ADeletionPerformed,
     string ACompletionMessage)
 {
     if (ADeletionPerformed)
     {
         DoRecalculateScreenParts();
     }
 }
        /// <summary>
        /// Validates the personal language data of a Person.
        /// </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 ValidatePersonalLanguageManual(object AContext, PmPersonLanguageRow ARow,
            ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict)
        {
            DataColumn ValidationColumn;
            TValidationControlsData ValidationControlsData;
            TVerificationResult VerificationResult;
            PtLanguageLevelTable LanguageLevelTable;
            PtLanguageLevelRow LanguageLevelRow = null;

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

            // 'Language Level' must not be unassignable
            ValidationColumn = ARow.Table.Columns[PmPersonLanguageTable.ColumnLanguageLevelId];

            if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData))
            {
                VerificationResult = null;

                if (!ARow.IsLanguageLevelNull())
                {
                    LanguageLevelTable = (PtLanguageLevelTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate(
                        TCacheablePersonTablesEnum.LanguageLevelList);
                    LanguageLevelRow = (PtLanguageLevelRow)LanguageLevelTable.Rows.Find(ARow.LanguageLevel);

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

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