Example #1
0
        /// <summary>
        /// Switch to the given tab
        /// </summary>
        /// <param name="ATab"></param>
        /// <param name="AAllowRepeatEvent"></param>
        public void SelectTab(eGLTabs ATab, bool AAllowRepeatEvent = false)
        {
            //Between the tab changing and seleted events changes are incorrectly detected on Journal controls
            // TODO: find cause but use this field for now
            if (!FChangesDetected && FPetraUtilsObject.HasChanges)
            {
                FPetraUtilsObject.DisableSaveButton();
            }
            else if (FChangesDetected && !FPetraUtilsObject.HasChanges)
            {
                FChangesDetected = false;
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (ATab == eGLTabs.Batches)
                {
                    if ((FPreviouslySelectedTab == eGLTabs.Batches) && !AAllowRepeatEvent)
                    {
                        //Repeat event
                        return;
                    }

                    FPreviouslySelectedTab = eGLTabs.Batches;

                    this.tabGLBatch.SelectedTab = this.tpgBatches;
                    this.tpgJournals.Enabled    = (ucoBatches.GetSelectedDetailRow() != null);
                    this.tabGLBatch.TabStop     = this.tpgJournals.Enabled;

                    if (this.tpgTransactions.Enabled)
                    {
                        this.ucoTransactions.CancelChangesToFixedBatches();
                        this.ucoJournals.CancelChangesToFixedBatches();
                    }

                    ucoBatches.AutoEnableTransTabForBatch();
                    ucoBatches.SetInitialFocus();
                }
                else if (ATab == eGLTabs.Journals)
                {
                    if ((FPreviouslySelectedTab == eGLTabs.Journals) && !AAllowRepeatEvent)
                    {
                        //Repeat event
                        return;
                    }

                    if (this.tpgJournals.Enabled)
                    {
                        FPreviouslySelectedTab = eGLTabs.Journals;

                        this.tabGLBatch.SelectedTab = this.tpgJournals;

                        LoadJournals(ucoBatches.GetSelectedDetailRow());

                        this.tpgTransactions.Enabled =
                            (ucoJournals.GetSelectedDetailRow() != null && ucoJournals.GetSelectedDetailRow().JournalStatus !=
                             MFinanceConstants.BATCH_CANCELLED);

                        this.ucoJournals.UpdateHeaderTotals(ucoBatches.GetSelectedDetailRow());
                    }
                }
                else if (ATab == eGLTabs.Transactions)
                {
                    if ((FPreviouslySelectedTab == eGLTabs.Transactions) && !AAllowRepeatEvent)
                    {
                        //Repeat event
                        return;
                    }

                    if (this.tpgTransactions.Enabled)
                    {
                        bool batchWasPreviousTab = (FPreviouslySelectedTab == eGLTabs.Batches);
                        FPreviouslySelectedTab = eGLTabs.Transactions;

                        // Note!! This call may result in this (SelectTab) method being called again (but no new transactions will be loaded the second time)
                        this.tabGLBatch.SelectedTab = this.tpgTransactions;

                        if (batchWasPreviousTab)
                        {
                            //This only happens when the user clicks from Batch to Transactions,
                            //  which is only allowed when one journal exists

                            //Need to make sure that the Journal is loaded
                            LoadJournals(ucoBatches.GetSelectedDetailRow());
                        }

                        LoadTransactions(ucoJournals.GetSelectedDetailRow().BatchNumber,
                                         ucoBatches.GetSelectedDetailRow().BatchStatus,
                                         ucoJournals.GetSelectedDetailRow().JournalNumber,
                                         ucoJournals.GetSelectedDetailRow().JournalStatus,
                                         ucoJournals.GetSelectedDetailRow().TransactionCurrency,
                                         batchWasPreviousTab);

                        //Warn if missing International Exchange Rate
                        WarnAboutMissingIntlExchangeRate = true;
                        GetInternationalCurrencyExchangeRate();
                    }
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
                this.Refresh();
            }
        }
        /// <summary>
        /// Switch to the given tab
        /// </summary>
        /// <param name="ATab"></param>
        public void SelectTab(eGLTabs ATab)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (ATab == eGLTabs.RecurringBatches)
                {
                    this.tabRecurringGLBatch.SelectedTab = this.tpgRecurringBatches;
                    this.tpgRecurringJournals.Enabled    = (ucoRecurringBatches.GetSelectedDetailRow() != null);
                    this.tabRecurringGLBatch.TabStop     = this.tpgRecurringJournals.Enabled;

                    ucoRecurringBatches.AutoEnableTransTabForBatch();
                    ucoRecurringBatches.SetInitialFocus();
                    FPreviousTab = eGLTabs.RecurringBatches;
                }
                else if ((ucoRecurringBatches.GetSelectedDetailRow() != null) && (ATab == eGLTabs.RecurringJournals))
                {
                    if (this.tpgRecurringJournals.Enabled)
                    {
                        this.tabRecurringGLBatch.SelectedTab = this.tpgRecurringJournals;

                        this.ucoRecurringJournals.LoadJournals(FLedgerNumber,
                                                               ucoRecurringBatches.GetSelectedDetailRow().BatchNumber);

                        this.tpgRecurringTransactions.Enabled = (ucoRecurringJournals.GetSelectedDetailRow() != null);

                        this.ucoRecurringJournals.UpdateHeaderTotals(ucoRecurringBatches.GetSelectedDetailRow());

                        FPreviousTab = eGLTabs.RecurringJournals;
                    }
                }
                else if (ATab == eGLTabs.RecurringTransactions)
                {
                    if (this.tpgRecurringTransactions.Enabled)
                    {
                        // Note!! This call may result in this (SelectTab) method being called again (but no new transactions will be loaded the second time)
                        this.tabRecurringGLBatch.SelectedTab = this.tpgRecurringTransactions;

                        bool fromBatchTab = false;

                        if (FPreviousTab == eGLTabs.RecurringBatches)
                        {
                            fromBatchTab = true;
                            //This only happens when the user clicks from Batch to Transactions,
                            //  which is only allowed when one journal exists

                            //Need to make sure that the Journal is loaded
                            this.ucoRecurringJournals.LoadJournals(FLedgerNumber,
                                                                   ucoRecurringBatches.GetSelectedDetailRow().BatchNumber);
                        }

                        this.ucoRecurringTransactions.LoadRecurringTransactions(
                            FLedgerNumber,
                            ucoRecurringJournals.GetSelectedDetailRow().BatchNumber,
                            ucoRecurringJournals.GetSelectedDetailRow().JournalNumber,
                            ucoRecurringJournals.GetSelectedDetailRow().TransactionCurrency,
                            fromBatchTab);

                        FPreviousTab = eGLTabs.RecurringTransactions;
                    }
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
                this.Refresh();
            }
        }
        /// <summary>
        /// Switch to the given tab
        /// </summary>
        /// <param name="ATab"></param>
        public void SelectTab(eGLTabs ATab)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (ATab == eGLTabs.Batches)
                {
                    this.tabGLBatch.SelectedTab = this.tpgBatches;
                    this.tpgJournals.Enabled = (ucoBatches.GetSelectedDetailRow() != null);
                    this.tabGLBatch.TabStop = this.tpgJournals.Enabled;

                    if (this.tpgTransactions.Enabled)
                    {
                        this.ucoTransactions.CancelChangesToFixedBatches();
                        this.ucoJournals.CancelChangesToFixedBatches();
                    }

                    ucoBatches.AutoEnableTransTabForBatch();
                    ucoBatches.SetInitialFocus();
                    FPreviouslySelectedTab = eGLTabs.Batches;
                }
                else if ((ucoBatches.GetSelectedDetailRow() != null) && (ATab == eGLTabs.Journals))
                {
                    if (this.tpgJournals.Enabled)
                    {
                        this.tabGLBatch.SelectedTab = this.tpgJournals;

                        this.ucoJournals.LoadJournals(FLedgerNumber,
                            ucoBatches.GetSelectedDetailRow().BatchNumber,
                            ucoBatches.GetSelectedDetailRow().BatchStatus);

                        this.tpgTransactions.Enabled =
                            (ucoJournals.GetSelectedDetailRow() != null && ucoJournals.GetSelectedDetailRow().JournalStatus !=
                             MFinanceConstants.BATCH_CANCELLED);

                        this.ucoJournals.UpdateHeaderTotals(ucoBatches.GetSelectedDetailRow());

                        FPreviouslySelectedTab = eGLTabs.Journals;
                    }
                }
                else if (ATab == eGLTabs.Transactions)
                {
                    if (this.tpgTransactions.Enabled)
                    {
                        // Note!! This call may result in this (SelectTab) method being called again (but no new transactions will be loaded the second time)
                        this.tabGLBatch.SelectedTab = this.tpgTransactions;

                        bool fromBatchTab = false;

                        if (FPreviouslySelectedTab == eGLTabs.Batches)
                        {
                            fromBatchTab = true;
                            //This only happens when the user clicks from Batch to Transactions,
                            //  which is only allowed when one journal exists

                            //Need to make sure that the Journal is loaded
                            this.ucoJournals.LoadJournals(FLedgerNumber,
                                ucoBatches.GetSelectedDetailRow().BatchNumber,
                                ucoBatches.GetSelectedDetailRow().BatchStatus);
                        }

                        this.ucoTransactions.LoadTransactions(
                            FLedgerNumber,
                            ucoJournals.GetSelectedDetailRow().BatchNumber,
                            ucoJournals.GetSelectedDetailRow().JournalNumber,
                            ucoJournals.GetSelectedDetailRow().TransactionCurrency,
                            fromBatchTab,
                            ucoBatches.GetSelectedDetailRow().BatchStatus,
                            ucoJournals.GetSelectedDetailRow().JournalStatus);

                        FPreviouslySelectedTab = eGLTabs.Transactions;
                    }
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
                this.Refresh();
            }
        }
        /// <summary>
        /// Switch to the given tab
        /// </summary>
        /// <param name="ATab"></param>
        /// <param name="AAllowRepeatEvent"></param>
        public void SelectTab(eGLTabs ATab, bool AAllowRepeatEvent = false)
        {
            //Between the tab changing and seleted events changes are incorrectly detected on Journal controls
            // TODO: find cause but use this field for now
            if (!FChangesDetected && FPetraUtilsObject.HasChanges)
            {
                FPetraUtilsObject.DisableSaveButton();
            }
            else if (FChangesDetected && !FPetraUtilsObject.HasChanges)
            {
                FChangesDetected = false;
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (ATab == eGLTabs.Batches)
                {
                    if ((FPreviouslySelectedTab == eGLTabs.Batches) && !AAllowRepeatEvent)
                    {
                        //Repeat event
                        return;
                    }

                    FPreviouslySelectedTab = eGLTabs.Batches;

                    this.tabGLBatch.SelectedTab = this.tpgBatches;
                    this.tpgJournals.Enabled = (ucoBatches.GetSelectedDetailRow() != null);
                    this.tabGLBatch.TabStop = this.tpgJournals.Enabled;

                    if (this.tpgTransactions.Enabled)
                    {
                        this.ucoTransactions.CancelChangesToFixedBatches();
                        this.ucoJournals.CancelChangesToFixedBatches();
                    }

                    ucoBatches.AutoEnableTransTabForBatch();
                    ucoBatches.SetInitialFocus();
                }
                else if (ATab == eGLTabs.Journals)
                {
                    if ((FPreviouslySelectedTab == eGLTabs.Journals) && !AAllowRepeatEvent)
                    {
                        //Repeat event
                        return;
                    }

                    if (this.tpgJournals.Enabled)
                    {
                        FPreviouslySelectedTab = eGLTabs.Journals;

                        this.tabGLBatch.SelectedTab = this.tpgJournals;

                        LoadJournals(ucoBatches.GetSelectedDetailRow());

                        this.tpgTransactions.Enabled =
                            (ucoJournals.GetSelectedDetailRow() != null && ucoJournals.GetSelectedDetailRow().JournalStatus !=
                             MFinanceConstants.BATCH_CANCELLED);

                        this.ucoJournals.UpdateHeaderTotals(ucoBatches.GetSelectedDetailRow());
                    }
                }
                else if (ATab == eGLTabs.Transactions)
                {
                    if ((FPreviouslySelectedTab == eGLTabs.Transactions) && !AAllowRepeatEvent)
                    {
                        //Repeat event
                        return;
                    }

                    if (this.tpgTransactions.Enabled)
                    {
                        bool batchWasPreviousTab = (FPreviouslySelectedTab == eGLTabs.Batches);
                        FPreviouslySelectedTab = eGLTabs.Transactions;

                        // Note!! This call may result in this (SelectTab) method being called again (but no new transactions will be loaded the second time)
                        this.tabGLBatch.SelectedTab = this.tpgTransactions;

                        if (batchWasPreviousTab)
                        {
                            //This only happens when the user clicks from Batch to Transactions,
                            //  which is only allowed when one journal exists

                            //Need to make sure that the Journal is loaded
                            LoadJournals(ucoBatches.GetSelectedDetailRow());
                        }

                        LoadTransactions(ucoJournals.GetSelectedDetailRow().BatchNumber,
                            ucoBatches.GetSelectedDetailRow().BatchStatus,
                            ucoJournals.GetSelectedDetailRow().JournalNumber,
                            ucoJournals.GetSelectedDetailRow().JournalStatus,
                            ucoJournals.GetSelectedDetailRow().TransactionCurrency,
                            batchWasPreviousTab);

                        //Warn if missing International Exchange Rate
                        WarnAboutMissingIntlExchangeRate = true;
                        GetInternationalCurrencyExchangeRate();
                    }
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
                this.Refresh();
            }
        }