Пример #1
0
        public void TestDeleteVenue()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String               TextMessage;
            Boolean              CanDeletePartner;
            PPartnerRow          VenuePartnerRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            VenuePartnerRow = TCreateTestPartnerData.CreateNewVenuePartner(MainDS);
            result          = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create venue record");

            // check if Venue partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(VenuePartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // set up buildings for this venue so deletion is not allowed
            PcBuildingTable BuildingTable = new PcBuildingTable();
            PcBuildingRow   BuildingRow   = BuildingTable.NewRowTyped();

            BuildingRow.VenueKey     = VenuePartnerRow.PartnerKey;
            BuildingRow.BuildingCode = "Test";
            BuildingTable.Rows.Add(BuildingRow);

            PcBuildingAccess.SubmitChanges(BuildingTable, DBAccess.GDBAccessObj.Transaction);

            // now deletion must not be possible since a building is linked to the venue
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(VenuePartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of venue partner
            VenuePartnerRow = TCreateTestPartnerData.CreateNewVenuePartner(MainDS);
            PartnerKey      = VenuePartnerRow.PartnerKey;
            result          = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create venue record for deletion");

            // check if Venue record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that Venue record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
Пример #2
0
        public void TestDeleteOrganisation()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String               TextMessage;
            Boolean              CanDeletePartner;
            PPartnerRow          OrganisationPartnerRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            OrganisationPartnerRow = TCreateTestPartnerData.CreateNewOrganisationPartner(MainDS);
            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create organisation record");

            // check if organisation partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(OrganisationPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // now test actual deletion of Organisation partner
            PartnerKey = OrganisationPartnerRow.PartnerKey;
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that Organisation record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
Пример #3
0
        public void TestDeleteUnit()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String               TextMessage;
            Boolean              CanDeletePartner;
            PPartnerRow          UnitPartnerRow;
            PUnitRow             UnitRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TDataBase db = DBAccess.Connect("TestDeleteUnit");
            TPartnerEditUIConnector connector = new TPartnerEditUIConnector(db);

            PartnerEditTDS MainDS = new PartnerEditTDS();

            UnitPartnerRow = TCreateTestPartnerData.CreateNewUnitPartner(MainDS, db);
            result         = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);

            // check if Unit partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(UnitPartnerRow.PartnerKey, out TextMessage, db);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // set unit type to Key Ministry which means it is not allowed to be deleted any longer
            UnitRow = (PUnitRow)MainDS.PUnit.Rows[0];
            UnitRow.UnitTypeCode = MPartnerConstants.UNIT_TYPE_KEYMIN;
            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "set unit type to " + MPartnerConstants.UNIT_TYPE_KEYMIN);

            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(UnitPartnerRow.PartnerKey, out TextMessage, db);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of Unit partner
            UnitPartnerRow = TCreateTestPartnerData.CreateNewUnitPartner(MainDS, db);
            PartnerKey     = UnitPartnerRow.PartnerKey;
            result         = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create unit record for deletion");

            // check if Unit record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult, db));

            // check that Unit record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
        private void DeletePartnerKeyWithUnit(Int64 APartnerKey)
        {
            TVerificationResultCollection VerificationResult;

            // check if Unit record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(APartnerKey,
                                                             out VerificationResult), "Error deleting partner-key-with-unit " + APartnerKey.ToString());

            // check that Unit record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(APartnerKey),
                          "Error. Partner-key-with-unit " + APartnerKey.ToString() + " still exists!");
        }
Пример #5
0
        public static bool DeletePartner(Int64 APartnerKey,
                                         out TVerificationResultCollection AVerificationResult)
        {
            string ErrorMsg = String.Empty;

            if (!TPartnerWebConnector.CanPartnerBeDeleted(APartnerKey, out ErrorMsg))
            {
                AVerificationResult = new TVerificationResultCollection();
                AVerificationResult.Add(new TVerificationResult("error", ErrorMsg, TResultSeverity.Resv_Critical));
                return(false);
            }

            return(TPartnerWebConnector.DeletePartner(APartnerKey, out AVerificationResult));
        }
Пример #6
0
        public static bool DeleteChild(
            Int64 APartnerKey,
            Int32 ALedgerNumber,
            out TVerificationResultCollection AVerificationResult)
        {
            AVerificationResult = new TVerificationResultCollection();

            string         SponsorshipStatus;
            SponsorshipTDS MainDS = GetChildDetails(APartnerKey,
                                                    ALedgerNumber,
                                                    false,
                                                    out SponsorshipStatus);

            // cannot delete if there are sponsorships
            if (MainDS.ARecurringGiftDetail.Rows.Count != 0)
            {
                AVerificationResult.Add(new TVerificationResult("error", "Please manually delete the sponsorship first", "",
                                                                "MaintainChildren.ErrFirstDeleteSponsorship", TResultSeverity.Resv_Critical));
                return(false);
            }

            // delete the child, and the comments and reminders.
            return(TPartnerWebConnector.DeletePartner(APartnerKey, out AVerificationResult));
        }
Пример #7
0
        public void TestDeleteBank()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String               TextMessage;
            Boolean              CanDeletePartner;
            PPartnerRow          BankPartnerRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            BankPartnerRow = TCreateTestPartnerData.CreateNewBankPartner(MainDS);
            result         = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create bank record");

            // check if Bank partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(BankPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // set up details (e.g. bank account) for this Bank so deletion is not allowed
            PBankingDetailsTable BankingDetailsTable = new PBankingDetailsTable();
            PBankingDetailsRow   BankingDetailsRow   = BankingDetailsTable.NewRowTyped();

            BankingDetailsRow.BankKey           = BankPartnerRow.PartnerKey;
            BankingDetailsRow.BankingType       = 0;
            BankingDetailsRow.BankingDetailsKey = Convert.ToInt32(TSequenceWebConnector.GetNextSequence(TSequenceNames.seq_bank_details));
            BankingDetailsTable.Rows.Add(BankingDetailsRow);

            PBankingDetailsAccess.SubmitChanges(BankingDetailsTable, DBAccess.GDBAccessObj.Transaction);

            // now deletion must not be possible since a bank account is set up for the bank
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(BankPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of venue partner
            BankPartnerRow = TCreateTestPartnerData.CreateNewBankPartner(MainDS);
            PartnerKey     = BankPartnerRow.PartnerKey;
            result         = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create bank partner for deletion");

            // check if Venue record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that Bank record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
Пример #8
0
        public void TestDeleteChurch()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String               TextMessage;
            Boolean              CanDeletePartner;
            PPartnerRow          ChurchPartnerRow;
            PPartnerRow          PartnerRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            ChurchPartnerRow = TCreateTestPartnerData.CreateNewChurchPartner(MainDS);
            result           = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create church record");

            // check if church partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(ChurchPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // create family partner and relationship to church partner
            PartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            PPartnerRelationshipRow RelationshipRow = MainDS.PPartnerRelationship.NewRowTyped();

            RelationshipRow.PartnerKey   = ChurchPartnerRow.PartnerKey;
            RelationshipRow.RelationName = "SUPPCHURCH";
            RelationshipRow.RelationKey  = PartnerRow.PartnerKey;

            MainDS.PPartnerRelationship.Rows.Add(RelationshipRow);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "add relationship record to church record");

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                                                                                "There was a critical error when saving:");

            // now deletion must not be possible since relationship as SUPPCHURCH exists
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(ChurchPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of church partner
            ChurchPartnerRow = TCreateTestPartnerData.CreateNewChurchPartner(MainDS);
            PartnerKey       = ChurchPartnerRow.PartnerKey;
            result           = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create church record for deletion");

            // check if church record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that church record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
Пример #9
0
        public void TestDeletePerson()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String               TextMessage;
            Boolean              CanDeletePartner;
            PPartnerRow          FamilyPartnerRow;
            PPartnerRow          UnitPartnerRow;
            PPersonRow           PersonRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            // create new family, location and person
            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            TCreateTestPartnerData.CreateNewLocation(FamilyPartnerRow.PartnerKey, MainDS);
            PersonRow = TCreateTestPartnerData.CreateNewPerson(MainDS,
                                                               FamilyPartnerRow.PartnerKey,
                                                               MainDS.PLocation[0].LocationKey,
                                                               "Mike",
                                                               "Mr",
                                                               0);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create family and person record");

            // check if Family partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(PersonRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // add a commitment for the person which means the person is not allowed to be deleted any longer
            UnitPartnerRow = TCreateTestPartnerData.CreateNewUnitPartner(MainDS);
            PmStaffDataTable CommitmentTable = new PmStaffDataTable();
            PmStaffDataRow   CommitmentRow   = CommitmentTable.NewRowTyped();

            CommitmentRow.Key               = Convert.ToInt32(TSequenceWebConnector.GetNextSequence(TSequenceNames.seq_staff_data));
            CommitmentRow.PartnerKey        = PersonRow.PartnerKey;
            CommitmentRow.StartOfCommitment = DateTime.Today.Date;
            CommitmentRow.EndOfCommitment   = DateTime.Today.AddDays(90).Date;
            CommitmentRow.OfficeRecruitedBy = UnitPartnerRow.PartnerKey;
            CommitmentRow.HomeOffice        = UnitPartnerRow.PartnerKey;
            CommitmentRow.ReceivingField    = UnitPartnerRow.PartnerKey;
            CommitmentTable.Rows.Add(CommitmentRow);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create unit to be used in commitment");
            PmStaffDataAccess.SubmitChanges(CommitmentTable, DBAccess.GDBAccessObj.Transaction);

            // this should now not be allowed since person record has a commitment linked to it
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(PersonRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of Person partner
            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            TCreateTestPartnerData.CreateNewLocation(FamilyPartnerRow.PartnerKey, MainDS);
            PersonRow = TCreateTestPartnerData.CreateNewPerson(MainDS,
                                                               FamilyPartnerRow.PartnerKey,
                                                               MainDS.PLocation[0].LocationKey,
                                                               "Mary",
                                                               "Mrs",
                                                               0);
            PartnerKey = PersonRow.PartnerKey;

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create family and person record to be deleted");

            // check if Family record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that Family record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
Пример #10
0
        public void TestDeleteFamily()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String               TextMessage;
            Boolean              CanDeletePartner;
            PPartnerRow          FamilyPartnerRow;
            PFamilyRow           FamilyRow;
            PPersonRow           PersonRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            result           = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "Create family record");

            // check if Family partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(FamilyPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // add a person to the family which means the family is not allowed to be deleted any longer
            FamilyRow = (PFamilyRow)MainDS.PFamily.Rows[0];
            FamilyRow.FamilyMembers = true;
            TCreateTestPartnerData.CreateNewLocation(FamilyPartnerRow.PartnerKey, MainDS);
            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create new location");

            PartnerEditTDS PersonDS = new PartnerEditTDS();

            PersonRow = TCreateTestPartnerData.CreateNewPerson(PersonDS, FamilyPartnerRow.PartnerKey,
                                                               MainDS.PLocation[0].LocationKey, "Adam", "Mr", 0);
            PersonRow.FamilyKey = FamilyPartnerRow.PartnerKey;
            result = connector.SubmitChanges(ref PersonDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create person record");

            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(FamilyPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);


            // create new family and create subscription given as gift from this family: not allowed to be deleted
            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            PPublicationTable PublicationTable = PPublicationAccess.LoadByPrimaryKey("TESTPUBLICATION", DBAccess.GDBAccessObj.Transaction);

            if (PublicationTable.Count == 0)
            {
                // first check if frequency "Annual" exists and if not then create it
                if (!AFrequencyAccess.Exists("Annual", DBAccess.GDBAccessObj.Transaction))
                {
                    // set up details (e.g. bank account) for this Bank so deletion is not allowed
                    AFrequencyTable FrequencyTable = new AFrequencyTable();
                    AFrequencyRow   FrequencyRow   = FrequencyTable.NewRowTyped();
                    FrequencyRow.FrequencyCode        = "Annual";
                    FrequencyRow.FrequencyDescription = "Annual Frequency";
                    FrequencyTable.Rows.Add(FrequencyRow);

                    AFrequencyAccess.SubmitChanges(FrequencyTable, DBAccess.GDBAccessObj.Transaction);
                }

                // now add the publication "TESTPUBLICATION"
                PPublicationRow PublicationRow = PublicationTable.NewRowTyped();
                PublicationRow.PublicationCode = "TESTPUBLICATION";
                PublicationRow.FrequencyCode   = "Annual";
                PublicationTable.Rows.Add(PublicationRow);

                PPublicationAccess.SubmitChanges(PublicationTable, DBAccess.GDBAccessObj.Transaction);
            }

            // make sure that "reason subscription given" exists
            if (!PReasonSubscriptionGivenAccess.Exists("FREE", DBAccess.GDBAccessObj.Transaction))
            {
                // set up details (e.g. bank account) for this Bank so deletion is not allowed
                PReasonSubscriptionGivenTable ReasonTable = new PReasonSubscriptionGivenTable();
                PReasonSubscriptionGivenRow   ReasonRow   = ReasonTable.NewRowTyped();
                ReasonRow.Code        = "FREE";
                ReasonRow.Description = "Free Subscription";
                ReasonTable.Rows.Add(ReasonRow);

                PReasonSubscriptionGivenAccess.SubmitChanges(ReasonTable, DBAccess.GDBAccessObj.Transaction);
            }

            // now add the publication "TESTPUBLICATION" to the first family record and indicate it was a gift from newly created family record
            PSubscriptionRow SubscriptionRow = MainDS.PSubscription.NewRowTyped();

            SubscriptionRow.PublicationCode     = "TESTPUBLICATION";
            SubscriptionRow.PartnerKey          = FamilyRow.PartnerKey;        // link subscription with original family
            SubscriptionRow.GiftFromKey         = FamilyPartnerRow.PartnerKey; // indicate that subscription is a gift from newly created family
            SubscriptionRow.ReasonSubsGivenCode = "FREE";
            MainDS.PSubscription.Rows.Add(SubscriptionRow);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "add publication to family record");

            // this should now not be allowed since partner record has a subscription linked to it
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(FamilyPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of Family partner
            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            PartnerKey       = FamilyPartnerRow.PartnerKey;
            result           = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create family record");

            // check if Family record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that Family record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
Пример #11
0
        public void TestRecurringBatchLoadingRecalculations()
        {
            TVerificationResultCollection VerificationResult;

            Int64 RecipientKey;
            Int64 RealRecipientLedgerNumber;
            Int64 FalseRecipientLedgerNumber;
            Int32 RecurringGiftBatchNumber;

            //
            // Arrange: Create all data needed for this test (Recurring Gift Detail will have 'fake' RecipientLedgerNumber)
            //
            TestRecurringBatchSubmitRecalculations_Arrange(out RecipientKey, out RealRecipientLedgerNumber,
                                                           out FalseRecipientLedgerNumber, out RecurringGiftBatchNumber);

            //
            // Act: Load the batch
            //
            GiftBatchTDS GiftBatchDS = TGiftTransactionWebConnector.LoadARecurringGiftBatchAndRelatedData(FLedgerNumber, RecurringGiftBatchNumber);

            //
            // Assert
            //

            // Initial Assert: Tests that the load returns results
            Assert.IsNotNull(GiftBatchDS, "TestRecurringBatchLoadingRecalculations fail: Loading GiftBatch failed");
            Assert.IsNotNull(GiftBatchDS.ARecurringGiftDetail, "TestRecurringBatchLoadingRecalculations fail: Loading GiftBatch failed");

            // Primary Assert: Chaeck that the gift has the correct RecipientLedgerNumber
            TDBTransaction          Transaction            = null;
            ARecurringGiftDetailRow RecurringGiftDetailRow = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                      TEnforceIsolationLevel.eilMinimum,
                                                                      ref Transaction,
                                                                      delegate
            {
                RecurringGiftDetailRow =
                    ARecurringGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, RecurringGiftBatchNumber, 1, 1, Transaction)[0];
            });

            Assert.IsNotNull(
                RecurringGiftDetailRow, "TestRecurringBatchLoadingRecalculations fail: Obtaining RecurringGiftDetailRow from database failed");

            Assert.AreEqual(RealRecipientLedgerNumber, RecurringGiftDetailRow.RecipientLedgerNumber,
                            "TestRecurringBatchLoadingRecalculations fail: RecipientLedgerNumber for RecurringGiftDetailRow is incorrect");

            // Cleanup: Delete test records

            bool SubmissionOK = true;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable,
                                                                  TEnforceIsolationLevel.eilMinimum,
                                                                  ref Transaction,
                                                                  ref SubmissionOK,
                                                                  delegate
            {
                ARecurringGiftDetailAccess.DeleteRow(ARecurringGiftDetailTable.TableId, RecurringGiftDetailRow, Transaction);
            });

            TPartnerWebConnector.DeletePartner(RecipientKey, out VerificationResult);
            TPartnerWebConnector.DeletePartner(RealRecipientLedgerNumber, out VerificationResult);
            TPartnerWebConnector.DeletePartner(FalseRecipientLedgerNumber, out VerificationResult);
        }
Пример #12
0
        public void TestRecurringBatchSubmitRecalculations()
        {
            TVerificationResultCollection VerificationResult;

            Int64 RecipientKey;
            Int64 RealRecipientLedgerNumber;
            Int64 FalseRecipientLedgerNumber;
            Int32 RecurringGiftBatchNumber;
            Int32 GiftBatchNumber = -1;

            //
            // Arrange: Create all data needed for this test (Recurring Gift Detail will have 'fake' RecipientLedgerNumber)
            //
            TestRecurringBatchSubmitRecalculations_Arrange(out RecipientKey, out RealRecipientLedgerNumber,
                                                           out FalseRecipientLedgerNumber, out RecurringGiftBatchNumber);

            //
            // Act: Submit the batch
            //

            Hashtable requestParams = new Hashtable();

            requestParams.Add("ALedgerNumber", FLedgerNumber);
            requestParams.Add("ABatchNumber", RecurringGiftBatchNumber);
            requestParams.Add("AEffectiveDate", DateTime.Today);
            requestParams.Add("AExchangeRateToBase", (decimal)1);
            requestParams.Add("AExchangeRateIntlToBase", (decimal)1);

            TGiftTransactionWebConnector.SubmitRecurringGiftBatch(requestParams);

            //
            // Assert
            //

            // Primary Assert: Chaeck that the RecurringGiftDetail and the newly created GiftDetail have the correct RecipientLedgerNumber
            TDBTransaction          Transaction            = null;
            ARecurringGiftDetailRow RecurringGiftDetailRow = null;
            AGiftDetailRow          GiftDetailRow          = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.Serializable,
                                                                      TEnforceIsolationLevel.eilMinimum,
                                                                      ref Transaction,
                                                                      delegate
            {
                RecurringGiftDetailRow =
                    ARecurringGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, RecurringGiftBatchNumber, 1, 1, Transaction)[0];

                GiftBatchNumber = ALedgerAccess.LoadByPrimaryKey(FLedgerNumber, Transaction)[0].LastGiftBatchNumber;
                GiftDetailRow   = AGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, GiftBatchNumber, 1, 1, Transaction)[0];
            });

            Assert.IsNotNull(
                RecurringGiftDetailRow, "TestRecurringBatchSubmitRecalculations fail: Obtaining RecurringGiftDetailRow from database failed");
            Assert.IsNotNull(
                GiftDetailRow, "TestRecurringBatchSubmitRecalculations fail: Obtaining GiftDetailRow from database failed");

            Assert.AreEqual(RealRecipientLedgerNumber, RecurringGiftDetailRow.RecipientLedgerNumber,
                            "TestRecurringBatchSubmitRecalculations fail: RecipientLedgerNumber for RecurringGiftDetailRow is incorrect");
            Assert.AreEqual(RealRecipientLedgerNumber, GiftDetailRow.RecipientLedgerNumber,
                            "TestRecurringBatchSubmitRecalculations fail: RecipientLedgerNumber for GiftDetailRow is incorrect");

            // Cleanup: Delete test records

            bool SubmissionOK = true;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable,
                                                                  TEnforceIsolationLevel.eilMinimum,
                                                                  ref Transaction,
                                                                  ref SubmissionOK,
                                                                  delegate
            {
                AGiftDetailAccess.DeleteRow(AGiftDetailTable.TableId, GiftDetailRow, Transaction);
                ARecurringGiftDetailAccess.DeleteRow(ARecurringGiftDetailTable.TableId, RecurringGiftDetailRow, Transaction);
            });

            TPartnerWebConnector.DeletePartner(RecipientKey, out VerificationResult);
            TPartnerWebConnector.DeletePartner(RealRecipientLedgerNumber, out VerificationResult);
            TPartnerWebConnector.DeletePartner(FalseRecipientLedgerNumber, out VerificationResult);
        }
Пример #13
0
        public void TestBatchLoadingRecalculations()
        {
            TVerificationResultCollection VerificationResult;

            Int64        RecipientKey;
            Int64        RealRecipientLedgerNumber;
            Int64        FalseRecipientLedgerNumber;
            const string REALCOSTCENTRECODE  = "4300";
            const string FALSECOSTCENTRECODE = "3500";
            Int32        GiftBatchNumber;

            //
            // Arrange: Create all data needed for this test (Gift Detail has a 'fake' RecipientLedgerNumber and CostCentreCode)
            //
            TestBatchPostingRecalculations_Arrange(out RecipientKey, out RealRecipientLedgerNumber,
                                                   out FalseRecipientLedgerNumber, REALCOSTCENTRECODE, FALSECOSTCENTRECODE, out GiftBatchNumber);

            //
            // Act: Load the batch
            //
            GiftBatchTDS GiftBatchDS = TGiftTransactionWebConnector.LoadAGiftBatchAndRelatedData(FLedgerNumber, GiftBatchNumber);

            //
            // Assert
            //

            // Initial Assert: Tests that the load returns results
            Assert.IsNotNull(GiftBatchDS, "TestBatchLoadingRecalculations fail: Loading GiftBatch failed");
            Assert.IsNotNull(GiftBatchDS.AGiftDetail, "TestBatchLoadingRecalculations fail: Loading GiftBatch failed");

            // Primary Assert: Chaeck that the gift has the correct RecipientLedgerNumber and CostCentreCode
            TDBTransaction Transaction           = null;
            AGiftDetailRow PositiveGiftDetailRow = null;
            AGiftDetailRow NegativeGiftDetailRow = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                      TEnforceIsolationLevel.eilMinimum,
                                                                      ref Transaction,
                                                                      delegate
            {
                PositiveGiftDetailRow = AGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, GiftBatchNumber, 1, 1, Transaction)[0];
                NegativeGiftDetailRow = AGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, GiftBatchNumber, 2, 1, Transaction)[0];
            });

            Assert.IsNotNull(PositiveGiftDetailRow, "TestBatchPostingRecalculations fail: Obtaining PositiveGiftDetailRow from database failed");
            Assert.IsNotNull(NegativeGiftDetailRow, "TestBatchPostingRecalculations fail: Obtaining NegativeGiftDetailRow from database failed");

            Assert.AreEqual(RealRecipientLedgerNumber, PositiveGiftDetailRow.RecipientLedgerNumber,
                            "TestBatchPostingRecalculations fail: RecipientLedgerNumber for PositiveGiftDetailRow is incorrect");
            Assert.AreEqual(FalseRecipientLedgerNumber, NegativeGiftDetailRow.RecipientLedgerNumber,
                            "TestBatchPostingRecalculations fail: RecipientLedgerNumber for NegativeGiftDetailRow is incorrect");
            Assert.AreEqual(REALCOSTCENTRECODE, PositiveGiftDetailRow.CostCentreCode,
                            "TestBatchPostingRecalculations fail: CostCentreCode for PositiveGiftDetailRow is incorrect");
            Assert.AreEqual(FALSECOSTCENTRECODE, NegativeGiftDetailRow.CostCentreCode,
                            "TestBatchPostingRecalculations fail: CostCentreCode for NegativeGiftDetailRow is incorrect");

            // Cleanup: Delete test records

            bool SubmissionOK = true;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable,
                                                                  TEnforceIsolationLevel.eilMinimum,
                                                                  ref Transaction,
                                                                  ref SubmissionOK,
                                                                  delegate
            {
                AGiftDetailAccess.DeleteRow(AGiftDetailTable.TableId, PositiveGiftDetailRow, Transaction);
                AGiftDetailAccess.DeleteRow(AGiftDetailTable.TableId, NegativeGiftDetailRow, Transaction);
            });

            TPartnerWebConnector.DeletePartner(RecipientKey, out VerificationResult);
            TPartnerWebConnector.DeletePartner(RealRecipientLedgerNumber, out VerificationResult);
            TPartnerWebConnector.DeletePartner(FalseRecipientLedgerNumber, out VerificationResult);
        }
Пример #14
0
        public void TestBatchPostingRecalculations()
        {
            TVerificationResultCollection VerificationResult;

            Int64        RecipientKey;
            Int64        RealRecipientLedgerNumber;
            Int64        FalseRecipientLedgerNumber;
            const string REALCOSTCENTRECODE  = "4300";
            const string FALSECOSTCENTRECODE = "3500";
            const string ACCOUNTCODE         = "0100";

            Int32 GiftBatchNumber;

            //
            // Arrange: Create all data needed for this test (Gift Details have 'fake' RecipientLedgerNumber and CostCentreCode)
            //
            TestBatchPostingRecalculations_Arrange(out RecipientKey, out RealRecipientLedgerNumber,
                                                   out FalseRecipientLedgerNumber, REALCOSTCENTRECODE, FALSECOSTCENTRECODE, out GiftBatchNumber);

            //
            // Act: Post the batch
            //
            bool result = TGiftTransactionWebConnector.PostGiftBatch(FLedgerNumber, GiftBatchNumber, out VerificationResult);

            //
            // Assert
            //

            // Initial Assert: Tests that the post returns positive
            Assert.AreEqual(true,
                            result,
                            "TestBatchPostingRecalculations fail: Posting GiftBatch failed: " + VerificationResult.BuildVerificationResultString());

            // Primary Assert: Chaeck that the gifts have the correct RecipientLedgerNumber, CostCentreCode and Account
            TDBTransaction  Transaction           = null;
            AGiftDetailRow  PositiveGiftDetailRow = null;
            AGiftDetailRow  NegativeGiftDetailRow = null;
            ATransactionRow TransactionRow        = null;
            Int32           GLBatchNumber         = -1;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                      TEnforceIsolationLevel.eilMinimum,
                                                                      ref Transaction,
                                                                      delegate
            {
                PositiveGiftDetailRow = AGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, GiftBatchNumber, 1, 1, Transaction)[0];
                NegativeGiftDetailRow = AGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, GiftBatchNumber, 2, 1, Transaction)[0];

                GLBatchNumber  = ALedgerAccess.LoadByPrimaryKey(FLedgerNumber, Transaction)[0].LastBatchNumber;
                TransactionRow = ATransactionAccess.LoadByPrimaryKey(FLedgerNumber, GLBatchNumber, 1, 1, Transaction)[0];
            });

            Assert.IsNotNull(PositiveGiftDetailRow, "TestBatchPostingRecalculations fail: Obtaining PositiveGiftDetailRow from database failed");
            Assert.IsNotNull(NegativeGiftDetailRow, "TestBatchPostingRecalculations fail: Obtaining NegativeGiftDetailRow from database failed");
            Assert.IsNotNull(TransactionRow, "TestBatchPostingRecalculations fail: Obtaining Transaction from database failed");

            Assert.AreEqual(RealRecipientLedgerNumber, PositiveGiftDetailRow.RecipientLedgerNumber,
                            "TestBatchPostingRecalculations fail: RecipientLedgerNumber for PositiveGiftDetailRow is incorrect");
            Assert.AreEqual(FalseRecipientLedgerNumber, NegativeGiftDetailRow.RecipientLedgerNumber,
                            "TestBatchPostingRecalculations fail: RecipientLedgerNumber for NegativeGiftDetailRow is incorrect");
            Assert.AreEqual(REALCOSTCENTRECODE, PositiveGiftDetailRow.CostCentreCode,
                            "TestBatchPostingRecalculations fail: CostCentreCode for PositiveGiftDetailRow is incorrect");
            Assert.AreEqual(FALSECOSTCENTRECODE, NegativeGiftDetailRow.CostCentreCode,
                            "TestBatchPostingRecalculations fail: CostCentreCode for NegativeGiftDetailRow is incorrect");
            Assert.AreEqual(ACCOUNTCODE, TransactionRow.AccountCode,
                            "TestBatchPostingRecalculations fail: AccountCode for PositiveGiftDetailRow is incorrect");

            // Cleanup: Delete test records

            bool SubmissionOK = true;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable,
                                                                  TEnforceIsolationLevel.eilMinimum,
                                                                  ref Transaction,
                                                                  ref SubmissionOK,
                                                                  delegate
            {
                AProcessedFeeAccess.DeleteUsingTemplate(
                    new TSearchCriteria[] { new TSearchCriteria("a_ledger_number_i", FLedgerNumber),
                                            new TSearchCriteria("a_batch_number_i", GiftBatchNumber) },
                    Transaction);

                AGiftDetailAccess.DeleteRow(AGiftDetailTable.TableId, PositiveGiftDetailRow, Transaction);
                AGiftDetailAccess.DeleteRow(AGiftDetailTable.TableId, NegativeGiftDetailRow, Transaction);
            });

            TPartnerWebConnector.DeletePartner(RecipientKey, out VerificationResult);
            TPartnerWebConnector.DeletePartner(RealRecipientLedgerNumber, out VerificationResult);
            TPartnerWebConnector.DeletePartner(FalseRecipientLedgerNumber, out VerificationResult);
        }
Пример #15
0
        public static bool DeleteAllPartners(
            out TVerificationResultCollection AVerificationResult)
        {
            string ErrorMsg = String.Empty;
            TVerificationResultCollection VerificationResult = new TVerificationResultCollection();

            List <Int64> PartnersToDelete = new List <Int64>();

            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(ref Transaction,
                                     delegate
            {
                PPartnerTable partners = PPartnerAccess.LoadAll(Transaction);

                foreach (PPartnerRow row in partners.Rows)
                {
                    if (row.PartnerClass == "FAMILY" || row.PartnerClass == "ORGANISATION")
                    {
                        if (!TPartnerWebConnector.CanPartnerBeDeleted(row.PartnerKey, out ErrorMsg, Transaction.DataBaseObj))
                        {
                            VerificationResult.Add(new TVerificationResult("error", ErrorMsg + " " + row.PartnerKey.ToString(), TResultSeverity.Resv_Critical));
                            break;
                        }

                        PartnersToDelete.Add(row.PartnerKey);
                    }
                }
            });

            if (VerificationResult.HasCriticalErrors)
            {
                AVerificationResult = new TVerificationResultCollection(VerificationResult);
                return(false);
            }

            Transaction = new TDBTransaction();
            bool Submit = false;

            DBAccess.WriteTransaction(ref Transaction,
                                      ref Submit,
                                      delegate
            {
                foreach (Int64 PartnerKey in PartnersToDelete)
                {
                    if (!TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult, Transaction.DataBaseObj))
                    {
                        break;
                    }
                }

                if (!VerificationResult.HasCriticalErrors)
                {
                    Submit = true;
                }
            });

            if (VerificationResult.HasCriticalErrors)
            {
                AVerificationResult = new TVerificationResultCollection(VerificationResult);
                return(false);
            }

            AVerificationResult = new TVerificationResultCollection();
            return(true);
        }