/// <summary> /// Checks wheter a given DateTime is an invalid date. A check whether it is an undefined DateTime is always performed. /// If Delegate <see cref="SharedGetDateVerificationResultDelegate" /> is set up and Argument /// <paramref name="AResultControl" /> isn't null, the 'DateVerificationResult' of the TtxtPetraDate Control is /// returned by this Method through this Method if it isn't null. That way the Data Validation Framework can /// use the detailed Data Verification error that is held by the Control. /// </summary> /// <returns>Null if validation succeeded, otherwise a <see cref="TVerificationResult" /> is /// returned that contains details about the problem.</returns> public static TVerificationResult IsNotInvalidDate(DateTime? ADate, String ADescription, TVerificationResultCollection AVerificationResultCollection, bool ATreatNullAsInvalid = false, object AResultContext = null, System.Data.DataColumn AResultColumn = null, Control AResultControl = null) { TVerificationResult VerificationResult; if (FDelegateSharedGetDateVerificationResult != null) { if ((AResultControl != null)) { VerificationResult = FDelegateSharedGetDateVerificationResult(AResultControl); if (VerificationResult == null) { VerificationResult = TDateChecks.IsNotUndefinedDateTime(ADate, ADescription, ATreatNullAsInvalid, AResultContext, AResultColumn, AResultControl); } else { VerificationResult.OverrideResultContext(AResultContext); VerificationResult = new TScreenVerificationResult(VerificationResult, AResultColumn, AResultControl); } } else { VerificationResult = TDateChecks.IsNotUndefinedDateTime(ADate, ADescription, ATreatNullAsInvalid, AResultContext, AResultColumn, AResultControl); } // Remove Verification Result that would have been recorded earlier for the same DataColumn TVerificationResult OtherRecordedVerificationResult = AVerificationResultCollection.FindBy(AResultColumn); if (OtherRecordedVerificationResult != null) { AVerificationResultCollection.Remove(OtherRecordedVerificationResult); } } else { VerificationResult = TDateChecks.IsNotUndefinedDateTime(ADate, ADescription, ATreatNullAsInvalid, AResultContext, AResultColumn, AResultControl); } return VerificationResult; }
/// <summary> /// Validates the Gift Detail data. /// </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> /// <param name="ARecipientPartnerClass">Recipient's Partner Class (used for Motivation Detail validation).</param> /// <param name="ASetupForILT">Optional - Is the recipient set up for inter-ledger transfers.</param> /// <param name="ACostCentres">Optional - a CostCentres table. Is required for import validation. </param> /// <param name="AAccounts">Optional - a Accounts table. Is required for import validation. </param> /// <param name="AMotivationGroups">Optional - a MotivationGroups table. Is required for import validation. </param> /// <param name="AMotivationDetails">Optional - a MotivationDetails table. Is required for import validation. </param> /// <param name="AMailingTable">Optional - a Mailing table. Is required for import validation. </param> /// <param name="ARecipientField">Optional The recipient field for the gift. Is required for import validation. </param> /// <returns>True if the validation found no data validation errors, otherwise false.</returns> public static bool ValidateGiftDetailManual(object AContext, GiftBatchTDSAGiftDetailRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict, TPartnerClass? ARecipientPartnerClass, bool? ASetupForILT = null, ACostCentreTable ACostCentres = null, AAccountTable AAccounts = null, AMotivationGroupTable AMotivationGroups = null, AMotivationDetailTable AMotivationDetails = null, PMailingTable AMailingTable = null, Int64 ARecipientField = -1) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult = null; object ValidationContext; int VerifResultCollAddedCount = 0; bool ValidPartner = true; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return true; } bool isImporting = AContext.ToString().Contains("Importing"); // Check if valid recipient ValidationColumn = ARow.Table.Columns[AGiftDetailTable.ColumnRecipientKeyId]; ValidationContext = String.Format("Batch no. {0}, gift no. {1}, detail no. {2}", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); VerificationResult = TSharedPartnerValidation_Partner.IsValidPartner( ARow.RecipientKey, new TPartnerClass[] { TPartnerClass.FAMILY, TPartnerClass.UNIT }, true, isImporting ? Catalog.GetString("Recipient key") : "Recipient of " + THelper.NiceValueDescription(ValidationContext.ToString()), AContext, ValidationColumn, null); if (VerificationResult != null) { AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); ValidPartner = false; } // 'Gift amount must be non-zero ValidationColumn = ARow.Table.Columns[AGiftDetailTable.ColumnGiftTransactionAmountId]; ValidationContext = String.Format("Batch Number {0} (transaction:{1} detail:{2})", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TNumericalChecks.IsNonZeroDecimal(ARow.GiftTransactionAmount, ValidationControlsData.ValidationControlLabel + (isImporting ? String.Empty : " of " + ValidationContext), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } } // If recipient is non-zero, field must also be non-zero. Only check for valid recipient keys. ValidationColumn = ARow.Table.Columns[AGiftDetailTable.ColumnRecipientLedgerNumberId]; ValidationContext = String.Format("batch:{0} transaction:{1} detail:{2}", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if ((ARow.RecipientKey > 0) && ValidPartner && (ARow.RecipientLedgerNumber == 0)) { VerificationResult = TNumericalChecks.IsGreaterThanZero(ARow.RecipientLedgerNumber, "Recipient field of " + ValidationContext + " is 0", AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } } // Motivation Group code must exist if (!ARow.IsMotivationGroupCodeNull() && (AMotivationGroups != null)) { AMotivationGroupRow foundRow = (AMotivationGroupRow)AMotivationGroups.Rows.Find( new object[] { ARow.LedgerNumber, ARow.MotivationGroupCode }); if ((foundRow == null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString("Unknown motivation group code '{0}'."), ARow.MotivationGroupCode), TResultSeverity.Resv_Critical), ValidationColumn)) { VerifResultCollAddedCount++; } } } if (!isImporting) { // NOTE AlanP Oct 2014. This gets checked by standard validation so may no longer be necessary? // (There was a bug in standard validation where NULL and empty string checks did not quite work as they should ... // so maybe this was necessary before. Anyway I am leaving it in for now. I know that importing works fine, // but maybe it is necessary in other circumstances?) // Motivation Detail must not be null ValidationColumn = ARow.Table.Columns[AGiftDetailTable.ColumnMotivationDetailCodeId]; ValidationContext = String.Format("(batch:{0} transaction:{1} detail:{2})", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (ARow.IsMotivationDetailCodeNull() || (ARow.MotivationDetailCode == String.Empty)) { VerificationResult = TGeneralChecks.ValueMustNotBeNullOrEmptyString(ARow.MotivationDetailCode, (isImporting ? ValidationControlsData.ValidationControlLabel : "Motivation Detail code " + ValidationContext), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } } } } // Motivation Detail must be valid ValidationColumn = ARow.Table.Columns[AGiftDetailTable.ColumnMotivationDetailCodeId]; ValidationContext = String.Format("(batch:{0} transaction:{1} detail:{2})", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (!ARow.IsMotivationDetailCodeNull() && (AMotivationDetails != null)) { AMotivationDetailRow foundRow = (AMotivationDetailRow)AMotivationDetails.Rows.Find( new object[] { ARow.LedgerNumber, ARow.MotivationGroupCode, ARow.MotivationDetailCode }); if ((foundRow == null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString("Unknown motivation detail code '{0}' for group '{1}'."), ARow.MotivationDetailCode, ARow.MotivationGroupCode), TResultSeverity.Resv_Critical), ValidationColumn)) { VerifResultCollAddedCount++; } if ((foundRow != null) && (foundRow.MotivationStatus == false) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString("Motivation detail code '{0}' is no longer in use."), ARow.MotivationDetailCode), TResultSeverity.Resv_Critical), ValidationColumn)) { VerifResultCollAddedCount++; } if ((foundRow != null) && (foundRow.RecipientKey != 0) && (ARow.RecipientKey != 0) && (foundRow.RecipientKey != ARow.RecipientKey) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString( "The recipient partner key for motivation detail code '{0}' does not match the recipient partner key in the import line."), ARow.MotivationDetailCode), TResultSeverity.Resv_Critical), ValidationColumn)) { VerifResultCollAddedCount++; } } // Motivation Detail must not be 'Field' or 'Keymin' if the recipient is a Family partner ValidationColumn = ARow.Table.Columns[AGiftDetailTable.ColumnMotivationDetailCodeId]; ValidationContext = String.Format("(batch:{0} transaction:{1} detail:{2})", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (!ARow.IsMotivationDetailCodeNull() && (ARow.MotivationGroupCode == MFinanceConstants.MOTIVATION_GROUP_GIFT) && (ARecipientPartnerClass != null) && ((ARow.MotivationDetailCode == MFinanceConstants.GROUP_DETAIL_FIELD) || (ARow.MotivationDetailCode == MFinanceConstants.GROUP_DETAIL_KEY_MIN)) && (ARecipientPartnerClass == TPartnerClass.FAMILY)) { if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = new TVerificationResult(AContext, String.Format(Catalog.GetString("Motivation Detail code '{0}' is not allowed for Family recipients."), ARow.MotivationDetailCode), TResultSeverity.Resv_Critical); if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, new TScreenVerificationResult(VerificationResult, ValidationColumn, ValidationControlsData.ValidationControl), ValidationColumn, true)) { VerifResultCollAddedCount++; } } } // Cost Centre Code must exist and be active. Only required for importing because the GUI does this for us otherwise. if (isImporting && (ACostCentres != null) && !ARow.IsCostCentreCodeNull()) { ValidationColumn = ARow.Table.Columns[AGiftDetailTable.ColumnCostCentreCodeId]; ValidationContext = ARow.CostCentreCode; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { // We even need to check that the code exists! DataRow foundRow = ACostCentres.Rows.Find(new object[] { ARow.LedgerNumber, ARow.CostCentreCode }); if ((foundRow == null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TScreenVerificationResult(ValidationContext, ValidationColumn, String.Format(Catalog.GetString("Unknown cost centre code '{0}'."), ARow.CostCentreCode), ValidationControlsData.ValidationControl, TResultSeverity.Resv_Critical), /* * new TVerificationResult(ValidationContext, * String.Format(Catalog.GetString("Unknown cost centre code '{0}'."), ARow.CostCentreCode), * TResultSeverity.Resv_Critical), */ ValidationColumn)) { VerifResultCollAddedCount++; } VerificationResult = (TScreenVerificationResult)TStringChecks.ValidateValueIsActive(ARow.LedgerNumber, ACostCentres, ValidationContext.ToString(), ACostCentreTable.GetCostCentreActiveFlagDBName(), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if ((VerificationResult != null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } } } // Account Code must exist and be active. Only required for importing because the GUI does this for us otherwise. if (isImporting && (AAccounts != null) && !ARow.IsAccountCodeNull()) { DataColumn[] ValidationColumns = new DataColumn[] { ARow.Table.Columns[AGiftDetailTable.ColumnAccountCodeId], ARow.Table.Columns[AGiftDetailTable.ColumnTaxDeductibleAccountCodeId] }; string[] AccountCodes = new string[] { ARow.AccountCode, ARow.TaxDeductibleAccountCode }; for (int i = 0; i < 2; i++) { if (AValidationControlsDict.TryGetValue(ValidationColumns[i], out ValidationControlsData)) { // We even need to check that the code exists! DataRow foundRow = AAccounts.Rows.Find(new object[] { ARow.LedgerNumber, AccountCodes[i] }); if ((foundRow == null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(AccountCodes[i], String.Format(Catalog.GetString("Unknown account code '{0}'."), AccountCodes[i]), TResultSeverity.Resv_Critical), ValidationColumns[i])) { VerifResultCollAddedCount++; } VerificationResult = (TScreenVerificationResult)TStringChecks.ValidateValueIsActive(ARow.LedgerNumber, AAccounts, AccountCodes[i], AAccountTable.GetAccountActiveFlagDBName(), AContext, ValidationColumns[i], ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if ((VerificationResult != null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumns[i], true)) { VerifResultCollAddedCount++; } } } } // Mailing code must exist ValidationColumn = ARow.Table.Columns[AGiftDetailTable.ColumnMailingCodeId]; ValidationContext = String.Format("(batch:{0} transaction:{1} detail:{2})", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (!ARow.IsMailingCodeNull() && (AMailingTable != null)) { PMailingRow foundRow = (PMailingRow)AMailingTable.Rows.Find(ARow.MailingCode); if ((foundRow == null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString("Unknown mailing code '{0}'."), ARow.MailingCode), TResultSeverity.Resv_Critical), ValidationColumn)) { VerifResultCollAddedCount++; } } // Detail comments type 1 must not be null if associated comment is not null ValidationColumn = ARow.Table.Columns[AGiftDetailTable.ColumnCommentOneTypeId]; ValidationContext = String.Format("(batch:{0} transaction:{1} detail:{2})", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (!ARow.IsGiftCommentOneNull() && (ARow.GiftCommentOne != String.Empty)) { VerificationResult = TGeneralChecks.ValueMustNotBeNullOrEmptyString(ARow.CommentOneType, (isImporting ? ValidationControlsData.ValidationControlLabel : "Comment 1 type " + ValidationContext), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } if (VerificationResult == null) { // There is a comment type for the comment - but it needs to be one of the valid types if ((ARow.CommentOneType != MFinanceConstants.GIFT_COMMENT_TYPE_DONOR) && (ARow.CommentOneType != MFinanceConstants.GIFT_COMMENT_TYPE_RECIPIENT) && (ARow.CommentOneType != MFinanceConstants.GIFT_COMMENT_TYPE_BOTH) && (ARow.CommentOneType != MFinanceConstants.GIFT_COMMENT_TYPE_OFFICE) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString("Comment type must be one of '{0}', '{1}', '{2}' or '{3}'."), MFinanceConstants.GIFT_COMMENT_TYPE_DONOR, MFinanceConstants.GIFT_COMMENT_TYPE_RECIPIENT, MFinanceConstants.GIFT_COMMENT_TYPE_BOTH, MFinanceConstants.GIFT_COMMENT_TYPE_OFFICE), TResultSeverity.Resv_Critical), ValidationColumn)) { VerifResultCollAddedCount++; } } } } // Detail comments type 2 must not be null if associated comment is not null ValidationColumn = ARow.Table.Columns[AGiftDetailTable.ColumnCommentTwoTypeId]; ValidationContext = String.Format("(batch:{0} transaction:{1} detail:{2})", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (!ARow.IsGiftCommentTwoNull() && (ARow.GiftCommentTwo != String.Empty)) { VerificationResult = TGeneralChecks.ValueMustNotBeNullOrEmptyString(ARow.CommentTwoType, (isImporting ? ValidationControlsData.ValidationControlLabel : "Comment 2 type " + ValidationContext), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } if (VerificationResult == null) { // There is a comment type for the comment - but it needs to be one of the valid types if ((ARow.CommentTwoType != MFinanceConstants.GIFT_COMMENT_TYPE_DONOR) && (ARow.CommentTwoType != MFinanceConstants.GIFT_COMMENT_TYPE_RECIPIENT) && (ARow.CommentTwoType != MFinanceConstants.GIFT_COMMENT_TYPE_BOTH) && (ARow.CommentTwoType != MFinanceConstants.GIFT_COMMENT_TYPE_OFFICE) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString("Comment type must be one of '{0}', '{1}', '{2}' or '{3}'."), MFinanceConstants.GIFT_COMMENT_TYPE_DONOR, MFinanceConstants.GIFT_COMMENT_TYPE_RECIPIENT, MFinanceConstants.GIFT_COMMENT_TYPE_BOTH, MFinanceConstants.GIFT_COMMENT_TYPE_OFFICE), TResultSeverity.Resv_Critical), ValidationColumn)) { VerifResultCollAddedCount++; } } } } // Detail comments type 3 must not be null if associated comment is not null ValidationColumn = ARow.Table.Columns[AGiftDetailTable.ColumnCommentThreeTypeId]; ValidationContext = String.Format("(batch:{0} transaction:{1} detail:{2})", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (!ARow.IsGiftCommentThreeNull() && (ARow.GiftCommentThree != String.Empty)) { VerificationResult = TGeneralChecks.ValueMustNotBeNullOrEmptyString(ARow.CommentThreeType, (isImporting ? ValidationControlsData.ValidationControlLabel : "Comment 3 type " + ValidationContext), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } if (VerificationResult == null) { // There is a comment type for the comment - but it needs to be one of the valid types if ((ARow.CommentThreeType != MFinanceConstants.GIFT_COMMENT_TYPE_DONOR) && (ARow.CommentThreeType != MFinanceConstants.GIFT_COMMENT_TYPE_RECIPIENT) && (ARow.CommentThreeType != MFinanceConstants.GIFT_COMMENT_TYPE_BOTH) && (ARow.CommentThreeType != MFinanceConstants.GIFT_COMMENT_TYPE_OFFICE) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString("Comment type must be one of '{0}', '{1}', '{2}' or '{3}'."), MFinanceConstants.GIFT_COMMENT_TYPE_DONOR, MFinanceConstants.GIFT_COMMENT_TYPE_RECIPIENT, MFinanceConstants.GIFT_COMMENT_TYPE_BOTH, MFinanceConstants.GIFT_COMMENT_TYPE_OFFICE), TResultSeverity.Resv_Critical), ValidationColumn)) { VerifResultCollAddedCount++; } } } } return VerifResultCollAddedCount == 0; }
/// <summary> /// Validation for Gift table /// </summary> /// <param name="AContext"></param> /// <param name="ARow"></param> /// <param name="AYear"></param> /// <param name="APeriod"></param> /// <param name="AControl">Need to pass the validation control because it is not a bound control</param> /// <param name="AVerificationResultCollection"></param> /// <param name="AValidationControlsDict"></param> /// <param name="AMethodOfGivingRef">Required for import validation</param> /// <param name="AMethodOfPaymentRef">Required for</param> /// <param name="AFormLetterCodeTbl">Supplied in import validation</param> /// <returns></returns> public static bool ValidateGiftManual(object AContext, AGiftRow ARow, Int32 AYear, Int32 APeriod, Control AControl, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict, AMethodOfGivingTable AMethodOfGivingRef = null, AMethodOfPaymentTable AMethodOfPaymentRef = null, PFormTable AFormLetterCodeTbl = null) { DataColumn ValidationColumn; //TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult = null; object ValidationContext; int VerifResultCollAddedCount = 0; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return true; } bool isImporting = AContext.ToString().Contains("Importing"); // Check if valid donor ValidationColumn = ARow.Table.Columns[AGiftTable.ColumnDonorKeyId]; ValidationContext = String.Format("Batch no. {0}, gift no. {1}", ARow.BatchNumber, ARow.GiftTransactionNumber); VerificationResult = TSharedPartnerValidation_Partner.IsValidPartner( ARow.DonorKey, new TPartnerClass[] { }, true, (isImporting) ? String.Empty : "Donor of " + THelper.NiceValueDescription(ValidationContext.ToString()), AContext, ValidationColumn, null); if (VerificationResult != null) { AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } // 'Entered From Date' must be valid // But we do not test for this when importing because the date is tested for the batch rather than the individual gift(s) if (!isImporting) { ValidationColumn = ARow.Table.Columns[AGiftTable.ColumnDateEnteredId]; ValidationContext = String.Format("Gift No.: {0}", ARow.GiftTransactionNumber); DateTime StartDateCurrentPeriod; DateTime EndDateCurrentPeriod; TSharedFinanceValidationHelper.GetValidPeriodDates(ARow.LedgerNumber, AYear, 0, APeriod, out StartDateCurrentPeriod, out EndDateCurrentPeriod); VerificationResult = (TScreenVerificationResult)TDateChecks.IsDateBetweenDates(ARow.DateEntered, StartDateCurrentPeriod, EndDateCurrentPeriod, (isImporting) ? String.Empty : "Gift Date for " + ValidationContext.ToString(), TDateBetweenDatesCheckType.dbdctUnspecific, TDateBetweenDatesCheckType.dbdctUnspecific, AContext, ValidationColumn, AControl); //ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } } // A method of giving must be valid ValidationColumn = ARow.Table.Columns[AGiftTable.ColumnMethodOfGivingCodeId]; ValidationContext = String.Format("Batch no. {0}, gift no. {1}", ARow.BatchNumber, ARow.GiftTransactionNumber); if (!ARow.IsMethodOfGivingCodeNull() && (AMethodOfGivingRef != null)) { AMethodOfGivingRow foundRow = (AMethodOfGivingRow)AMethodOfGivingRef.Rows.Find(ARow.MethodOfGivingCode); if ((foundRow == null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString("Unknown method of giving code '{0}'."), ARow.MethodOfGivingCode), TResultSeverity.Resv_Critical), ValidationColumn)) { VerifResultCollAddedCount++; } } // A method of payment must be valid ValidationColumn = ARow.Table.Columns[AGiftTable.ColumnMethodOfPaymentCodeId]; ValidationContext = String.Format("Batch no. {0}, gift no. {1}", ARow.BatchNumber, ARow.GiftTransactionNumber); if (!ARow.IsMethodOfPaymentCodeNull() && (AMethodOfPaymentRef != null)) { AMethodOfPaymentRow foundRow = (AMethodOfPaymentRow)AMethodOfPaymentRef.Rows.Find(ARow.MethodOfPaymentCode); if ((foundRow == null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString("Unknown method of payment code '{0}'."), ARow.MethodOfPaymentCode), TResultSeverity.Resv_Critical), ValidationColumn)) { VerifResultCollAddedCount++; } } // If supplied, Receipt Letter Code must be a name specified in PForm. if (!ARow.IsReceiptLetterCodeNull() && (AFormLetterCodeTbl != null)) { AFormLetterCodeTbl.DefaultView.RowFilter = String.Format("p_form_name_c='{0}'", ARow.ReceiptLetterCode); if ((AFormLetterCodeTbl.DefaultView.Count == 0) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString("Unknown Letter Code '{0}'."), ARow.ReceiptLetterCode), TResultSeverity.Resv_Critical), ValidationColumn)) { VerifResultCollAddedCount++; } } return VerifResultCollAddedCount == 0; }
/// <summary> /// Validation for Recurring Gift table /// </summary> /// <param name="AContext"></param> /// <param name="ARow"></param> /// <param name="AVerificationResultCollection"></param> /// <param name="AValidationControlsDict"></param> /// <returns></returns> public static bool ValidateRecurringGiftManual(object AContext, ARecurringGiftRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { DataColumn ValidationColumn; //TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult = null; object ValidationContext; int VerifResultCollAddedCount = 0; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return true; } // Check if valid donor ValidationColumn = ARow.Table.Columns[ARecurringGiftTable.ColumnDonorKeyId]; ValidationContext = String.Format("Batch no. {0}, gift no. {1}", ARow.BatchNumber, ARow.GiftTransactionNumber); VerificationResult = TSharedPartnerValidation_Partner.IsValidPartner( ARow.DonorKey, new TPartnerClass[] { }, true, "Donor of " + THelper.NiceValueDescription(ValidationContext.ToString()), AContext, ValidationColumn, null); if (VerificationResult != null) { AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } return VerifResultCollAddedCount == 0; }
/// <summary> /// Validates the Recurring Gift Detail data. /// </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> /// <param name="ARecipientField">Optional</param> /// <returns>True if the validation found no data validation errors, otherwise false.</returns> public static bool ValidateRecurringGiftDetailManual(object AContext, ARecurringGiftDetailRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict, Int64 ARecipientField = -1) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult = null; object ValidationContext; int VerifResultCollAddedCount = 0; bool ValidPartner = true; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return true; } // Check if valid donor ValidationColumn = ARow.Table.Columns[ARecurringGiftDetailTable.ColumnRecipientKeyId]; ValidationContext = String.Format("Batch no. {0}, gift no. {1}, detail no. {2}", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); VerificationResult = TSharedPartnerValidation_Partner.IsValidPartner( ARow.RecipientKey, new TPartnerClass[] { TPartnerClass.FAMILY, TPartnerClass.UNIT }, true, "Recipient of " + THelper.NiceValueDescription(ValidationContext.ToString()), AContext, ValidationColumn, null); if (VerificationResult != null) { AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); ValidPartner = false; } // 'Gift amount must be non-zero ValidationColumn = ARow.Table.Columns[ARecurringGiftDetailTable.ColumnGiftAmountId]; ValidationContext = String.Format("Batch Number {0} (transaction:{1} detail:{2})", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TNumericalChecks.IsPositiveDecimal(ARow.GiftAmount, ValidationControlsData.ValidationControlLabel + " of " + ValidationContext, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } } // If recipient is non-zero, field must also be non-zero. Only check for valid recipient keys. ValidationColumn = ARow.Table.Columns[ARecurringGiftDetailTable.ColumnRecipientLedgerNumberId]; ValidationContext = String.Format("batch:{0} transaction:{1} detail:{2}", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if ((ARow.RecipientKey > 0) && ValidPartner && (ARow.RecipientLedgerNumber == 0)) { VerificationResult = TNumericalChecks.IsGreaterThanZero(ARow.RecipientLedgerNumber, "Recipient field of " + ValidationContext + " is 0", AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } } } // Motivation Detail must not be null ValidationColumn = ARow.Table.Columns[ARecurringGiftDetailTable.ColumnMotivationDetailCodeId]; ValidationContext = String.Format("(batch:{0} transaction:{1} detail:{2})", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (ARow.IsMotivationDetailCodeNull() || (ARow.MotivationDetailCode == String.Empty)) { VerificationResult = TGeneralChecks.ValueMustNotBeNullOrEmptyString(ARow.MotivationDetailCode, "Motivation Detail code " + ValidationContext, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } } } // Detail comments type 1 must not be null if associated comment is not null ValidationColumn = ARow.Table.Columns[ARecurringGiftDetailTable.ColumnCommentOneTypeId]; ValidationContext = String.Format("(batch:{0} transaction:{1} detail:{2})", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (!ARow.IsGiftCommentOneNull() && (ARow.GiftCommentOne != String.Empty)) { VerificationResult = TGeneralChecks.ValueMustNotBeNullOrEmptyString(ARow.CommentOneType, "Comment 1 type " + ValidationContext, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } } } // Detail comments type 2 must not be null if associated comment is not null ValidationColumn = ARow.Table.Columns[ARecurringGiftDetailTable.ColumnCommentTwoTypeId]; ValidationContext = String.Format("(batch:{0} transaction:{1} detail:{2})", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (!ARow.IsGiftCommentTwoNull() && (ARow.GiftCommentTwo != String.Empty)) { VerificationResult = TGeneralChecks.ValueMustNotBeNullOrEmptyString(ARow.CommentTwoType, "Comment 2 type " + ValidationContext, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } } } // Detail comments type 3 must not be null if associated comment is not null ValidationColumn = ARow.Table.Columns[ARecurringGiftDetailTable.ColumnCommentThreeTypeId]; ValidationContext = String.Format("(batch:{0} transaction:{1} detail:{2})", ARow.BatchNumber, ARow.GiftTransactionNumber, ARow.DetailNumber); if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (!ARow.IsGiftCommentThreeNull() && (ARow.GiftCommentThree != String.Empty)) { VerificationResult = TGeneralChecks.ValueMustNotBeNullOrEmptyString(ARow.CommentThreeType, "Comment 3 type " + ValidationContext, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn, true)) { VerifResultCollAddedCount++; } } } return VerifResultCollAddedCount == 0; }
/// <summary> /// Validates the Relationship 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> /// <param name="AValidateForNewPartner">true if validation is run for a new partner record</param> /// <param name="APartnerKey">main partner key this validation is run for</param> /// <returns>void</returns> public static void ValidateRelationshipManual(object AContext, PPartnerRelationshipRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict, bool AValidateForNewPartner = false, Int64 APartnerKey = 0) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'Partner' must have a valid partner key and must not be 0 ValidationColumn = ARow.Table.Columns[PPartnerRelationshipTable.ColumnPartnerKeyId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = null; // don't complain if this is done for a new partner record (partner key not yet saved in db) if (!(AValidateForNewPartner && (APartnerKey == ARow.PartnerKey))) { VerificationResult = TSharedPartnerValidation_Partner.IsValidPartner( ARow.PartnerKey, new TPartnerClass[] { }, false, "", AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } // 'Partner Key' and 'Another Partner Key'must not be the same // (Partner Key 0 will be dealt with by other checks) if ((ARow.PartnerKey != 0) && (ARow.PartnerKey == ARow.RelationKey)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUESIDENTICAL_ERROR, new string[] { ARow.PartnerKey.ToString(), ARow.RelationKey.ToString() })), ValidationColumn, ValidationControlsData.ValidationControl); } // Handle addition to/removal from TVerificationResultCollection //if (AVerificationResultCollection.Contains(ValidationColumn)) //{xxx AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); //} } // 'Another Partner' must have a valid partner key and must not be 0 ValidationColumn = ARow.Table.Columns[PPartnerRelationshipTable.ColumnRelationKeyId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { // don't complain if this is done for a new partner record (partner key not yet saved in db) if (!(AValidateForNewPartner && (APartnerKey == ARow.RelationKey))) { VerificationResult = TSharedPartnerValidation_Partner.IsValidPartner( ARow.RelationKey, new TPartnerClass[] { }, false, "", AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } } // 'Relation' must be valid and have a value ValidationColumn = ARow.Table.Columns[PPartnerRelationshipTable.ColumnRelationNameId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PRelationTable RelationTable; PRelationRow RelationRow; VerificationResult = null; if ((!ARow.IsRelationNameNull()) && (ARow.RelationName != String.Empty)) { RelationTable = (PRelationTable)TSharedDataCache.TMPartner.GetCacheablePartnerTable( TCacheablePartnerTablesEnum.RelationList); RelationRow = (PRelationRow)RelationTable.Rows.Find(ARow.RelationName); // 'Relation' must be valid if ((RelationRow != null) && !RelationRow.ValidRelation) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.RelationName })), ValidationColumn, ValidationControlsData.ValidationControl); } } else { VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.RelationName, ValidationControlsData.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } }
/// <summary> /// todoComment /// </summary> /// <param name="e"></param> /// <param name="AVerificationResultCollection"></param> /// <param name="AVerificationResult"></param> public static void VerifyDates(DataColumnChangeEventArgs e, TVerificationResultCollection AVerificationResultCollection, out TVerificationResult AVerificationResult) { AVerificationResult = null; DateTime DateGoodUntil = new DateTime(); DateTime DateEffective = new DateTime(); try { if (e.Column.ColumnName == PPartnerLocationTable.GetDateEffectiveDBName()) { // MessageBox.Show('p_date_effective_d: ' + e.Row['p_date_effective_d', DataRowVersion.Current].ToString); DateEffective = TSaveConvert.ObjectToDate(e.ProposedValue); DateGoodUntil = TSaveConvert.ObjectToDate(e.Row[PPartnerLocationTable.GetDateGoodUntilDBName()]); } else if (e.Column.ColumnName == PPartnerLocationTable.GetDateGoodUntilDBName()) { DateEffective = TSaveConvert.ObjectToDate(e.Row[PPartnerLocationTable.GetDateEffectiveDBName()]); DateGoodUntil = TSaveConvert.ObjectToDate(e.ProposedValue); } // MessageBox.Show('p_date_effective_d: ' + DateEffective.ToString + Environment.NewLine + // 'p_date_good_until_d: ' + DateGoodUntil.ToString); if (e.Column.ColumnName == PPartnerLocationTable.GetDateEffectiveDBName()) { AVerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate(DateEffective, DateGoodUntil, "Valid From", "Valid To"); } else { AVerificationResult = TDateChecks.FirstGreaterOrEqualThanSecondDate(DateGoodUntil, DateEffective, "Valid To", "Valid From"); } if (e.Column.ColumnName == PPartnerLocationTable.GetDateEffectiveDBName()) { // delete any error that might have been there from a verification of the other column AVerificationResultCollection.Remove(PPartnerLocationTable.GetDateGoodUntilDBName()); } else { // delete any error that might have been there from a verification of the other column AVerificationResultCollection.Remove(PPartnerLocationTable.GetDateEffectiveDBName()); } } catch (Exception Exp) { MessageBox.Show("Exception occured in TPartnerAddressVerification.VerifyDates: " + Exp.ToString()); } }
/// <summary> /// Validates a Gift Destination record /// </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 ValidateGiftDestinationRowManual(object AContext, PPartnerGiftDestinationRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult = null; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'Field Key' must be a Partner associated with a Cost Centre DataColumn ValidationColumn = ARow.Table.Columns[PPartnerGiftDestinationTable.ColumnFieldKeyId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (!TSharedPartnerValidationHelper.PartnerIsLinkedToCC(ARow.FieldKey)) { VerificationResult = new TScreenVerificationResult(AContext, ValidationColumn, String.Format( Catalog.GetString("Gift Destination ({0}) must be a Partner linked to a Cost Centre."), ARow.FieldKey), Catalog.GetString("Partner Validation"), PetraErrorCodes.ERR_PARTNER_MUST_BE_CC, ValidationControlsData.ValidationControl, TResultSeverity.Resv_Critical); } // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } // Date Effective must not be after Date Expired (it can be equal) ValidationColumn = ARow.Table.Columns[PPartnerGiftDestinationTable.ColumnDateEffectiveId]; if (ARow.DateEffective > ARow.DateExpires) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_INVALID_DATES)), ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } }
/// <summary> /// Validates the Partner Contact Types Setup usercontrol data. /// </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> public static void ValidateContactTypesSetupManual(object AContext, PPartnerAttributeTypeRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult = null; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'HyperLink Format' must be correct if ARow.AttributeTypeValueKind is "CONTACTDETAIL_HYPERLINK_WITHVALUE" ValidationColumn = ARow.Table.Columns[PPartnerAttributeTypeTable.ColumnHyperlinkFormatId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (ARow.AttributeTypeValueKind == "CONTACTDETAIL_HYPERLINK_WITHVALUE") { // Remove any Data Validation errors that might have been recorded AVerificationResultCollection.Remove(ValidationColumn); // 'HyperLink Format' must not be empty string VerificationResult = TGeneralChecks.ValueMustNotBeNullOrEmptyString(ARow.HyperlinkFormat, Catalog.GetString("Link Format"), AContext, ValidationColumn, ValidationControlsData.ValidationControl); if ((VerificationResult == null) && (ARow.HyperlinkFormat == THyperLinkHandling.HYPERLINK_WITH_VALUE_VALUE_PLACEHOLDER_IDENTIFIER)) { // 'HyperLink Format' must contain more than just THyperLinkHandling.HYPERLINK_WITH_VALUE_VALUE_PLACEHOLDER_IDENTIFIER VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_INVALID_HYPERLINK_WITH_VALUE_JUST_CONTAINING_PLACEHOLDER, new string[] { THyperLinkHandling.HYPERLINK_WITH_VALUE_VALUE_PLACEHOLDER_IDENTIFIER })), ValidationColumn, ValidationControlsData.ValidationControl); } if ((VerificationResult == null) && (ARow.HyperlinkFormat.IndexOf(THyperLinkHandling.HYPERLINK_WITH_VALUE_VALUE_PLACEHOLDER_IDENTIFIER, StringComparison.InvariantCulture) == -1)) { // 'HyperLink Format' must contain THyperLinkHandling.HYPERLINK_WITH_VALUE_VALUE_PLACEHOLDER_IDENTIFIER, VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_INVALID_HYPERLINK_WITH_VALUE_NOT_CONTAINING_PLACEHOLDER, new string[] { THyperLinkHandling.HYPERLINK_WITH_VALUE_VALUE_PLACEHOLDER_IDENTIFIER })), ValidationColumn, ValidationControlsData.ValidationControl); } // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } else { // Remove any Data Validation errors that might have been recorded AVerificationResultCollection.Remove(ValidationColumn); } } VerificationResult = null; // 'Unssignable Date' must not be empty if the flag is set ValidationColumn = ARow.Table.Columns[PPartnerAttributeTypeTable.ColumnUnassignableDateId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (ARow.Unassignable) { VerificationResult = TSharedValidationControlHelper.IsNotInvalidDate(ARow.UnassignableDate, ValidationControlsData.ValidationControlLabel, AVerificationResultCollection, true, AContext, ValidationColumn, ValidationControlsData.ValidationControl); } // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } }
/// <summary> /// Validates the Banking Details screen data. /// </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="ABankingDetails">test if there is only one main account</param> /// <param name="ACountryCode">Country Code for ARow's corresponding Bank's country</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> public static void ValidateBankingDetails(object AContext, PBankingDetailsRow ARow, PBankingDetailsTable ABankingDetails, string ACountryCode, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult = null; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'BankKey' must be a valid BANK partner ValidationColumn = ARow.Table.Columns[PBankingDetailsTable.ColumnBankKeyId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (ARow.BankKey != 0) { VerificationResult = IsValidPartner( ARow.BankKey, new TPartnerClass[] { TPartnerClass.BANK }, false, string.Empty, AContext, ValidationColumn, ValidationControlsData.ValidationControl ); } // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // validate that there are not multiple main accounts ValidationColumn = ARow.Table.Columns[PartnerEditTDSPBankingDetailsTable.ColumnMainAccountId]; int countMainAccount = 0; foreach (PartnerEditTDSPBankingDetailsRow bdrow in ABankingDetails.Rows) { if (bdrow.RowState != DataRowState.Deleted) { if (bdrow.MainAccount) { countMainAccount++; } } } if (countMainAccount > 1) { // will we ever get here? AVerificationResultCollection.Add( new TScreenVerificationResult( new TVerificationResult( AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_BANKINGDETAILS_ONLYONEMAINACCOUNT)), ((PartnerEditTDSPBankingDetailsTable)ARow.Table).ColumnMainAccount, ValidationControlsData.ValidationControl )); } VerificationResult = null; // validate the account number (if validation exists for bank's country) ValidationColumn = ARow.Table.Columns[PBankingDetailsTable.ColumnBankAccountNumberId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { CommonRoutines Routines = new CommonRoutines(); if (!string.IsNullOrEmpty(ARow.BankAccountNumber) && (Routines.CheckAccountNumber(ARow.BankAccountNumber, ACountryCode) <= 0)) { VerificationResult = new TScreenVerificationResult( new TVerificationResult( AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_ACCOUNTNUMBER_INVALID)), ((PartnerEditTDSPBankingDetailsTable)ARow.Table).ColumnBankAccountNumber, ValidationControlsData.ValidationControl); } AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } VerificationResult = null; // validate the IBAN (if it exists) ValidationColumn = ARow.Table.Columns[PBankingDetailsTable.ColumnIbanId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { AVerificationResultCollection.Remove(ValidationColumn); if (!string.IsNullOrEmpty(ARow.Iban) && (CommonRoutines.CheckIBAN(ARow.Iban, out VerificationResult) == false)) { VerificationResult = new TScreenVerificationResult( new TVerificationResult(AContext, VerificationResult.ResultText, VerificationResult.ResultCode, VerificationResult.ResultSeverity), ValidationColumn, ValidationControlsData.ValidationControl); } AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } }
/// <summary> /// Validates the Partner Interest screen data. /// </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> /// <param name="AInterestCategory">The chosen interest category.</param> public static void ValidatePartnerInterestManual(object AContext, PPartnerInterestRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict, string AInterestCategory) { DataColumn ValidationColumn; DataColumn ValidationColumn2; DataColumn ValidationColumn3; TValidationControlsData ValidationControlsData; TValidationControlsData ValidationControlsData2; TValidationControlsData ValidationControlsData3; TVerificationResult VerificationResult = null; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // remove possible previous columns from result collection ValidationColumn = ARow.Table.Columns[PPartnerInterestTable.ColumnLevelId]; AVerificationResultCollection.Remove(ValidationColumn); ValidationColumn = ARow.Table.Columns[PPartnerInterestTable.ColumnInterestId]; AVerificationResultCollection.Remove(ValidationColumn); // check that level is entered within valid range (depending on interest category) ValidationColumn = ARow.Table.Columns[PPartnerInterestTable.ColumnLevelId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PInterestCategoryTable CategoryTable; PInterestCategoryRow CategoryRow; int LevelRangeLow; int LevelRangeHigh; // check if level is within valid range (retrieve valid range from cached tables) CategoryTable = (PInterestCategoryTable)TSharedDataCache.TMPartner.GetCacheablePartnerTable( TCacheablePartnerTablesEnum.InterestCategoryList); CategoryRow = (PInterestCategoryRow)CategoryTable.Rows.Find(new object[] { AInterestCategory }); if ((CategoryRow != null) && !ARow.IsLevelNull()) { LevelRangeLow = 0; LevelRangeHigh = 0; if (!CategoryRow.IsLevelRangeLowNull()) { LevelRangeLow = CategoryRow.LevelRangeLow; } if (!CategoryRow.IsLevelRangeHighNull()) { LevelRangeHigh = CategoryRow.LevelRangeHigh; } if ((!CategoryRow.IsLevelRangeLowNull() && (ARow.Level < CategoryRow.LevelRangeLow)) || (!CategoryRow.IsLevelRangeHighNull() && (ARow.Level > CategoryRow.LevelRangeHigh))) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUE_OUTSIDE_OF_RANGE, new string[] { ValidationControlsData.ValidationControlLabel, LevelRangeLow.ToString(), LevelRangeHigh.ToString() })), ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } } // check that at least one of interest, country or field is filled ValidationColumn = ARow.Table.Columns[PPartnerInterestTable.ColumnInterestId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { ValidationColumn2 = ARow.Table.Columns[PPartnerInterestTable.ColumnCountryId]; if (AValidationControlsDict.TryGetValue(ValidationColumn2, out ValidationControlsData2)) { ValidationColumn3 = ARow.Table.Columns[PPartnerInterestTable.ColumnFieldKeyId]; if (AValidationControlsDict.TryGetValue(ValidationColumn3, out ValidationControlsData3)) { if ((ARow.IsInterestNull() || (ARow.Interest == String.Empty)) && (ARow.IsCountryNull() || (ARow.Country == String.Empty)) && (ARow.IsFieldKeyNull() || (ARow.FieldKey == 0))) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_INTEREST_NO_DATA_SET_AT_ALL, new string[] { })), ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } } } // check that interest is filled if a category is set if (AInterestCategory != "") { ValidationColumn = ARow.Table.Columns[PPartnerInterestTable.ColumnInterestId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (ARow.IsInterestNull() || (ARow.Interest == String.Empty)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_INTEREST_NOT_SET, new string[] { AInterestCategory })), ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } } // 'Field' must be a valid UNIT partner (if set at all) ValidationColumn = ARow.Table.Columns[PPartnerInterestTable.ColumnFieldKeyId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (!ARow.IsFieldKeyNull()) { VerificationResult = IsValidPartner( ARow.FieldKey, new TPartnerClass[] { TPartnerClass.UNIT }, true, string.Empty, AContext, ValidationColumn, ValidationControlsData.ValidationControl ); } // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } }
/// <summary> /// Validates the general application record 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="AEventApplication">true if application for event, false if application for field.</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 ValidateGeneralApplicationManual(object AContext, PmGeneralApplicationRow ARow, bool AEventApplication, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'Application Type' must have a value and must not be unassignable ValidationColumn = ARow.Table.Columns[PmGeneralApplicationTable.ColumnAppTypeNameId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.AppTypeName, ValidationControlsData.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); PtApplicationTypeTable AppTypeTable; PtApplicationTypeRow AppTypeRow = null; VerificationResult = null; if (!ARow.IsAppTypeNameNull()) { AppTypeTable = (PtApplicationTypeTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate( TCacheablePersonTablesEnum.ApplicationTypeList); AppTypeRow = (PtApplicationTypeRow)AppTypeTable.Rows.Find(ARow.AppTypeName); // 'Application Type' must not be unassignable if ((AppTypeRow != null) && AppTypeRow.UnassignableFlag && (AppTypeRow.IsUnassignableDateNull() || (AppTypeRow.UnassignableDate <= DateTime.Today))) { // if 'Application Type' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmGeneralApplicationTable.GetAppTypeNameDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.AppTypeName })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Application Status' must not be unassignable ValidationColumn = ARow.Table.Columns[PmGeneralApplicationTable.ColumnGenApplicationStatusId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtApplicantStatusTable AppStatusTable; PtApplicantStatusRow AppStatusRow = null; VerificationResult = null; if (!ARow.IsGenApplicationStatusNull()) { AppStatusTable = (PtApplicantStatusTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate( TCacheablePersonTablesEnum.ApplicantStatusList); AppStatusRow = (PtApplicantStatusRow)AppStatusTable.Rows.Find(ARow.GenApplicationStatus); // 'Application Status' must not be unassignable if ((AppStatusRow != null) && AppStatusRow.UnassignableFlag && (AppStatusRow.IsUnassignableDateNull() || (AppStatusRow.UnassignableDate <= DateTime.Today))) { // if 'Application Status' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmGeneralApplicationTable.GetGenApplicationStatusDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.GenApplicationStatus })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // following validation only relevant for event applications if (AEventApplication) { // 'Organization Contact 1' must not be unassignable ValidationColumn = ARow.Table.Columns[PmGeneralApplicationTable.ColumnGenContact1Id]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtContactTable ContactTable; PtContactRow ContactRow; VerificationResult = null; if ((!ARow.IsGenContact1Null()) && (ARow.GenContact1 != String.Empty)) { ContactTable = (PtContactTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTable( TCacheablePersonTablesEnum.ContactList); ContactRow = (PtContactRow)ContactTable.Rows.Find(ARow.GenContact1); // 'Contact' must not be unassignable if ((ContactRow != null) && ContactRow.UnassignableFlag && (ContactRow.IsUnassignableDateNull() || (ContactRow.UnassignableDate <= DateTime.Today))) { // if 'Contact' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmGeneralApplicationTable.GetGenContact1DBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.GenContact1 })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Organization Contact 2' must not be unassignable ValidationColumn = ARow.Table.Columns[PmGeneralApplicationTable.ColumnGenContact2Id]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtContactTable ContactTable; PtContactRow ContactRow; VerificationResult = null; if ((!ARow.IsGenContact2Null()) && (ARow.GenContact2 != String.Empty)) { ContactTable = (PtContactTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTable( TCacheablePersonTablesEnum.ContactList); ContactRow = (PtContactRow)ContactTable.Rows.Find(ARow.GenContact2); // 'Contact' must not be unassignable if ((ContactRow != null) && ContactRow.UnassignableFlag && (ContactRow.IsUnassignableDateNull() || (ContactRow.UnassignableDate <= DateTime.Today))) { // if 'Contact' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmGeneralApplicationTable.GetGenContact2DBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.GenContact2 })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } } // following validation only relevant for field applications if (!AEventApplication) { // Field Application: 'Field' must be a Partner of Class 'UNIT' and must not be 0 and not be null ValidationColumn = ARow.Table.Columns[PmGeneralApplicationTable.ColumnGenAppPossSrvUnitKeyId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (ARow.IsGenAppPossSrvUnitKeyNull()) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_PARTNERKEY_INVALID_NOTNULL, new string[] { ValidationControlsData.ValidationControlLabel })), ValidationColumn, ValidationControlsData.ValidationControl); } else { VerificationResult = TSharedPartnerValidation_Partner.IsValidUNITPartner( ARow.GenAppPossSrvUnitKey, false, THelper.NiceValueDescription( ValidationControlsData.ValidationControlLabel) + " must be set correctly.", AContext, ValidationColumn, ValidationControlsData.ValidationControl); } // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } } // 'Cancellation date' must not be a future date ValidationColumn = ARow.Table.Columns[PmGeneralApplicationTable.ColumnGenAppCancelledId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = null; VerificationResult = TDateChecks.IsCurrentOrPastDate(ARow.GenAppCancelled, ValidationControlsData.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Accepted by sending field date' must not be a future date ValidationColumn = ARow.Table.Columns[PmGeneralApplicationTable.ColumnGenAppSendFldAcceptDateId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = null; VerificationResult = TDateChecks.IsCurrentOrPastDate(ARow.GenAppSendFldAcceptDate, ValidationControlsData.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Accepted by receiving field date' must not be a future date ValidationColumn = ARow.Table.Columns[PmGeneralApplicationTable.ColumnGenAppRecvgFldAcceptId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = null; VerificationResult = TDateChecks.IsCurrentOrPastDate(ARow.GenAppRecvgFldAccept, ValidationControlsData.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } }
/// <summary> /// Validates the Commitment 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 ValidateCommitmentManual(object AContext, PmStaffDataRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'Receiving Field' must be a Partner of Class 'UNIT' and must not be 0 ValidationColumn = ARow.Table.Columns[PmStaffDataTable.ColumnReceivingFieldId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TSharedPartnerValidation_Partner.IsValidUNITPartner( ARow.ReceivingField, false, THelper.NiceValueDescription( ValidationControlsData.ValidationControlLabel) + " must be set correctly.", AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } // 'Home Office' must be a Partner of Class 'UNIT' ValidationColumn = ARow.Table.Columns[PmStaffDataTable.ColumnHomeOfficeId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TSharedPartnerValidation_Partner.IsValidUNITPartner(ARow.HomeOffice, false, THelper.NiceValueDescription(ValidationControlsData.ValidationControlLabel) + " must be set correctly.", AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } // 'Recruiting Office' must be a Partner of Class 'UNIT' ValidationColumn = ARow.Table.Columns[PmStaffDataTable.ColumnOfficeRecruitedById]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TSharedPartnerValidation_Partner.IsValidUNITPartner(ARow.OfficeRecruitedBy, false, THelper.NiceValueDescription(ValidationControlsData.ValidationControlLabel) + " must be set correctly.", AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } // 'End of Commitment' must be later than 'Start of Commitment' ValidationColumn = ARow.Table.Columns[PmStaffDataTable.ColumnEndOfCommitmentId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TDateChecks.FirstGreaterOrEqualThanSecondDate(ARow.EndOfCommitment, ARow.StartOfCommitment, ValidationControlsData.ValidationControlLabel, ValidationControlsData.SecondValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Status' must have a value ValidationColumn = ARow.Table.Columns[PmStaffDataTable.ColumnStatusCodeId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.StatusCode, ValidationControlsData.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } }
/// <summary> /// Validates the Job Assignment 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 ValidateJobAssignmentManual(object AContext, PmJobAssignmentRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'From Date' must be defined ValidationColumn = ARow.Table.Columns[PmJobAssignmentTable.ColumnFromDateId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TSharedValidationControlHelper.IsNotInvalidDate(ARow.FromDate, ValidationControlsData.ValidationControlLabel, AVerificationResultCollection, true, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'To Date' must be later than 'From Date' ValidationColumn = ARow.Table.Columns[PmJobAssignmentTable.ColumnToDateId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TDateChecks.FirstGreaterOrEqualThanSecondDate(ARow.ToDate, ARow.FromDate, ValidationControlsData.ValidationControlLabel, ValidationControlsData.SecondValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Unit' must be a Partner of Class 'UNIT' and must not be 0 ValidationColumn = ARow.Table.Columns[PmJobAssignmentTable.ColumnUnitKeyId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TSharedPartnerValidation_Partner.IsValidUNITPartner( ARow.UnitKey, false, THelper.NiceValueDescription( ValidationControlsData.ValidationControlLabel) + " must be set correctly.", AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } // 'Assignment Type' must not be unassignable ValidationColumn = ARow.Table.Columns[PmJobAssignmentTable.ColumnAssignmentTypeCodeId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtAssignmentTypeTable TypeTable; PtAssignmentTypeRow TypeRow; VerificationResult = null; if ((!ARow.IsAssignmentTypeCodeNull()) && (ARow.AssignmentTypeCode != String.Empty)) { TypeTable = (PtAssignmentTypeTable)TSharedDataCache.TMPersonnel.GetCacheableUnitsTable( TCacheableUnitTablesEnum.JobAssignmentTypeList); TypeRow = (PtAssignmentTypeRow)TypeTable.Rows.Find(ARow.AssignmentTypeCode); // 'Assignment Type' must not be unassignable if ((TypeRow != null) && TypeRow.UnassignableFlag && (TypeRow.IsUnassignableDateNull() || (TypeRow.UnassignableDate <= DateTime.Today))) { // if 'Assignment Type' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmJobAssignmentTable.GetAssignmentTypeCodeDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.AssignmentTypeCode })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Position' must be not be null and not unassignable ValidationColumn = ARow.Table.Columns[PmJobAssignmentTable.ColumnPositionNameId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtPositionTable PositionTable; PtPositionRow PositionRow; VerificationResult = null; if ((!ARow.IsPositionNameNull()) && (ARow.PositionName != String.Empty)) { PositionTable = (PtPositionTable)TSharedDataCache.TMPersonnel.GetCacheableUnitsTable( TCacheableUnitTablesEnum.PositionList); PositionRow = (PtPositionRow)PositionTable.Rows.Find(new object[] { ARow.PositionName, ARow.PositionScope }); // 'Position' must not be unassignable if ((PositionRow != null) && PositionRow.UnassignableFlag && (PositionRow.IsUnassignableDateNull() || (PositionRow.UnassignableDate <= DateTime.Today))) { // if 'Position' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmJobAssignmentTable.GetPositionNameDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.PositionName })), ValidationColumn, ValidationControlsData.ValidationControl); } } } else { // Position name must not be null VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.PositionName, ValidationControlsData.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } }
/// <summary> /// Validates the event (short term) application record 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 ValidateEventApplicationManual(object AContext, PmShortTermApplicationRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'Event' must be a Partner of Class 'UNIT' and must not be 0 ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnStConfirmedOptionId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (ARow.IsStConfirmedOptionNull()) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_PARTNERKEY_INVALID_NOTNULL, new string[] { ValidationControlsData.ValidationControlLabel })), ValidationColumn, ValidationControlsData.ValidationControl); } else { VerificationResult = TSharedPartnerValidation_Partner.IsValidUNITPartner( ARow.StConfirmedOption, false, THelper.NiceValueDescription( ValidationControlsData.ValidationControlLabel) + " must be set correctly.", AContext, ValidationColumn, ValidationControlsData.ValidationControl); } // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } // 'Charged Field' must be a Partner of Class 'UNIT' // // HOWEVER, 'null' is a perfectly valid value for 'Charged Field' (according to WolfgangB). // If it is null then we must not call TSharedPartnerValidation_Partner.IsValidUNITPartner // as the attempt to retrieve 'ARow.StFieldCharged' would result in // 'System.Data.StrongTypingException("Error: DB null", null)'!!! if (!ARow.IsStFieldChargedNull()) { ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnStFieldChargedId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TSharedPartnerValidation_Partner.IsValidUNITPartner( ARow.StFieldCharged, true, THelper.NiceValueDescription( ValidationControlsData.ValidationControlLabel) + " must be set correctly.", AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } } // 'Arrival Method' must not be unassignable ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnTravelTypeToCongCodeId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtTravelTypeTable TravelTypeTable; PtTravelTypeRow TravelTypeRow = null; VerificationResult = null; if (!ARow.IsTravelTypeToCongCodeNull()) { TravelTypeTable = (PtTravelTypeTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate( TCacheablePersonTablesEnum.TransportTypeList); TravelTypeRow = (PtTravelTypeRow)TravelTypeTable.Rows.Find(ARow.TravelTypeToCongCode); // 'Arrival Method' must not be unassignable if ((TravelTypeRow != null) && TravelTypeRow.UnassignableFlag && (TravelTypeRow.IsUnassignableDateNull() || (TravelTypeRow.UnassignableDate <= DateTime.Today))) { // if 'Arrival Method' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmShortTermApplicationTable.GetTravelTypeToCongCodeDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.TravelTypeToCongCode })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Departure Method' must not be unassignable ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnTravelTypeFromCongCodeId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtTravelTypeTable TravelTypeTable; PtTravelTypeRow TravelTypeRow = null; VerificationResult = null; if (!ARow.IsTravelTypeFromCongCodeNull()) { TravelTypeTable = (PtTravelTypeTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate( TCacheablePersonTablesEnum.TransportTypeList); TravelTypeRow = (PtTravelTypeRow)TravelTypeTable.Rows.Find(ARow.TravelTypeFromCongCode); // 'Departure Method' must not be unassignable if ((TravelTypeRow != null) && TravelTypeRow.UnassignableFlag && (TravelTypeRow.IsUnassignableDateNull() || (TravelTypeRow.UnassignableDate <= DateTime.Today))) { // if 'Departure Method' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmShortTermApplicationTable.GetTravelTypeFromCongCodeDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.TravelTypeFromCongCode })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Departure Date' must be later than 'Arrival Date' ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnDepartureId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TDateChecks.FirstGreaterOrEqualThanSecondDate(ARow.Departure, ARow.Arrival, ValidationControlsData.ValidationControlLabel, ValidationControlsData.SecondValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Arrival Hour' must be between 0 and 24 ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnArrivalHourId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TNumericalChecks.IsInRange(ARow.ArrivalHour, 0, 24, Catalog.GetString("Arrival Hour"), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Arrival Minute' must be between 0 and 59 ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnArrivalMinuteId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TNumericalChecks.IsInRange(ARow.ArrivalMinute, 0, 59, Catalog.GetString("Arrival Minute"), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Departure Hour' must be between 0 and 24 ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnDepartureHourId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TNumericalChecks.IsInRange(ARow.DepartureHour, 0, 24, Catalog.GetString("Departure Hour"), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Departure Minute' must be between 0 and 59 ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnDepartureMinuteId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TNumericalChecks.IsInRange(ARow.DepartureMinute, 0, 59, Catalog.GetString("Departure Minute"), AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Arrival Point' must not be unassignable ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnArrivalPointCodeId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtArrivalPointTable ArrivalPointTable; PtArrivalPointRow ArrivalPointRow; VerificationResult = null; if ((!ARow.IsArrivalPointCodeNull()) && (ARow.ArrivalPointCode != String.Empty)) { ArrivalPointTable = (PtArrivalPointTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTable( TCacheablePersonTablesEnum.ArrivalDeparturePointList); ArrivalPointRow = (PtArrivalPointRow)ArrivalPointTable.Rows.Find(ARow.ArrivalPointCode); // 'Arrival Point' must not be unassignable if ((ArrivalPointRow != null) && ArrivalPointRow.UnassignableFlag && (ArrivalPointRow.IsUnassignableDateNull() || (ArrivalPointRow.UnassignableDate <= DateTime.Today))) { // if 'Contact' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmShortTermApplicationTable.GetArrivalPointCodeDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.ArrivalPointCode })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Departure Point' must not be unassignable ValidationColumn = ARow.Table.Columns[PmShortTermApplicationTable.ColumnDeparturePointCodeId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtArrivalPointTable ArrivalPointTable; PtArrivalPointRow ArrivalPointRow; VerificationResult = null; if ((!ARow.IsDeparturePointCodeNull()) && (ARow.DeparturePointCode != String.Empty)) { ArrivalPointTable = (PtArrivalPointTable)TSharedDataCache.TMPersonnel.GetCacheablePersonnelTable( TCacheablePersonTablesEnum.ArrivalDeparturePointList); ArrivalPointRow = (PtArrivalPointRow)ArrivalPointTable.Rows.Find(ARow.DeparturePointCode); // 'Arrival Point' must not be unassignable if ((ArrivalPointRow != null) && ArrivalPointRow.UnassignableFlag && (ArrivalPointRow.IsUnassignableDateNull() || (ArrivalPointRow.UnassignableDate <= DateTime.Today))) { // if 'Arrival Point' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmShortTermApplicationTable.GetDeparturePointCodeDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.DeparturePointCode })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } //TODO: if arrival hour == 24 then arrival minute must be 0 //TODO: if departure hour == 24 then departure minute must be 0 //TODO: make sure that no other application already exists for this event and this person }
/// <summary> /// Validates a Gift Destination record /// </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 ValidateGiftDestinationRowManual(object AContext, PPartnerGiftDestinationRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'Field Key' must be a Partner of Class 'UNIT' and must not be 0 ValidationColumn = ARow.Table.Columns[PPartnerGiftDestinationTable.ColumnFieldKeyId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = IsValidUNITPartner( ARow.FieldKey, false, THelper.NiceValueDescription( ValidationControlsData.ValidationControlLabel) + " must be set correctly.", AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } // Date Effective must not be after Date Expired (it can be equal) ValidationColumn = ARow.Table.Columns[PPartnerGiftDestinationTable.ColumnDateEffectiveId]; if (ARow.DateEffective > ARow.DateExpires) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_INVALID_DATES)), ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } }