Beispiel #1
0
        private DataTable GetInstalledSitesListTable(TDBTransaction AReadTransaction, string ATableName)
        {
            // Used eg. in New Partner Dialog.
            StringCollection RequiredColumns = new StringCollection();

            RequiredColumns.Add(PPartnerLedgerTable.GetPartnerKeyDBName());
            PPartnerLedgerTable TmpInstalledSitesDT = PPartnerLedgerAccess.LoadAll(RequiredColumns, AReadTransaction, null, 0, 0);

            if (TmpInstalledSitesDT.Rows.Count != 0)
            {
                TmpInstalledSitesDT.Columns.Remove(PPartnerLedgerTable.GetLastPartnerIdDBName());
                TmpInstalledSitesDT.Columns.Add(PPartnerTable.GetPartnerShortNameDBName(), System.Type.GetType("System.String"));
                RequiredColumns = new StringCollection();
                RequiredColumns.Add(PPartnerTable.GetPartnerShortNameDBName());

                for (int Counter = 0; Counter <= TmpInstalledSitesDT.Rows.Count - 1; Counter += 1)
                {
                    PPartnerTable PartnerDT = PPartnerAccess.LoadByPrimaryKey(
                        TmpInstalledSitesDT[Counter].PartnerKey,
                        RequiredColumns,
                        AReadTransaction,
                        null,
                        0,
                        0);
                    TmpInstalledSitesDT[Counter][PPartnerTable.GetPartnerShortNameDBName()] = PartnerDT[0].PartnerShortName;
                }
            }

            // As part of bug 5556 testing, checked if this DataTable contained any Added rows.  It didn't, so there isn't an issue here.
            // Findings: DataTable summary: 1 rows; 0 Added, 0 deleted, 0 detached, 1 modified, 0 unchanged.  Table name PPartnerLedger
            return(TmpInstalledSitesDT);
        }
Beispiel #2
0
        /// <summary>
        /// Tests whether the current user has access to a particular Partner.
        /// </summary>
        /// <remarks>Corresponds to Progress 4GL Method 'CanAccessPartner' in
        /// common/sp_partn.p</remarks>
        /// <param name="APartnerKey">PartnerKey of Partner for which access should
        /// be checked for.</param>
        /// <param name="AThrowExceptionIfDenied"></param>
        /// <param name="ADataBase">An instantiated <see cref="TDataBase" /> object, or null (default = null). If null
        /// gets passed then the Method executes DB commands with a new Database connection</param>
        /// <returns><see cref="TPartnerAccessLevelEnum.palGranted" /> if access
        /// to the Partner is granted (or Partner doesn't exist), otherwise a different
        /// <see cref="TPartnerAccessLevelEnum" /> value.</returns>
        public static TPartnerAccessLevelEnum CanAccessPartnerByKey(Int64 APartnerKey,
                                                                    bool AThrowExceptionIfDenied, TDataBase ADataBase = null)
        {
            TDBTransaction ReadTransaction;
            Boolean        NewTransaction;
            PPartnerTable  PartnerTable;

            if (APartnerKey != 0)
            {
                TDataBase db = DBAccess.Connect("DetermineBestAddress", ADataBase);
                ReadTransaction = db.GetNewOrExistingTransaction(
                    IsolationLevel.ReadCommitted,
                    out NewTransaction);

                // Load Partner
                try
                {
                    PartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);

                    if (PartnerTable.Rows.Count > 0)
                    {
                        // Partner exists, now check Access Level
                        if (!AThrowExceptionIfDenied)
                        {
                            return(CanAccessPartner(PartnerTable[0], ADataBase));
                        }
                        else
                        {
                            CanAccessPartnerExc(PartnerTable[0], ADataBase);

                            /*
                             * The previous Method call would throw an Exception
                             * in case access would not be granted and program execution
                             * would leave this Method at that point; if it doesn't
                             * then this implies that access is granted.
                             */
                            return(TPartnerAccessLevelEnum.palGranted);
                        }
                    }
                    else
                    {
                        // Partner not found. Access Level is Granted in this case.
                        return(TPartnerAccessLevelEnum.palGranted);
                    }
                }
                finally
                {
                    if (NewTransaction)
                    {
                        ReadTransaction.Commit();
                        TLogging.LogAtLevel(8, "TSecurity.CanAccessPartnerByKey: committed own transaction.");
                    }
                }
            }
            else
            {
                // Invalid Partner. Access Level is Granted in this case.
                return(TPartnerAccessLevelEnum.palGranted);
            }
        }
Beispiel #3
0
        private String PartnerShortName(Int64 partnerKey)
        {
            if (partnerKey > 0)
            {
                // Get Partner ShortName
                PPartnerTable pt = null;

                TDBTransaction Transaction = null;
                DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                          TEnforceIsolationLevel.eilMinimum,
                                                                          ref Transaction,
                                                                          delegate
                {
                    pt =
                        PPartnerAccess.LoadByPrimaryKey(partnerKey,
                                                        StringHelper.InitStrArr(new String[] { PPartnerTable.GetPartnerShortNameDBName() }),
                                                        Transaction, null, 0, 0);
                });

                if (pt.Rows.Count == 1)
                {
                    return(pt[0].PartnerShortName);
                }
            }

            return("");
        }
Beispiel #4
0
        public static bool GetPartnerReceiptingInfo(
            Int64 APartnerKey,
            out bool AReceiptEachGift,
            out String AReceiptLetterFrequency,
            out bool AEmailGiftStatement,
            out bool AAnonymousDonor)
        {
            TDBTransaction ReadTransaction = null;
            PPartnerTable  PartnerTbl      = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                      TEnforceIsolationLevel.eilMinimum, ref ReadTransaction,
                                                                      delegate
            {
                PartnerTbl = PPartnerAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);
            });

            if (PartnerTbl.Rows.Count > 0)
            {
                PPartnerRow Row = PartnerTbl[0];
                AReceiptEachGift        = Row.ReceiptEachGift;
                AReceiptLetterFrequency = Row.ReceiptLetterFrequency;
                AEmailGiftStatement     = Row.EmailGiftStatement;
                AAnonymousDonor         = Row.AnonymousDonor;
                return(true);
            }
            else
            {
                AReceiptEachGift        = false;
                AReceiptLetterFrequency = "";
                AEmailGiftStatement     = false;
                AAnonymousDonor         = false;
                return(false);
            }
        }
        private DataTable GetInstalledSitesListTable(TDBTransaction AReadTransaction, string ATableName)
        {
            // Used eg. in New Partner Dialog.
            StringCollection RequiredColumns = new StringCollection();

            RequiredColumns.Add(PPartnerLedgerTable.GetPartnerKeyDBName());
            PPartnerLedgerTable TmpInstalledSitesDT = PPartnerLedgerAccess.LoadAll(RequiredColumns, AReadTransaction, null, 0, 0);

            if (TmpInstalledSitesDT.Rows.Count != 0)
            {
                TmpInstalledSitesDT.Columns.Remove(PPartnerLedgerTable.GetLastPartnerIdDBName());
                TmpInstalledSitesDT.Columns.Add(PPartnerTable.GetPartnerShortNameDBName(), System.Type.GetType("System.String"));
                RequiredColumns = new StringCollection();
                RequiredColumns.Add(PPartnerTable.GetPartnerShortNameDBName());

                for (int Counter = 0; Counter <= TmpInstalledSitesDT.Rows.Count - 1; Counter += 1)
                {
                    PPartnerTable PartnerDT = PPartnerAccess.LoadByPrimaryKey(
                        TmpInstalledSitesDT[Counter].PartnerKey,
                        RequiredColumns,
                        AReadTransaction,
                        null,
                        0,
                        0);
                    TmpInstalledSitesDT[Counter][PPartnerTable.GetPartnerShortNameDBName()] = PartnerDT[0].PartnerShortName;
                }
            }

            return(TmpInstalledSitesDT);
        }
Beispiel #6
0
        /// <summary>
        /// returns the site name of the current site key,
        /// which is stored in s_system_parameter
        ///
        /// </summary>
        /// <returns>void</returns>
        private String GetSiteName()
        {
            String        ReturnValue = "";
            string        strSql;
            DataTable     tab;
            long          SiteKey = -1;
            PPartnerTable PartnerTable;

            strSql = "SELECT PUB_s_system_defaults.s_default_value_c " + "FROM PUB_s_system_defaults " +
                     "WHERE PUB_s_system_defaults.s_default_code_c = 'SiteKey'";

            tab = situation.GetDatabaseConnection().SelectDT(strSql, "table", situation.GetDatabaseConnection().Transaction);

            if (tab.Rows.Count > 0)
            {
                String SiteKeyString = Convert.ToString(tab.Rows[0]["s_default_value_c"]);
                try
                {
                    SiteKey = Convert.ToInt64(SiteKeyString);
                }
                catch (Exception)
                {
                    SiteKey = -1;
                }
            }

            PartnerTable = PPartnerAccess.LoadByPrimaryKey(SiteKey, situation.GetDatabaseConnection().Transaction);

            if (PartnerTable.Rows.Count > 0)
            {
                ReturnValue = (String)PartnerTable.Rows[0][PPartnerTable.GetPartnerShortNameDBName()];
            }

            return(ReturnValue);
        }
Beispiel #7
0
        /// <summary>
        /// Checks for the existance of a Partner.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of the Partner to check for.</param>
        /// <param name="AMustNotBeMergedPartner">Set to true to check whether the Partner
        /// must not be a Merged Partner.</param>
        /// <returns>An instance of PPartnerRow if the Partner exists (taking AMustNotBeMergedPartner into consideration),
        /// otherwise null.</returns>
        /// <param name="ADataBase">An instantiated <see cref="TDataBase" /> object, or null (default = null). If null
        /// gets passed then the Method executes DB commands with a new Database connection</param>
        public static PPartnerRow CheckPartnerExists2(Int64 APartnerKey, bool AMustNotBeMergedPartner,
                                                      TDataBase ADataBase = null)
        {
            PPartnerRow    ReturnValue     = null;
            TDBTransaction ReadTransaction = new TDBTransaction();
            PPartnerTable  PartnerTable    = null;

            if (APartnerKey != 0)
            {
                TDataBase db = DBAccess.Connect("CheckPartnerExists2", ADataBase);
                db.ReadTransaction(ref ReadTransaction,
                                   delegate
                {
                    PartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);
                });

                if (PartnerTable.Rows.Count != 0)
                {
                    if (AMustNotBeMergedPartner)
                    {
                        if (SharedTypes.StdPartnerStatusCodeStringToEnum(
                                PartnerTable[0].StatusCode) != TStdPartnerStatusCode.spscMERGED)
                        {
                            ReturnValue = PartnerTable[0];
                        }
                    }
                    else
                    {
                        ReturnValue = PartnerTable[0];
                    }
                }
            }

            return(ReturnValue);
        }
Beispiel #8
0
        } // ExportAllGiftBatchData

        private String PartnerShortName(Int64 partnerKey)
        {
            if (partnerKey > 0)
            {
                // Get Partner ShortName
                PPartnerTable pt = null;

                TDBTransaction Transaction = new TDBTransaction();
                TDataBase      db          = DBAccess.Connect("PartnerShortName");
                db.ReadTransaction(
                    ref Transaction,
                    delegate
                {
                    pt =
                        PPartnerAccess.LoadByPrimaryKey(partnerKey,
                                                        StringHelper.InitStrArr(new String[] { PPartnerTable.GetPartnerShortNameDBName() }),
                                                        Transaction, null, 0, 0);
                });

                if (pt.Rows.Count == 1)
                {
                    return(pt[0].PartnerShortName);
                }
            }

            return("");
        }
Beispiel #9
0
        public static Boolean GetConferenceApplications(ref ConferenceApplicationTDS AMainDS, Int64 AConferenceKey)
        {
            // make sure outreach codes are up to date in case it has changed in Unit record
            TAttendeeManagement.RefreshOutreachCode(AConferenceKey);

            TDataBase      db = DBAccess.Connect("GetConferenceApplications");
            TDBTransaction ReadTransaction = db.BeginTransaction(IsolationLevel.ReadCommitted);

            PcConferenceTable ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, ReadTransaction);

            if (ConferenceTable.Count == 0)
            {
                ReadTransaction.Rollback();
                throw new Exception("Cannot find conference " + AConferenceKey.ToString("0000000000"));
            }

            string OutreachPrefix = ConferenceTable[0].OutreachPrefix;

            // load application data for all conference attendees from db
            TApplicationManagement.GetApplications(ref AMainDS, AConferenceKey, OutreachPrefix, "all", -1, true, null, false);

            // obtain PPartner records for all the home offices
            foreach (PcAttendeeRow AttendeeRow in AMainDS.PcAttendee.Rows)
            {
                if (AMainDS.PPartner.Rows.Find(new object[] { AttendeeRow.HomeOfficeKey }) == null)
                {
                    PPartnerAccess.LoadByPrimaryKey(AMainDS, AttendeeRow.HomeOfficeKey, ReadTransaction);
                }
            }

            ReadTransaction.Rollback();

            return(true);
        }
        public static PPartnerTable SharedBankAccountPartners(int ABankingDetailsKey, long APartnerKey)
        {
            PPartnerTable PartnerTable = new PPartnerTable();

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                           ref Transaction,
                                                           delegate
            {
                PPartnerBankingDetailsTable PartnerBankingDetailsTable = PPartnerBankingDetailsAccess.LoadViaPBankingDetails(ABankingDetailsKey,
                                                                                                                             Transaction);

                foreach (PPartnerBankingDetailsRow Row in PartnerBankingDetailsTable.Rows)
                {
                    // if record exists with a different partner key then the Bank Account is shared
                    if (Row.PartnerKey != APartnerKey)
                    {
                        PPartnerRow PartnerRow = (PPartnerRow)PPartnerAccess.LoadByPrimaryKey(Row.PartnerKey, Transaction).Rows[0];

                        PPartnerRow NewRow      = PartnerTable.NewRowTyped(false);
                        NewRow.PartnerKey       = Row.PartnerKey;
                        NewRow.PartnerShortName = PartnerRow.PartnerShortName;
                        PartnerTable.Rows.Add(NewRow);
                    }
                }
            });

            return(PartnerTable);
        }
        public static bool GetGiftsForFieldChangeAdjustment(ref GiftBatchTDS AGiftDS, Int32 ALedgerNumber,
                                                            Int64 ARecipientKey,
                                                            DateTime AStartDate,
                                                            DateTime AEndDate,
                                                            Int64 AOldField,
                                                            out TVerificationResultCollection AMessages)
        {
            TDBTransaction Transaction = new TDBTransaction();
            TDataBase      db          = DBAccess.Connect("GetGiftsForFieldChangeAdjustment");
            GiftBatchTDS   MainDS      = new GiftBatchTDS();

            AMessages = new TVerificationResultCollection();

            db.ReadTransaction(
                ref Transaction,
                delegate
            {
                string SqlStmt = TDataBase.ReadSqlFile("Gift.GetGiftsToAdjustField.sql");

                List <OdbcParameter> parameters = new List <OdbcParameter>();
                OdbcParameter param             = new OdbcParameter("LedgerNumber", OdbcType.Int);
                param.Value = ALedgerNumber;
                parameters.Add(param);
                param       = new OdbcParameter("StartDate", OdbcType.Date);
                param.Value = AStartDate;
                parameters.Add(param);
                param       = new OdbcParameter("EndDate", OdbcType.Date);
                param.Value = AEndDate;
                parameters.Add(param);
                param       = new OdbcParameter("RecipientKey", OdbcType.BigInt);
                param.Value = ARecipientKey;
                parameters.Add(param);
                param       = new OdbcParameter("OldField", OdbcType.BigInt);
                param.Value = AOldField;
                parameters.Add(param);

                db.Select(MainDS, SqlStmt, MainDS.AGiftDetail.TableName, Transaction, parameters.ToArray());

                // get additional data
                foreach (GiftBatchTDSAGiftDetailRow Row in MainDS.AGiftDetail.Rows)
                {
                    AGiftBatchAccess.LoadByPrimaryKey(MainDS, Row.LedgerNumber, Row.BatchNumber, Transaction);
                    AGiftRow GiftRow =
                        AGiftAccess.LoadByPrimaryKey(MainDS, Row.LedgerNumber, Row.BatchNumber, Row.GiftTransactionNumber, Transaction);

                    Row.DateEntered = GiftRow.DateEntered;
                    Row.DonorKey    = GiftRow.DonorKey;
                    Row.IchNumber   = 0;
                    Row.DonorName   = PPartnerAccess.LoadByPrimaryKey(Row.DonorKey, Transaction)[0].PartnerShortName;
                }
            });

            AGiftDS = MainDS;

            db.CloseDBConnection();

            return(CheckGiftsNotPreviouslyReversed(AGiftDS, out AMessages));
        }
Beispiel #12
0
        /// <summary>
        /// Load all the data of a partner into a TDS
        /// </summary>
        public static PartnerImportExportTDS ExportPartner(Int64 APartnerKey)
        {
            PartnerImportExportTDS MainDS      = new PartnerImportExportTDS();
            TDBTransaction         Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            PChurchAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            PFamilyAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            PPersonAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            POrganisationAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            PUnitAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            PVenueAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

            PLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
            PPartnerLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

            PPartnerCommentAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
            PPartnerTypeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
            PPartnerInterestAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
            PPartnerGiftDestinationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

            PInterestAccess.LoadAll(MainDS, Transaction);

            PmPersonalDataAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            PmPassportDetailsAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmDocumentAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
            PmDocumentTypeAccess.LoadAll(MainDS, Transaction);
            PmPersonQualificationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmSpecialNeedAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmPastExperienceAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmPersonLanguageAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmPersonAbilityAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmJobAssignmentAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
            PmPersonEvaluationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);

            PmGeneralApplicationAccess.LoadViaPPersonPartnerKey(MainDS, APartnerKey, Transaction);
            PtApplicationTypeAccess.LoadAll(MainDS, Transaction);
            PmShortTermApplicationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmYearProgramApplicationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);

            UmUnitStructureAccess.LoadViaPUnitChildUnitKey(MainDS, APartnerKey, Transaction);
            UmUnitAbilityAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
            UmUnitLanguageAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
            UmUnitCostAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
            UmJobAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
            UmJobRequirementAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
            UmJobLanguageAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
            UmJobQualificationAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);

            PcBuildingAccess.LoadViaPVenue(MainDS, APartnerKey, Transaction);
            PcRoomAccess.LoadViaPVenue(MainDS, APartnerKey, Transaction);

            DBAccess.GDBAccessObj.RollbackTransaction();
            return(MainDS);
        }
Beispiel #13
0
        private static PartnerDetails GetRecipient(Int64 APartnerKey)
        {
            if (RecipientList.ContainsKey(APartnerKey))
            {
                return(RecipientList[APartnerKey]);
            }

            PartnerDetails Ret        = new PartnerDetails();
            PPartnerTable  PartnerTbl = PPartnerAccess.LoadByPrimaryKey(APartnerKey, FTransaction);

            if (PartnerTbl.Rows.Count > 0)
            {
                PPartnerRow PartnerRow = PartnerTbl[0];

                Ret.LastName = PartnerRow.PartnerShortName;

                if (PartnerRow.PartnerClass == "PERSON")
                {
                    PPersonTable PersonTbl = PPersonAccess.LoadByPrimaryKey(APartnerKey, FTransaction);

                    if (PersonTbl.Rows.Count > 0)
                    {
                        PPersonRow PersonRow = PersonTbl[0];
                        Ret.FirstName = PersonRow.FirstName;
                        Ret.LastName  = PersonRow.FamilyName;
                        Ret.Class     = "PERSON";
                    }
                }

                if (PartnerRow.PartnerClass == "FAMILY")
                {
                    PFamilyTable FamilyTbl = PFamilyAccess.LoadByPrimaryKey(APartnerKey, FTransaction);

                    if (FamilyTbl.Rows.Count > 0)
                    {
                        PFamilyRow FamilyRow = FamilyTbl[0];
                        Ret.FirstName = FamilyRow.FirstName;
                        Ret.LastName  = FamilyRow.FamilyName;
                        Ret.Class     = "FAMILY";
                    }
                }

                PPartnerLocationRow LocationRow;
                TLocationPK         LocationKey = ServerCalculations.DetermineBestAddress(APartnerKey, out LocationRow);

                if (LocationKey.LocationKey != -1)
                {
                    Ret.Email = LocationRow.EmailAddress;
                }
            }

            RecipientList.Add(APartnerKey, Ret);
            return(Ret);
        }
        /// <summary>
        /// get the number and name of the registration offices that the current user has access for
        /// </summary>
        /// <returns></returns>
        public static PPartnerTable GetRegistrationOffices()
        {
            bool           NewTransaction;
            TDataBase      db          = DBAccess.Connect("GetRegistrationOffices");
            TDBTransaction Transaction = db.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, out NewTransaction);

            PPartnerTable result = new PPartnerTable();

            try
            {
                List <Int64> offices = GetRegistrationOfficeKeysOfUser(Transaction);

                StringCollection FieldList = new StringCollection();
                FieldList.Add(PPartnerTable.GetPartnerKeyDBName());
                FieldList.Add(PPartnerTable.GetPartnerShortNameDBName());

                // get the short names of the registration offices
                foreach (Int64 OfficeKey in offices)
                {
                    PPartnerTable partnerTable = PPartnerAccess.LoadByPrimaryKey(OfficeKey, FieldList, Transaction);

                    result.Merge(partnerTable);
                }

                // remove unwanted columns
                List <string> ColumnNames = new List <string>();

                foreach (DataColumn column in result.Columns)
                {
                    ColumnNames.Add(column.ColumnName);
                }

                foreach (string columnName in ColumnNames)
                {
                    if (!FieldList.Contains(columnName))
                    {
                        result.Columns.Remove(columnName.ToString());
                    }
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    Transaction.Rollback();
                }
            }

            result.DefaultView.Sort = PPartnerTable.GetPartnerKeyDBName();

            return(result);
        }
Beispiel #15
0
        public static PartnerEditTDS GetPartnerDetails(Int64 APartnerKey, bool AWithAddressDetails, bool AWithSubscriptions, bool AWithRelationships)
        {
            PartnerEditTDS MainDS = new PartnerEditTDS();

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, 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;
                        }

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

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

                        if (AWithSubscriptions)
                        {
                            PSubscriptionAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);
                        }
                    }
                });

            return MainDS;
        }
Beispiel #16
0
        public static PartnerEditTDS GetPartnerDetails(Int64 APartnerKey, bool AWithAddressDetails, bool AWithSubscriptions, bool AWithRelationships)
        {
            PartnerEditTDS MainDS = new PartnerEditTDS();

            TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable);

            PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

            if (MainDS.PPartner.Rows.Count == 0)
            {
                return(null);
            }

            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;
            }

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

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

            if (AWithSubscriptions)
            {
                PSubscriptionAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);
            }

            DBAccess.GDBAccessObj.RollbackTransaction();

            return(MainDS);
        }
Beispiel #17
0
        public static PersonnelTDS LoadPersonellStaffData(Int64 APartnerKey)
        {
            PersonnelTDS   MainDS      = new PersonnelTDS();
            TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

            PmCommitmentStatusAccess.LoadAll(MainDS, Transaction);
            PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);

            DBAccess.GDBAccessObj.RollbackTransaction();
            return(MainDS);
        }
Beispiel #18
0
        /// <summary>
        /// Retrieves the Partner ShortName, the PartnerClass and PartnerStatus.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey to identify the Partner.</param>
        /// <param name="APartnerShortName">Returns the ShortName.</param>
        /// <param name="APartnerClass">Returns the PartnerClass (FAMILY, ORGANISATION, etc).</param>
        /// <param name="APartnerStatus">Returns the PartnerStatus (eg. ACTIVE, DIED).</param>
        /// <param name="ATransaction">Open DB Transaction.</param>
        /// <returns>True if partner was found, otherwise false.</returns>
        public static Boolean RetrievePartnerShortName(Int64 APartnerKey,
                                                       out String APartnerShortName,
                                                       out TPartnerClass APartnerClass,
                                                       out TStdPartnerStatusCode APartnerStatus,
                                                       TDBTransaction ATransaction)
        {
            Boolean          ReturnValue;
            StringCollection RequiredColumns;
            PPartnerTable    PartnerTable;

            // initialise out Arguments
            APartnerShortName = "";

            // Default. This is not really correct but the best compromise if PartnerKey is 0 or Partner isn't found since we have an enum here.
            APartnerClass = TPartnerClass.FAMILY;

            // Default. This is not really correct but the best compromise if PartnerKey is 0 or Partner isn't found since we have an enum here.
            APartnerStatus = TStdPartnerStatusCode.spscINACTIVE;

            if (APartnerKey != 0)
            {
                // only some fields are needed
                RequiredColumns = new StringCollection();
                RequiredColumns.Add(PPartnerTable.GetPartnerShortNameDBName());
                RequiredColumns.Add(PPartnerTable.GetPartnerClassDBName());
                RequiredColumns.Add(PPartnerTable.GetStatusCodeDBName());

                PartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, RequiredColumns, ATransaction, null, 0, 0);

                if (PartnerTable.Rows.Count == 0)
                {
                    ReturnValue = false;
                }
                else
                {
                    // since we loaded by primary key there must just be one partner row
                    APartnerShortName = PartnerTable[0].PartnerShortName;
                    APartnerClass     = SharedTypes.PartnerClassStringToEnum(PartnerTable[0].PartnerClass);

                    APartnerStatus = SharedTypes.StdPartnerStatusCodeStringToEnum(PartnerTable[0].StatusCode);
                    ReturnValue    = true;
                }
            }
            else
            {
                // Return result as valid if Partner Key is 0.
                ReturnValue = true;
            }

            return(ReturnValue);
        }
        /// <summary>
        /// Retrieves the ShortName of a Partner.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of the Partner.</param>
        /// <param name="ATransaction">Database transaction to use.</param>
        /// <returns>ShortName of the specified Partner.</returns>
        private static string GetPartnerShortName(long APartnerKey, TDBTransaction ATransaction)
        {
            // Can't use TPartnerServerLookups from here:
            // TPartnerServerLookups.GetPartnerShortName(APartnerKey, out ShortName, out PartnerClass);

            PPartnerTable PartnerTable;
            var           Columns = new StringCollection();

            Columns.Add(PPartnerTable.GetPartnerKeyDBName());
            Columns.Add(PPartnerTable.GetPartnerShortNameDBName());

            PartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, Columns, ATransaction);

            return(PartnerTable[0].PartnerShortName);
        }
Beispiel #20
0
        /// <summary>
        /// Gets all the languages of the person
        /// </summary>
        /// <param name="APartnerKey">Partner Key</param>
        /// <returns></returns>
        private String GetPersonLanguages(Int64 APartnerKey)
        {
            PmPersonLanguageTable LanguageTable;
            PPartnerTable         PartnerTable;
            String SpokenLanguages    = "";
            String MotherLanguageCode = "99";
            bool   MotherTongeInList  = false;

            PartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, situation.GetDatabaseConnection().Transaction);

            if (PartnerTable.Rows.Count > 0)
            {
                MotherLanguageCode = ((PPartnerRow)PartnerTable.Rows[0]).LanguageCode;
            }

            LanguageTable = PmPersonLanguageAccess.LoadViaPPerson(APartnerKey, situation.GetDatabaseConnection().Transaction);

            for (int Counter = 0; Counter < LanguageTable.Rows.Count; ++Counter)
            {
                PmPersonLanguageRow Row = (PmPersonLanguageRow)LanguageTable.Rows[Counter];

                if (Row.LanguageCode == MotherLanguageCode)
                {
                    SpokenLanguages  += MotherLanguageCode + " (M";
                    MotherTongeInList = true;
                }
                else
                {
                    SpokenLanguages += Row.LanguageCode + " (" + Row.LanguageLevel;
                }

                SpokenLanguages += "), ";
            }

            if (!MotherTongeInList)
            {
                // Insert mother tongue at the first place:
                SpokenLanguages = MotherLanguageCode + " (M), " + SpokenLanguages;
            }

            // remove the last comma and space
            if (SpokenLanguages.Length > 2)
            {
                SpokenLanguages.Remove(SpokenLanguages.Length - 2);
            }

            return(SpokenLanguages);
        }
        public static bool GetGiftsForTaxDeductiblePctAdjustment(ref GiftBatchTDS AGiftDS,
                                                                 Int64 ARecipientKey,
                                                                 DateTime ADateFrom,
                                                                 decimal ANewPct,
                                                                 out TVerificationResultCollection AMessages)
        {
            TDBTransaction Transaction = new TDBTransaction();
            TDataBase      db          = DBAccess.Connect("GetGiftsForTaxDeductiblePctAdjustment");
            GiftBatchTDS   MainDS      = new GiftBatchTDS();

            AMessages = new TVerificationResultCollection();

            db.ReadTransaction(ref Transaction,
                               delegate
            {
                string Query = "SELECT a_gift_detail.*" +

                               " FROM a_gift_detail, a_gift_batch" +

                               " WHERE a_gift_detail.p_recipient_key_n = " + ARecipientKey +
                               " AND a_gift_detail.a_tax_deductible_pct_n <> " + ANewPct +
                               " AND a_gift_detail.a_modified_detail_l <> true" +
                               " AND a_gift_detail.a_tax_deductible_l = true" +
                               " AND a_gift_batch.a_ledger_number_i = a_gift_detail.a_ledger_number_i" +
                               " AND a_gift_batch.a_batch_number_i = a_gift_detail.a_batch_number_i" +
                               " AND a_gift_batch.a_ledger_number_i = a_gift_detail.a_ledger_number_i" +
                               " AND a_gift_batch.a_batch_status_c = 'Posted' " +
                               " AND a_gift_batch.a_gl_effective_date_d >= '" + ADateFrom.ToString("yyyy-MM-dd") + "'";

                db.Select(MainDS, Query, MainDS.AGiftDetail.TableName, Transaction);

                // get additional data
                foreach (GiftBatchTDSAGiftDetailRow Row in MainDS.AGiftDetail.Rows)
                {
                    AGiftBatchAccess.LoadByPrimaryKey(MainDS, Row.LedgerNumber, Row.BatchNumber, Transaction);
                    AGiftRow GiftRow =
                        AGiftAccess.LoadByPrimaryKey(MainDS, Row.LedgerNumber, Row.BatchNumber, Row.GiftTransactionNumber, Transaction);

                    Row.DateEntered = GiftRow.DateEntered;
                    Row.DonorKey    = GiftRow.DonorKey;
                    Row.DonorName   = PPartnerAccess.LoadByPrimaryKey(Row.DonorKey, Transaction)[0].PartnerShortName;
                }
            });

            AGiftDS = MainDS;

            return(TAdjustmentWebConnector.CheckGiftsNotPreviouslyReversed(AGiftDS, out AMessages));
        }
Beispiel #22
0
        public static PersonnelTDS LoadPersonellStaffData(Int64 APartnerKey)
        {
            PersonnelTDS   MainDS      = new PersonnelTDS();
            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, ref Transaction,
                                                           delegate
            {
                PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                PmCommitmentStatusAccess.LoadAll(MainDS, Transaction);
                PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            });

            return(MainDS);
        }
Beispiel #23
0
        public static PersonnelTDS LoadPersonellStaffData(Int64 APartnerKey)
        {
            PersonnelTDS   MainDS      = new PersonnelTDS();
            TDBTransaction Transaction = new TDBTransaction();

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

                PmCommitmentStatusAccess.LoadAll(MainDS, Transaction);
                PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            });

            return(MainDS);
        }
        public static Boolean GetConferenceApplications(ref ConferenceApplicationTDS AMainDS, Int64 AConferenceKey)
        {
            Boolean NewTransaction;

            // make sure outreach codes are up to date in case it has changed in Unit record
            TAttendeeManagement.RefreshOutreachCode(AConferenceKey);

            TDBTransaction ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(
                IsolationLevel.ReadCommitted,
                TEnforceIsolationLevel.eilMinimum,
                out NewTransaction);

            try
            {
                PcConferenceTable ConferenceTable = PcConferenceAccess.LoadByPrimaryKey(AConferenceKey, ReadTransaction);

                if (ConferenceTable.Count == 0)
                {
                    throw new Exception("Cannot find conference " + AConferenceKey.ToString());
                }

                string OutreachPrefix = ConferenceTable[0].OutreachPrefix;

                // load application data for all conference attendees from db
                TApplicationManagement.GetApplications(ref AMainDS, AConferenceKey, OutreachPrefix, "all", -1, true, null, false);

                // obtain PPartner records for all the home offices
                foreach (PcAttendeeRow AttendeeRow in AMainDS.PcAttendee.Rows)
                {
                    if (AMainDS.PPartner.Rows.Find(new object[] { AttendeeRow.HomeOfficeKey }) == null)
                    {
                        PPartnerAccess.LoadByPrimaryKey(AMainDS, AttendeeRow.HomeOfficeKey, ReadTransaction);
                    }
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TConferenceDataReaderWebConnector.GetConferenceApplications: commit own transaction.");
                }
            }

            return(true);
        }
Beispiel #25
0
        /// <summary>
        /// Checks for the existance of a Partner.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of the Partner to check for.</param>
        /// <param name="AMustNotBeMergedPartner">Set to true to check whether the Partner
        /// must not be a Merged Partner.</param>
        /// <returns>An instance of PPartnerRow if the Partner exists (taking AMustNotBeMergedPartner into consideration),
        /// otherwise null.</returns>
        public static PPartnerRow CheckPartnerExists2(Int64 APartnerKey, bool AMustNotBeMergedPartner)
        {
            PPartnerRow    ReturnValue = null;
            TDBTransaction ReadTransaction;
            Boolean        NewTransaction;
            PPartnerTable  PartnerTable;

            if (APartnerKey != 0)
            {
                ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted,
                                                                                    TEnforceIsolationLevel.eilMinimum,
                                                                                    out NewTransaction);

                try
                {
                    PartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);
                }
                finally
                {
                    if (NewTransaction)
                    {
                        DBAccess.GDBAccessObj.CommitTransaction();
                        TLogging.LogAtLevel(7, "CheckPartnerExists: committed own transaction.");
                    }
                }

                if (PartnerTable.Rows.Count != 0)
                {
                    if (AMustNotBeMergedPartner)
                    {
                        if (SharedTypes.StdPartnerStatusCodeStringToEnum(
                                PartnerTable[0].StatusCode) != TStdPartnerStatusCode.spscMERGED)
                        {
                            ReturnValue = PartnerTable[0];
                        }
                    }
                    else
                    {
                        ReturnValue = PartnerTable[0];
                    }
                }
            }

            return(ReturnValue);
        }
        /// <summary>
        /// Retrieves the short name of a partner.
        /// </summary>
        /// <param name="APartnerKey">Partner key</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns></returns>
        public static String GetPartnerShortName(Int64 APartnerKey, ref TRptSituation ASituation)
        {
            String           ReturnValue;
            PPartnerTable    table;
            StringCollection fields;

            ReturnValue = "N/A";
            fields      = new StringCollection();
            fields.Add(PPartnerTable.GetPartnerShortNameDBName());
            table = PPartnerAccess.LoadByPrimaryKey(APartnerKey, fields, ASituation.GetDatabaseConnection().Transaction);

            if (table.Rows.Count > 0)
            {
                ReturnValue = table[0].PartnerShortName;
            }

            return(ReturnValue);
        }
Beispiel #27
0
        public static Boolean VerifyPartner(Int64 APartnerKey)
        {
            TDBTransaction ReadTransaction;
            Boolean        NewTransaction;
            PPartnerTable  PartnerTable;
            Boolean        ReturnValue = true;

            // initialise outout Arguments
            if (APartnerKey != 0)
            {
                ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted,
                                                                                    TEnforceIsolationLevel.eilMinimum,
                                                                                    out NewTransaction);
                try
                {
                    PartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction);
                }
                finally
                {
                    if (NewTransaction)
                    {
                        DBAccess.GDBAccessObj.CommitTransaction();
                        TLogging.LogAtLevel(7, "TPartnerServerLookups.VerifyPartner: committed own transaction.");
                    }
                }

                if (PartnerTable.Rows.Count == 0)
                {
                    ReturnValue = false;
                }
                else
                {
                    ReturnValue = true;
                }
            }
            else
            {
                // Return result as valid if Partner Key is 0.
                ReturnValue = true;
            }

            return(ReturnValue);
        }
Beispiel #28
0
        private String GetPartnerContact(Int64 APartnerKey)
        {
            String        PartnerContact = "";
            PPartnerTable PartnerTable;

            PartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, situation.GetDatabaseConnection().Transaction);

            if (PartnerTable.Rows.Count > 0)
            {
                PPartnerRow Row = (PPartnerRow)PartnerTable.Rows[0];

                if (Row.PartnerKey != 0)
                {
                    PartnerContact = "Contact: " + Row.PartnerKey.ToString() + " " + Row.PartnerShortName;
                }
            }

            return(PartnerContact);
        }
Beispiel #29
0
        public static ConferenceSetupTDS LoadConferenceSettings(long AConferenceKey, out string AConferenceName)
        {
            Boolean NewTransaction;

            ConferenceSetupTDS MainDS = new ConferenceSetupTDS();

            TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted,
                                                                                           TEnforceIsolationLevel.eilMinimum,
                                                                                           out NewTransaction);

            PPartnerLocationAccess.LoadViaPPartner(MainDS, AConferenceKey, Transaction);
            PcConferenceAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction);
            PcConferenceOptionAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction);
            PcDiscountAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction);
            PcConferenceVenueAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction);
            PUnitAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction);
            AConferenceName = PPartnerAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction).PartnerShortName;

            foreach (ConferenceSetupTDSPcConferenceVenueRow VenueRow in MainDS.PcConferenceVenue.Rows)
            {
                string        VenueName;
                TPartnerClass PartnerClass;
                MPartner.Partner.ServerLookups.WebConnectors.TPartnerServerLookups.GetPartnerShortName(VenueRow.VenueKey,
                                                                                                       out VenueName,
                                                                                                       out PartnerClass);
                VenueRow.VenueName = VenueName;
            }

            // Accept row changes here so that the Client gets 'unmodified' rows
            MainDS.AcceptChanges();

            // Remove all Tables that were not filled with data before remoting them.
            MainDS.RemoveEmptyTables();

            if (NewTransaction)
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
            }

            return(MainDS);
        }
Beispiel #30
0
        public static ConferenceSetupTDS LoadConferenceSettings(long AConferenceKey, out string AConferenceName)
        {
            ConferenceSetupTDS MainDS         = new ConferenceSetupTDS();
            string             ConferenceName = null;

            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(
                ref Transaction,
                delegate
            {
                PPartnerLocationAccess.LoadViaPPartner(MainDS, AConferenceKey, Transaction);
                PcConferenceAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction);
                PcConferenceOptionAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction);
                PcDiscountAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction);
                PcConferenceVenueAccess.LoadViaPcConference(MainDS, AConferenceKey, Transaction);
                PUnitAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction);
                ConferenceName = PPartnerAccess.LoadByPrimaryKey(MainDS, AConferenceKey, Transaction).PartnerShortName;
            });

            foreach (ConferenceSetupTDSPcConferenceVenueRow VenueRow in MainDS.PcConferenceVenue.Rows)
            {
                string        VenueName;
                TPartnerClass PartnerClass;
                MPartner.Partner.ServerLookups.WebConnectors.TPartnerServerLookups.GetPartnerShortName(VenueRow.VenueKey,
                                                                                                       out VenueName,
                                                                                                       out PartnerClass);
                VenueRow.VenueName = VenueName;
            }

            // Accept row changes here so that the Client gets 'unmodified' rows
            MainDS.AcceptChanges();

            // Remove all Tables that were not filled with data before remoting them.
            MainDS.RemoveEmptyTables();

            AConferenceName = ConferenceName;

            return(MainDS);
        }