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 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(); }
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); }
public static void ActivateAccountsPayableSubsystem(Int32 ALedgerNumber) { #region Validate Arguments if (ALedgerNumber <= 0) { throw new EFinanceSystemInvalidLedgerNumberException(String.Format(Catalog.GetString( "Function:{0} - The Ledger number must be greater than 0!"), Utilities.GetMethodName(true)), ALedgerNumber); } #endregion Validate Arguments TDBTransaction Transaction = null; bool SubmissionOK = false; try { DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref Transaction, ref SubmissionOK, delegate { // if subsystem already active then no need to go further if (!IsAccountsPayableSubsystemActivated(ALedgerNumber)) { // make sure transaction type exists for accounts payable subsystem ATransactionTypeTable TemplateTransactionTypeTable; ATransactionTypeRow TemplateTransactionTypeRow; StringCollection TemplateTransactionTypeOperators; TemplateTransactionTypeTable = new ATransactionTypeTable(); TemplateTransactionTypeRow = TemplateTransactionTypeTable.NewRowTyped(false); TemplateTransactionTypeRow.LedgerNumber = ALedgerNumber; TemplateTransactionTypeRow.SubSystemCode = CommonAccountingSubSystemsEnum.AP.ToString(); TemplateTransactionTypeOperators = new StringCollection(); TemplateTransactionTypeOperators.Add("="); if (ATransactionTypeAccess.CountUsingTemplate(TemplateTransactionTypeRow, TemplateTransactionTypeOperators, Transaction) == 0) { ATransactionTypeTable TransactionTypeTable; ATransactionTypeRow TransactionTypeRow; TransactionTypeTable = new ATransactionTypeTable(); TransactionTypeRow = TransactionTypeTable.NewRowTyped(); TransactionTypeRow.LedgerNumber = ALedgerNumber; TransactionTypeRow.SubSystemCode = CommonAccountingSubSystemsEnum.AP.ToString(); TransactionTypeRow.TransactionTypeCode = CommonAccountingTransactionTypesEnum.INV.ToString(); TransactionTypeRow.DebitAccountCode = MFinanceConstants.ACCOUNT_BAL_SHT; TransactionTypeRow.CreditAccountCode = MFinanceConstants.ACCOUNT_CREDITORS; TransactionTypeRow.TransactionTypeDescription = "Input Creditor's Invoice"; TransactionTypeRow.SpecialTransactionType = true; TransactionTypeTable.Rows.Add(TransactionTypeRow); ATransactionTypeAccess.SubmitChanges(TransactionTypeTable, Transaction); } // create or update system interface record for accounts payable ASystemInterfaceTable SystemInterfaceTable; ASystemInterfaceRow SystemInterfaceRow; SystemInterfaceTable = ASystemInterfaceAccess.LoadByPrimaryKey(ALedgerNumber, CommonAccountingSubSystemsEnum.AP.ToString(), Transaction); if (SystemInterfaceTable.Count == 0) { SystemInterfaceRow = SystemInterfaceTable.NewRowTyped(); SystemInterfaceRow.LedgerNumber = ALedgerNumber; SystemInterfaceRow.SubSystemCode = CommonAccountingSubSystemsEnum.AP.ToString(); SystemInterfaceRow.SetUpComplete = true; SystemInterfaceTable.Rows.Add(SystemInterfaceRow); } else { SystemInterfaceRow = (ASystemInterfaceRow)SystemInterfaceTable.Rows[0]; SystemInterfaceRow.SetUpComplete = true; } ASystemInterfaceAccess.SubmitChanges(SystemInterfaceTable, Transaction); SubmissionOK = true; } }); } catch (Exception ex) { TLogging.Log(String.Format("Method:{0} - Unexpected error!{1}{1}{2}", Utilities.GetMethodSignature(), Environment.NewLine, ex.Message)); throw ex; } }
public static void ActivateGiftProcessingSubsystem(Int32 ALedgerNumber, Int32 AStartingReceiptNumber) { #region Validate Arguments if (ALedgerNumber <= 0) { throw new EFinanceSystemInvalidLedgerNumberException(String.Format(Catalog.GetString( "Function:{0} - The Ledger number must be greater than 0!"), Utilities.GetMethodName(true)), ALedgerNumber); } #endregion Validate Arguments TDBTransaction Transaction = null; bool SubmissionOK = false; try { DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref Transaction, ref SubmissionOK, delegate { // if subsystem already active then no need to go further if (!IsGiftProcessingSubsystemActivated(ALedgerNumber)) { // create or update account for Creditor's Control // make sure transaction type exists for gift processing subsystem ATransactionTypeTable TemplateTransactionTypeTable; ATransactionTypeRow TemplateTransactionTypeRow; StringCollection TemplateTransactionTypeOperators; TemplateTransactionTypeTable = new ATransactionTypeTable(); TemplateTransactionTypeRow = TemplateTransactionTypeTable.NewRowTyped(false); TemplateTransactionTypeRow.LedgerNumber = ALedgerNumber; TemplateTransactionTypeRow.SubSystemCode = CommonAccountingSubSystemsEnum.GR.ToString(); TemplateTransactionTypeOperators = new StringCollection(); TemplateTransactionTypeOperators.Add("="); if (ATransactionTypeAccess.CountUsingTemplate(TemplateTransactionTypeRow, TemplateTransactionTypeOperators, Transaction) == 0) { ATransactionTypeTable TransactionTypeTable; ATransactionTypeRow TransactionTypeRow; TransactionTypeTable = new ATransactionTypeTable(); TransactionTypeRow = TransactionTypeTable.NewRowTyped(); TransactionTypeRow.LedgerNumber = ALedgerNumber; TransactionTypeRow.SubSystemCode = CommonAccountingSubSystemsEnum.GR.ToString(); TransactionTypeRow.TransactionTypeCode = CommonAccountingTransactionTypesEnum.GR.ToString(); TransactionTypeRow.DebitAccountCode = MFinanceConstants.CASH_ACCT; // "CASH"; TransactionTypeRow.CreditAccountCode = MFinanceConstants.ACCOUNT_GIFT; // "GIFT"; TransactionTypeRow.TransactionTypeDescription = MFinanceConstants.TRANS_TYPE_GIFT_PROCESSING; // "Gift Processing"; TransactionTypeRow.SpecialTransactionType = true; TransactionTypeTable.Rows.Add(TransactionTypeRow); ATransactionTypeAccess.SubmitChanges(TransactionTypeTable, Transaction); } ASystemInterfaceTable SystemInterfaceTable = null; ASystemInterfaceRow SystemInterfaceRow = null; SystemInterfaceTable = ASystemInterfaceAccess.LoadByPrimaryKey(ALedgerNumber, CommonAccountingSubSystemsEnum.GR.ToString(), Transaction); #region Validate Data 1 if (SystemInterfaceTable == null) { throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString( "System Interface Table data for Ledger number {0} does not exist!"), ALedgerNumber)); } #endregion Validate Data 1 if (SystemInterfaceTable.Count == 0) { SystemInterfaceRow = SystemInterfaceTable.NewRowTyped(); SystemInterfaceRow.LedgerNumber = ALedgerNumber; SystemInterfaceRow.SubSystemCode = CommonAccountingSubSystemsEnum.GR.ToString(); SystemInterfaceRow.SetUpComplete = true; SystemInterfaceTable.Rows.Add(SystemInterfaceRow); } else { SystemInterfaceRow = (ASystemInterfaceRow)SystemInterfaceTable.Rows[0]; SystemInterfaceRow.SetUpComplete = true; } ASystemInterfaceAccess.SubmitChanges(SystemInterfaceTable, Transaction); // now set the starting receipt number ALedgerTable LedgerTable = ALedgerAccess.LoadByPrimaryKey(ALedgerNumber, Transaction); #region Validate Data 2 if ((LedgerTable == null) || (LedgerTable.Count == 0)) { throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString( "Ledger Data for Ledger number {0} does not exist!"), ALedgerNumber)); } #endregion Validate Data 2 ALedgerRow LedgerRow = (ALedgerRow)LedgerTable.Rows[0]; LedgerRow.LastHeaderRNumber = AStartingReceiptNumber; ALedgerAccess.SubmitChanges(LedgerTable, Transaction); } SubmissionOK = true; }); } catch (EFinanceSystemDataTableReturnedNoDataException ex) { throw new EFinanceSystemDataTableReturnedNoDataException(String.Format("Function:{0} - {1}", Utilities.GetMethodName(true), ex.Message)); } catch (Exception ex) { TLogging.Log(String.Format("Method:{0} - Unexpected error!{1}{1}{2}", Utilities.GetMethodSignature(), Environment.NewLine, ex.Message)); throw ex; } }
public static void ActivateAccountsPayableSubsystem(Int32 ALedgerNumber) { Boolean NewTransaction; TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, out NewTransaction); try { // if subsystem already active then no need to go further if (!IsAccountsPayableSubsystemActivated(ALedgerNumber)) { // make sure transaction type exists for accounts payable subsystem ATransactionTypeTable TemplateTransactionTypeTable; ATransactionTypeRow TemplateTransactionTypeRow; StringCollection TemplateTransactionTypeOperators; TemplateTransactionTypeTable = new ATransactionTypeTable(); TemplateTransactionTypeRow = TemplateTransactionTypeTable.NewRowTyped(false); TemplateTransactionTypeRow.LedgerNumber = ALedgerNumber; TemplateTransactionTypeRow.SubSystemCode = CommonAccountingSubSystemsEnum.AP.ToString(); TemplateTransactionTypeOperators = new StringCollection(); TemplateTransactionTypeOperators.Add("="); if (ATransactionTypeAccess.CountUsingTemplate(TemplateTransactionTypeRow, TemplateTransactionTypeOperators, Transaction) == 0) { ATransactionTypeTable TransactionTypeTable; ATransactionTypeRow TransactionTypeRow; TransactionTypeTable = new ATransactionTypeTable(); TransactionTypeRow = TransactionTypeTable.NewRowTyped(); TransactionTypeRow.LedgerNumber = ALedgerNumber; TransactionTypeRow.SubSystemCode = CommonAccountingSubSystemsEnum.AP.ToString(); TransactionTypeRow.TransactionTypeCode = CommonAccountingTransactionTypesEnum.INV.ToString(); TransactionTypeRow.DebitAccountCode = MFinanceConstants.ACCOUNT_BAL_SHT; TransactionTypeRow.CreditAccountCode = MFinanceConstants.ACCOUNT_CREDITORS; TransactionTypeRow.TransactionTypeDescription = "Input Creditor's Invoice"; TransactionTypeRow.SpecialTransactionType = true; TransactionTypeTable.Rows.Add(TransactionTypeRow); ATransactionTypeAccess.SubmitChanges(TransactionTypeTable, Transaction); } // create or update system interface record for accounts payable ASystemInterfaceTable SystemInterfaceTable; ASystemInterfaceRow SystemInterfaceRow; SystemInterfaceTable = ASystemInterfaceAccess.LoadByPrimaryKey(ALedgerNumber, CommonAccountingSubSystemsEnum.AP.ToString(), Transaction); if (SystemInterfaceTable.Count == 0) { SystemInterfaceRow = SystemInterfaceTable.NewRowTyped(); SystemInterfaceRow.LedgerNumber = ALedgerNumber; SystemInterfaceRow.SubSystemCode = CommonAccountingSubSystemsEnum.AP.ToString(); SystemInterfaceRow.SetUpComplete = true; SystemInterfaceTable.Rows.Add(SystemInterfaceRow); } else { SystemInterfaceRow = (ASystemInterfaceRow)SystemInterfaceTable.Rows[0]; SystemInterfaceRow.SetUpComplete = true; } ASystemInterfaceAccess.SubmitChanges(SystemInterfaceTable, Transaction); } if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); } } catch (Exception Exc) { TLogging.Log("An Exception occured while activating the Accounts Payable Subsystem:" + Environment.NewLine + Exc.ToString()); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } throw; } }
public static void ActivateGiftProcessingSubsystem(Int32 ALedgerNumber, Int32 AStartingReceiptNumber) { Boolean NewTransaction; TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, out NewTransaction); try { // if subsystem already active then no need to go further if (!IsGiftProcessingSubsystemActivated(ALedgerNumber)) { // create or update account for Creditor's Control // make sure transaction type exists for gift processing subsystem ATransactionTypeTable TemplateTransactionTypeTable; ATransactionTypeRow TemplateTransactionTypeRow; StringCollection TemplateTransactionTypeOperators; TemplateTransactionTypeTable = new ATransactionTypeTable(); TemplateTransactionTypeRow = TemplateTransactionTypeTable.NewRowTyped(false); TemplateTransactionTypeRow.LedgerNumber = ALedgerNumber; TemplateTransactionTypeRow.SubSystemCode = CommonAccountingSubSystemsEnum.GR.ToString(); TemplateTransactionTypeOperators = new StringCollection(); TemplateTransactionTypeOperators.Add("="); if (ATransactionTypeAccess.CountUsingTemplate(TemplateTransactionTypeRow, TemplateTransactionTypeOperators, Transaction) == 0) { ATransactionTypeTable TransactionTypeTable; ATransactionTypeRow TransactionTypeRow; TransactionTypeTable = new ATransactionTypeTable(); TransactionTypeRow = TransactionTypeTable.NewRowTyped(); TransactionTypeRow.LedgerNumber = ALedgerNumber; TransactionTypeRow.SubSystemCode = CommonAccountingSubSystemsEnum.GR.ToString(); TransactionTypeRow.TransactionTypeCode = CommonAccountingTransactionTypesEnum.GR.ToString(); TransactionTypeRow.DebitAccountCode = "CASH"; TransactionTypeRow.CreditAccountCode = "GIFT"; TransactionTypeRow.TransactionTypeDescription = "Gift Processing"; TransactionTypeRow.SpecialTransactionType = true; TransactionTypeTable.Rows.Add(TransactionTypeRow); ATransactionTypeAccess.SubmitChanges(TransactionTypeTable, Transaction); } ASystemInterfaceTable SystemInterfaceTable; ASystemInterfaceRow SystemInterfaceRow; SystemInterfaceTable = ASystemInterfaceAccess.LoadByPrimaryKey(ALedgerNumber, CommonAccountingSubSystemsEnum.GR.ToString(), Transaction); if (SystemInterfaceTable.Count == 0) { SystemInterfaceRow = SystemInterfaceTable.NewRowTyped(); SystemInterfaceRow.LedgerNumber = ALedgerNumber; SystemInterfaceRow.SubSystemCode = CommonAccountingSubSystemsEnum.GR.ToString(); SystemInterfaceRow.SetUpComplete = true; SystemInterfaceTable.Rows.Add(SystemInterfaceRow); } else { SystemInterfaceRow = (ASystemInterfaceRow)SystemInterfaceTable.Rows[0]; SystemInterfaceRow.SetUpComplete = true; } ASystemInterfaceAccess.SubmitChanges(SystemInterfaceTable, Transaction); // now set the starting receipt number ALedgerTable LedgerTable; ALedgerRow LedgerRow; LedgerTable = ALedgerAccess.LoadByPrimaryKey(ALedgerNumber, Transaction); LedgerRow = (ALedgerRow)LedgerTable.Rows[0]; LedgerRow.LastHeaderRNumber = AStartingReceiptNumber; ALedgerAccess.SubmitChanges(LedgerTable, Transaction); } if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); } } catch (Exception Exc) { TLogging.Log("An Exception occured while activating the Gift Receipting Subsystem:" + Environment.NewLine + Exc.ToString()); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } throw; } }