Esempio n. 1
0
        private void UpdateLedgerTableSettings()
        {
            int LedgerLastRecurringGLBatchNumber = 0;

            //Update the last recurring GL batch number
            DataView RecurringGLBatchDV = new DataView(FMainDS.ARecurringBatch);

            RecurringGLBatchDV.RowFilter = string.Empty;
            RecurringGLBatchDV.Sort      = string.Format("{0} DESC",
                                                         ARecurringBatchTable.GetBatchNumberDBName());

            //Recurring batch numbers can be reused so reset current highest number
            if (RecurringGLBatchDV.Count > 0)
            {
                LedgerLastRecurringGLBatchNumber = (int)(RecurringGLBatchDV[0][ARecurringBatchTable.GetBatchNumberDBName()]);
            }

            if (FMainDS.ALedger[0].LastRecurringBatchNumber != LedgerLastRecurringGLBatchNumber)
            {
                FMainDS.ALedger[0].LastRecurringBatchNumber = LedgerLastRecurringGLBatchNumber;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Undo all changes to the specified batch ready to cancel it.
        ///  This avoids unecessary validation errors when cancelling.
        /// </summary>
        /// <param name="ABatchToDelete"></param>
        /// <param name="ARedisplay"></param>
        public void PrepareBatchDataForDeleting(Int32 ABatchToDelete, Boolean ARedisplay)
        {
            //This code will only be called when the Batch tab is active.

            DataView GLBatchDV   = new DataView(FMainDS.ARecurringBatch);
            DataView JournalDV   = new DataView(FMainDS.ARecurringJournal);
            DataView TransDV     = new DataView(FMainDS.ARecurringTransaction);
            DataView TransAnalDV = new DataView(FMainDS.ARecurringTransAnalAttrib);

            GLBatchDV.RowFilter = String.Format("{0}={1}",
                                                ARecurringBatchTable.GetBatchNumberDBName(),
                                                ABatchToDelete);

            JournalDV.RowFilter = String.Format("{0}={1}",
                                                ARecurringJournalTable.GetBatchNumberDBName(),
                                                ABatchToDelete);

            TransDV.RowFilter = String.Format("{0}={1}",
                                              ARecurringTransactionTable.GetBatchNumberDBName(),
                                              ABatchToDelete);

            TransAnalDV.RowFilter = String.Format("{0}={1}",
                                                  ARecurringTransAnalAttribTable.GetBatchNumberDBName(),
                                                  ABatchToDelete);

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

                foreach (DataRowView drv in TransAnalDV)
                {
                    ARecurringTransAnalAttribRow transAnalRow = (ARecurringTransAnalAttribRow)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}, {1}",
                                             ARecurringTransactionTable.GetJournalNumberDBName(),
                                             ARecurringTransactionTable.GetTransactionNumberDBName());

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

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

            if (JournalDV.Count > 0)
            {
                JournalDV.Sort = String.Format("{0}", ARecurringJournalTable.GetJournalNumberDBName());

                foreach (DataRowView drv in JournalDV)
                {
                    ARecurringJournalRow journalRow = (ARecurringJournalRow)drv.Row;

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

            if (GLBatchDV.Count > 0)
            {
                ARecurringBatchRow batchRow = (ARecurringBatchRow)GLBatchDV[0].Row;

                //No need to check for Added state as new batches are always saved
                // on creation

                if (batchRow.RowState != DataRowState.Unchanged)
                {
                    batchRow.RejectChanges();
                }

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

            if (TransDV.Count == 0)
            {
                //Load all related data for batch ready to delete/cancel
                FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringJournalAndRelatedTablesForBatch(FLedgerNumber, ABatchToDelete));
            }
        }