Exemplo n.º 1
0
        public static PBankingDetailsTable GetPartnerBankingDetails(long AFromPartnerKey, long AToPartnerKey)
        {
            PBankingDetailsTable ReturnTable = new PBankingDetailsTable();
            TDBTransaction       Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                           ref Transaction,
                                                           delegate
            {
                PBankingDetailsTable FromBankingDetailsTable = PBankingDetailsAccess.LoadViaPPartner(AFromPartnerKey, Transaction);
                PBankingDetailsTable ToBankingDetailsTable   = PBankingDetailsAccess.LoadViaPPartner(AToPartnerKey, Transaction);

                // clone the data in each table and add them to a new table to combine the data

                foreach (DataRow Row in FromBankingDetailsTable.Rows)
                {
                    object[] RowArray      = Row.ItemArray;
                    object[] RowArrayClone = (object[])RowArray.Clone();
                    DataRow RowClone       = ReturnTable.NewRowTyped(false);
                    RowClone.ItemArray     = RowArrayClone;
                    ReturnTable.Rows.Add(RowClone);
                }

                foreach (DataRow Row in ToBankingDetailsTable.Rows)
                {
                    object[] RowArray      = Row.ItemArray;
                    object[] RowArrayClone = (object[])RowArray.Clone();
                    DataRow RowClone       = ReturnTable.NewRowTyped(false);
                    RowClone.ItemArray     = RowArrayClone;
                    ReturnTable.Rows.Add(RowClone);
                }
            });

            return(ReturnTable);
        }
Exemplo n.º 2
0
        public static int CanFamilyMergeIntoDifferentClass(long APartnerKey)
        {
            int            ReturnValue = 0;
            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                           ref Transaction,
                                                           delegate
            {
                PPersonTable PersonTable = PPersonAccess.LoadViaPFamily(APartnerKey, Transaction);

                if (PersonTable.Rows.Count > 0)
                {
                    ReturnValue = 1;
                }

                AGiftDetailTable GiftDetailTable = AGiftDetailAccess.LoadViaPPartnerRecipientKey(APartnerKey, Transaction);

                if (GiftDetailTable.Rows.Count > 0)
                {
                    ReturnValue = 2;
                }

                PBankingDetailsTable BankingDetailsTable = PBankingDetailsAccess.LoadViaPPartner(APartnerKey, Transaction);

                if (BankingDetailsTable.Rows.Count > 0)
                {
                    ReturnValue = 3;
                }
            });

            return(ReturnValue);
        }
        public static PBankingDetailsTable GetBankingDetailsRow(int ABankingDetailsKey)
        {
            PBankingDetailsTable ReturnRow = null;

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                           ref Transaction,
                                                           delegate
            {
                ReturnRow = PBankingDetailsAccess.LoadByPrimaryKey(ABankingDetailsKey, Transaction);
            });

            return(ReturnRow);
        }
Exemplo n.º 4
0
        public static PBankingDetailsTable GetBankingDetailsRow(int ABankingDetailsKey)
        {
            PBankingDetailsTable ReturnRow = null;

            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(
                ref Transaction,
                delegate
            {
                ReturnRow = PBankingDetailsAccess.LoadByPrimaryKey(ABankingDetailsKey, Transaction);
            });

            return(ReturnRow);
        }
Exemplo n.º 5
0
        public static PBankingDetailsTable GetPartnerBankingDetails(long AFromPartnerKey, long AToPartnerKey)
        {
            TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            PBankingDetailsTable ReturnTable = new PBankingDetailsTable();

            try
            {
                PBankingDetailsTable FromBankingDetailsTable = PBankingDetailsAccess.LoadViaPPartner(AFromPartnerKey, Transaction);
                PBankingDetailsTable ToBankingDetailsTable   = PBankingDetailsAccess.LoadViaPPartner(AToPartnerKey, Transaction);

                // clone the data in each table and add them to a new table to combine the data

                foreach (DataRow Row in FromBankingDetailsTable.Rows)
                {
                    object[] RowArray      = Row.ItemArray;
                    object[] RowArrayClone = (object[])RowArray.Clone();
                    DataRow  RowClone      = ReturnTable.NewRowTyped(false);
                    RowClone.ItemArray = RowArrayClone;
                    ReturnTable.Rows.Add(RowClone);
                }

                foreach (DataRow Row in ToBankingDetailsTable.Rows)
                {
                    object[] RowArray      = Row.ItemArray;
                    object[] RowArrayClone = (object[])RowArray.Clone();
                    DataRow  RowClone      = ReturnTable.NewRowTyped(false);
                    RowClone.ItemArray = RowArrayClone;
                    ReturnTable.Rows.Add(RowClone);
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
            }
            finally
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
                TLogging.LogAtLevel(7, "TMergePartnersWebConnector.GetPartnerBankingDetails: rollback own transaction.");
            }

            return(ReturnTable);
        }
Exemplo n.º 6
0
        public static int CanFamilyMergeIntoDifferentClass(long APartnerKey)
        {
            TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            try
            {
                PPersonTable PersonTable = PPersonAccess.LoadViaPFamily(APartnerKey, Transaction);

                if (PersonTable.Rows.Count > 0)
                {
                    return(1);
                }

                AGiftDetailTable GiftDetailTable = AGiftDetailAccess.LoadViaPPartnerRecipientKey(APartnerKey, Transaction);

                if (GiftDetailTable.Rows.Count > 0)
                {
                    return(2);
                }

                PBankingDetailsTable BankingDetailsTable = PBankingDetailsAccess.LoadViaPPartner(APartnerKey, Transaction);

                if (BankingDetailsTable.Rows.Count > 0)
                {
                    return(3);
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
            }
            finally
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
                TLogging.LogAtLevel(7, "TMergePartnersWebConnector.CanFamilyMergeIntoDifferentClass: rollback own transaction.");
            }

            return(0);
        }
        public static PBankingDetailsTable GetBankingDetailsRow(int ABankingDetailsKey)
        {
            PBankingDetailsTable ReturnRow = null;
            TDBTransaction       ReadTransaction;
            Boolean NewTransaction;

            ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted,
                                                                                TEnforceIsolationLevel.eilMinimum,
                                                                                out NewTransaction);
            try
            {
                ReturnRow = PBankingDetailsAccess.LoadByPrimaryKey(ABankingDetailsKey, ReadTransaction);
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TPartnerDataReaderWebConnector.GetBankingDetailsRow: committed own transaction.");
                }
            }

            return(ReturnRow);
        }
Exemplo n.º 8
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));
        }
Exemplo n.º 9
0
        public static PartnerEditTDS GetPartnerDetails(Int64 APartnerKey,
                                                       out List <string> ASubscriptions,
                                                       out List <string> APartnerTypes,
                                                       out string ADefaultEmailAddress,
                                                       out string ADefaultPhoneMobile,
                                                       out string ADefaultPhoneLandline)
        {
            PartnerEditTDS MainDS               = new PartnerEditTDS();
            List <string>  Subscriptions        = new List <string>();
            List <string>  PartnerTypes         = new List <string>();
            string         DefaultEmailAddress  = String.Empty;
            string         DefaultPhoneMobile   = String.Empty;
            string         DefaultPhoneLandline = String.Empty;

            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(ref Transaction,
                                     delegate
            {
                PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                if (MainDS.PPartner.Rows.Count > 0)
                {
                    switch (MainDS.PPartner[0].PartnerClass)
                    {
                    case MPartnerConstants.PARTNERCLASS_FAMILY:
                        PFamilyAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_PERSON:
                        PPersonAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_CHURCH:
                        PChurchAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_ORGANISATION:
                        POrganisationAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_BANK:
                        PBankAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_UNIT:
                        PUnitAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;
                    }

                    if (true)
                    {
                        PPartnerLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                        PLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                    }

                    if (true)
                    {
                        PPartnerRelationshipAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);
                    }

                    if (true)
                    {
                        PCountryAccess.LoadAll(MainDS, Transaction);
                    }

                    if (true)
                    {
                        PPublicationAccess.LoadAll(MainDS, Transaction);
                        PSubscriptionAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);

                        foreach (PSubscriptionRow subscription in MainDS.PSubscription.Rows)
                        {
                            Subscriptions.Add(subscription.PublicationCode);
                        }
                    }

                    if (true)
                    {
                        PBankingDetailsAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                        PPartnerBankingDetailsAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                        PBankingDetailsUsageAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                        foreach (PartnerEditTDSPBankingDetailsRow banking in MainDS.PBankingDetails.Rows)
                        {
                            PBankAccess.LoadByPrimaryKey(MainDS, banking.BankKey, Transaction);
                            banking.Bic        = MainDS.PBank[0].Bic;
                            banking.BranchName = MainDS.PBank[0].BranchName;
                            banking.Iban       = FormatIBAN(banking.Iban);
                            MainDS.PBank.Rows.Clear();
                        }

                        foreach (PartnerEditTDSPBankingDetailsRow bd in MainDS.PBankingDetails.Rows)
                        {
                            bd.MainAccount =
                                (MainDS.PBankingDetailsUsage.Rows.Find(
                                     new object[] { APartnerKey, bd.BankingDetailsKey, MPartnerConstants.BANKINGUSAGETYPE_MAIN }) != null);
                        }

                        MainDS.PBankingDetailsUsage.Rows.Clear();
                    }

                    PPartnerStatusAccess.LoadAll(MainDS, Transaction);
                    PTypeRow templateRow   = MainDS.PType.NewRowTyped();
                    templateRow.SystemType = false;
                    templateRow.SetTypeDeletableNull();
                    templateRow.SetDateCreatedNull();
                    PTypeAccess.LoadUsingTemplate(MainDS, templateRow, Transaction);
                    PPartnerTypeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                    foreach (PPartnerTypeRow partnertype in MainDS.PPartnerType.Rows)
                    {
                        PartnerTypes.Add(partnertype.TypeCode);
                    }

                    PPartnerAttributeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                    foreach (PPartnerAttributeRow partnerattr in MainDS.PPartnerAttribute.Rows)
                    {
                        if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_EMAIL)
                        {
                            DefaultEmailAddress = partnerattr.Value;
                        }
                        else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_PHONE)
                        {
                            DefaultPhoneLandline = partnerattr.Value;
                        }
                        else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_MOBILE_PHONE)
                        {
                            DefaultPhoneMobile = partnerattr.Value;
                        }
                    }
                }
            });

            APartnerTypes         = PartnerTypes;
            ASubscriptions        = Subscriptions;
            ADefaultEmailAddress  = DefaultEmailAddress;
            ADefaultPhoneMobile   = DefaultPhoneMobile;
            ADefaultPhoneLandline = DefaultPhoneLandline;

            return(MainDS);
        }