public static DataTable GetOutreachTypes(long APartnerKey)
        {
            TDBTransaction ReadTransaction;

            ReadTransaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            DataTable Table = new PUnitTable();

            try
            {
                string OutreachPrefixCode =
                    ((PcConferenceRow)PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction).Rows[0]).OutreachPrefix;

                PUnitTable UnitTable = PUnitAccess.LoadAll(ReadTransaction);

                // add PUnit rows with matching OutreachPrefixCode to the new DataTable
                foreach (PUnitRow Row in UnitTable.Rows)
                {
                    if ((Row.OutreachCode.Length == 13) && (Row.OutreachCode.Substring(0, 5) == OutreachPrefixCode))
                    {
                        DataRow CopyRow = Table.NewRow();
                        ((PUnitRow)CopyRow).PartnerKey   = Row.PartnerKey;
                        ((PUnitRow)CopyRow).OutreachCode = Row.OutreachCode.Substring(5, 6);
                        ((PUnitRow)CopyRow).UnitName     = Row.UnitName;
                        Table.Rows.Add(CopyRow);
                    }
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
            }
            finally
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
                TLogging.LogAtLevel(7, "TConferenceDataReaderWebConnector.GetOutreachTypes: commit own transaction.");
            }

            return(Table);
        }
        public static PUnitTable GetActiveFieldUnits()
        {
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow   UnitRow;

            TLogging.LogAtLevel(9, "TPartnerDataReaderWebConnector.GetActiveFieldUnits called!");

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                           ref Transaction,
                                                           delegate
            {
                // Load data
                string SqlStmt = "SELECT pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 ", pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetUnitNameDBName() +
                                 " FROM " + PUnitTable.GetTableDBName() + ", " + PPartnerTable.GetTableDBName() +
                                 " WHERE ((" + PUnitTable.GetOutreachCodeDBName() + " IS NULL)" +
                                 "        OR(" + PUnitTable.GetOutreachCodeDBName() + " = ''))" +
                                 " AND " + PUnitTable.GetUnitTypeCodeDBName() + " <> 'KEY-MIN'" +
                                 " AND pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 " = pub_" + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() +
                                 " AND " + PPartnerTable.GetStatusCodeDBName() + " = 'ACTIVE'";

                // sort rows according to name
                SqlStmt = SqlStmt + " ORDER BY " + PUnitTable.GetUnitNameDBName();

                DataTable events = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "fields", Transaction);

                foreach (DataRow eventRow in events.Rows)
                {
                    UnitRow            = (PUnitRow)UnitTable.NewRow();
                    UnitRow.PartnerKey = Convert.ToInt64(eventRow[0]);
                    UnitRow.UnitName   = Convert.ToString(eventRow[1]);
                    UnitTable.Rows.Add(UnitRow);
                }
            });

            return(UnitTable);
        }
        public static PUnitTable GetLedgerUnits()
        {
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow   UnitRow;

            TLogging.LogAtLevel(9, "TPartnerDataReaderWebConnector.GetLedgerUnits called!");

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                           ref Transaction,
                                                           delegate
            {
                // Load data
                string SqlStmt = "SELECT pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 ", pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetUnitNameDBName() +
                                 " FROM " + PUnitTable.GetTableDBName() + ", " + PPartnerTypeTable.GetTableDBName() +
                                 " WHERE pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 " = pub_" + PPartnerTypeTable.GetTableDBName() + "." + PPartnerTypeTable.GetPartnerKeyDBName() +
                                 " AND " + PPartnerTypeTable.GetTypeCodeDBName() + " = '" + MPartnerConstants.PARTNERTYPE_LEDGER + "'";

                // sort rows according to name
                SqlStmt = SqlStmt + " ORDER BY " + PUnitTable.GetUnitNameDBName();

                DataTable events = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "ledgers", Transaction);

                foreach (DataRow eventRow in events.Rows)
                {
                    UnitRow            = (PUnitRow)UnitTable.NewRow();
                    UnitRow.PartnerKey = Convert.ToInt64(eventRow[0]);
                    UnitRow.UnitName   = Convert.ToString(eventRow[1]);
                    UnitTable.Rows.Add(UnitRow);
                }
            });

            return(UnitTable);
        }
        public static PUnitTable GetLedgerUnits()
        {
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow UnitRow;

            TLogging.LogAtLevel(9, "TPartnerDataReaderWebConnector.GetLedgerUnits called!");

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                ref Transaction,
                delegate
                {
                    // Load data
                    string SqlStmt = "SELECT pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                     ", pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetUnitNameDBName() +
                                     " FROM " + PUnitTable.GetTableDBName() + ", " + PPartnerTypeTable.GetTableDBName() +
                                     " WHERE pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                     " = pub_" + PPartnerTypeTable.GetTableDBName() + "." + PPartnerTypeTable.GetPartnerKeyDBName() +
                                     " AND " + PPartnerTypeTable.GetTypeCodeDBName() + " = '" + MPartnerConstants.PARTNERTYPE_LEDGER + "'";

                    // sort rows according to name
                    SqlStmt = SqlStmt + " ORDER BY " + PUnitTable.GetUnitNameDBName();

                    DataTable events = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "ledgers", Transaction);

                    foreach (DataRow eventRow in events.Rows)
                    {
                        UnitRow = (PUnitRow)UnitTable.NewRow();
                        UnitRow.PartnerKey = Convert.ToInt64(eventRow[0]);
                        UnitRow.UnitName = Convert.ToString(eventRow[1]);
                        UnitTable.Rows.Add(UnitRow);
                    }
                });

            return UnitTable;
        }
        public static PUnitTable GetActiveFieldUnits()
        {
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow UnitRow;

            TLogging.LogAtLevel(9, "TPartnerDataReaderWebConnector.GetActiveFieldUnits called!");

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                ref Transaction,
                delegate
                {
                    // Load data
                    string SqlStmt = "SELECT pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                     ", pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetUnitNameDBName() +
                                     " FROM " + PUnitTable.GetTableDBName() + ", " + PPartnerTable.GetTableDBName() +
                                     " WHERE ((" + PUnitTable.GetOutreachCodeDBName() + " IS NULL)" +
                                     "        OR(" + PUnitTable.GetOutreachCodeDBName() + " = ''))" +
                                     " AND " + PUnitTable.GetUnitTypeCodeDBName() + " <> 'KEY-MIN'" +
                                     " AND pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                     " = pub_" + PPartnerTable.GetTableDBName() + "." + PPartnerTable.GetPartnerKeyDBName() +
                                     " AND " + PPartnerTable.GetStatusCodeDBName() + " = 'ACTIVE'";

                    // sort rows according to name
                    SqlStmt = SqlStmt + " ORDER BY " + PUnitTable.GetUnitNameDBName();

                    DataTable events = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "fields", Transaction);

                    foreach (DataRow eventRow in events.Rows)
                    {
                        UnitRow = (PUnitRow)UnitTable.NewRow();
                        UnitRow.PartnerKey = Convert.ToInt64(eventRow[0]);
                        UnitRow.UnitName = Convert.ToString(eventRow[1]);
                        UnitTable.Rows.Add(UnitRow);
                    }
                });

            return UnitTable;
        }
        public static PUnitTable GetLedgerUnits(string ALedgerName)
        {
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow   UnitRow;

            TDBTransaction ReadTransaction;
            Boolean        NewTransaction = false;

            if (ALedgerName == "*")
            {
                ALedgerName = "";
            }
            else if (ALedgerName.EndsWith("*"))
            {
                ALedgerName = ALedgerName.Substring(0, ALedgerName.Length - 1);
            }

            TLogging.LogAtLevel(9, "TPartnerDataReaderWebConnector.GetLedgerUnits called!");

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

            try
            {
                // Load data
                string SqlStmt = "SELECT pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 ", pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetUnitNameDBName() +
                                 " FROM " + PUnitTable.GetTableDBName() + ", " + PPartnerTypeTable.GetTableDBName() +
                                 " WHERE pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 " = pub_" + PPartnerTypeTable.GetTableDBName() + "." + PPartnerTypeTable.GetPartnerKeyDBName() +
                                 " AND " + PPartnerTypeTable.GetTypeCodeDBName() + " = '" + MPartnerConstants.PARTNERTYPE_LEDGER + "'";

                if (ALedgerName.Length > 0)
                {
                    // in case there is a filter set for the event name
                    ALedgerName = ALedgerName.Replace('*', '%') + "%";
                    SqlStmt     = SqlStmt + " AND " + PUnitTable.GetUnitNameDBName() +
                                  " LIKE '" + ALedgerName + "'";
                }

                // sort rows according to name
                SqlStmt = SqlStmt + " ORDER BY " + PUnitTable.GetUnitNameDBName();

                DataTable events = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "ledgers", ReadTransaction);

                foreach (DataRow eventRow in events.Rows)
                {
                    UnitRow            = (PUnitRow)UnitTable.NewRow();
                    UnitRow.PartnerKey = Convert.ToInt64(eventRow[0]);
                    UnitRow.UnitName   = Convert.ToString(eventRow[1]);
                    UnitTable.Rows.Add(UnitRow);
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TPartnerDataReaderWebConnector.GetLedgerUnits: committed own transaction.");
                }
            }

            return(UnitTable);
        }
        public static DataTable GetOutreachTypes(long APartnerKey)
        {
            TDBTransaction ReadTransaction;

            ReadTransaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            DataTable Table = new PUnitTable();

            try
            {
                string OutreachPrefixCode =
                    ((PcConferenceRow)PcConferenceAccess.LoadByPrimaryKey(APartnerKey, ReadTransaction).Rows[0]).OutreachPrefix;

                PUnitTable UnitTable = PUnitAccess.LoadAll(ReadTransaction);

                // add PUnit rows with matching OutreachPrefixCode to the new DataTable
                foreach (PUnitRow Row in UnitTable.Rows)
                {
                    if ((Row.OutreachCode.Length == 13) && (Row.OutreachCode.Substring(0, 5) == OutreachPrefixCode))
                    {
                        DataRow CopyRow = Table.NewRow();
                        ((PUnitRow)CopyRow).PartnerKey = Row.PartnerKey;
                        ((PUnitRow)CopyRow).OutreachCode = Row.OutreachCode.Substring(5, 6);
                        ((PUnitRow)CopyRow).UnitName = Row.UnitName;
                        Table.Rows.Add(CopyRow);
                    }
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
            }
            finally
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
                TLogging.LogAtLevel(7, "TConferenceDataReaderWebConnector.GetOutreachTypes: commit own transaction.");
            }

            return Table;
        }
        public static PUnitTable GetLedgerUnits(string ALedgerName)
        {
            PUnitTable UnitTable = new PUnitTable();
            PUnitRow UnitRow;

            TDBTransaction ReadTransaction;
            Boolean NewTransaction = false;

            if (ALedgerName == "*")
            {
                ALedgerName = "";
            }
            else if (ALedgerName.EndsWith("*"))
            {
                ALedgerName = ALedgerName.Substring(0, ALedgerName.Length - 1);
            }

            TLogging.LogAtLevel(9, "TPartnerDataReaderWebConnector.GetLedgerUnits called!");

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

            try
            {
                // Load data
                string SqlStmt = "SELECT pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 ", pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetUnitNameDBName() +
                                 " FROM " + PUnitTable.GetTableDBName() + ", " + PPartnerTypeTable.GetTableDBName() +
                                 " WHERE pub_" + PUnitTable.GetTableDBName() + "." + PUnitTable.GetPartnerKeyDBName() +
                                 " = pub_" + PPartnerTypeTable.GetTableDBName() + "." + PPartnerTypeTable.GetPartnerKeyDBName() +
                                 " AND " + PPartnerTypeTable.GetTypeCodeDBName() + " = '" + MPartnerConstants.PARTNERTYPE_LEDGER + "'";

                if (ALedgerName.Length > 0)
                {
                    // in case there is a filter set for the event name
                    ALedgerName = ALedgerName.Replace('*', '%') + "%";
                    SqlStmt = SqlStmt + " AND " + PUnitTable.GetUnitNameDBName() +
                              " LIKE '" + ALedgerName + "'";
                }

                // sort rows according to name
                SqlStmt = SqlStmt + " ORDER BY " + PUnitTable.GetUnitNameDBName();

                DataTable events = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "ledgers", ReadTransaction);

                foreach (DataRow eventRow in events.Rows)
                {
                    UnitRow = (PUnitRow)UnitTable.NewRow();
                    UnitRow.PartnerKey = Convert.ToInt64(eventRow[0]);
                    UnitRow.UnitName = Convert.ToString(eventRow[1]);
                    UnitTable.Rows.Add(UnitRow);
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TPartnerDataReaderWebConnector.GetLedgerUnits: committed own transaction.");
                }
            }

            return UnitTable;
        }