Ejemplo n.º 1
0
        /// <summary>
        /// Switch to the given tab
        /// </summary>
        /// <param name="ATab"></param>
        /// <param name="AAllowRepeatEvent"></param>
        public void SelectTab(TGLBatchEnums.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 == TGLBatchEnums.eGLTabs.Batches)
                {
                    if ((FPreviouslySelectedTab == TGLBatchEnums.eGLTabs.Batches) && !AAllowRepeatEvent)
                    {
                        //Repeat event
                        return;
                    }

                    FPreviouslySelectedTab = TGLBatchEnums.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 == TGLBatchEnums.eGLTabs.Journals)
                {
                    if ((FPreviouslySelectedTab == TGLBatchEnums.eGLTabs.Journals) && !AAllowRepeatEvent)
                    {
                        //Repeat event
                        return;
                    }

                    if (this.tpgJournals.Enabled)
                    {
                        FPreviouslySelectedTab = TGLBatchEnums.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 == TGLBatchEnums.eGLTabs.Transactions)
                {
                    if ((FPreviouslySelectedTab == TGLBatchEnums.eGLTabs.Transactions) && !AAllowRepeatEvent)
                    {
                        //Repeat event
                        return;
                    }

                    if (this.tpgTransactions.Enabled)
                    {
                        ABatchRow batchRow = ucoBatches.GetSelectedDetailRow();

                        string loadingMessage      = string.Empty;
                        bool   batchWasPreviousTab = (FPreviouslySelectedTab == TGLBatchEnums.eGLTabs.Batches);

                        FPreviouslySelectedTab = TGLBatchEnums.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(batchRow);
                        }

                        GLBatchTDSAJournalRow journalRow = ucoJournals.GetSelectedDetailRow();

                        if ((batchRow == null) || batchRow.IsBatchStatusNull())
                        {
                            loadingMessage = Catalog.GetString(
                                "There has been a problem loading the batch, please reselect the Batch tab and batch again and then retry.");
                        }
                        else if ((journalRow == null) || journalRow.IsJournalStatusNull())
                        {
                            loadingMessage = Catalog.GetString(
                                "There has been a problem loading the journals, please reselect the Batch tab and then the Journal tab and then retry.");
                        }

                        if (loadingMessage.Length == 0)
                        {
                            LoadTransactions(journalRow.BatchNumber,
                                             batchRow.BatchStatus,
                                             journalRow.JournalNumber,
                                             journalRow.JournalStatus,
                                             journalRow.TransactionCurrency,
                                             batchWasPreviousTab);

                            //Warn if missing International Exchange Rate
                            WarnAboutMissingIntlExchangeRate = true;
                            GetInternationalCurrencyExchangeRate();
                        }
                        else
                        {
                            MessageBox.Show(loadingMessage,
                                            "View Transactions",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Warning);
                        }
                    }
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
                this.Refresh();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Switch to the given tab
        /// </summary>
        /// <param name="ATab"></param>
        /// <param name="AAllowRepeatEvent"></param>
        public void SelectTab(TGLBatchEnums.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 == TGLBatchEnums.eGLTabs.Batches)
                {
                    if ((FPreviouslySelectedTab == TGLBatchEnums.eGLTabs.Batches) && !AAllowRepeatEvent)
                    {
                        //Repeat event
                        return;
                    }

                    FPreviouslySelectedTab = TGLBatchEnums.eGLTabs.Batches;

                    this.tabRecurringGLBatch.SelectedTab = this.tpgRecurringBatches;
                    this.tpgRecurringJournals.Enabled    = (ucoRecurringBatches.GetSelectedDetailRow() != null);
                    this.tabRecurringGLBatch.TabStop     = this.tpgRecurringJournals.Enabled;

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

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

                        this.tabRecurringGLBatch.SelectedTab = this.tpgRecurringJournals;

                        LoadJournals(ucoRecurringBatches.GetSelectedDetailRow());

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

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

                    if (this.tpgRecurringTransactions.Enabled)
                    {
                        bool batchWasPreviousTab = (FPreviouslySelectedTab == TGLBatchEnums.eGLTabs.Batches);
                        FPreviouslySelectedTab = TGLBatchEnums.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.tabRecurringGLBatch.SelectedTab = this.tpgRecurringTransactions;

                        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(ucoRecurringBatches.GetSelectedDetailRow());
                        }

                        LoadTransactions(ucoRecurringJournals.GetSelectedDetailRow().BatchNumber,
                                         ucoRecurringJournals.GetSelectedDetailRow().JournalNumber,
                                         ucoRecurringJournals.GetSelectedDetailRow().TransactionCurrency,
                                         batchWasPreviousTab);
                    }
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
                this.Refresh();
            }
        }