Beispiel #1
0
        public static bool GetSupplierCurrency(long APartnerKey, out string ACurrency)
        {
            ACurrency = "";
            TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            try
            {
                AApSupplierTable Table = AApSupplierAccess.LoadByPrimaryKey(APartnerKey, Transaction);

                if (Table.Rows.Count != 0)
                {
                    ACurrency = ((AApSupplierRow)Table.Rows[0]).CurrencyCode;
                    return(true);
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
            }
            finally
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
                TLogging.LogAtLevel(7, "TMergePartnersWebConnector.GetSupplierCurrency: rollback own transaction.");
            }

            return(false);
        }
Beispiel #2
0
        public static bool GetSupplierCurrency(long APartnerKey, out string ACurrency)
        {
            Boolean Result = false;

            ACurrency = "";
            string Currency = "";

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                           ref Transaction,
                                                           delegate
            {
                AApSupplierTable Table = AApSupplierAccess.LoadByPrimaryKey(APartnerKey, Transaction);

                if (Table.Rows.Count != 0)
                {
                    Currency = ((AApSupplierRow)Table.Rows[0]).CurrencyCode;
                    Result   = true;
                }
            });

            ACurrency = Currency;

            return(Result);
        }
Beispiel #3
0
        private Boolean FIsSupplierDataChanged = true;      // Initially we don't have any!

        /// <summary>
        /// Static method to get a supplier from a partner key.  Used by the AP subsystem.
        /// </summary>
        /// <param name="Tbl"></param>
        /// <param name="APartnerKey"></param>
        /// <returns></returns>
        public static AApSupplierRow GetSupplier(AApSupplierTable Tbl, Int64 APartnerKey)
        {
            Tbl.DefaultView.Sort = "p_partner_key_n";

            int indexSupplier = Tbl.DefaultView.Find(APartnerKey);

            if (indexSupplier == -1)
            {
                return(null);
            }

            return((AApSupplierRow)Tbl.DefaultView[indexSupplier].Row);
        }
        /// <summary>
        /// Static method to get a supplier from a partner key.  Used by the AP subsystem.
        /// </summary>
        /// <param name="Tbl"></param>
        /// <param name="APartnerKey"></param>
        /// <returns></returns>
        public static AApSupplierRow GetSupplier(AApSupplierTable Tbl, Int64 APartnerKey)
        {
            Tbl.DefaultView.Sort = "p_partner_key_n";

            int indexSupplier = Tbl.DefaultView.Find(APartnerKey);

            if (indexSupplier == -1)
            {
                return null;
            }

            return (AApSupplierRow)Tbl.DefaultView[indexSupplier].Row;
        }
        public static void GetData(string ATablename, TSearchCriteria[] ASearchCriteria, out TTypedDataTable AResultTable,
                                   TDBTransaction AReadTransaction)
        {
            AResultTable = null;
            string context = string.Format("GetData {0}", SharedConstants.MODULE_ACCESS_MANAGER);

            // check access permissions for the current user
            TModuleAccessManager.CheckUserPermissionsForTable(ATablename, TTablePermissionEnum.eCanRead);

            // TODO: auto generate
            if (ATablename == AApSupplierTable.GetTableDBName())
            {
                AResultTable = AApSupplierAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == AApDocumentTable.GetTableDBName())
            {
                AResultTable = AApDocumentAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == ATransactionTypeTable.GetTableDBName())
            {
                AResultTable = ATransactionTypeAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == ACurrencyTable.GetTableDBName())
            {
                AResultTable = ACurrencyAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == ADailyExchangeRateTable.GetTableDBName())
            {
                AResultTable = ADailyExchangeRateAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == ACorporateExchangeRateTable.GetTableDBName())
            {
                AResultTable = ACorporateExchangeRateAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == ACurrencyLanguageTable.GetTableDBName())
            {
                AResultTable = ACurrencyLanguageAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == AFeesPayableTable.GetTableDBName())
            {
                AResultTable = AFeesPayableAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == AFeesReceivableTable.GetTableDBName())
            {
                AResultTable = AFeesReceivableAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == AAnalysisTypeTable.GetTableDBName())
            {
                AResultTable = AAnalysisTypeAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == AGiftBatchTable.GetTableDBName())
            {
                AResultTable = AGiftBatchAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == AJournalTable.GetTableDBName())
            {
                AResultTable = AJournalAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == ALedgerTable.GetTableDBName())
            {
                AResultTable = ALedgerAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == MExtractMasterTable.GetTableDBName())
            {
                if (ASearchCriteria == null)
                {
                    AResultTable = MExtractMasterAccess.LoadAll(AReadTransaction);
                }
                else
                {
                    AResultTable = MExtractMasterAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
                }
            }
            else if (ATablename == MExtractTable.GetTableDBName())
            {
                // it does not make sense to load ALL extract rows for all extract masters so search criteria needs to be set
                if (ASearchCriteria != null)
                {
                    AResultTable = MExtractAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
                }
            }
            else if (ATablename == PcAttendeeTable.GetTableDBName())
            {
                AResultTable = PcAttendeeAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == PcConferenceCostTable.GetTableDBName())
            {
                AResultTable = PcConferenceCostAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == PcEarlyLateTable.GetTableDBName())
            {
                AResultTable = PcEarlyLateAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == PcSupplementTable.GetTableDBName())
            {
                AResultTable = PcSupplementAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == PcDiscountTable.GetTableDBName())
            {
                AResultTable = PcDiscountAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == PCountryTable.GetTableDBName())
            {
                AResultTable = PCountryAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == PFormTable.GetTableDBName())
            {
                string[]         columns   = TTypedDataTable.GetColumnStringList(PFormTable.TableId);
                StringCollection fieldList = new StringCollection();

                for (int i = 0; i < columns.Length; i++)
                {
                    // Do not load the template document - we don't display it and it is big!
                    if (columns[i] != PFormTable.GetTemplateDocumentDBName())
                    {
                        fieldList.Add(columns[i]);
                    }
                }

                AResultTable = PFormAccess.LoadAll(fieldList, AReadTransaction);
            }
            else if (ATablename == PInternationalPostalTypeTable.GetTableDBName())
            {
                AResultTable = PInternationalPostalTypeAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == PtApplicationTypeTable.GetTableDBName())
            {
                AResultTable = PtApplicationTypeAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == PFormalityTable.GetTableDBName())
            {
                AResultTable = PFormalityAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == PMailingTable.GetTableDBName())
            {
                AResultTable = PMailingAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == PPartnerGiftDestinationTable.GetTableDBName())
            {
                AResultTable = PPartnerGiftDestinationAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == PmDocumentTypeTable.GetTableDBName())
            {
                AResultTable = PmDocumentTypeAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == SGroupTable.GetTableDBName())
            {
                TSecurityChecks.CheckUserModulePermissions(SharedConstants.PETRAMODULE_SYSADMIN, context);
                AResultTable = SGroupAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == SSystemDefaultsTable.GetTableDBName())
            {
                TSecurityChecks.CheckUserModulePermissions(SharedConstants.PETRAMODULE_SYSADMIN, context);
                AResultTable = SSystemDefaultsAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == SSystemDefaultsGuiTable.GetTableDBName())
            {
                AResultTable = SSystemDefaultsGuiAccess.LoadAll(AReadTransaction);
            }
            else
            {
                throw new Exception("TCommonDataReader.GetData: unknown table " + ATablename);
            }

            // Accept row changes here so that the Client gets 'unmodified' rows
            AResultTable.AcceptChanges();
        }
        private static AApSupplierRow GetSupplier(AApSupplierTable Tbl, Int64 APartnerKey)
        {
            Tbl.DefaultView.Sort = AApSupplierTable.GetPartnerKeyDBName();

            int indexSupplier = Tbl.DefaultView.Find(APartnerKey);

            if (indexSupplier == -1)
            {
                return null;
            }

            return (AApSupplierRow)Tbl.DefaultView[indexSupplier].Row;
        }
        /// <summary>
        /// generate the partners from a text file that was generated with Benerator
        /// </summary>
        /// <param name="AInputBeneratorFile"></param>
        public static void GenerateOrganisationPartners(string AInputBeneratorFile)
        {
            PartnerEditTDS   MainDS        = new PartnerEditTDS();
            AApSupplierTable supplierTable = new AApSupplierTable();

            XmlDocument doc = TCsv2Xml.ParseCSV2Xml(AInputBeneratorFile, ",", Encoding.UTF8);

            XmlNode RecordNode = doc.FirstChild.NextSibling.FirstChild;

            Int32 NumberOfPartnerKeysReserved = 100;
            Int64 NextPartnerKey = TNewPartnerKey.ReservePartnerKeys(-1, ref NumberOfPartnerKeysReserved);

            while (RecordNode != null)
            {
                if (NumberOfPartnerKeysReserved == 0)
                {
                    NumberOfPartnerKeysReserved = 100;
                    NextPartnerKey = TNewPartnerKey.ReservePartnerKeys(-1, ref NumberOfPartnerKeysReserved);
                }

                long OrgPartnerKey = NextPartnerKey;
                NextPartnerKey++;
                NumberOfPartnerKeysReserved--;

                POrganisationRow organisationRecord = MainDS.POrganisation.NewRowTyped();
                organisationRecord.PartnerKey       = OrgPartnerKey;
                organisationRecord.OrganisationName = TXMLParser.GetAttribute(RecordNode, "OrganisationName");
                MainDS.POrganisation.Rows.Add(organisationRecord);

                PPartnerRow PartnerRow = MainDS.PPartner.NewRowTyped();
                PartnerRow.PartnerKey        = organisationRecord.PartnerKey;
                PartnerRow.PartnerClass      = MPartnerConstants.PARTNERCLASS_ORGANISATION;
                PartnerRow.StatusCode        = MPartnerConstants.PARTNERSTATUS_ACTIVE;
                PartnerRow.PartnerShortName  = organisationRecord.OrganisationName;
                PartnerRow.AddresseeTypeCode = MPartnerConstants.ADDRESSEETYPE_ORGANISATION;
                MainDS.PPartner.Rows.Add(PartnerRow);

                PLocationRow locationRow = MainDS.PLocation.NewRowTyped();

                locationRow.SiteKey     = 0; // DomainManager.GSiteKey;
                locationRow.LocationKey = (MainDS.PLocation.Count + 1) * -1;
                locationRow.StreetName  = TXMLParser.GetAttribute(RecordNode, "Addr2");
                locationRow.PostalCode  = TXMLParser.GetAttribute(RecordNode, "PostCode");
                locationRow.City        = TXMLParser.GetAttribute(RecordNode, "City");
                locationRow.County      = TXMLParser.GetAttribute(RecordNode, "Province");
                locationRow.CountryCode = TXMLParser.GetAttribute(RecordNode, "CountryCode");

                MainDS.PLocation.Rows.Add(locationRow);

                PPartnerLocationRow organisationLocationRow = MainDS.PPartnerLocation.NewRowTyped();

                organisationLocationRow.PartnerKey   = PartnerRow.PartnerKey;
                organisationLocationRow.LocationKey  = locationRow.LocationKey;
                organisationLocationRow.SiteKey      = locationRow.SiteKey;
                organisationLocationRow.LocationType = MPartnerConstants.LOCATIONTYPE_BUSINESS;
                organisationLocationRow.SendMail     = true;

                if (TXMLParser.GetAttribute(RecordNode, "IsSupplier") == "yes")
                {
                    AApSupplierRow supplierRow = supplierTable.NewRowTyped(true);

                    supplierRow.PartnerKey   = organisationRecord.PartnerKey;
                    supplierRow.CurrencyCode = TXMLParser.GetAttribute(RecordNode, "Currency");

                    if (supplierRow.CurrencyCode == "GBP")
                    {
                        supplierRow.DefaultBankAccount = "6210";
                    }
                    else
                    {
                        supplierRow.DefaultBankAccount = "6200";
                    }

                    supplierRow.DefaultApAccount  = "9100";
                    supplierRow.DefaultCostCentre = (FLedgerNumber * 100).ToString("0000");
                    supplierRow.DefaultExpAccount = "4200";

                    supplierTable.Rows.Add(supplierRow);
                }

                MainDS.PPartnerLocation.Rows.Add(organisationLocationRow);

                RecordNode = RecordNode.NextSibling;
            }

            PartnerEditTDSAccess.SubmitChanges(MainDS);

            AApSupplierAccess.SubmitChanges(supplierTable, null);
        }
        /// <summary>
        /// generate the partners from a text file that was generated with Benerator
        /// </summary>
        /// <param name="AInputBeneratorFile"></param>
        public static void GenerateOrganisationPartners(string AInputBeneratorFile)
        {
            PartnerEditTDS MainDS = new PartnerEditTDS();
            AApSupplierTable supplierTable = new AApSupplierTable();

            XmlDocument doc = TCsv2Xml.ParseCSV2Xml(AInputBeneratorFile, ",", Encoding.UTF8);

            XmlNode RecordNode = doc.FirstChild.NextSibling.FirstChild;

            Int32 NumberOfPartnerKeysReserved = 100;
            Int64 NextPartnerKey = TNewPartnerKey.ReservePartnerKeys(-1, ref NumberOfPartnerKeysReserved);

            while (RecordNode != null)
            {
                if (NumberOfPartnerKeysReserved == 0)
                {
                    NumberOfPartnerKeysReserved = 100;
                    NextPartnerKey = TNewPartnerKey.ReservePartnerKeys(-1, ref NumberOfPartnerKeysReserved);
                }

                long OrgPartnerKey = NextPartnerKey;
                NextPartnerKey++;
                NumberOfPartnerKeysReserved--;

                POrganisationRow organisationRecord = MainDS.POrganisation.NewRowTyped();
                organisationRecord.PartnerKey = OrgPartnerKey;
                organisationRecord.OrganisationName = TXMLParser.GetAttribute(RecordNode, "OrganisationName");
                MainDS.POrganisation.Rows.Add(organisationRecord);

                PPartnerRow PartnerRow = MainDS.PPartner.NewRowTyped();
                PartnerRow.PartnerKey = organisationRecord.PartnerKey;
                PartnerRow.PartnerClass = MPartnerConstants.PARTNERCLASS_ORGANISATION;
                PartnerRow.StatusCode = MPartnerConstants.PARTNERSTATUS_ACTIVE;
                PartnerRow.PartnerShortName = organisationRecord.OrganisationName;
                PartnerRow.AddresseeTypeCode = MPartnerConstants.ADDRESSEETYPE_ORGANISATION;
                MainDS.PPartner.Rows.Add(PartnerRow);

                PLocationRow locationRow = MainDS.PLocation.NewRowTyped();

                locationRow.SiteKey = 0; // DomainManager.GSiteKey;
                locationRow.LocationKey = (MainDS.PLocation.Count + 1) * -1;
                locationRow.StreetName = TXMLParser.GetAttribute(RecordNode, "Addr2");
                locationRow.PostalCode = TXMLParser.GetAttribute(RecordNode, "PostCode");
                locationRow.City = TXMLParser.GetAttribute(RecordNode, "City");
                locationRow.County = TXMLParser.GetAttribute(RecordNode, "Province");
                locationRow.CountryCode = TXMLParser.GetAttribute(RecordNode, "CountryCode");

                MainDS.PLocation.Rows.Add(locationRow);

                PPartnerLocationRow organisationLocationRow = MainDS.PPartnerLocation.NewRowTyped();

                organisationLocationRow.PartnerKey = PartnerRow.PartnerKey;
                organisationLocationRow.LocationKey = locationRow.LocationKey;
                organisationLocationRow.SiteKey = locationRow.SiteKey;
                organisationLocationRow.LocationType = MPartnerConstants.LOCATIONTYPE_BUSINESS;
                organisationLocationRow.SendMail = true;

                //organisationLocationRow.EmailAddress = TXMLParser.GetAttribute(RecordNode, "Email");

                if (TXMLParser.GetAttribute(RecordNode, "IsSupplier") == "yes")
                {
                    AApSupplierRow supplierRow = supplierTable.NewRowTyped(true);

                    supplierRow.PartnerKey = organisationRecord.PartnerKey;
                    supplierRow.CurrencyCode = TXMLParser.GetAttribute(RecordNode, "Currency");

                    if (supplierRow.CurrencyCode == "GBP")
                    {
                        supplierRow.DefaultBankAccount = "6210";
                    }
                    else
                    {
                        supplierRow.DefaultBankAccount = "6200";
                    }

                    supplierRow.DefaultApAccount = "9100";
                    supplierRow.DefaultCostCentre = (FLedgerNumber * 100).ToString("0000");
                    supplierRow.DefaultExpAccount = "4200";

                    supplierTable.Rows.Add(supplierRow);
                }

                MainDS.PPartnerLocation.Rows.Add(organisationLocationRow);

                RecordNode = RecordNode.NextSibling;
            }

            PartnerEditTDSAccess.SubmitChanges(MainDS);

            AApSupplierAccess.SubmitChanges(supplierTable, null);
        }
        /// <summary>
        /// generate the partners from a text file that was generated with Benerator
        /// </summary>
        /// <param name="AInputBeneratorFile"></param>
        public static void GenerateOrganisationPartners(string AInputBeneratorFile)
        {
            PartnerEditTDS   MainDS        = new PartnerEditTDS();
            AApSupplierTable supplierTable = new AApSupplierTable();

            // AlanP: May 2016 - We may no longer need the UTF8 because the method now automatically discovers the encoding even with no BOM
            XmlDocument doc = TCsv2Xml.ParseCSVFile2Xml(AInputBeneratorFile, ",", Encoding.UTF8);

            XmlNode RecordNode = doc.FirstChild.NextSibling.FirstChild;

            Int32 NumberOfPartnerKeysReserved = 100;
            Int64 NextPartnerKey = TNewPartnerKey.ReservePartnerKeys(-1, ref NumberOfPartnerKeysReserved);

            while (RecordNode != null)
            {
                if (NumberOfPartnerKeysReserved == 0)
                {
                    NumberOfPartnerKeysReserved = 100;
                    NextPartnerKey = TNewPartnerKey.ReservePartnerKeys(-1, ref NumberOfPartnerKeysReserved);
                }

                long OrgPartnerKey = NextPartnerKey;
                NextPartnerKey++;
                NumberOfPartnerKeysReserved--;

                POrganisationRow organisationRecord = MainDS.POrganisation.NewRowTyped();
                organisationRecord.PartnerKey       = OrgPartnerKey;
                organisationRecord.OrganisationName = TXMLParser.GetAttribute(RecordNode, "OrganisationName");
                MainDS.POrganisation.Rows.Add(organisationRecord);

                PPartnerRow PartnerRow = MainDS.PPartner.NewRowTyped();
                PartnerRow.PartnerKey        = organisationRecord.PartnerKey;
                PartnerRow.PartnerClass      = MPartnerConstants.PARTNERCLASS_ORGANISATION;
                PartnerRow.StatusCode        = MPartnerConstants.PARTNERSTATUS_ACTIVE;
                PartnerRow.PartnerShortName  = organisationRecord.OrganisationName;
                PartnerRow.AddresseeTypeCode = MPartnerConstants.ADDRESSEETYPE_ORGANISATION;
                MainDS.PPartner.Rows.Add(PartnerRow);

                PLocationRow locationRow = MainDS.PLocation.NewRowTyped();

                locationRow.SiteKey     = 0; // DomainManager.GSiteKey;
                locationRow.LocationKey = (MainDS.PLocation.Count + 1) * -1;
                locationRow.StreetName  = TXMLParser.GetAttribute(RecordNode, "Addr2");
                locationRow.PostalCode  = TXMLParser.GetAttribute(RecordNode, "PostCode");
                locationRow.City        = TXMLParser.GetAttribute(RecordNode, "City");
                locationRow.County      = TXMLParser.GetAttribute(RecordNode, "Province");
                locationRow.CountryCode = TXMLParser.GetAttribute(RecordNode, "CountryCode");

                MainDS.PLocation.Rows.Add(locationRow);

                PPartnerLocationRow organisationLocationRow = MainDS.PPartnerLocation.NewRowTyped();

                organisationLocationRow.PartnerKey   = PartnerRow.PartnerKey;
                organisationLocationRow.LocationKey  = locationRow.LocationKey;
                organisationLocationRow.SiteKey      = locationRow.SiteKey;
                organisationLocationRow.LocationType = MPartnerConstants.LOCATIONTYPE_BUSINESS;
                organisationLocationRow.SendMail     = true;

                if (TXMLParser.GetAttribute(RecordNode, "IsSupplier") == "yes")
                {
                    AApSupplierRow supplierRow = supplierTable.NewRowTyped(true);

                    supplierRow.PartnerKey   = organisationRecord.PartnerKey;
                    supplierRow.CurrencyCode = TXMLParser.GetAttribute(RecordNode, "Currency");

                    if (supplierRow.CurrencyCode == "GBP")
                    {
                        supplierRow.DefaultBankAccount = "6210";
                    }
                    else
                    {
                        supplierRow.DefaultBankAccount = "6200";
                    }

                    supplierRow.DefaultApAccount  = "9100";
                    supplierRow.DefaultCostCentre = (FLedgerNumber * 100).ToString("0000");
                    supplierRow.DefaultExpAccount = "4200";

                    supplierTable.Rows.Add(supplierRow);
                }

                MainDS.PPartnerLocation.Rows.Add(organisationLocationRow);

                RecordNode = RecordNode.NextSibling;
            }

            TDataBase      db          = DBAccess.Connect("GenerateOrganisationPartners");
            TDBTransaction Transaction = new TDBTransaction();
            bool           SubmitOK    = false;

            db.WriteTransaction(
                ref Transaction,
                ref SubmitOK,
                delegate
            {
                PartnerEditTDSAccess.SubmitChanges(MainDS, db);
                AApSupplierAccess.SubmitChanges(supplierTable, Transaction);
                SubmitOK = true;
            });
            db.CloseDBConnection();
        }
        public static bool GetData(string ATablename, TSearchCriteria[] ASearchCriteria, out TTypedDataTable AResultTable)
        {
            // TODO: check access permissions for the current user

            TDBTransaction ReadTransaction = null;

            TTypedDataTable tempTable = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.RepeatableRead,
                                                                      TEnforceIsolationLevel.eilMinimum,
                                                                      ref ReadTransaction,
                                                                      delegate
            {
                // TODO: auto generate
                if (ATablename == AApSupplierTable.GetTableDBName())
                {
                    tempTable = AApSupplierAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == AApDocumentTable.GetTableDBName())
                {
                    tempTable = AApDocumentAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == ATransactionTypeTable.GetTableDBName())
                {
                    tempTable = ATransactionTypeAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == ACurrencyTable.GetTableDBName())
                {
                    tempTable = ACurrencyAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == ADailyExchangeRateTable.GetTableDBName())
                {
                    tempTable = ADailyExchangeRateAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == ACorporateExchangeRateTable.GetTableDBName())
                {
                    tempTable = ACorporateExchangeRateAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == ACurrencyLanguageTable.GetTableDBName())
                {
                    tempTable = ACurrencyLanguageAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == AFeesPayableTable.GetTableDBName())
                {
                    tempTable = AFeesPayableAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == AFeesReceivableTable.GetTableDBName())
                {
                    tempTable = AFeesReceivableAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == AAnalysisTypeTable.GetTableDBName())
                {
                    tempTable = AAnalysisTypeAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == AGiftBatchTable.GetTableDBName())
                {
                    tempTable = AGiftBatchAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == AJournalTable.GetTableDBName())
                {
                    tempTable = AJournalAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == ALedgerTable.GetTableDBName())
                {
                    tempTable = ALedgerAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == MExtractMasterTable.GetTableDBName())
                {
                    if (ASearchCriteria == null)
                    {
                        tempTable = MExtractMasterAccess.LoadAll(ReadTransaction);
                    }
                    else
                    {
                        tempTable = MExtractMasterAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                    }
                }
                else if (ATablename == MExtractTable.GetTableDBName())
                {
                    // it does not make sense to load ALL extract rows for all extract masters so search criteria needs to be set
                    if (ASearchCriteria != null)
                    {
                        tempTable = MExtractAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                    }
                }
                else if (ATablename == PcAttendeeTable.GetTableDBName())
                {
                    tempTable = PcAttendeeAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == PcConferenceCostTable.GetTableDBName())
                {
                    tempTable = PcConferenceCostAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == PcEarlyLateTable.GetTableDBName())
                {
                    tempTable = PcEarlyLateAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == PcSupplementTable.GetTableDBName())
                {
                    tempTable = PcSupplementAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == PcDiscountTable.GetTableDBName())
                {
                    tempTable = PcDiscountAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == PFormTable.GetTableDBName())
                {
                    string[] columns           = TTypedDataTable.GetColumnStringList(PFormTable.TableId);
                    StringCollection fieldList = new StringCollection();

                    for (int i = 0; i < columns.Length; i++)
                    {
                        // Do not load the template document - we don't display it and it is big!
                        if (columns[i] != PFormTable.GetTemplateDocumentDBName())
                        {
                            fieldList.Add(columns[i]);
                        }
                    }

                    tempTable = PFormAccess.LoadAll(fieldList, ReadTransaction);
                }
                else if (ATablename == PInternationalPostalTypeTable.GetTableDBName())
                {
                    tempTable = PInternationalPostalTypeAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == PtApplicationTypeTable.GetTableDBName())
                {
                    tempTable = PtApplicationTypeAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == PFormalityTable.GetTableDBName())
                {
                    tempTable = PFormalityAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == PMailingTable.GetTableDBName())
                {
                    tempTable = PMailingAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == PPartnerGiftDestinationTable.GetTableDBName())
                {
                    tempTable = PPartnerGiftDestinationAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == PmDocumentTypeTable.GetTableDBName())
                {
                    tempTable = PmDocumentTypeAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == SGroupTable.GetTableDBName())
                {
                    tempTable = SGroupAccess.LoadAll(ReadTransaction);
                }
                else
                {
                    throw new Exception("TCommonDataReader.GetData: unknown table " + ATablename);
                }
            });

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

            // return the table
            AResultTable = tempTable;

            return(true);
        }
        public static bool GetData(string ATablename, TSearchCriteria[] ASearchCriteria, out TTypedDataTable AResultTable)
        {
            // TODO: check access permissions for the current user

            bool           NewTransaction = false;
            TDBTransaction ReadTransaction;

            TTypedDataTable tempTable = null;

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

                // TODO: auto generate
                if (ATablename == AApSupplierTable.GetTableDBName())
                {
                    tempTable = AApSupplierAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == AApDocumentTable.GetTableDBName())
                {
                    tempTable = AApDocumentAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == ATransactionTypeTable.GetTableDBName())
                {
                    tempTable = ATransactionTypeAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == ACurrencyTable.GetTableDBName())
                {
                    tempTable = ACurrencyAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == ADailyExchangeRateTable.GetTableDBName())
                {
                    tempTable = ADailyExchangeRateAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == ACorporateExchangeRateTable.GetTableDBName())
                {
                    tempTable = ACorporateExchangeRateAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == ACurrencyLanguageTable.GetTableDBName())
                {
                    tempTable = ACurrencyLanguageAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == AFeesPayableTable.GetTableDBName())
                {
                    tempTable = AFeesPayableAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == AFeesReceivableTable.GetTableDBName())
                {
                    tempTable = AFeesReceivableAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == AAnalysisTypeTable.GetTableDBName())
                {
                    tempTable = AAnalysisTypeAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == AGiftBatchTable.GetTableDBName())
                {
                    tempTable = AGiftBatchAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == AJournalTable.GetTableDBName())
                {
                    tempTable = AJournalAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == ALedgerTable.GetTableDBName())
                {
                    tempTable = ALedgerAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == MExtractMasterTable.GetTableDBName())
                {
                    if (ASearchCriteria == null)
                    {
                        tempTable = MExtractMasterAccess.LoadAll(ReadTransaction);
                    }
                    else
                    {
                        tempTable = MExtractMasterAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                    }
                }
                else if (ATablename == MExtractTable.GetTableDBName())
                {
                    // it does not make sense to load ALL extract rows for all extract masters so search criteria needs to be set
                    if (ASearchCriteria != null)
                    {
                        tempTable = MExtractAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                    }
                }
                else if (ATablename == PcAttendeeTable.GetTableDBName())
                {
                    tempTable = PcAttendeeAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == PcConferenceCostTable.GetTableDBName())
                {
                    tempTable = PcConferenceCostAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == PcEarlyLateTable.GetTableDBName())
                {
                    tempTable = PcEarlyLateAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == PcSupplementTable.GetTableDBName())
                {
                    tempTable = PcSupplementAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == PcDiscountTable.GetTableDBName())
                {
                    tempTable = PcDiscountAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == PInternationalPostalTypeTable.GetTableDBName())
                {
                    tempTable = PInternationalPostalTypeAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == PtApplicationTypeTable.GetTableDBName())
                {
                    tempTable = PtApplicationTypeAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == PMailingTable.GetTableDBName())
                {
                    tempTable = PMailingAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == PPartnerGiftDestinationTable.GetTableDBName())
                {
                    tempTable = PPartnerGiftDestinationAccess.LoadUsingTemplate(ASearchCriteria, ReadTransaction);
                }
                else if (ATablename == PmDocumentTypeTable.GetTableDBName())
                {
                    tempTable = PmDocumentTypeAccess.LoadAll(ReadTransaction);
                }
                else if (ATablename == SGroupTable.GetTableDBName())
                {
                    tempTable = SGroupAccess.LoadAll(ReadTransaction);
                }
                else
                {
                    throw new Exception("TCommonDataReader.GetData: unknown table " + ATablename);
                }
            }
            catch (Exception Exp)
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
                TLogging.Log("TCommonDataReader.GetData exception: " + Exp.ToString(), TLoggingType.ToLogfile);
                TLogging.Log(Exp.StackTrace, TLoggingType.ToLogfile);
                throw;
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TCommonDataReader.GetData: committed own transaction.");
                }
            }

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

            // return the table
            AResultTable = tempTable;

            return(true);
        }