private void InitializeMotivationGroupList() { // don't do anything unless screen is activated or settings are loaded if (FDuringLoadSettings) { return; } string CheckedMemberMotGroup = "CHECKED"; string ValueMemberMotGroup = AMotivationGroupTable.GetMotivationGroupCodeDBName(); string DisplayMemberMotGroup = AMotivationGroupTable.GetMotivationGroupDescriptionDBName(); if (FMotGroupTable == null) { SetGroupTable(); } DataView MotGroupView = new DataView(FMotGroupTable); MotGroupView.Sort = ValueMemberMotGroup; DataTable NewMotGroupTable = MotGroupView.ToTable(true, new string[] { ValueMemberMotGroup, DisplayMemberMotGroup }); NewMotGroupTable.Columns.Add(new DataColumn(CheckedMemberMotGroup, typeof(bool))); clbMotivationGroup.SpecialKeys = ((SourceGrid.GridSpecialKeys)((((((SourceGrid.GridSpecialKeys.Arrows | SourceGrid.GridSpecialKeys.PageDownUp) | SourceGrid.GridSpecialKeys.Enter) | SourceGrid.GridSpecialKeys.Escape) | SourceGrid.GridSpecialKeys.Control) | SourceGrid.GridSpecialKeys.Shift))); clbMotivationGroup.Columns.Clear(); clbMotivationGroup.AddCheckBoxColumn("", NewMotGroupTable.Columns[CheckedMemberMotGroup], 17, false); clbMotivationGroup.AddTextColumn(Catalog.GetString("Group Code"), NewMotGroupTable.Columns[ValueMemberMotGroup]); clbMotivationGroup.AddTextColumn(Catalog.GetString("Description"), NewMotGroupTable.Columns[DisplayMemberMotGroup]); clbMotivationGroup.DataBindGrid(NewMotGroupTable, ValueMemberMotGroup, CheckedMemberMotGroup, ValueMemberMotGroup, false, true, false); clbMotivationGroup.AutoResizeGrid(); clbMotivationGroup.AutoStretchColumnsToFitWidth = true; // set flag as otherwise InitializeMotivationDetailList will be processed unnecessarily FDuringLoadSettings = true; clbMotivationGroup.SetCheckedStringList(""); FDuringLoadSettings = false; }
public static void ExportGifts(int ALedgerNumber, string ACostCentre, string AAcctCode, string AMonthName, int APeriodNumber, DateTime APeriodStartDate, DateTime APeriodEndDate, string ACurrencySelect, int AIchNumber, DataTable AExportDataTable, TVerificationResultCollection AVerificationResult) { /* Define local variables */ bool FirstLoopFlag = true; Int32 LastRecipKey = 0; string LastGroup = string.Empty; string LastDetail = string.Empty; string LastDetailDesc = string.Empty; decimal IndividualDebitTotal = 0; decimal IndividualCreditTotal = 0; string ExportDescription = string.Empty; Int32 tmpLastRecipKey = 0; string tmpLastGroup = string.Empty; string tmpLastDetail = string.Empty; //Find and total each gift transaction string SQLStmt = TDataBase.ReadSqlFile("ICH.HOSAExportGiftsInner.sql"); TDBTransaction DBTransaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref DBTransaction, delegate { OdbcParameter parameter; List <OdbcParameter> parameters = new List <OdbcParameter>(); parameter = new OdbcParameter("LedgerNumber", OdbcType.Int); parameter.Value = ALedgerNumber; parameters.Add(parameter); parameter = new OdbcParameter("CostCentre", OdbcType.VarChar); parameter.Value = ACostCentre; parameters.Add(parameter); parameter = new OdbcParameter("ICHNumber", OdbcType.Int); parameter.Value = AIchNumber; parameters.Add(parameter); parameter = new OdbcParameter("BatchStatus", OdbcType.VarChar); parameter.Value = MFinanceConstants.BATCH_POSTED; parameters.Add(parameter); parameter = new OdbcParameter("StartDate", OdbcType.DateTime); parameter.Value = APeriodStartDate; parameters.Add(parameter); parameter = new OdbcParameter("EndDate", OdbcType.DateTime); parameter.Value = APeriodEndDate; parameters.Add(parameter); parameter = new OdbcParameter("AccountCode", OdbcType.VarChar); parameter.Value = AAcctCode; parameters.Add(parameter); DataTable TmpTable = DBAccess.GDBAccessObj.SelectDT(SQLStmt, "table", DBTransaction, parameters.ToArray()); foreach (DataRow untypedTransRow in TmpTable.Rows) { /* Print totals etc. found for last recipient */ /* Only do after first loop due to last recipient key check */ tmpLastRecipKey = Convert.ToInt32(untypedTransRow[8]); //a_gift_detail.p_recipient_key_n tmpLastGroup = untypedTransRow[6].ToString(); //a_motivation_detail.a_motivation_group_code_c tmpLastDetail = untypedTransRow[7].ToString(); //a_motivation_detail.a_motivation_detail_code_c if (!FirstLoopFlag && ((tmpLastRecipKey != LastRecipKey) || (tmpLastGroup != LastGroup) || (tmpLastDetail != LastDetail) ) ) { if ((IndividualCreditTotal != 0) || (IndividualDebitTotal != 0)) { if (LastRecipKey != 0) { /* Find partner short name details */ PPartnerTable PartnerTable = PPartnerAccess.LoadByPrimaryKey(LastRecipKey, DBTransaction); PPartnerRow PartnerRow = (PPartnerRow)PartnerTable.Rows[0]; LastDetailDesc += " : " + PartnerRow.PartnerShortName; ExportDescription = ALedgerNumber.ToString() + AMonthName + ":" + LastDetailDesc; } else { AMotivationGroupTable MotivationGroupTable = AMotivationGroupAccess.LoadByPrimaryKey(ALedgerNumber, LastGroup, DBTransaction); AMotivationGroupRow MotivationGroupRow = (AMotivationGroupRow)MotivationGroupTable.Rows[0]; ExportDescription = ALedgerNumber.ToString() + AMonthName + ":" + MotivationGroupRow.MotivationGroupDescription.TrimEnd( new Char[] { (' ') }) + "," + LastDetailDesc; } //Add data to export table DataRow DR = (DataRow)AExportDataTable.NewRow(); DR[0] = ACostCentre; DR[1] = ConvertAccount(AAcctCode); DR[2] = ExportDescription; DR[3] = "ICH-" + APeriodNumber.ToString("00"); DR[4] = APeriodEndDate; DR[5] = IndividualDebitTotal; DR[6] = IndividualCreditTotal; AExportDataTable.Rows.Add(DR); /* Reset total */ IndividualDebitTotal = 0; IndividualCreditTotal = 0; } } if (ACurrencySelect == MFinanceConstants.CURRENCY_BASE) { Decimal GiftAmount = Convert.ToDecimal(untypedTransRow[4]); //a_gift_detail.a_gift_amount_n if (GiftAmount < 0) { IndividualDebitTotal -= GiftAmount; } else { IndividualCreditTotal += GiftAmount; } } else { Decimal IntlGiftAmount = Convert.ToDecimal(untypedTransRow[5]); //a_gift_detail.a_gift_amount_intl_n if (IntlGiftAmount < 0) { IndividualDebitTotal -= IntlGiftAmount; } else { IndividualCreditTotal += IntlGiftAmount; } } /* Set loop variables */ LastRecipKey = tmpLastRecipKey; LastGroup = tmpLastGroup; LastDetail = tmpLastDetail; LastDetailDesc = Convert.ToString(untypedTransRow[10]); //a_motivation_detail.a_motivation_detail_desc_c FirstLoopFlag = false; } // foreach /* Print totals etc. found for last recipient */ /* Only do after first loop due to last recipient key check */ if (!FirstLoopFlag && ((IndividualCreditTotal != 0) || (IndividualDebitTotal != 0))) { if (LastRecipKey != 0) { /* Find partner short name details */ PPartnerTable PartnerTable = PPartnerAccess.LoadByPrimaryKey(LastRecipKey, DBTransaction); PPartnerRow PartnerRow = (PPartnerRow)PartnerTable.Rows[0]; LastDetailDesc += ":" + PartnerRow.PartnerShortName; ExportDescription = ALedgerNumber.ToString() + AMonthName + ":" + LastDetailDesc; } else { AMotivationGroupTable MotivationGroupTable = AMotivationGroupAccess.LoadByPrimaryKey(ALedgerNumber, LastGroup, DBTransaction); AMotivationGroupRow MotivationGroupRow = (AMotivationGroupRow)MotivationGroupTable.Rows[0]; ExportDescription = ALedgerNumber.ToString() + AMonthName + ":" + MotivationGroupRow.MotivationGroupDescription.TrimEnd() + "," + LastDetailDesc; } //Add rows to export table DataRow DR = (DataRow)AExportDataTable.NewRow(); DR[0] = ACostCentre; DR[1] = ConvertAccount(AAcctCode); DR[2] = ExportDescription; DR[3] = "ICH-" + APeriodNumber.ToString("00"); DR[4] = APeriodEndDate;; DR[5] = IndividualDebitTotal; DR[6] = IndividualCreditTotal; AExportDataTable.Rows.Add(DR); } }); // Get NewOrExisting AutoReadTransaction } // Export Gifts
private void ParseTransactionLine(AGiftRow AGift, AGiftBatchRow AGiftBatch, ref AGiftRow APreviousGift, int ANumberOfColumns, ref decimal ATotalBatchAmount, ref string AImportMessage, int ARowNumber, TVerificationResultCollection AMessages, TValidationControlsDict AValidationControlsDictGift, TValidationControlsDict AValidationControlsDictGiftDetail, ACostCentreTable AValidationCostCentreTable, AMotivationGroupTable AValidationMotivationGroupTable, AMotivationDetailTable AValidationMotivationDetailTable, AMethodOfGivingTable AValidationMethodOfGivingTable, AMethodOfPaymentTable AValidationMethodOfPaymentTable, ref GiftBatchTDSAGiftDetailTable ANeedRecipientLedgerNumber, out AGiftDetailRow AGiftDetails) { // Is this the format with extra columns? // Actually if it has the extra columns but does not have the optional final 8 columns we cannot distiguish using this test... // A file without extra columns will have between 13 and 21 columns - depending on whether some of the optional ones at the end are included. // A file with extra columns will be between 19 and 27. // So any count between 19 and 21 is ambiguous. We will assume that if the file has extra columns it also has // at least enough of the optional ones to exceed 21. bool HasExtraColumns = (ANumberOfColumns > 21); AImportMessage = Catalog.GetString("Importing the gift data"); AGift.DonorKey = ImportInt64(Catalog.GetString("Donor key"), FMainDS.AGift.ColumnDonorKey, ARowNumber, AMessages, AValidationControlsDictGift); ImportString(Catalog.GetString("short name of donor (unused)"), null, null); // unused // This group is optional and database NULL's are allowed AGift.MethodOfGivingCode = ImportString(Catalog.GetString("Method of giving Code"), FMainDS.AGift.ColumnMethodOfGivingCode, AValidationControlsDictGift, false); AGift.MethodOfPaymentCode = ImportString(Catalog.GetString("Method Of Payment Code"), FMainDS.AGift.ColumnMethodOfPaymentCode, AValidationControlsDictGift, false); AGift.Reference = ImportString(Catalog.GetString("Reference"), FMainDS.AGift.ColumnReference, AValidationControlsDictGift, false); AGift.ReceiptLetterCode = ImportString(Catalog.GetString("Receipt letter code"), FMainDS.AGift.ColumnReceiptLetterCode, AValidationControlsDictGift, false); if (HasExtraColumns) { ImportInt32(Catalog.GetString("Receipt number"), FMainDS.AGift.ColumnReceiptNumber, ARowNumber, AMessages, AValidationControlsDictGift); ImportBoolean(Catalog.GetString("First time gift"), FMainDS.AGift.ColumnFirstTimeGift, AValidationControlsDictGift); ImportBoolean(Catalog.GetString("Receipt printed"), FMainDS.AGift.ColumnReceiptPrinted, AValidationControlsDictGift); } AImportMessage = Catalog.GetString("Importing the gift details"); AGiftDetails = FMainDS.AGiftDetail.NewRowTyped(true); if ((APreviousGift != null) && (AGift.DonorKey == APreviousGift.DonorKey) && (AGift.MethodOfGivingCode == APreviousGift.MethodOfGivingCode) && (AGift.MethodOfPaymentCode == APreviousGift.MethodOfPaymentCode) && (AGift.Reference == APreviousGift.Reference) && (AGift.ReceiptLetterCode == APreviousGift.ReceiptLetterCode) && (AGift.ReceiptNumber == APreviousGift.ReceiptNumber) && (AGift.FirstTimeGift == APreviousGift.FirstTimeGift) && (AGift.ReceiptPrinted == APreviousGift.ReceiptPrinted)) { // this row is a new detail for the previousGift AGift = APreviousGift; AGift.LastDetailNumber++; AGiftDetails.DetailNumber = AGift.LastDetailNumber; } else { APreviousGift = AGift; AGift.LedgerNumber = AGiftBatch.LedgerNumber; AGift.BatchNumber = AGiftBatch.BatchNumber; AGift.GiftTransactionNumber = AGiftBatch.LastGiftNumber + 1; AGiftBatch.LastGiftNumber++; AGift.LastDetailNumber = 1; FMainDS.AGift.Rows.Add(AGift); AGiftDetails.DetailNumber = 1; } AGiftDetails.LedgerNumber = AGift.LedgerNumber; AGiftDetails.BatchNumber = AGiftBatch.BatchNumber; AGiftDetails.GiftTransactionNumber = AGift.GiftTransactionNumber; FMainDS.AGiftDetail.Rows.Add(AGiftDetails); AGiftDetails.RecipientKey = ImportInt64(Catalog.GetString("Recipient key"), FMainDS.AGiftDetail.ColumnRecipientKey, ARowNumber, AMessages, AValidationControlsDictGiftDetail); ImportString(Catalog.GetString("short name of recipient (unused)"), null, null); // unused if (HasExtraColumns) { ImportInt32(Catalog.GetString("Recipient ledger number"), FMainDS.AGiftDetail.ColumnRecipientLedgerNumber, ARowNumber, AMessages, AValidationControlsDictGiftDetail); } // we always calculate RecipientLedgerNumber AGiftDetails.RecipientLedgerNumber = TGiftTransactionWebConnector.GetRecipientFundNumber( AGiftDetails.RecipientKey, AGiftBatch.GlEffectiveDate); decimal currentGiftAmount = ImportDecimal(Catalog.GetString("Gift amount"), FMainDS.AGiftDetail.ColumnGiftTransactionAmount, ARowNumber, AMessages, AValidationControlsDictGiftDetail); AGiftDetails.GiftTransactionAmount = currentGiftAmount; // amount in batch currency ATotalBatchAmount += currentGiftAmount; AGiftDetails.GiftAmount = GLRoutines.Divide(currentGiftAmount, AGiftBatch.ExchangeRateToBase); // amount in ledger currency if (HasExtraColumns) { // amount in international currency ImportDecimal(Catalog.GetString("Gift amount intl"), FMainDS.AGiftDetail.ColumnGiftAmountIntl, ARowNumber, AMessages, AValidationControlsDictGiftDetail); } AGiftDetails.ConfidentialGiftFlag = ImportBoolean(Catalog.GetString("Confidential gift"), FMainDS.AGiftDetail.ColumnConfidentialGiftFlag, AValidationControlsDictGiftDetail, "no"); AGiftDetails.MotivationGroupCode = ImportString(Catalog.GetString("Motivation group code"), FMainDS.AGiftDetail.ColumnMotivationGroupCode, AValidationControlsDictGiftDetail); AGiftDetails.MotivationDetailCode = ImportString(Catalog.GetString("Motivation detail"), FMainDS.AGiftDetail.ColumnMotivationDetailCode, AValidationControlsDictGiftDetail); if (HasExtraColumns) { ImportString(Catalog.GetString("Cost centre code"), FMainDS.AGiftDetail.ColumnCostCentreCode, AValidationControlsDictGiftDetail); } // "In Petra Cost Centre is always inferred from recipient field and motivation detail so is not needed in the import." AGiftDetails.CostCentreCode = InferCostCentre(AGiftDetails); // All the remaining columns are optional and can contain database NULL AGiftDetails.GiftCommentOne = ImportString(Catalog.GetString("Gift comment one"), FMainDS.AGiftDetail.ColumnGiftCommentOne, AValidationControlsDictGiftDetail, false); string commentOneType = ImportString(Catalog.GetString("Comment one type"), FMainDS.AGiftDetail.ColumnCommentOneType, AValidationControlsDictGiftDetail, false); AGiftDetails.MailingCode = ImportString(Catalog.GetString("Mailing code"), FMainDS.AGiftDetail.ColumnMailingCode, AValidationControlsDictGiftDetail, false); AGiftDetails.GiftCommentTwo = ImportString(Catalog.GetString("Gift comment two"), FMainDS.AGiftDetail.ColumnGiftCommentTwo, AValidationControlsDictGiftDetail, false); string commentTwoType = ImportString(Catalog.GetString("Comment two type"), FMainDS.AGiftDetail.ColumnCommentTwoType, AValidationControlsDictGiftDetail, false); AGiftDetails.GiftCommentThree = ImportString(Catalog.GetString("Gift comment three"), FMainDS.AGiftDetail.ColumnGiftCommentThree, AValidationControlsDictGiftDetail, false); string commentThreeType = ImportString(Catalog.GetString("Comment three type"), FMainDS.AGiftDetail.ColumnCommentThreeType, AValidationControlsDictGiftDetail, false); SetCommentTypeCase(ref commentOneType); AGiftDetails.CommentOneType = commentOneType; SetCommentTypeCase(ref commentTwoType); AGiftDetails.CommentOneType = commentTwoType; SetCommentTypeCase(ref commentThreeType); AGiftDetails.CommentOneType = commentThreeType; // Find the default Tax deductabilty from the motivation detail. This ensures that the column can be missing. AMotivationDetailRow motivationDetailRow = (AMotivationDetailRow)AValidationMotivationDetailTable.Rows.Find( new object[] { FLedgerNumber, AGiftDetails.MotivationGroupCode, AGiftDetails.MotivationDetailCode }); string defaultTaxDeductible = ((motivationDetailRow != null) && !motivationDetailRow.IsTaxDeductibleAccountNull() && motivationDetailRow.TaxDeductible) ? "yes" : "no"; AGiftDetails.TaxDeductible = ImportBoolean(Catalog.GetString("Tax deductible"), FMainDS.AGiftDetail.ColumnTaxDeductible, AValidationControlsDictGiftDetail, defaultTaxDeductible); // Date entered cannot be imported although it can be modified in the GUI. // This is because it would have to be the last column in the import for compatibility // but it belongs with the gift and not the detail so it would need to go in an earlier column. // For now the import date entered is the effective date. AGift.DateEntered = AGiftBatch.GlEffectiveDate; // Enforce the correct case for our GIFT constant if (String.Compare(AGiftDetails.MotivationGroupCode, MFinanceConstants.MOTIVATION_GROUP_GIFT, true) == 0) { AGiftDetails.MotivationGroupCode = MFinanceConstants.MOTIVATION_GROUP_GIFT; } TPartnerClass RecipientClass; string RecipientDescription; TPartnerServerLookups.GetPartnerShortName(AGiftDetails.RecipientKey, out RecipientDescription, out RecipientClass); // If the gift has a Family recipient with no Gift Destination then the import will fail. Gift is added to a table and returned to client. if ((AGiftDetails.RecipientLedgerNumber == 0) && (AGiftDetails.MotivationGroupCode == MFinanceConstants.MOTIVATION_GROUP_GIFT)) { if (RecipientClass == TPartnerClass.FAMILY) { ((GiftBatchTDSAGiftDetailRow)AGiftDetails).RecipientDescription = RecipientDescription; ANeedRecipientLedgerNumber.Rows.Add((object[])AGiftDetails.ItemArray.Clone()); } } AImportMessage = Catalog.GetString("Validating the gift data"); int messageCountBeforeValidate = AMessages.Count; // Do our standard validation on this gift AGiftValidation.Validate(this, AGift, ref AMessages, AValidationControlsDictGift); TSharedFinanceValidation_Gift.ValidateGiftManual(this, AGift, AGiftBatch.BatchYear, AGiftBatch.BatchPeriod, null, ref AMessages, AValidationControlsDictGift, AValidationMethodOfGivingTable, AValidationMethodOfPaymentTable); AImportMessage = Catalog.GetString("Validating the gift details data"); AGiftDetailValidation.Validate(this, AGiftDetails, ref AMessages, AValidationControlsDictGiftDetail); TSharedFinanceValidation_Gift.ValidateGiftDetailManual(this, (GiftBatchTDSAGiftDetailRow)AGiftDetails, ref AMessages, AValidationControlsDictGiftDetail, RecipientClass, AValidationCostCentreTable, AValidationMotivationGroupTable, AValidationMotivationDetailTable, AGiftDetails.RecipientKey); for (int i = messageCountBeforeValidate; i < AMessages.Count; i++) { ((TVerificationResult)AMessages[i]).OverrideResultContext(String.Format(MCommonConstants.StrValidationErrorInLine, ARowNumber)); if (AMessages[i] is TScreenVerificationResult) { TVerificationResult downgrade = new TVerificationResult((TScreenVerificationResult)AMessages[i]); AMessages.RemoveAt(i); AMessages.Insert(i, downgrade); } } }
/// <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; }
public static void ExportGifts(int ALedgerNumber, string ACostCentre, string AAcctCode, string AMonthName, int APeriodNumber, DateTime APeriodStartDate, DateTime APeriodEndDate, string ACurrencySelect, int AIchNumber, DataTable AExportDataTable, TVerificationResultCollection AVerificationResult) { /* Define local variables */ bool FirstLoopFlag = true; Int32 LastRecipKey = 0; string LastGroup = string.Empty; string LastDetail = string.Empty; string LastDetailDesc = string.Empty; decimal IndividualDebitTotal = 0; decimal IndividualCreditTotal = 0; string ExportDescription = string.Empty; Int32 tmpLastRecipKey = 0; string tmpLastGroup = string.Empty; string tmpLastDetail = string.Empty; //Find and total each gift transaction TDBTransaction DBTransaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref DBTransaction, delegate { String IchNumberFilter = ""; if (AIchNumber > 0) { IchNumberFilter = " AND GiftDetail.a_ich_number_i = " + AIchNumber; } String Query = "SELECT " + " GiftDetail.a_ledger_number_i, " + " GiftDetail.a_batch_number_i, " + " GiftDetail.a_gift_transaction_number_i, " + " GiftDetail.a_detail_number_i, " + " GiftDetail.a_gift_amount_n, " + " GiftDetail.a_gift_amount_intl_n, " + " GiftDetail.a_motivation_group_code_c, " + " GiftDetail.a_motivation_detail_code_c, " + " GiftDetail.p_recipient_key_n, " + " Gift.a_gift_status_c, " + " MotiviationDetail.a_motivation_detail_desc_c, " + " GiftBatch.a_batch_description_c " + " FROM " + " public.a_gift_detail AS GiftDetail, " + " public.a_gift_batch AS GiftBatch, " + " public.a_motivation_detail AS MotiviationDetail, " + " public.a_gift AS Gift " + " WHERE " + " GiftDetail.a_ledger_number_i = GiftBatch.a_ledger_number_i " + " AND GiftDetail.a_batch_number_i = GiftBatch.a_batch_number_i " + " AND GiftDetail.a_ledger_number_i = MotiviationDetail.a_ledger_number_i " + " AND GiftDetail.a_motivation_group_code_c = MotiviationDetail.a_motivation_group_code_c " + " AND GiftDetail.a_motivation_detail_code_c = MotiviationDetail.a_motivation_detail_code_c " + " AND GiftDetail.a_ledger_number_i = Gift.a_ledger_number_i " + " AND GiftDetail.a_batch_number_i = Gift.a_batch_number_i " + " AND GiftDetail.a_gift_transaction_number_i = Gift.a_gift_transaction_number_i " + " AND GiftDetail.a_ledger_number_i = " + ALedgerNumber + " AND GiftDetail.a_cost_centre_code_c = '" + ACostCentre + "'" + IchNumberFilter + " AND GiftBatch.a_batch_status_c = '" + MFinanceConstants.BATCH_POSTED + "'" + " AND GiftBatch.a_gl_effective_date_d >= " + APeriodStartDate.ToString("#yyyy-MM-dd#") + " AND GiftBatch.a_gl_effective_date_d <= " + APeriodEndDate.ToString("#yyyy-MM-dd#") + " AND MotiviationDetail.a_account_code_c = '" + AAcctCode + "'" + " ORDER BY " + " GiftDetail.p_recipient_key_n ASC, " + " GiftDetail.a_motivation_group_code_c ASC, " + " GiftDetail.a_motivation_detail_code_c ASC;"; DataTable TmpTable = DBAccess.GDBAccessObj.SelectDT(Query, "table", DBTransaction); foreach (DataRow Row in TmpTable.Rows) { /* Print totals etc. found for last recipient */ /* Only do after first loop due to last recipient key check */ tmpLastRecipKey = Convert.ToInt32(Row["p_recipient_key_n"]); tmpLastGroup = Row["a_motivation_group_code_c"].ToString(); tmpLastDetail = Row["a_motivation_detail_code_c"].ToString(); if (!FirstLoopFlag && ((tmpLastRecipKey != LastRecipKey) || (tmpLastGroup != LastGroup) || (tmpLastDetail != LastDetail) ) ) { if ((IndividualCreditTotal != 0) || (IndividualDebitTotal != 0)) { if (LastRecipKey != 0) { /* Find partner short name details */ PPartnerTable PartnerTable = PPartnerAccess.LoadByPrimaryKey(LastRecipKey, DBTransaction); PPartnerRow PartnerRow = (PPartnerRow)PartnerTable.Rows[0]; LastDetailDesc += " : " + PartnerRow.PartnerShortName; ExportDescription = ALedgerNumber.ToString() + AMonthName + ":" + LastDetailDesc; } else { AMotivationGroupTable MotivationGroupTable = AMotivationGroupAccess.LoadByPrimaryKey(ALedgerNumber, LastGroup, DBTransaction); AMotivationGroupRow MotivationGroupRow = (AMotivationGroupRow)MotivationGroupTable.Rows[0]; ExportDescription = ALedgerNumber.ToString() + AMonthName + ":" + MotivationGroupRow.MotivationGroupDescription.TrimEnd( new Char[] { (' ') }) + "," + LastDetailDesc; } //Add data to export table DataRow DR = (DataRow)AExportDataTable.NewRow(); DR[0] = ACostCentre; DR[1] = ConvertAccount(AAcctCode); DR[2] = ExportDescription; DR[3] = "ICH-" + APeriodNumber.ToString("00"); DR[4] = APeriodEndDate; DR[5] = IndividualDebitTotal; DR[6] = IndividualCreditTotal; AExportDataTable.Rows.Add(DR); /* Reset total */ IndividualDebitTotal = 0; IndividualCreditTotal = 0; } } if (ACurrencySelect == MFinanceConstants.CURRENCY_BASE) { Decimal GiftAmount = Convert.ToDecimal(Row["a_gift_amount_n"]); if (GiftAmount < 0) { IndividualDebitTotal -= GiftAmount; } else { IndividualCreditTotal += GiftAmount; } } else { Decimal IntlGiftAmount = Convert.ToDecimal(Row["a_gift_amount_intl_n"]); if (IntlGiftAmount < 0) { IndividualDebitTotal -= IntlGiftAmount; } else { IndividualCreditTotal += IntlGiftAmount; } } /* Set loop variables */ LastRecipKey = tmpLastRecipKey; LastGroup = tmpLastGroup; LastDetail = tmpLastDetail; LastDetailDesc = Convert.ToString(Row["a_motivation_detail_desc_c"]); FirstLoopFlag = false; } // foreach /* Print totals etc. found for last recipient */ /* Only do after first loop due to last recipient key check */ if (!FirstLoopFlag && ((IndividualCreditTotal != 0) || (IndividualDebitTotal != 0))) { if (LastRecipKey != 0) { /* Find partner short name details */ PPartnerTable PartnerTable = PPartnerAccess.LoadByPrimaryKey(LastRecipKey, DBTransaction); PPartnerRow PartnerRow = (PPartnerRow)PartnerTable.Rows[0]; LastDetailDesc += ":" + PartnerRow.PartnerShortName; ExportDescription = ALedgerNumber.ToString() + AMonthName + ":" + LastDetailDesc; } else { AMotivationGroupTable MotivationGroupTable = AMotivationGroupAccess.LoadByPrimaryKey(ALedgerNumber, LastGroup, DBTransaction); AMotivationGroupRow MotivationGroupRow = (AMotivationGroupRow)MotivationGroupTable.Rows[0]; ExportDescription = ALedgerNumber.ToString() + AMonthName + ":" + MotivationGroupRow.MotivationGroupDescription.TrimEnd() + "," + LastDetailDesc; } //Add rows to export table DataRow DR = (DataRow)AExportDataTable.NewRow(); DR[0] = ACostCentre; DR[1] = ConvertAccount(AAcctCode); DR[2] = ExportDescription; DR[3] = "ICH-" + APeriodNumber.ToString("00"); DR[4] = APeriodEndDate;; DR[5] = IndividualDebitTotal; DR[6] = IndividualCreditTotal; AExportDataTable.Rows.Add(DR); } }); // Get NewOrExisting AutoReadTransaction } // Export Gifts