Exemplo n.º 1
0
        /// <summary>
        /// update the journal header fields from a batch
        /// </summary>
        /// <param name="ABatch"></param>
        public void UpdateHeaderTotals(ABatchRow ABatch)
        {
            decimal SumDebits  = 0.0M;
            decimal SumCredits = 0.0M;

            DataView JournalDV = new DataView(FMainDS.AJournal);

            JournalDV.RowFilter = String.Format("{0}={1}",
                                                AJournalTable.GetBatchNumberDBName(),
                                                ABatch.BatchNumber);

            foreach (DataRowView v in JournalDV)
            {
                AJournalRow r = (AJournalRow)v.Row;

                SumCredits += r.JournalCreditTotal;
                SumDebits  += r.JournalDebitTotal;
            }

            FPetraUtilsObject.DisableDataChangedEvent();

            txtDebit.NumberValueDecimal   = SumDebits;
            txtCredit.NumberValueDecimal  = SumCredits;
            txtControl.NumberValueDecimal = ABatch.BatchControlTotal;
            txtCurrentPeriod.Text         = ABatch.BatchPeriod.ToString();

            FPetraUtilsObject.EnableDataChangedEvent();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculate the base amount for the transactions, and update the totals for the journals and the current batch
        /// </summary>
        /// <param name="AMainDS"></param>
        /// <param name="ACurrentBatch"></param>
        public static void UpdateTotalsOfBatch(ref GLBatchTDS AMainDS,
                                               ABatchRow ACurrentBatch)
        {
            decimal BatchDebitTotal  = 0.0m;
            decimal BatchCreditTotal = 0.0m;

            DataView jnlDataView = new DataView(AMainDS.AJournal);

            jnlDataView.RowFilter = String.Format("{0}={1}",
                                                  AJournalTable.GetBatchNumberDBName(),
                                                  ACurrentBatch.BatchNumber);

            foreach (DataRowView journalView in jnlDataView)
            {
                GLBatchTDSAJournalRow journalRow = (GLBatchTDSAJournalRow)journalView.Row;

                UpdateTotalsOfJournal(ref AMainDS, ref journalRow);

                BatchDebitTotal  += journalRow.JournalDebitTotal;
                BatchCreditTotal += journalRow.JournalCreditTotal;
            }

            if ((ACurrentBatch.BatchDebitTotal != BatchDebitTotal) ||
                (ACurrentBatch.BatchCreditTotal != BatchCreditTotal))
            {
                ACurrentBatch.BatchDebitTotal  = BatchDebitTotal;
                ACurrentBatch.BatchCreditTotal = BatchCreditTotal;
            }
        }
Exemplo n.º 3
0
        private void SetJournalDefaultView()
        {
            string DVRowFilter = string.Format("{0}={1}",
                                               AJournalTable.GetBatchNumberDBName(),
                                               FBatchNumber);

            FMainDS.AJournal.DefaultView.RowFilter = DVRowFilter;
            FMainDS.AJournal.DefaultView.Sort      = String.Format("{0} DESC",
                                                                   AJournalTable.GetJournalNumberDBName()
                                                                   );

            FFilterAndFindObject.FilterPanelControls.SetBaseFilter(DVRowFilter, true);
            FFilterAndFindObject.CurrentActiveFilter = DVRowFilter;
        }
Exemplo n.º 4
0
        // This manual method lets us peek at the data that is about to be saved...
        // The data has already been collected from the contols and validated and there is definitely something to save...
        private TSubmitChangesResult StoreManualCode(ref GLBatchTDS SubmitDS, out TVerificationResultCollection VerificationResult)
        {
            FLatestSaveIncludedForex = false;

            if (SubmitDS.AJournal != null)
            {
                // Check whether we are saving any rows that are in foreign currency
                DataView dv = new DataView(SubmitDS.AJournal,
                                           String.Format("{0}<>{1}", AJournalTable.GetTransactionCurrencyDBName(), AJournalTable.GetBaseCurrencyDBName()),
                                           String.Empty, DataViewRowState.CurrentRows);
                FLatestSaveIncludedForex = (dv.Count > 0);
            }

            // Now do the standard call to save the changes
            return(TRemote.MFinance.GL.WebConnectors.SaveGLBatchTDS(ref SubmitDS, out VerificationResult));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Cancel any changes made to this form
        /// </summary>
        public void CancelChangesToFixedBatches()
        {
            if ((GetBatchRow() != null) && (GetBatchRow().BatchStatus != MFinanceConstants.BATCH_UNPOSTED))
            {
                DataView journalDV = new DataView(FMainDS.AJournal);
                journalDV.RowFilter = string.Format("{0}={1}",
                                                    AJournalTable.GetBatchNumberDBName(),
                                                    GetBatchRow().BatchNumber);

                foreach (DataRowView drv in journalDV)
                {
                    AJournalRow jr = (AJournalRow)drv.Row;
                    jr.RejectChanges();
                }
            }
        }
        private void LoadJournalsForCurrentBatch()
        {
            if (FPreviouslySelectedDetailRow == null)
            {
                return;
            }

            //Current Batch number
            int    BatchNumber = FPreviouslySelectedDetailRow.BatchNumber;
            string BatchStatus = FPreviouslySelectedDetailRow.BatchStatus;

            if (FMainDS.AJournal != null)
            {
                FMainDS.AJournal.DefaultView.RowFilter = String.Format("{0}={1}",
                                                                       AJournalTable.GetBatchNumberDBName(),
                                                                       BatchNumber);

                if (FMainDS.AJournal.DefaultView.Count == 0)
                {
                    ((TFrmGLBatch)this.ParentForm).LoadJournals(FPreviouslySelectedDetailRow);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// load the journals into the grid
        /// </summary>
        /// <param name="ACurrentBatchRow"></param>
        public void LoadJournals(ABatchRow ACurrentBatchRow)
        {
            FJournalsLoaded = false;

            FBatchRow = ACurrentBatchRow;

            if (FBatchRow == null)
            {
                return;
            }

            Int32  CurrentLedgerNumber = FBatchRow.LedgerNumber;
            Int32  CurrentBatchNumber  = FBatchRow.BatchNumber;
            string CurrentBatchStatus  = FBatchRow.BatchStatus;
            bool   BatchIsUnposted     = (FBatchRow.BatchStatus == MFinanceConstants.BATCH_UNPOSTED);

            bool FirstRun           = (FLedgerNumber != CurrentLedgerNumber);
            bool BatchChanged       = (FBatchNumber != CurrentBatchNumber);
            bool BatchStatusChanged = (!BatchChanged && (FBatchStatus != CurrentBatchStatus));

            if (FirstRun)
            {
                FLedgerNumber = CurrentLedgerNumber;
            }

            if (BatchChanged)
            {
                FBatchNumber = CurrentBatchNumber;
            }

            if (BatchStatusChanged)
            {
                FBatchStatus = CurrentBatchStatus;
            }

            //Create object to control deletion
            FCancelLogicObject = new TUC_GLJournals_Cancel(FPetraUtilsObject, FLedgerNumber, FMainDS);

            //Make sure the current effective date for the Batch is correct
            DateTime BatchDateEffective = FBatchRow.DateEffective;

            //Check if need to load Journals
            if (!(FirstRun || BatchChanged || BatchStatusChanged))
            {
                //Need to reconnect FPrev in some circumstances
                if (FPreviouslySelectedDetailRow == null)
                {
                    DataRowView rowView = (DataRowView)grdDetails.Rows.IndexToDataSourceRow(FPrevRowChangedRow);

                    if (rowView != null)
                    {
                        FPreviouslySelectedDetailRow = (GLBatchTDSAJournalRow)(rowView.Row);
                    }
                }

                // The journals are the same and we have loaded them already
                if (BatchIsUnposted)
                {
                    if (GetSelectedRowIndex() > 0)
                    {
                        GetDetailsFromControls(GetSelectedDetailRow());
                    }
                }
            }
            else
            {
                // a different journal
                SetJournalDefaultView();
                FPreviouslySelectedDetailRow = null;

                //Load Journals
                if (FMainDS.AJournal.DefaultView.Count == 0)
                {
                    FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadAJournal(FLedgerNumber, FBatchNumber));
                }

                if (BatchIsUnposted)
                {
                    if (!dtpDetailDateEffective.Date.HasValue || (dtpDetailDateEffective.Date.Value != BatchDateEffective))
                    {
                        dtpDetailDateEffective.Date = BatchDateEffective;
                    }
                }

                //Check if DateEffective has changed and then update all
                foreach (DataRowView drv in FMainDS.AJournal.DefaultView)
                {
                    AJournalRow jr = (AJournalRow)drv.Row;

                    if (jr.DateEffective != BatchDateEffective)
                    {
                        ((TFrmGLBatch)ParentForm).GetTransactionsControl().UpdateTransactionTotals(TGLBatchEnums.eGLLevel.Batch, true);
                        break;
                    }
                }

                ShowData();

                // Now set up the complete current filter
                FFilterAndFindObject.FilterPanelControls.SetBaseFilter(FMainDS.AJournal.DefaultView.RowFilter, true);
                FFilterAndFindObject.ApplyFilter();
            }

            int nRowToSelect = 1;

            TFrmGLBatch myParentForm = (TFrmGLBatch)ParentForm;

            if (myParentForm.InitialBatchFound)
            {
                DataView myView = (grdDetails.DataSource as DevAge.ComponentModel.BoundDataView).DataView;

                for (int counter = 0; (counter < myView.Count); counter++)
                {
                    int myViewJournalNumber = (int)myView[counter][AJournalTable.GetJournalNumberDBName()];

                    if (myViewJournalNumber == myParentForm.InitialJournalNumber)
                    {
                        nRowToSelect = counter + 1;
                        break;
                    }
                }
            }
            else
            {
                nRowToSelect = (BatchChanged || FirstRun) ? 1 : FPrevRowChangedRow;
            }

            //This will also call UpdateChangeableStatus
            SelectRowInGrid(nRowToSelect);

            UpdateRecordNumberDisplay();
            FFilterAndFindObject.SetRecordNumberDisplayProperties();

            txtControl.CurrencyCode = TTxtCurrencyTextBox.CURRENCY_STANDARD_2_DP;
            txtCredit.CurrencyCode  = FLedgerBaseCurrency;
            txtDebit.CurrencyCode   = FLedgerBaseCurrency;

            FJournalsLoaded = true;
        }
Exemplo n.º 8
0
        private static bool CanSubsystemBeDeactivated(Int32 ALedgerNumber, String ASubsystemCode)
        {
            Boolean NewTransaction;
            Boolean Result = false;

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

            if (ASubsystemCode == CommonAccountingSubSystemsEnum.GR.ToString())
            {
                // for gift processing don't allow to deactivate if 'Posted' or 'Unposted' gift batches exist
                AGiftBatchTable TemplateGiftBatchTable;
                AGiftBatchRow TemplateGiftBatchRow;
                StringCollection TemplateGiftBatchOperators;

                TemplateGiftBatchTable = new AGiftBatchTable();
                TemplateGiftBatchRow = TemplateGiftBatchTable.NewRowTyped(false);
                TemplateGiftBatchRow.LedgerNumber = ALedgerNumber;
                TemplateGiftBatchRow.BatchStatus = MFinanceConstants.BATCH_POSTED;
                TemplateGiftBatchOperators = new StringCollection();
                TemplateGiftBatchOperators.Add("=");

                if (AGiftBatchAccess.CountUsingTemplate(TemplateGiftBatchRow, TemplateGiftBatchOperators, Transaction) == 0)
                {
                    Result = true;
                }

                if (!Result)
                {
                    TemplateGiftBatchRow.BatchStatus = MFinanceConstants.BATCH_UNPOSTED;

                    if (AGiftBatchAccess.CountUsingTemplate(TemplateGiftBatchRow, TemplateGiftBatchOperators, Transaction) == 0)
                    {
                        Result = true;
                    }
                }
            }

            if (!Result)
            {
                AJournalTable TemplateJournalTable;
                AJournalRow TemplateJournalRow;
                StringCollection TemplateJournalOperators;

                TemplateJournalTable = new AJournalTable();
                TemplateJournalRow = TemplateJournalTable.NewRowTyped(false);
                TemplateJournalRow.LedgerNumber = ALedgerNumber;
                TemplateJournalRow.SubSystemCode = ASubsystemCode;
                TemplateJournalOperators = new StringCollection();
                TemplateJournalOperators.Add("=");

                ARecurringJournalTable TemplateRJournalTable;
                ARecurringJournalRow TemplateRJournalRow;
                StringCollection TemplateRJournalOperators;

                TemplateRJournalTable = new ARecurringJournalTable();
                TemplateRJournalRow = TemplateRJournalTable.NewRowTyped(false);
                TemplateRJournalRow.LedgerNumber = ALedgerNumber;
                TemplateRJournalRow.SubSystemCode = ASubsystemCode;
                TemplateRJournalOperators = new StringCollection();
                TemplateRJournalOperators.Add("=");

                // do not allow to deactivate subsystem if journals already exist
                if ((AJournalAccess.CountUsingTemplate(TemplateJournalRow, TemplateJournalOperators, Transaction) == 0)
                    && (ARecurringJournalAccess.CountUsingTemplate(TemplateRJournalRow, TemplateRJournalOperators, Transaction) == 0))
                {
                    Result = true;
                }
            }

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

            return Result;
        }
        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);
        }
Exemplo n.º 11
0
        private static bool CanSubsystemBeDeactivated(Int32 ALedgerNumber, String ASubsystemCode)
        {
            #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);
            }
            else if (ASubsystemCode.Length == 0)
            {
                throw new ArgumentException(String.Format(Catalog.GetString("Function:{0} - The Subsystem code is empty!"),
                        Utilities.GetMethodName(true)));
            }

            #endregion Validate Arguments

            Boolean Result = false;

            TDBTransaction Transaction = null;

            try
            {
                DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                    TEnforceIsolationLevel.eilMinimum, ref Transaction,
                    delegate
                    {
                        if (ASubsystemCode == CommonAccountingSubSystemsEnum.GR.ToString())
                        {
                            // for gift processing don't allow to deactivate if 'Posted' or 'Unposted' gift batches exist
                            AGiftBatchTable TemplateGiftBatchTable;
                            AGiftBatchRow TemplateGiftBatchRow;
                            StringCollection TemplateGiftBatchOperators;

                            TemplateGiftBatchTable = new AGiftBatchTable();
                            TemplateGiftBatchRow = TemplateGiftBatchTable.NewRowTyped(false);
                            TemplateGiftBatchRow.LedgerNumber = ALedgerNumber;
                            TemplateGiftBatchRow.BatchStatus = MFinanceConstants.BATCH_POSTED;
                            TemplateGiftBatchOperators = new StringCollection();
                            TemplateGiftBatchOperators.Add("=");

                            if (AGiftBatchAccess.CountUsingTemplate(TemplateGiftBatchRow, TemplateGiftBatchOperators, Transaction) == 0)
                            {
                                Result = true;
                            }

                            if (!Result)
                            {
                                TemplateGiftBatchRow.BatchStatus = MFinanceConstants.BATCH_UNPOSTED;

                                if (AGiftBatchAccess.CountUsingTemplate(TemplateGiftBatchRow, TemplateGiftBatchOperators, Transaction) == 0)
                                {
                                    Result = true;
                                }
                            }
                        }

                        if (!Result)
                        {
                            AJournalTable TemplateJournalTable;
                            AJournalRow TemplateJournalRow;
                            StringCollection TemplateJournalOperators;

                            TemplateJournalTable = new AJournalTable();
                            TemplateJournalRow = TemplateJournalTable.NewRowTyped(false);
                            TemplateJournalRow.LedgerNumber = ALedgerNumber;
                            TemplateJournalRow.SubSystemCode = ASubsystemCode;
                            TemplateJournalOperators = new StringCollection();
                            TemplateJournalOperators.Add("=");

                            ARecurringJournalTable TemplateRJournalTable;
                            ARecurringJournalRow TemplateRJournalRow;
                            StringCollection TemplateRJournalOperators;

                            TemplateRJournalTable = new ARecurringJournalTable();
                            TemplateRJournalRow = TemplateRJournalTable.NewRowTyped(false);
                            TemplateRJournalRow.LedgerNumber = ALedgerNumber;
                            TemplateRJournalRow.SubSystemCode = ASubsystemCode;
                            TemplateRJournalOperators = new StringCollection();
                            TemplateRJournalOperators.Add("=");

                            // do not allow to deactivate subsystem if journals already exist
                            if ((AJournalAccess.CountUsingTemplate(TemplateJournalRow, TemplateJournalOperators, Transaction) == 0)
                                && (ARecurringJournalAccess.CountUsingTemplate(TemplateRJournalRow, TemplateRJournalOperators, Transaction) == 0))
                            {
                                Result = true;
                            }
                        }
                    });
            }
            catch (Exception ex)
            {
                TLogging.Log(String.Format("Method:{0} - Unexpected error!{1}{1}{2}",
                        Utilities.GetMethodSignature(),
                        Environment.NewLine,
                        ex.Message));
                throw ex;
            }

            return Result;
        }
Exemplo n.º 12
0
        public static void GenerateHOSAReports(int ALedgerNumber,
                                               int APeriodNumber,
                                               int AIchNumber,
                                               string ACurrencySelect,
                                               out TVerificationResultCollection AVerificationResult
                                               )
        {
            AVerificationResult = new TVerificationResultCollection();

            //Begin the transaction
            bool NewTransaction = false;

            TDBTransaction    DBTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, out NewTransaction);
            ALedgerTable      ALedger       = ALedgerAccess.LoadByPrimaryKey(ALedgerNumber, DBTransaction);
            AJournalTable     AJournal      = new AJournalTable();
            ATransactionTable ATransaction  = new ATransactionTable();
            ACostCentreTable  ACostCentre   = new ACostCentreTable();

            try
            {
#if TODO
                ALedgerRow LedgerRow = PostingDS.ALedger[0];
                //Find the Ledger Name = Partner Short Name
                PPartnerTable PartnerTable = PPartnerAccess.LoadByPrimaryKey(LedgerRow.PartnerKey, DBTransaction);
                PPartnerRow   PartnerRow   = (PPartnerRow)PartnerTable.Rows[0];
                string        LedgerName   = PartnerRow.PartnerShortName;
#endif

                //
                // Load the Journals, and Transactions for this period:
                String JournalQuery = "SELECT PUB_a_journal.* FROM PUB_a_batch, PUB_a_journal WHERE " +
                                      "PUB_a_batch.a_ledger_number_i = " + ALedgerNumber +
                                      " AND PUB_a_batch.a_batch_year_i = " + ALedger[0].CurrentFinancialYear +
                                      " AND PUB_a_batch.a_batch_period_i = " + APeriodNumber +
                                      " AND PUB_a_batch.a_batch_status_c = 'Posted'" +
                                      " AND PUB_a_batch.a_ledger_number_i = PUB_a_journal.a_ledger_number_i" +
                                      " AND PUB_a_batch.a_batch_number_i = PUB_a_journal.a_batch_number_i";

                DBAccess.GDBAccessObj.SelectDT(AJournal, JournalQuery, DBTransaction);

                String TransactionQuery = "SELECT PUB_a_transaction.* FROM PUB_a_batch, PUB_a_transaction WHERE " +
                                          "PUB_a_batch.a_ledger_number_i = " + ALedgerNumber +
                                          " AND PUB_a_batch.a_batch_year_i = " + ALedger[0].CurrentFinancialYear +
                                          " AND PUB_a_batch.a_batch_period_i = " + APeriodNumber +
                                          " AND PUB_a_batch.a_batch_status_c = 'Posted'" +
                                          " AND PUB_a_batch.a_ledger_number_i = PUB_a_transaction.a_ledger_number_i" +
                                          " AND PUB_a_batch.a_batch_number_i = PUB_a_transaction.a_batch_number_i";

                DBAccess.GDBAccessObj.SelectDT(ATransaction, TransactionQuery, DBTransaction);

                String CostCentreQuery = "SELECT * FROM a_cost_centre WHERE " +
                                         ACostCentreTable.GetLedgerNumberDBName() + " = " + ALedgerNumber +
                                         " AND " + ACostCentreTable.GetPostingCostCentreFlagDBName() + " = True" +
                                         " AND " + ACostCentreTable.GetCostCentreTypeDBName() + " LIKE '" + MFinanceConstants.FOREIGN_CC_TYPE + "'" +
                                         " ORDER BY " + ACostCentreTable.GetCostCentreCodeDBName();

                DBAccess.GDBAccessObj.SelectDT(ACostCentre, CostCentreQuery, DBTransaction);

                //Iterate through the cost centres
                foreach (ACostCentreRow CostCentreRow in ACostCentre.Rows)
                {
                    bool TransactionExists = false;

                    //Iterate through the journals
                    foreach (AJournalRow JournalRow in AJournal.Rows)
                    {
                        int BatchNumber   = JournalRow.BatchNumber;
                        int JournalNumber = JournalRow.JournalNumber;

#if TODO
                        String TransFilter =
                            ATransactionTable.GetBatchNumberDBName() + " = " + BatchNumber.ToString() +
                            " AND " + ATransactionTable.GetJournalNumberDBName() + " = " + JournalNumber.ToString() +
                            " AND " + ATransactionTable.GetCostCentreCodeDBName() + " = '" + CostCentreRow.CostCentreCode + "'" +
                            " AND (" + ATransactionTable.GetIchNumberDBName() + " = 0" +
                            "      OR " + ATransactionTable.GetIchNumberDBName() + " = " + AIchNumber.ToString() +
                            ")";

                        DataRow[] FoundTransRows = BatchDS.ATransaction.Select(TransFilter);

                        foreach (DataRow untypedTransRow in FoundTransRows)
                        {
                            ATransactionRow TransactionRow = (ATransactionRow)untypedTransRow;

                            TransactionExists = true;

                            string DefaultData = ALedgerNumber.ToString() + "," +
                                                 LedgerName + "," +
                                                 APeriodNumber.ToString() + "," +
                                                 APeriodNumber.ToString() + "," +
                                                 CostCentreRow.CostCentreCode + "," +
                                                 "" + "," +
                                                 "" + "," +
                                                 "" + "," +
                                                 "A" + "," +
                                                 LedgerRow.CurrentFinancialYear.ToString() + "," +
                                                 LedgerRow.CurrentPeriod.ToString() + "," +
                                                 MFinanceConstants.MAX_PERIODS.ToString() + "," +
                                                 "h" + "," +
                                                 ACurrency + "," +
                                                 AIchNumber.ToString();

                            string ReportTitle = "Home Office Stmt of Acct: " + CostCentreRow.CostCentreName;

                            //call code for gl2120p.p Produces Account Detail, Analysis Attribute and HOSA Reprint reports.

                            /* RUN sm9000.w ("gl2120p.p",
                             *                               lv_report_title_c,
                             *                               lv_default_data_c).*/
                            //TODO: call code to produce reports
                            break;
                        }
#endif

                        if (TransactionExists)
                        {
                            //only need to run above code once for 1 transaction per cost centre code
                            break;     //goto next cost centre else try next journal
                        }
                    }
                }

                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.RollbackTransaction();
                }
            }
            catch (Exception Exp)
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.RollbackTransaction();
                }

                TLogging.Log(Exp.Message);
                TLogging.Log(Exp.StackTrace);

                throw;
            }
        }
Exemplo n.º 13
0
        public static void GenerateHOSAReports(int ALedgerNumber,
            int APeriodNumber,
            int AIchNumber,
            string ACurrencySelect,
            out TVerificationResultCollection AVerificationResult
            )
        {
            AVerificationResult = new TVerificationResultCollection();

            //Begin the transaction
            bool NewTransaction = false;

            TDBTransaction DBTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, out NewTransaction);
            ALedgerTable ALedger = ALedgerAccess.LoadByPrimaryKey(ALedgerNumber, DBTransaction);
            AJournalTable AJournal = new AJournalTable();
            ATransactionTable ATransaction = new ATransactionTable();
            ACostCentreTable ACostCentre = new ACostCentreTable();

            try
            {
#if TODO
                ALedgerRow LedgerRow = PostingDS.ALedger[0];
                //Find the Ledger Name = Partner Short Name
                PPartnerTable PartnerTable = PPartnerAccess.LoadByPrimaryKey(LedgerRow.PartnerKey, DBTransaction);
                PPartnerRow PartnerRow = (PPartnerRow)PartnerTable.Rows[0];
                string LedgerName = PartnerRow.PartnerShortName;
#endif

                //
                // Load the Journals, and Transactions for this period:
                String JournalQuery = "SELECT PUB_a_journal.* FROM PUB_a_batch, PUB_a_journal WHERE " +
                                      "PUB_a_batch.a_ledger_number_i = " + ALedgerNumber +
                                      " AND PUB_a_batch.a_batch_year_i = " + ALedger[0].CurrentFinancialYear +
                                      " AND PUB_a_batch.a_batch_period_i = " + APeriodNumber +
                                      " AND PUB_a_batch.a_batch_status_c = 'Posted'" +
                                      " AND PUB_a_batch.a_ledger_number_i = PUB_a_journal.a_ledger_number_i" +
                                      " AND PUB_a_batch.a_batch_number_i = PUB_a_journal.a_batch_number_i";

                DBAccess.GDBAccessObj.SelectDT(AJournal, JournalQuery, DBTransaction);

                String TransactionQuery = "SELECT PUB_a_transaction.* FROM PUB_a_batch, PUB_a_transaction WHERE " +
                                          "PUB_a_batch.a_ledger_number_i = " + ALedgerNumber +
                                          " AND PUB_a_batch.a_batch_year_i = " + ALedger[0].CurrentFinancialYear +
                                          " AND PUB_a_batch.a_batch_period_i = " + APeriodNumber +
                                          " AND PUB_a_batch.a_batch_status_c = 'Posted'" +
                                          " AND PUB_a_batch.a_ledger_number_i = PUB_a_transaction.a_ledger_number_i" +
                                          " AND PUB_a_batch.a_batch_number_i = PUB_a_transaction.a_batch_number_i";

                DBAccess.GDBAccessObj.SelectDT(ATransaction, TransactionQuery, DBTransaction);

                String CostCentreQuery = "SELECT * FROM a_cost_centre WHERE " +
                                         ACostCentreTable.GetLedgerNumberDBName() + " = " + ALedgerNumber +
                                         " AND " + ACostCentreTable.GetPostingCostCentreFlagDBName() + " = True" +
                                         " AND " + ACostCentreTable.GetCostCentreTypeDBName() + " LIKE '" + MFinanceConstants.FOREIGN_CC_TYPE + "'" +
                                         " ORDER BY " + ACostCentreTable.GetCostCentreCodeDBName();

                DBAccess.GDBAccessObj.SelectDT(ACostCentre, CostCentreQuery, DBTransaction);

                //Iterate through the cost centres
                foreach (ACostCentreRow CostCentreRow in ACostCentre.Rows)
                {
                    bool TransactionExists = false;

                    //Iterate through the journals
                    foreach (AJournalRow JournalRow in AJournal.Rows)
                    {
                        int BatchNumber = JournalRow.BatchNumber;
                        int JournalNumber = JournalRow.JournalNumber;

#if TODO
                        String TransFilter =
                            ATransactionTable.GetBatchNumberDBName() + " = " + BatchNumber.ToString() +
                            " AND " + ATransactionTable.GetJournalNumberDBName() + " = " + JournalNumber.ToString() +
                            " AND " + ATransactionTable.GetCostCentreCodeDBName() + " = '" + CostCentreRow.CostCentreCode + "'" +
                            " AND (" + ATransactionTable.GetIchNumberDBName() + " = 0" +
                            "      OR " + ATransactionTable.GetIchNumberDBName() + " = " + AIchNumber.ToString() +
                            ")";

                        DataRow[] FoundTransRows = BatchDS.ATransaction.Select(TransFilter);

                        foreach (DataRow untypedTransRow in FoundTransRows)
                        {
                            ATransactionRow TransactionRow = (ATransactionRow)untypedTransRow;

                            TransactionExists = true;

                            string DefaultData = ALedgerNumber.ToString() + "," +
                                                 LedgerName + "," +
                                                 APeriodNumber.ToString() + "," +
                                                 APeriodNumber.ToString() + "," +
                                                 CostCentreRow.CostCentreCode + "," +
                                                 "" + "," +
                                                 "" + "," +
                                                 "" + "," +
                                                 "A" + "," +
                                                 LedgerRow.CurrentFinancialYear.ToString() + "," +
                                                 LedgerRow.CurrentPeriod.ToString() + "," +
                                                 MFinanceConstants.MAX_PERIODS.ToString() + "," +
                                                 "h" + "," +
                                                 ACurrency + "," +
                                                 AIchNumber.ToString();

                            string ReportTitle = "Home Office Stmt of Acct: " + CostCentreRow.CostCentreName;

                            //call code for gl2120p.p Produces Account Detail, Analysis Attribute and HOSA Reprint reports.

                            /* RUN sm9000.w ("gl2120p.p",
                             *                               lv_report_title_c,
                             *                               lv_default_data_c).*/
                            //TODO: call code to produce reports
                            break;
                        }
#endif

                        if (TransactionExists)
                        {
                            //only need to run above code once for 1 transaction per cost centre code
                            break;     //goto next cost centre else try next journal
                        }
                    }
                }

                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.RollbackTransaction();
                }
            }
            catch (Exception Exp)
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.RollbackTransaction();
                }

                TLogging.Log(Exp.Message);
                TLogging.Log(Exp.StackTrace);

                throw;
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// load the journals into the grid
        /// </summary>
        /// <param name="ALedgerNumber"></param>
        /// <param name="ABatchNumber"></param>
        /// <param name="ABatchStatus"></param>
        public void LoadJournals(Int32 ALedgerNumber, Int32 ABatchNumber, string ABatchStatus = MFinanceConstants.BATCH_UNPOSTED)
        {
            FJournalsLoaded = false;
            FBatchRow       = GetBatchRow();

            if (FBatchRow == null)
            {
                return;
            }

            FCancelLogicObject = new TUC_GLJournals_Cancel(FPetraUtilsObject, FLedgerNumber, FMainDS);

            //Make sure the current effective date for the Batch is correct
            DateTime BatchDateEffective = FBatchRow.DateEffective;

            bool FirstRun           = (FLedgerNumber != ALedgerNumber);
            bool BatchChanged       = (FBatchNumber != ABatchNumber);
            bool BatchStatusChanged = (!BatchChanged && FBatchStatus != ABatchStatus);

            //Check if need to load Journals
            if (FirstRun || BatchChanged || BatchStatusChanged)
            {
                FLedgerNumber = ALedgerNumber;
                FBatchNumber  = ABatchNumber;
                FBatchStatus  = ABatchStatus;

                SetJournalDefaultView();
                FPreviouslySelectedDetailRow = null;

                //Load Journals
                if (FMainDS.AJournal.DefaultView.Count == 0)
                {
                    FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadAJournalAndContent(FLedgerNumber, FBatchNumber));
                }

                if (FBatchStatus == MFinanceConstants.BATCH_UNPOSTED)
                {
                    if (!dtpDetailDateEffective.Date.HasValue || (dtpDetailDateEffective.Date.Value != BatchDateEffective))
                    {
                        dtpDetailDateEffective.Date = BatchDateEffective;
                    }
                }

                foreach (DataRowView drv in FMainDS.AJournal.DefaultView)
                {
                    AJournalRow jr = (AJournalRow)drv.Row;

                    if (jr.DateEffective != BatchDateEffective)
                    {
                        ((TFrmGLBatch)ParentForm).GetTransactionsControl().UpdateTransactionTotals("BATCH", true);
                        break;
                    }
                }

                ShowData();

                // Now set up the complete current filter
                FFilterAndFindObject.FilterPanelControls.SetBaseFilter(FMainDS.AJournal.DefaultView.RowFilter, true);
                FFilterAndFindObject.ApplyFilter();
            }
            else
            {
                // The journals are the same and we have loaded them already
                if (FBatchRow.BatchStatus == MFinanceConstants.BATCH_UNPOSTED)
                {
                    if (GetSelectedRowIndex() > 0)
                    {
                        GetDetailsFromControls(GetSelectedDetailRow());
                    }
                }
            }

            int nRowToSelect = 1;

            TFrmGLBatch myParentForm = (TFrmGLBatch)ParentForm;

            if (myParentForm.InitialBatchFound)
            {
                string   filter = String.Format("{0}={1}", AJournalTable.GetJournalNumberDBName(), myParentForm.InitialJournalNumber);
                DataView dv     = new DataView(FMainDS.AJournal, filter, "", DataViewRowState.CurrentRows);

                if (dv.Count > 0)
                {
                    nRowToSelect = grdDetails.DataSourceRowToIndex2(dv[0].Row) + 1;
                }
            }
            else
            {
                nRowToSelect = (BatchChanged || FirstRun) ? 1 : FPrevRowChangedRow;
            }

            //This will also call UpdateChangeableStatus
            SelectRowInGrid(nRowToSelect);

            UpdateRecordNumberDisplay();
            FFilterAndFindObject.SetRecordNumberDisplayProperties();

            FJournalsLoaded = true;
        }
Exemplo n.º 15
0
        /// <summary>
        /// ResetForwardPeriodBatches.RunOperation
        ///
        /// Reset period columns on batch, journal and gift batch tables for periods beyond end of the old year
        /// </summary>
        public override Int32 RunOperation()
        {
            Int32 JobSize = 0;
            bool NewTransaction;
            Boolean ShouldCommit = false;
            TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted,
                TEnforceIsolationLevel.eilMinimum,
                out NewTransaction);

            try
            {
                String Query =
                    "SELECT * FROM PUB_a_batch WHERE " +
                    "a_ledger_number_i=" + FLedgerInfo.LedgerNumber +
                    " AND a_batch_year_i=" + FOldYearNum +
                    " AND a_batch_period_i>" + FLedgerInfo.NumberOfAccountingPeriods;
                ABatchTable BatchTbl = new ABatchTable();
                DBAccess.GDBAccessObj.SelectDT(BatchTbl, Query, Transaction);

                if (BatchTbl.Rows.Count > 0)
                {
                    JobSize = BatchTbl.Rows.Count;

                    if (!FInfoMode)
                    {
                        foreach (ABatchRow BatchRow in BatchTbl.Rows)
                        {
                            BatchRow.BatchPeriod -= FLedgerInfo.NumberOfAccountingPeriods;
                            BatchRow.BatchYear += 1;
                        }

                        ABatchAccess.SubmitChanges(BatchTbl, Transaction);
                        ShouldCommit = true;
                    }
                }

                Query =
                    "SELECT PUB_a_journal.* FROM PUB_a_batch, PUB_a_journal WHERE " +
                    " PUB_a_journal.a_ledger_number_i=" + FLedgerInfo.LedgerNumber +
                    " AND PUB_a_batch.a_batch_number_i= PUB_a_journal.a_batch_number_i" +
                    " AND PUB_a_batch.a_batch_year_i=" + FOldYearNum +
                    " AND a_journal_period_i>" + FLedgerInfo.NumberOfAccountingPeriods;
                AJournalTable JournalTbl = new AJournalTable();
                DBAccess.GDBAccessObj.SelectDT(JournalTbl, Query, Transaction);

                if (JournalTbl.Rows.Count > 0)
                {
                    if (!FInfoMode)
                    {
                        foreach (AJournalRow JournalRow in JournalTbl.Rows)
                        {
                            JournalRow.JournalPeriod -= FLedgerInfo.NumberOfAccountingPeriods;
                        }

                        AJournalAccess.SubmitChanges(JournalTbl, Transaction);
                        ShouldCommit = true;
                    }
                }

                Query =
                    "SELECT * FROM PUB_a_gift_batch WHERE " +
                    " a_ledger_number_i=" + FLedgerInfo.LedgerNumber +
                    " AND a_batch_year_i=" + FOldYearNum +
                    " AND a_batch_period_i>" + FLedgerInfo.NumberOfAccountingPeriods;
                AGiftBatchTable GiftBatchTbl = new AGiftBatchTable();
                DBAccess.GDBAccessObj.SelectDT(GiftBatchTbl, Query, Transaction);

                if (GiftBatchTbl.Rows.Count > 0)
                {
                    JobSize += GiftBatchTbl.Rows.Count;

                    if (!FInfoMode)
                    {
                        foreach (AGiftBatchRow GiftBatchRow in GiftBatchTbl.Rows)
                        {
                            GiftBatchRow.BatchPeriod -= FLedgerInfo.NumberOfAccountingPeriods;
                            GiftBatchRow.BatchYear += 1;
                        }

                        AGiftBatchAccess.SubmitChanges(GiftBatchTbl, Transaction);
                        ShouldCommit = true;
                    }
                }
            }     // try
            finally
            {
                if (NewTransaction)
                {
                    if (ShouldCommit)
                    {
                        DBAccess.GDBAccessObj.CommitTransaction();
                    }
                    else
                    {
                        DBAccess.GDBAccessObj.RollbackTransaction();
                    }
                }
            }
            return JobSize;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Re-show the specified row
        /// </summary>
        /// <param name="ACurrentBatch"></param>
        /// <param name="AJournalToCancel"></param>
        /// <param name="ARedisplay"></param>
        public void PrepareJournalDataForCancelling(Int32 ACurrentBatch, Int32 AJournalToCancel, Boolean ARedisplay)
        {
            //This code will only be called when the Journal tab is active.

            DataView JournalDV   = new DataView(FMainDS.AJournal);
            DataView TransDV     = new DataView(FMainDS.ATransaction);
            DataView TransAnalDV = new DataView(FMainDS.ATransAnalAttrib);

            JournalDV.RowFilter = String.Format("{0}={1} And {2}={3}",
                                                AJournalTable.GetBatchNumberDBName(),
                                                ACurrentBatch,
                                                AJournalTable.GetJournalNumberDBName(),
                                                AJournalToCancel);

            TransDV.RowFilter = String.Format("{0}={1} And {2}={3}",
                                              ATransactionTable.GetBatchNumberDBName(),
                                              ACurrentBatch,
                                              ATransactionTable.GetJournalNumberDBName(),
                                              AJournalToCancel);

            TransAnalDV.RowFilter = String.Format("{0}={1} And {2}={3}",
                                                  ATransAnalAttribTable.GetBatchNumberDBName(),
                                                  ACurrentBatch,
                                                  ATransAnalAttribTable.GetJournalNumberDBName(),
                                                  AJournalToCancel);

            //Work from lowest level up
            if (TransAnalDV.Count > 0)
            {
                TransAnalDV.Sort = String.Format("{0}, {1}",
                                                 ATransAnalAttribTable.GetTransactionNumberDBName(),
                                                 ATransAnalAttribTable.GetAnalysisTypeCodeDBName());

                foreach (DataRowView drv in TransAnalDV)
                {
                    ATransAnalAttribRow transAnalRow = (ATransAnalAttribRow)drv.Row;

                    if (transAnalRow.RowState == DataRowState.Added)
                    {
                        //Do nothing
                    }
                    else if (transAnalRow.RowState != DataRowState.Unchanged)
                    {
                        transAnalRow.RejectChanges();
                    }
                }
            }

            if (TransDV.Count > 0)
            {
                TransDV.Sort = String.Format("{0}", ATransactionTable.GetTransactionNumberDBName());

                foreach (DataRowView drv in TransDV)
                {
                    ATransactionRow transRow = (ATransactionRow)drv.Row;

                    if (transRow.RowState == DataRowState.Added)
                    {
                        //Do nothing
                    }
                    else if (transRow.RowState != DataRowState.Unchanged)
                    {
                        transRow.RejectChanges();
                    }
                }
            }

            if (JournalDV.Count > 0)
            {
                GLBatchTDSAJournalRow journalRow = (GLBatchTDSAJournalRow)JournalDV[0].Row;

                //No need to check for Added state as new journals are always saved
                // on creation
                if (journalRow.RowState != DataRowState.Unchanged)
                {
                    journalRow.RejectChanges();
                }

                if (ARedisplay)
                {
                    ShowDetails(journalRow);
                }
            }

            if (TransDV.Count == 0)
            {
                //Load all related data for journal ready to delete/cancel
                FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadATransactionAndRelatedTablesForJournal(FLedgerNumber, ACurrentBatch,
                                                                                                           AJournalToCancel));
            }
        }
Exemplo n.º 17
0
        public static TSubmitChangesResult SaveData(string ATablename,
                                                    ref TTypedDataTable ASubmitTable,
                                                    out TVerificationResultCollection AVerificationResult)
        {
            TDBTransaction  SubmitChangesTransaction = null;
            bool            SubmissionOK             = false;
            TTypedDataTable SubmitTable = ASubmitTable;

            TVerificationResultCollection VerificationResult = null;

            // TODO: check write permissions

            if (ASubmitTable != null)
            {
                VerificationResult = new TVerificationResultCollection();

                DBAccess.GDBAccessObj.BeginAutoTransaction(IsolationLevel.Serializable, ref SubmitChangesTransaction, ref SubmissionOK,
                                                           delegate
                {
                    try
                    {
                        if (ATablename == AAccountingPeriodTable.GetTableDBName())
                        {
                            AAccountingPeriodAccess.SubmitChanges((AAccountingPeriodTable)SubmitTable, SubmitChangesTransaction);

                            TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                                TCacheableFinanceTablesEnum.AccountingPeriodList.ToString());
                        }
                        else if (ATablename == ACurrencyTable.GetTableDBName())
                        {
                            ACurrencyAccess.SubmitChanges((ACurrencyTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == ADailyExchangeRateTable.GetTableDBName())
                        {
                            ADailyExchangeRateAccess.SubmitChanges((ADailyExchangeRateTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == ACorporateExchangeRateTable.GetTableDBName())
                        {
                            ACorporateExchangeRateAccess.SubmitChanges((ACorporateExchangeRateTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == ACurrencyLanguageTable.GetTableDBName())
                        {
                            ACurrencyLanguageAccess.SubmitChanges((ACurrencyLanguageTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == AFeesPayableTable.GetTableDBName())
                        {
                            AFeesPayableAccess.SubmitChanges((AFeesPayableTable)SubmitTable, SubmitChangesTransaction);

                            TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                                TCacheableFinanceTablesEnum.FeesPayableList.ToString());
                        }
                        else if (ATablename == AFeesReceivableTable.GetTableDBName())
                        {
                            AFeesReceivableAccess.SubmitChanges((AFeesReceivableTable)SubmitTable, SubmitChangesTransaction);

                            TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                                TCacheableFinanceTablesEnum.FeesReceivableList.ToString());
                        }
                        else if (ATablename == AGiftBatchTable.GetTableDBName())
                        {
                            // This method is called from ADailyExchangeRate Setup - please do not remove
                            // The method is not required for changes made to the gift batch screens, which use a TDS
                            AGiftBatchAccess.SubmitChanges((AGiftBatchTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == AJournalTable.GetTableDBName())
                        {
                            // This method is called from ADailyExchangeRate Setup - please do not remove
                            // The method is not required for changes made to the journal screens, which use a TDS
                            AJournalAccess.SubmitChanges((AJournalTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == ARecurringJournalTable.GetTableDBName())
                        {
                            // This method is called from Submit Recurring GL Batch form - please do not remove
                            // The method is not required for changes made to the journal screens, which use a TDS
                            ARecurringJournalAccess.SubmitChanges((ARecurringJournalTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == ALedgerTable.GetTableDBName())
                        {
                            // This method is called from ADailyExchangeRate Testing - please do not remove
                            ALedgerAccess.SubmitChanges((ALedgerTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == AAnalysisTypeTable.GetTableDBName())
                        {
                            AAnalysisTypeAccess.SubmitChanges((AAnalysisTypeTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == ASuspenseAccountTable.GetTableDBName())
                        {
                            ASuspenseAccountAccess.SubmitChanges((ASuspenseAccountTable)SubmitTable, SubmitChangesTransaction);

                            TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                                TCacheableFinanceTablesEnum.SuspenseAccountList.ToString());
                        }
                        else if (ATablename == PcAttendeeTable.GetTableDBName())
                        {
                            PcAttendeeAccess.SubmitChanges((PcAttendeeTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == PcConferenceTable.GetTableDBName())
                        {
                            PcConferenceAccess.SubmitChanges((PcConferenceTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == PcConferenceCostTable.GetTableDBName())
                        {
                            PcConferenceCostAccess.SubmitChanges((PcConferenceCostTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == PcEarlyLateTable.GetTableDBName())
                        {
                            PcEarlyLateAccess.SubmitChanges((PcEarlyLateTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == PcSupplementTable.GetTableDBName())
                        {
                            PcSupplementAccess.SubmitChanges((PcSupplementTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == PcDiscountTable.GetTableDBName())
                        {
                            PcDiscountAccess.SubmitChanges((PcDiscountTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == PInternationalPostalTypeTable.GetTableDBName())
                        {
                            ValidateInternationalPostalType(ref VerificationResult, SubmitTable);
                            ValidateInternationalPostalTypeManual(ref VerificationResult, SubmitTable);

                            if (TVerificationHelper.IsNullOrOnlyNonCritical(VerificationResult))
                            {
                                PInternationalPostalTypeAccess.SubmitChanges((PInternationalPostalTypeTable)SubmitTable, SubmitChangesTransaction);
                            }
                        }
                        else if (ATablename == PtApplicationTypeTable.GetTableDBName())
                        {
                            PtApplicationTypeAccess.SubmitChanges((PtApplicationTypeTable)SubmitTable, SubmitChangesTransaction);

                            // mark dependent lists for needing to be refreshed since there was a change in base list
                            TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                                TCacheablePersonTablesEnum.EventApplicationTypeList.ToString());
                            TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                                TCacheablePersonTablesEnum.FieldApplicationTypeList.ToString());
                        }
                        else if (ATablename == PFormTable.GetTableDBName())
                        {
                            PFormAccess.SubmitChanges((PFormTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == PFormalityTable.GetTableDBName())
                        {
                            PFormalityAccess.SubmitChanges((PFormalityTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == PMailingTable.GetTableDBName())
                        {
                            PMailingAccess.SubmitChanges((PMailingTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == PPartnerGiftDestinationTable.GetTableDBName())
                        {
                            PPartnerGiftDestinationAccess.SubmitChanges((PPartnerGiftDestinationTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == PmDocumentTypeTable.GetTableDBName())
                        {
                            PmDocumentTypeAccess.SubmitChanges((PmDocumentTypeTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else if (ATablename == SGroupTable.GetTableDBName())
                        {
                            SGroupAccess.SubmitChanges((SGroupTable)SubmitTable, SubmitChangesTransaction);
                        }
                        else
                        {
                            throw new EOPAppException("TCommonDataReader.SaveData: unknown table '" + ATablename + "'");
                        }

                        SubmissionOK = true;
                    }
                    catch (Exception Exc)
                    {
                        VerificationResult.Add(
                            new TVerificationResult(null, "Cannot SubmitChanges:" + Environment.NewLine +
                                                    Exc.Message, "UNDEFINED", TResultSeverity.Resv_Critical));
                    }
                });
            }

            ASubmitTable        = SubmitTable;
            AVerificationResult = VerificationResult;

            if ((AVerificationResult != null) &&
                (AVerificationResult.Count > 0))
            {
                // Downgrade TScreenVerificationResults to TVerificationResults in order to allow
                // Serialisation (needed for .NET Remoting).
                TVerificationResultCollection.DowngradeScreenVerificationResults(AVerificationResult);

                return(AVerificationResult.HasCriticalErrors ? TSubmitChangesResult.scrError : TSubmitChangesResult.scrOK);
            }

            return(TSubmitChangesResult.scrOK);
        }
Exemplo n.º 18
0
        private int GetChangedRecordCountManual(out string AMessage)
        {
            // For GL Batch we will get some mix of batches, journals and transactions
            List <Tuple <string, int> > TableAndCountList = new List <Tuple <string, int> >();
            int allChangesCount = 0;

            // Work out how many changes in each table
            foreach (DataTable dt in FMainDS.Tables)
            {
                if (dt != null)
                {
                    int tableChangesCount = 0;

                    foreach (DataRow dr in dt.Rows)
                    {
                        if (dr.RowState != DataRowState.Unchanged)
                        {
                            tableChangesCount++;
                            allChangesCount++;
                        }
                    }

                    if (tableChangesCount > 0)
                    {
                        TableAndCountList.Add(new Tuple <string, int>(dt.TableName, tableChangesCount));
                    }
                }
            }

            // Now build up a sensible message
            AMessage = String.Empty;

            if (TableAndCountList.Count > 0)
            {
                int nBatches      = 0;
                int nJournals     = 0;
                int nTransactions = 0;

                foreach (Tuple <string, int> TableAndCount in TableAndCountList)
                {
                    if (TableAndCount.Item1.Equals(ABatchTable.GetTableName()))
                    {
                        nBatches = TableAndCount.Item2;
                    }
                    else if (TableAndCount.Item1.Equals(AJournalTable.GetTableName()))
                    {
                        nJournals = TableAndCount.Item2;
                    }
                    else if (TableAndCount.Item2 > nTransactions)
                    {
                        nTransactions = TableAndCount.Item2;
                    }
                }

                AMessage = Catalog.GetString("    You have made changes to ");
                string strBatches      = String.Empty;
                string strJournals     = String.Empty;
                string strTransactions = String.Empty;

                if (nBatches > 0)
                {
                    strBatches = String.Format("{0} {1}",
                                               nBatches,
                                               Catalog.GetPluralString("batch", "batches", nBatches));
                }

                if (nJournals > 0)
                {
                    strJournals = String.Format("{0} {1}",
                                                nJournals,
                                                Catalog.GetPluralString("journal", "journals", nJournals));
                }

                if (nTransactions > 0)
                {
                    strTransactions = String.Format("{0} {1}",
                                                    nTransactions,
                                                    Catalog.GetPluralString("transaction", "transactions", nTransactions));
                }

                bool bGotAll = (nBatches > 0) && (nJournals > 0) && (nTransactions > 0);

                if (nBatches > 0)
                {
                    AMessage += strBatches;
                }

                if (nJournals > 0)
                {
                    if (bGotAll)
                    {
                        AMessage += ", ";
                    }
                    else if (nBatches > 0)
                    {
                        AMessage += " and ";
                    }

                    AMessage += strJournals;
                }

                if (nTransactions > 0)
                {
                    if ((nBatches > 0) || (nJournals > 0))
                    {
                        AMessage += " and ";
                    }

                    AMessage += strTransactions;
                }

                AMessage += Environment.NewLine;
                AMessage += String.Format(TFrmPetraEditUtils.StrConsequenceIfNotSaved, Environment.NewLine);
            }

            return(allChangesCount);
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
 public static void LoadAll()
 {
     AJournal = new AJournalTable();
     SerialisableDS.LoadAll(AJournal, AJournalTable.GetTableDBName());
 }
Exemplo n.º 21
0
        /// <summary>
        /// Calculate the base amount for the transactions, and update the totals for the journals and the current batch
        ///   This assumes that all relevant data has already been loaded
        /// </summary>
        /// <param name="AMainDS"></param>
        /// <param name="ACurrentBatchRow"></param>
        /// <param name="ACurrentJournalNumber"></param>
        /// <returns>false if no change to batch totals</returns>
        public static bool UpdateBatchTotals(ref GLBatchTDS AMainDS,
                                             ref ABatchRow ACurrentBatchRow, Int32 ACurrentJournalNumber = 0)
        {
            #region Validate Arguments

            if (AMainDS == null)
            {
                throw new EFinanceSystemDataObjectNullOrEmptyException(String.Format(Catalog.GetString("Function:{0} - The GL Batch dataset is null!"),
                                                                                     Utilities.GetMethodName(true)));
            }
            else if (ACurrentBatchRow == null)
            {
                throw new EFinanceSystemDataObjectNullOrEmptyException(String.Format(Catalog.GetString(
                                                                                         "Function:{0} - The GL Batch data row is null!"),
                                                                                     Utilities.GetMethodName(true)));
            }
            else if (ACurrentBatchRow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED)
            {
                TLogging.Log(String.Format("Function:{0} - Tried to update totals for non-Unposted Batch:{1}",
                                           Utilities.GetMethodName(true),
                                           ACurrentBatchRow.BatchNumber));
                return(false);
            }

            #endregion Validate Arguments

            bool AmountsUpdated = false;

            decimal BatchDebitTotal  = 0.0m;
            decimal BatchCreditTotal = 0.0m;

            DataView JournalDV = new DataView(AMainDS.AJournal);

            JournalDV.RowFilter = String.Format("{0}={1}",
                                                AJournalTable.GetBatchNumberDBName(),
                                                ACurrentBatchRow.BatchNumber);

            foreach (DataRowView journalView in JournalDV)
            {
                GLBatchTDSAJournalRow journalRow = (GLBatchTDSAJournalRow)journalView.Row;

                if (((ACurrentJournalNumber > 0) && (ACurrentJournalNumber == journalRow.JournalNumber)) ||
                    (ACurrentJournalNumber == 0))
                {
                    if ((UpdateJournalTotals(ref AMainDS, ref journalRow)))
                    {
                        AmountsUpdated = true;
                    }
                }

                BatchDebitTotal  += journalRow.JournalDebitTotal;
                BatchCreditTotal += journalRow.JournalCreditTotal;
            }

            if ((ACurrentBatchRow.BatchDebitTotal != BatchDebitTotal) ||
                (ACurrentBatchRow.BatchCreditTotal != BatchCreditTotal))
            {
                ACurrentBatchRow.BatchDebitTotal  = BatchDebitTotal;
                ACurrentBatchRow.BatchCreditTotal = BatchCreditTotal;
                AmountsUpdated = true;
            }

            return(AmountsUpdated);
        }
        public static TSubmitChangesResult SaveData(string ATablename,
                                                    ref TTypedDataTable ASubmitTable, out TVerificationResultCollection AVerificationResult,
                                                    TDBTransaction AWriteTransaction)
        {
            AVerificationResult = null;

            // TODO: check write permissions
            string context = string.Format("SaveData {0}", SharedConstants.MODULE_ACCESS_MANAGER);

            if (ASubmitTable != null)
            {
                AVerificationResult = new TVerificationResultCollection();

                try
                {
                    if (ATablename == AAccountingPeriodTable.GetTableDBName())
                    {
                        AAccountingPeriodAccess.SubmitChanges((AAccountingPeriodTable)ASubmitTable, AWriteTransaction);

                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheableFinanceTablesEnum.AccountingPeriodList.ToString());
                    }
                    else if (ATablename == ACurrencyTable.GetTableDBName())
                    {
                        ACurrencyAccess.SubmitChanges((ACurrencyTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ADailyExchangeRateTable.GetTableDBName())
                    {
                        TSecurityChecks.CheckUserModulePermissions(
                            string.Format("AND({0},{1})", SharedConstants.PETRAGROUP_FINANCE1, SharedConstants.PETRAMODULE_FINEXRATE),
                            context);
                        ADailyExchangeRateAccess.SubmitChanges((ADailyExchangeRateTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ACorporateExchangeRateTable.GetTableDBName())
                    {
                        // AlanP:  I don't think this is used any more.  There is a TDS Save method instead
                        ACorporateExchangeRateAccess.SubmitChanges((ACorporateExchangeRateTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ACurrencyLanguageTable.GetTableDBName())
                    {
                        ACurrencyLanguageAccess.SubmitChanges((ACurrencyLanguageTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == AFeesPayableTable.GetTableDBName())
                    {
                        AFeesPayableAccess.SubmitChanges((AFeesPayableTable)ASubmitTable, AWriteTransaction);

                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheableFinanceTablesEnum.FeesPayableList.ToString());
                    }
                    else if (ATablename == AFeesReceivableTable.GetTableDBName())
                    {
                        AFeesReceivableAccess.SubmitChanges((AFeesReceivableTable)ASubmitTable, AWriteTransaction);

                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheableFinanceTablesEnum.FeesReceivableList.ToString());
                    }
                    else if (ATablename == AGiftBatchTable.GetTableDBName())
                    {
                        // This method is called from ADailyExchangeRate Setup - please do not remove
                        // The method is not required for changes made to the gift batch screens, which use a TDS
                        AGiftBatchAccess.SubmitChanges((AGiftBatchTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == AJournalTable.GetTableDBName())
                    {
                        // This method is called from ADailyExchangeRate Setup - please do not remove
                        // The method is not required for changes made to the journal screens, which use a TDS
                        AJournalAccess.SubmitChanges((AJournalTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ARecurringJournalTable.GetTableDBName())
                    {
                        // This method is called from Submit Recurring GL Batch form - please do not remove
                        // The method is not required for changes made to the journal screens, which use a TDS
                        ARecurringJournalAccess.SubmitChanges((ARecurringJournalTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ALedgerTable.GetTableDBName())
                    {
                        // This method is called from ADailyExchangeRate Testing - please do not remove
                        ALedgerAccess.SubmitChanges((ALedgerTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == AAnalysisTypeTable.GetTableDBName())
                    {
                        AAnalysisTypeAccess.SubmitChanges((AAnalysisTypeTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ASuspenseAccountTable.GetTableDBName())
                    {
                        ASuspenseAccountAccess.SubmitChanges((ASuspenseAccountTable)ASubmitTable, AWriteTransaction);

                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheableFinanceTablesEnum.SuspenseAccountList.ToString());
                    }
                    else if (ATablename == PcAttendeeTable.GetTableDBName())
                    {
                        PcAttendeeAccess.SubmitChanges((PcAttendeeTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcConferenceTable.GetTableDBName())
                    {
                        PcConferenceAccess.SubmitChanges((PcConferenceTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcConferenceCostTable.GetTableDBName())
                    {
                        PcConferenceCostAccess.SubmitChanges((PcConferenceCostTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcEarlyLateTable.GetTableDBName())
                    {
                        PcEarlyLateAccess.SubmitChanges((PcEarlyLateTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcSupplementTable.GetTableDBName())
                    {
                        PcSupplementAccess.SubmitChanges((PcSupplementTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcDiscountTable.GetTableDBName())
                    {
                        PcDiscountAccess.SubmitChanges((PcDiscountTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PInternationalPostalTypeTable.GetTableDBName())
                    {
                        ValidateInternationalPostalType(ref AVerificationResult, ASubmitTable);
                        ValidateInternationalPostalTypeManual(ref AVerificationResult, ASubmitTable);

                        if (TVerificationHelper.IsNullOrOnlyNonCritical(AVerificationResult))
                        {
                            PInternationalPostalTypeAccess.SubmitChanges((PInternationalPostalTypeTable)ASubmitTable, AWriteTransaction);
                        }
                    }
                    else if (ATablename == PtApplicationTypeTable.GetTableDBName())
                    {
                        PtApplicationTypeAccess.SubmitChanges((PtApplicationTypeTable)ASubmitTable, AWriteTransaction);

                        // mark dependent lists for needing to be refreshed since there was a change in base list
                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheablePersonTablesEnum.EventApplicationTypeList.ToString());
                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheablePersonTablesEnum.FieldApplicationTypeList.ToString());
                    }
                    else if (ATablename == PFormTable.GetTableDBName())
                    {
                        PFormAccess.SubmitChanges((PFormTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PFormalityTable.GetTableDBName())
                    {
                        PFormalityAccess.SubmitChanges((PFormalityTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PMailingTable.GetTableDBName())
                    {
                        PMailingAccess.SubmitChanges((PMailingTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PPartnerGiftDestinationTable.GetTableDBName())
                    {
                        PPartnerGiftDestinationAccess.SubmitChanges((PPartnerGiftDestinationTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PmDocumentTypeTable.GetTableDBName())
                    {
                        PmDocumentTypeAccess.SubmitChanges((PmDocumentTypeTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == SGroupTable.GetTableDBName())
                    {
                        SGroupAccess.SubmitChanges((SGroupTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == SSystemDefaultsTable.GetTableDBName())
                    {
                        SSystemDefaultsAccess.SubmitChanges((SSystemDefaultsTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == SSystemDefaultsGuiTable.GetTableDBName())
                    {
                        SSystemDefaultsGuiAccess.SubmitChanges((SSystemDefaultsGuiTable)ASubmitTable, AWriteTransaction);
                    }
                    else
                    {
                        throw new EOPAppException("TCommonDataReader.SaveData: unknown table '" + ATablename + "'");
                    }
                }
                catch (Exception Exc)
                {
                    AVerificationResult.Add(
                        new TVerificationResult(null, "Cannot SubmitChanges:" + Environment.NewLine +
                                                Exc.Message, "UNDEFINED", TResultSeverity.Resv_Critical));
                }
            }

            if ((AVerificationResult != null) &&
                (AVerificationResult.Count > 0))
            {
                // Downgrade TScreenVerificationResults to TVerificationResults in order to allow
                // Serialisation (needed for .NET Remoting).
                TVerificationResultCollection.DowngradeScreenVerificationResults(AVerificationResult);

                return(AVerificationResult.HasCriticalErrors ? TSubmitChangesResult.scrError : TSubmitChangesResult.scrOK);
            }

            return(TSubmitChangesResult.scrOK);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Update the specified Batch's LastJournal number. Assumes all necessary data is loaded for Batch
        /// </summary>
        /// <param name="AMainDS"></param>
        /// <param name="ACurrentBatchRow"></param>
        /// <returns>false if no change to batch totals</returns>
        public static bool UpdateBatchLastJournal(ref GLBatchTDS AMainDS,
                                                  ref ABatchRow ACurrentBatchRow)
        {
            #region Validate Arguments

            if (AMainDS == null)
            {
                throw new EFinanceSystemDataObjectNullOrEmptyException(String.Format(Catalog.GetString("Function:{0} - The GL Batch dataset is null!"),
                                                                                     Utilities.GetMethodName(true)));
            }
            else if (ACurrentBatchRow == null)
            {
                throw new EFinanceSystemDataObjectNullOrEmptyException(String.Format(Catalog.GetString(
                                                                                         "Function:{0} - The GL Batch data row is null!"),
                                                                                     Utilities.GetMethodName(true)));
            }
            else if (ACurrentBatchRow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED)
            {
                TLogging.Log(String.Format("Function:{0} - Tried to update totals for non-Unposted Batch:{1}",
                                           Utilities.GetMethodName(true),
                                           ACurrentBatchRow.BatchNumber));
                return(false);
            }

            #endregion Validate Arguments

            bool RowUpdated = false;
            int  ActualLastJournalNumber = 0;

            DataView JournalDV = new DataView(AMainDS.AJournal);

            JournalDV.RowFilter = String.Format("{0}={1}",
                                                AJournalTable.GetBatchNumberDBName(),
                                                ACurrentBatchRow.BatchNumber);

            //Highest Journal number first
            JournalDV.Sort = String.Format("{0} DESC",
                                           AJournalTable.GetJournalNumberDBName());

            foreach (DataRowView journalView in JournalDV)
            {
                GLBatchTDSAJournalRow journalRow = (GLBatchTDSAJournalRow)journalView.Row;

                //Run once only
                if (ActualLastJournalNumber == 0)
                {
                    ActualLastJournalNumber = journalRow.JournalNumber;
                }

                if (UpdateJournalLastTransaction(ref AMainDS, ref journalRow))
                {
                    RowUpdated = true;
                }
            }

            if (ACurrentBatchRow.LastJournal != ActualLastJournalNumber)
            {
                ACurrentBatchRow.LastJournal = ActualLastJournalNumber;
                RowUpdated = true;
            }

            return(RowUpdated);
        }
Exemplo n.º 24
0
        private int GetChangedRecordCountManual(out string AMessage)
        {
            // For GL Batch we will get some mix of batches, journals and transactions
            // Only check relevant tables.
            List <string> TablesToCheck = new List <string>();

            TablesToCheck.Add(FMainDS.ABatch.TableName);
            TablesToCheck.Add(FMainDS.AJournal.TableName);
            TablesToCheck.Add(FMainDS.ATransaction.TableName);
            TablesToCheck.Add(FMainDS.ATransAnalAttrib.TableName);

            List <Tuple <string, int> > TableAndCountList = new List <Tuple <string, int> >();
            int AllChangesCount = 0;

            if (FMainDS.HasChanges())
            {
                // Work out how many changes in each table
                foreach (DataTable dt in FMainDS.GetChanges().Tables)
                {
                    string currentTableName = dt.TableName;

                    if ((dt != null) &&
                        TablesToCheck.Contains(currentTableName) &&
                        (dt.Rows.Count > 0))
                    {
                        int tableChangesCount = 0;

                        DataTable dtChanges = dt.GetChanges();

                        foreach (DataRow dr in dtChanges.Rows)
                        {
                            if (DataUtilities.DataRowColumnsHaveChanged(dr))
                            {
                                tableChangesCount++;
                                AllChangesCount++;
                            }
                        }

                        if (tableChangesCount > 0)
                        {
                            TableAndCountList.Add(new Tuple <string, int>(currentTableName, tableChangesCount));
                        }
                    }
                }
            }

            // Now build up a sensible message
            AMessage = String.Empty;

            if (TableAndCountList.Count > 0)
            {
                int nBatches      = 0;
                int nJournals     = 0;
                int nTransactions = 0;

                foreach (Tuple <string, int> TableAndCount in TableAndCountList)
                {
                    if (TableAndCount.Item1.Equals(ABatchTable.GetTableName()))
                    {
                        nBatches = TableAndCount.Item2;
                    }
                    else if (TableAndCount.Item1.Equals(AJournalTable.GetTableName()))
                    {
                        nJournals = TableAndCount.Item2;
                    }
                    else if (TableAndCount.Item2 > nTransactions)
                    {
                        nTransactions = TableAndCount.Item2;
                    }
                }

                AMessage = Catalog.GetString("    You have made changes to ");
                string strBatches      = String.Empty;
                string strJournals     = String.Empty;
                string strTransactions = String.Empty;

                if (nBatches > 0)
                {
                    strBatches = String.Format("{0} {1}",
                                               nBatches,
                                               Catalog.GetPluralString("batch", "batches", nBatches));
                }

                if (nJournals > 0)
                {
                    strJournals = String.Format("{0} {1}",
                                                nJournals,
                                                Catalog.GetPluralString("journal", "journals", nJournals));
                }

                if (nTransactions > 0)
                {
                    strTransactions = String.Format("{0} {1}",
                                                    nTransactions,
                                                    Catalog.GetPluralString("transaction", "transactions", nTransactions));
                }

                bool bGotAll = (nBatches > 0) && (nJournals > 0) && (nTransactions > 0);

                if (nBatches > 0)
                {
                    AMessage += strBatches;
                }

                if (nJournals > 0)
                {
                    if (bGotAll)
                    {
                        AMessage += ", ";
                    }
                    else if (nBatches > 0)
                    {
                        AMessage += " and ";
                    }

                    AMessage += strJournals;
                }

                if (nTransactions > 0)
                {
                    if ((nBatches > 0) || (nJournals > 0))
                    {
                        AMessage += " and ";
                    }

                    AMessage += strTransactions;
                }

                AMessage += Environment.NewLine + Catalog.GetString("(some of the changes may include related background items)");
                AMessage += Environment.NewLine;
                AMessage += String.Format(TFrmPetraEditUtils.StrConsequenceIfNotSaved, Environment.NewLine);
            }

            return(AllChangesCount);
        }
Exemplo n.º 25
0
 public static void LoadAll()
 {
     AJournal = new AJournalTable();
     SerialisableDS.LoadAll(AJournal, AJournalTable.GetTableDBName());
 }