/// <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; }
private void ShowDetailsForGift(AGiftRow ACurrentGiftRow) { //Set GiftRow controls dtpDateEntered.Date = ACurrentGiftRow.DateEntered; txtDetailDonorKey.Text = ACurrentGiftRow.DonorKey.ToString(); if (ACurrentGiftRow.IsMethodOfGivingCodeNull()) { cmbDetailMethodOfGivingCode.SelectedIndex = -1; } else { cmbDetailMethodOfGivingCode.SetSelectedString(ACurrentGiftRow.MethodOfGivingCode); } if (ACurrentGiftRow.IsMethodOfPaymentCodeNull()) { cmbDetailMethodOfPaymentCode.SelectedIndex = -1; } else { cmbDetailMethodOfPaymentCode.SetSelectedString(ACurrentGiftRow.MethodOfPaymentCode); } if (ACurrentGiftRow.IsReferenceNull()) { txtDetailReference.Text = String.Empty; } else { txtDetailReference.Text = ACurrentGiftRow.Reference; } if (ACurrentGiftRow.IsReceiptLetterCodeNull()) { cmbDetailReceiptLetterCode.SelectedIndex = -1; } else { cmbDetailReceiptLetterCode.SetSelectedString(ACurrentGiftRow.ReceiptLetterCode); } }