示例#1
0
        private void LoadDataGrid(bool AFirstTime)
        {
            FMainDS.PcConference.Clear();
            FMainDS.PPartner.Clear();

            FMainDS.Merge(TRemote.MConference.WebConnectors.GetConferences("", ""));

            if (FMainDS.PcConference.Rows.Count == FMainDS.PPartner.Rows.Count)
            {
                if (AFirstTime)
                {
                    FMainDS.PcConference.Columns.Add(PPartnerTable.GetPartnerShortNameDBName(), Type.GetType("System.String"));
                    FMainDS.PcConference.DefaultView.AllowNew = false;
                }

                for (int Counter = 0; Counter < FMainDS.PcConference.Rows.Count; ++Counter)
                {
                    FMainDS.PcConference.Rows[Counter][PPartnerTable.GetPartnerShortNameDBName()] =
                        FMainDS.PPartner.Rows[Counter][PPartnerTable.GetPartnerShortNameDBName()];
                }
            }

            // sort order for grid
            DataView MyDataView = FMainDS.PcConference.DefaultView;

            MyDataView.Sort           = "p_partner_short_name_c ASC";
            grdConferences.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView);

            UpdateRecordNumberDisplay();
        }
示例#2
0
        private void AddAllocations(Object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            if (cmbDetailTransactionTypeCode.GetSelectedString() == CommonAccountingTransactionTypesEnum.ALLOC.ToString())
            {
                TFrmAllocationJournalDialog AddAllocationJournal = new TFrmAllocationJournalDialog(this.FindForm());
                AddAllocationJournal.Journal = this.GetSelectedDetailRow();

                // open as a modal form
                if (AddAllocationJournal.ShowDialog() == DialogResult.OK)
                {
                    FMainDS.Merge(AddAllocationJournal.MainDS);

                    // manually enable save button (otherwise this doesn't happen)
                    FPetraUtilsObject.SetChangedFlag();
                }
            }
            else if (cmbDetailTransactionTypeCode.GetSelectedString() == CommonAccountingTransactionTypesEnum.REALLOC.ToString())
            {
                TFrmReallocationJournalDialog AddReallocationJournal = new TFrmReallocationJournalDialog(this.FindForm());
                AddReallocationJournal.Journal = this.GetSelectedDetailRow();

                // open as a modal form
                if (AddReallocationJournal.ShowDialog() == DialogResult.OK)
                {
                    FMainDS.Merge(AddReallocationJournal.MainDS);

                    // manually enable save button (otherwise this doesn't happen)
                    FPetraUtilsObject.SetChangedFlag();
                }
            }

            Cursor = Cursors.Default;
        }
        private void LoadJournals()
        {
            FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringJournal(FLedgerNumber, FBatchNumber));

            DataView JournalDV = new DataView(FMainDS.ARecurringJournal);

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

            //Populate the dictionary with all journal currencies
            if (JournalDV.Count > 0)
            {
                string  currencyCode = string.Empty;
                decimal exchangeRate = 0;

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

                    currencyCode = jr.TransactionCurrency;
                    exchangeRate = (currencyCode == FBaseCurrencyCode) ? 1 : 0;

                    if (!FExchangeRateDictionary.ContainsKey(currencyCode))
                    {
                        FExchangeRateDictionary.Add(currencyCode, exchangeRate);
                    }

                    jr.ExchangeRateToBase = exchangeRate;
                }
            }

            SelectRowInGrid(1);
        }
        private void RefreshCurrencyAndExchangeRateControls(bool AFromUserAction = false)
        {
            if (FPreviouslySelectedDetailRow == null)
            {
                return;
            }

            txtDetailHashTotal.CurrencyCode = FPreviouslySelectedDetailRow.CurrencyCode;

            txtDetailExchangeRateToBase.NumberValueDecimal = FPreviouslySelectedDetailRow.ExchangeRateToBase;
            txtDetailExchangeRateToBase.Enabled            =
                (FPreviouslySelectedDetailRow.ExchangeRateToBase != DEFAULT_CURRENCY_EXCHANGE);

            if ((FMainDS.ALedger == null) || (FMainDS.ALedger.Count == 0))
            {
                FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadALedgerTable(FLedgerNumber));
            }

            btnGetSetExchangeRate.Enabled = (FPreviouslySelectedDetailRow.CurrencyCode != FMainDS.ALedger[0].BaseCurrency);

            if (AFromUserAction && btnGetSetExchangeRate.Enabled)
            {
                btnGetSetExchangeRate.Focus();
            }
        }
示例#5
0
        /// <summary>
        /// load the batches into the grid
        /// </summary>
        /// <param name="ALedgerNumber"></param>
        public void LoadRecurringBatches(Int32 ALedgerNumber)
        {
            InitialiseLedgerControls();

            ((TFrmRecurringGiftBatch)ParentForm).ClearCurrentSelections();

            // TODO: more criteria: state of batch, period, etc
            FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadARecurringGiftBatch(ALedgerNumber));

            // Load Motivation detail in this central place; it will be used by UC_GiftTransactions
            AMotivationDetailTable motivationDetail = (AMotivationDetailTable)TDataCache.TMFinance.GetCacheableFinanceTable(
                TCacheableFinanceTablesEnum.MotivationList,
                FLedgerNumber);

            motivationDetail.TableName = FMainDS.AMotivationDetail.TableName;
            FMainDS.Merge(motivationDetail);

            FMainDS.AMotivationDetail.AcceptChanges();

            FMainDS.ARecurringGiftBatch.DefaultView.Sort = String.Format("{0}, {1} DESC",
                                                                         ARecurringGiftBatchTable.GetLedgerNumberDBName(),
                                                                         ARecurringGiftBatchTable.GetBatchNumberDBName()
                                                                         );

            ((TFrmRecurringGiftBatch)this.ParentForm).EnableTransactions(grdDetails.Rows.Count > 1);
            ShowData();

            UpdateRecordNumberDisplay();
            SelectRowInGrid(1);

            FBatchLoaded = true;
        }
示例#6
0
        private void InitialiseLedgerControls()
        {
            // Load Motivation detail in this central place; it will be used by UC_GiftTransactions
            AMotivationDetailTable motivationDetail = (AMotivationDetailTable)TDataCache.TMFinance.GetCacheableFinanceTable(
                TCacheableFinanceTablesEnum.MotivationList,
                FLedgerNumber);

            motivationDetail.TableName = FMainDS.AMotivationDetail.TableName;
            FMainDS.Merge(motivationDetail);

            FMainDS.AcceptChanges();

            FMainDS.ARecurringGiftBatch.DefaultView.Sort = String.Format("{0}, {1} DESC",
                                                                         ARecurringGiftBatchTable.GetLedgerNumberDBName(),
                                                                         ARecurringGiftBatchTable.GetBatchNumberDBName()
                                                                         );

            SetupExtraGridFunctionality();
            RefreshBankAccountAndCostCentreData();

            // if this form is readonly, then we need all codes, because old codes might have been used
            bool ActiveOnly = this.Enabled;

            SetupAccountAndCostCentreCombos(ActiveOnly);

            cmbDetailMethodOfPaymentCode.AddNotSetRow("", "");
            TFinanceControls.InitialiseMethodOfPaymentCodeList(ref cmbDetailMethodOfPaymentCode, ActiveOnly);
        }
示例#7
0
        /// <summary>
        /// Reload batches after an import
        /// </summary>
        public void ReloadBatches()
        {
            FPetraUtilsObject.GetForm().Cursor = Cursors.WaitCursor;

            // Before we re-load make a note of the 'last' batch number so we can work out which batches have been imported.
            DataView dv = new DataView(FMainDS.ABatch, String.Empty, String.Format("{0} DESC",
                                                                                   ABatchTable.GetBatchNumberDBName()), DataViewRowState.CurrentRows);
            int lastBatchNumber = (dv.Count == 0) ? 0 : ((ABatchRow)dv[0].Row).BatchNumber;

            // Merge the new batches into our data set
            FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadABatch(FLedgerNumber, FCurrentLedgerYear, 0));

            // Go round each imported batch loading its journals
            // Start with the highest batch number and continue until we reach the 'old' last batch
            for (int i = 0; i < dv.Count; i++)
            {
                int batchNumber = ((ABatchRow)dv[i].Row).BatchNumber;

                if (batchNumber <= lastBatchNumber)
                {
                    break;
                }

                FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadAJournalAndContent(FLedgerNumber, batchNumber));
            }

            FPetraUtilsObject.GetForm().Cursor = Cursors.Default;
            EnsureNewBatchIsVisible();
        }
        /// <summary>
        /// Reload batches after an import
        /// </summary>
        public void ReloadBatches(bool AIsFromMessage = false)
        {
            try
            {
                FPetraUtilsObject.GetForm().Cursor = Cursors.WaitCursor;

                if (!AIsFromMessage)
                {
                    // Before we re-load make a note of the 'last' batch number so we can work out which batches have been imported.
                    DataView dv = new DataView(FMainDS.ABatch, String.Empty, String.Format("{0} DESC",
                                                                                           ABatchTable.GetBatchNumberDBName()), DataViewRowState.CurrentRows);
                    int lastBatchNumber = (dv.Count == 0) ? 0 : ((ABatchRow)dv[0].Row).BatchNumber;

                    // Merge the new batches into our data set
                    FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadABatch(FLedgerNumber, FCurrentLedgerYear, 0));

                    // Go round each imported batch loading its journals
                    // Start with the highest batch number and continue until we reach the 'old' last batch
                    for (int i = 0; i < dv.Count; i++)
                    {
                        ABatchRow batchRow    = (ABatchRow)dv[i].Row;
                        int       batchNumber = batchRow.BatchNumber;

                        if (batchNumber <= lastBatchNumber)
                        {
                            break;
                        }

                        batchRow.SetModified();

                        FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadAJournalAndRelatedTablesForBatch(FLedgerNumber, batchNumber));
                    }

                    EnsureNewBatchIsVisible();
                }
                else
                {
                    if (FPetraUtilsObject.HasChanges && !((TFrmGLBatch)ParentForm).SaveChanges())
                    {
                        string msg = String.Format(Catalog.GetString("A validation error has occured on the GL Batches" +
                                                                     " form while trying to refresh.{0}{0}" +
                                                                     "You will need to close and reopen the GL Batches form to see the new batch" +
                                                                     " after you have fixed the validation error."),
                                                   Environment.NewLine);

                        MessageBox.Show(msg, "Refresh GL Batches");
                        return;
                    }

                    FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadABatch(FLedgerNumber, FCurrentLedgerYear, 0));
                    grdDetails.SelectRowInGrid(1);
                }
            }
            finally
            {
                FPetraUtilsObject.GetForm().Cursor = Cursors.Default;
            }
        }
示例#9
0
        /// <summary>
        /// Deletes the current row and optionally populates a completion message
        /// </summary>
        /// <param name="ARowToDelete">the currently selected row to delete</param>
        /// <param name="ACompletionMessage">if specified, is the deletion completion message</param>
        /// <returns>true if row deletion is successful</returns>
        private bool DeleteRowManual(ARecurringGiftBatchRow ARowToDelete, ref string ACompletionMessage)
        {
            bool deletionSuccessful = false;

            int batchNumber = ARowToDelete.BatchNumber;

            bool newBatch = (ARowToDelete.RowState == DataRowState.Added);

            // first save any changes
            if (!((TFrmRecurringGiftBatch)FPetraUtilsObject.GetForm()).SaveChangesManual(TExtraGiftBatchChecks.GiftBatchAction.DELETING))
            {
                return(false);
            }

            try
            {
                ACompletionMessage = String.Format(Catalog.GetString("Batch no.: {0} deleted successfully."),
                                                   batchNumber);

                //clear any transactions currently being editied in the Transaction Tab
                ((TFrmRecurringGiftBatch)ParentForm).GetTransactionsControl().ClearCurrentSelection();

                if (!newBatch)
                {
                    //Load tables afresh
                    FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadRecurringGiftTransactionsForBatch(FLedgerNumber, batchNumber));
                    FMainDS.AcceptChanges();
                }

                ((TFrmRecurringGiftBatch)ParentForm).GetTransactionsControl().DeleteCurrentRecurringBatchGiftData(batchNumber);

                //Affect a change in the batch row, required by deletion process.
                ARowToDelete.DateModified = DateTime.Now;

                // Delete the recurring batch row.
                ARowToDelete.Delete();

                //FMainDS.AcceptChanges();
                FPreviouslySelectedDetailRow = null;

                deletionSuccessful = true;
            }
            catch (Exception ex)
            {
                ACompletionMessage = ex.Message;
                MessageBox.Show(ex.Message,
                                "Deletion Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            UpdateRecordNumberDisplay();

            return(deletionSuccessful);
        }
示例#10
0
        /// <summary>
        /// Loads Extract Master Data from Petra Server into FMainDS.
        /// </summary>
        /// <param name="AExtractNameFilter"></param>
        /// <param name="AAllUsers"></param>
        /// <param name="ACreatedByUser"></param>
        /// <param name="AModifiedByUser"></param>
        /// <returns>true if successful, otherwise false.</returns>
        private Boolean LoadData(String AExtractNameFilter, Boolean AAllUsers,
                                 String ACreatedByUser, String AModifiedByUser)
        {
            Boolean ReturnValue;

            // Load Extract Headers, if not already loaded
            try
            {
                // Make sure that Typed DataTables are already there at Client side
                if (FMainDS.MExtractMaster == null)
                {
                    FMainDS.Tables.Add(new MExtractMasterTable());
                    FMainDS.InitVars();
                }
                else
                {
                    // clear table so a load also works if records on the server have been removed
                    FMainDS.MExtractMaster.Clear();
                }

                // add filter data
                FMainDS.Merge(TRemote.MPartner.Partner.WebConnectors.GetAllExtractHeaders(AExtractNameFilter,
                                                                                          AAllUsers, ACreatedByUser, AModifiedByUser));

                // Make DataRows unchanged
                if (FMainDS.MExtractMaster.Rows.Count > 0)
                {
                    FMainDS.MExtractMaster.AcceptChanges();
                    FMainDS.AcceptChanges();
                }

                if (FMainDS.MExtractMaster.Rows.Count != 0)
                {
                    ReturnValue = true;
                }
                else
                {
                    ReturnValue = false;
                }
            }
            catch (System.NullReferenceException)
            {
                return(false);
            }
            catch (Exception)
            {
                throw;
            }

            return(ReturnValue);
        }
示例#11
0
        /// <summary>
        /// load the batches into the grid
        /// </summary>
        public void LoadBatchesForCurrentYear()
        {
            TFrmGiftBatch MyParentForm        = (TFrmGiftBatch)this.ParentForm;
            bool          PerformStandardLoad = true;

            if (MyParentForm.InitialBatchYear >= 0)
            {
                FLoadAndFilterLogicObject.StatusAll = true;

                int yearIndex = FLoadAndFilterLogicObject.FindYearAsIndex(MyParentForm.InitialBatchYear);

                if (yearIndex >= 0)
                {
                    FLoadAndFilterLogicObject.YearIndex = yearIndex;

                    if (MyParentForm.InitialBatchPeriod >= 0)
                    {
                        FLoadAndFilterLogicObject.PeriodIndex = FLoadAndFilterLogicObject.FindPeriodAsIndex(MyParentForm.InitialBatchPeriod);
                    }
                    else
                    {
                        FLoadAndFilterLogicObject.PeriodIndex = (MyParentForm.InitialBatchYear == FMainDS.ALedger[0].CurrentFinancialYear) ? 1 : 0;
                    }

                    PerformStandardLoad = false;
                }

                // Reset the start-up value
                MyParentForm.InitialBatchYear = -1;
            }

            MyParentForm.ClearCurrentSelections();

            if (ViewMode)
            {
                FMainDS.Merge(ViewModeTDS);
                FLoadAndFilterLogicObject.DisableYearAndPeriod(true);
            }

            if (PerformStandardLoad)
            {
                // Set up for current year with current and forwarding periods (on initial load this will already be set so will not fire a change)
                FLoadAndFilterLogicObject.YearIndex   = 0;
                FLoadAndFilterLogicObject.PeriodIndex = 0;
            }

            // Get the data, populate the grid and re-select the current row (or first row if none currently selected) ...
            RefreshAllData();

            FBatchLoaded = true;
        }
示例#12
0
        private void InitializeManualCode()
        {
            if (!FMainDS.Tables.Contains(PContactLogTable.GetTableName()))
            {
                FMainDS.Merge(TRemote.MPartner.Partner.WebConnectors.GetPartnerContactLogData(FMainDS.PPartner[0].PartnerKey));
                FMainDS.PContactLog.DefaultView.AllowNew = false;
            }

            FMainDS.InitVars();

            OnHookupDataChange(new THookupPartnerEditDataChangeEventArgs(TPartnerEditTabPageEnum.petpContacts));
            //Hook up DataSavingStarted Event to be able to run code before SaveChanges is doing anything
            FPetraUtilsObject.DataSavingStarted += new TDataSavingStartHandler(this.DataSavingStarted);
            ucoDetails.SpecialInitUserControl();
        }
        private void Search(object sender, EventArgs e)
        {
            FMainDS.PContactLog.Clear();

            FMainDS.Merge(TRemote.MPartner.Partner.WebConnectors.FindContacts(
                              txtContactor.Text,
                              dtpContactDate.Date,
                              txtCommentContains.Text,
                              cmbContactCode.Text,
                              "",
                              cmbMailingCode.Text));

            FMainDS.PContactLog.DefaultView.AllowNew = false;
            grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.PContactLog.DefaultView);
        }
        /// <summary>
        /// Loads Job Assignment Data from Petra Server into FMainDS, if not already loaded.
        /// </summary>
        /// <returns>true if successful, otherwise false.</returns>
        private Boolean LoadDataOnDemand()
        {
            Boolean ReturnValue;

            try
            {
                // Make sure that Typed DataTables are already there at Client side
                if (FMainDS.PmJobAssignment == null)
                {
                    FMainDS.Tables.Add(new PmJobAssignmentTable());
                    FMainDS.InitVars();
                }

                if (TClientSettings.DelayedDataLoading &&
                    (FMainDS.PmJobAssignment.Rows.Count == 0))
                {
                    FMainDS.Merge(FPartnerEditUIConnector.GetDataPersonnelIndividualData(TIndividualDataItemEnum.idiJobAssignments));

                    // Make DataRows unchanged
                    if (FMainDS.PmJobAssignment.Rows.Count > 0)
                    {
                        if (FMainDS.PmJobAssignment.Rows[0].RowState != DataRowState.Added)
                        {
                            FMainDS.PmJobAssignment.AcceptChanges();
                        }
                    }
                }

                if (FMainDS.PmJobAssignment.Rows.Count != 0)
                {
                    ReturnValue = true;
                }
                else
                {
                    ReturnValue = false;
                }
            }
            catch (System.NullReferenceException)
            {
                return(false);
            }
            catch (Exception)
            {
                throw;
            }

            return(ReturnValue);
        }
示例#15
0
        private void RunOnceOnParentActivationManual()
        {
            ParentForm.Cursor                  = Cursors.WaitCursor;
            grdDetails.DoubleClickCell        += new TDoubleClickCellEventHandler(this.ShowTransactionTab);
            grdDetails.DataSource.ListChanged += new System.ComponentModel.ListChangedEventHandler(DataSource_ListChanged);

            // Load the ledger table so we know the base currency
            FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadALedgerTable(FLedgerNumber));
            FLedgerBaseCurrency = FMainDS.ALedger[0].BaseCurrency;

            FLoadAndFilterLogicObject.ActivateFilter();
            LoadBatchesForCurrentYear();
            ParentForm.Cursor = Cursors.Default;

            SetInitialFocus();
        }
        private void LoadJournalsForCurrentBatch()
        {
            //Current Batch number
            Int32 BatchNumber = FPreviouslySelectedDetailRow.BatchNumber;

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

                if (FMainDS.AJournal.DefaultView.Count == 0)
                {
                    FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadAJournal(FLedgerNumber, BatchNumber));
                }
            }
        }
示例#17
0
        /// <summary>
        /// Ensure the data is loaded for the specified batch
        /// </summary>
        /// <param name="ALedgerNumber"></param>
        /// <param name="ABatchNumber"></param>
        /// <returns>If transactions exist</returns>
        public Boolean EnsureGiftDataPresent(Int32 ALedgerNumber, Int32 ABatchNumber)
        {
            DataView TransDV = new DataView(FMainDS.ARecurringGiftDetail);

            TransDV.RowFilter = String.Format("{0}={1} And {2}={3}",
                                              ARecurringGiftDetailTable.GetLedgerNumberDBName(),
                                              ALedgerNumber,
                                              ARecurringGiftDetailTable.GetBatchNumberDBName(),
                                              ABatchNumber);

            if (TransDV.Count == 0)
            {
                FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadARecurringGiftBatchAndRelatedData(ALedgerNumber, ABatchNumber, true));
            }

            return(TransDV.Count > 0);
        }
示例#18
0
        /// <summary>
        /// load the batches into the grid
        /// </summary>
        /// <param name="ALedgerNumber"></param>
        public void LoadBatches(Int32 ALedgerNumber)
        {
            //FBatchesLoaded = false;
            InitialiseControls();

            FLedgerNumber = ALedgerNumber;

            if ((FPetraUtilsObject == null) || FPetraUtilsObject.SuppressChangeDetection)
            {
                return;
            }

            FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringBatch(FLedgerNumber, TFinanceBatchFilterEnum.fbfAll));

            if (FCacheDS == null)
            {
                FCacheDS = TRemote.MFinance.GL.WebConnectors.LoadAAnalysisAttributes(FLedgerNumber, false);
            }

            btnNew.Enabled = true;

            FPreviouslySelectedDetailRow = null;
            grdDetails.DataSource        = new DevAge.ComponentModel.BoundDataView(FMainDS.ARecurringBatch.DefaultView);

            if (grdDetails.Rows.Count > 1)
            {
                SelectRowInGrid(1);
                ((TFrmRecurringGLBatch)this.ParentForm).EnableJournals();
                AutoEnableTransTabForBatch();
            }
            else
            {
                ClearControls();
                ((TFrmRecurringGLBatch)this.ParentForm).DisableJournals();
                ((TFrmRecurringGLBatch)this.ParentForm).DisableTransactions();
            }

            //Load all analysis attribute values
            ShowData();

            UpdateChangeableStatus();
            UpdateRecordNumberDisplay();
            SetAccountCostCentreTableVariables();

            //FBatchesLoaded = true;
        }
        /// <summary>
        /// Loads Partner Interest Data from Petra Server into FMainDS.
        /// </summary>
        /// <returns>true if successful, otherwise false.</returns>
        private Boolean LoadDataOnDemand()
        {
            Boolean ReturnValue;

            // Load Partner Types, if not already loaded
            try
            {
                // Make sure that Typed DataTables are already there at Client side
                if (FMainDS.PPartnerInterest == null)
                {
                    FMainDS.Tables.Add(new PartnerEditTDSPPartnerInterestTable());
                    FMainDS.InitVars();
                }

                if (TClientSettings.DelayedDataLoading)
                {
                    FMainDS.Merge(FPartnerEditUIConnector.GetDataPartnerInterests());

                    // Make DataRows unchanged
                    if (FMainDS.PPartnerInterest.Rows.Count > 0)
                    {
                        FMainDS.PPartnerInterest.AcceptChanges();
                    }
                }

                if (FMainDS.PPartnerInterest.Rows.Count != 0)
                {
                    ReturnValue = true;
                }
                else
                {
                    ReturnValue = false;
                }
            }
            catch (System.NullReferenceException)
            {
                return(false);
            }
            catch (Exception)
            {
                throw;
            }
            return(ReturnValue);
        }
        /// <summary>
        /// Loads Extract Master Data from Petra Server into FMainDS.
        /// </summary>
        /// <returns>true if successful, otherwise false.</returns>
        private Boolean LoadData()
        {
            Boolean ReturnValue;

            // Load Extract Headers, if not already loaded
            try
            {
                // Make sure that MasterTyped DataTables are already there at Client side
                if (FMainDS.MExtract == null)
                {
                    FMainDS.Tables.Add(new ExtractTDSMExtractTable());
                    FMainDS.InitVars();
                }

                FMainDS.Merge(TRemote.MPartner.Partner.WebConnectors.GetExtractRowsWithPartnerData(FExtractId));

                // Make DataRows unchanged
                if (FMainDS.MExtract.Rows.Count > 0)
                {
                    FMainDS.MExtract.AcceptChanges();
                    FMainDS.AcceptChanges();
                }

                if (FMainDS.MExtract.Rows.Count != 0)
                {
                    ReturnValue = true;
                }
                else
                {
                    ReturnValue = false;
                }
            }
            catch (System.NullReferenceException)
            {
                return(false);
            }
            catch (Exception)
            {
                throw;
            }
            return(ReturnValue);
        }
        /// <summary>
        /// load the batches into the grid
        /// </summary>
        public void LoadBatchesForCurrentYear()
        {
            FDateEffective = FDefaultDate;

            ((TFrmGiftBatch)ParentForm).ClearCurrentSelections();

            if (ViewMode)
            {
                FMainDS.Merge(ViewModeTDS);
                FLoadAndFilterLogicObject.DisableYearAndPeriod(true);
            }

            // Set up for current year with current and forwarding periods (on initial load this will already be set so will not fire a change)
            FLoadAndFilterLogicObject.YearIndex   = 0;
            FLoadAndFilterLogicObject.PeriodIndex = 0;

            // Get the data, populate the grid and re-select the current row (or first row if none currently selected) ...
            RefreshAllData();

            FBatchLoaded = true;
        }
示例#22
0
        /// <summary>
        /// Loads Partner Types Data from Petra Server into FMainDS.
        /// </summary>
        /// <returns>true if successful, otherwise false.</returns>
        private Boolean LoadDataOnDemand()
        {
            Boolean ReturnValue = true;

            // Load Partner Types, if not already loaded
            try
            {
                // Make sure that Typed DataTables are already there at Client side
                if (FMainDS.PDataLabelValuePartner == null)
                {
                    FMainDS.Tables.Add(new PDataLabelValuePartnerTable());
                    FMainDS.InitVars();
                }

                if (TClientSettings.DelayedDataLoading)
                {
                    FMainDS.Merge(FPartnerEditUIConnector.GetDataPersonnelIndividualData(TIndividualDataItemEnum.idiLocalPersonnelData));

                    // Make DataRows unchanged
                    if (FMainDS.PDataLabelValuePartner.Rows.Count > 0)
                    {
                        FMainDS.PDataLabelValuePartner.AcceptChanges();
                    }
                }

                if (FMainDS.PDataLabelValuePartner == null)
                {
                    ReturnValue = false;
                }
            }
            catch (System.NullReferenceException)
            {
                return(false);
            }
            catch (Exception)
            {
                throw;
            }
            return(ReturnValue);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="ALedgerNumber"></param>
        /// <param name="ABatchNumber"></param>
        /// <param name="ABatchYear"></param>
        /// <param name="ABatchPeriod"></param>
        public void LoadOneBatch(Int32 ALedgerNumber, Int32 ABatchNumber, int ABatchYear, int ABatchPeriod)
        {
            FLedgerNumber = ALedgerNumber;
            InitialiseLogicObjects();

            FMainDS.Merge(ViewModeTDS);
            FPetraUtilsObject.SuppressChangeDetection = true;

            if (FLoadAndFilterLogicObject.BatchYear != ABatchYear)
            {
                FLoadAndFilterLogicObject.BatchYear = ABatchYear;
                FLoadAndFilterLogicObject.RefreshPeriods(ABatchYear);
            }

            FLoadAndFilterLogicObject.BatchPeriod = ABatchPeriod;
            FLoadAndFilterLogicObject.DisableYearAndPeriod(false);

            FMainDS.AGiftBatch.DefaultView.RowFilter =
                String.Format("{0}={1}", AGiftBatchTable.GetBatchNumberDBName(), ABatchNumber);
            Int32 RowToSelect = GetDataTableRowIndexByPrimaryKeys(ALedgerNumber, ABatchNumber);

            FAccountAndCostCentreLogicObject.RefreshBankAccountAndCostCentreData(FLoadAndFilterLogicObject);
            SetupExtraGridFunctionality();

            // if this form is readonly, then we need all codes, because old codes might have been used
            bool ActiveOnly = this.Enabled;

            SetupAccountAndCostCentreCombos(ActiveOnly);

            cmbDetailMethodOfPaymentCode.AddNotSetRow("", "");
            TFinanceControls.InitialiseMethodOfPaymentCodeList(ref cmbDetailMethodOfPaymentCode, ActiveOnly);

            SelectRowInGrid(RowToSelect);

            UpdateChangeableStatus();
            FPetraUtilsObject.HasChanges = false;
            FPetraUtilsObject.SuppressChangeDetection = false;
            FBatchLoaded = true;
        }
示例#24
0
        private void ImportHierarchy(object sender, EventArgs e)
        {
            // TODO: open file; only will work if there are no GLM records and transactions yet
            XmlDocument doc;

            try
            {
                doc = TImportExportDialogs.ImportWithDialog(Catalog.GetString("Load Account Hierarchy from file"));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Catalog.GetString("Load Account Hierarchy from file"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (doc == null)
            {
                // was cancelled
                return;
            }

            if (!TRemote.MFinance.Setup.WebConnectors.ImportAccountHierarchy(FLedgerNumber, FSelectedHierarchy, TXMLParser.XmlToString(doc)))
            {
                MessageBox.Show(Catalog.GetString(
                                    "Import of new Account Hierarchy failed; perhaps there were already balances? Try with a new ledger!"),
                                Catalog.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                // refresh the screen
                FMainDS.Clear();
                FMainDS.Merge(TRemote.MFinance.Setup.WebConnectors.LoadAccountHierarchies(FLedgerNumber));
                ucoAccountsTree.PopulateTreeView(FMainDS, FLedgerNumber, FSelectedHierarchy);

                MessageBox.Show("Import of new Account Hierarchy has been successful",
                                Catalog.GetString("Success"), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void InitialiseLedgerControls()
        {
            // Load Motivation detail in this central place; it will be used by UC_GiftTransactions
            AMotivationDetailTable motivationDetail = (AMotivationDetailTable)TDataCache.TMFinance.GetCacheableFinanceTable(
                TCacheableFinanceTablesEnum.MotivationList,
                FLedgerNumber);

            motivationDetail.TableName = FMainDS.AMotivationDetail.TableName;
            FMainDS.Merge(motivationDetail);

            FMainDS.AcceptChanges();

            FMainDS.AGiftBatch.DefaultView.Sort = String.Format("{0}, {1} DESC",
                                                                AGiftBatchTable.GetLedgerNumberDBName(),
                                                                AGiftBatchTable.GetBatchNumberDBName()
                                                                );

            SetupExtraGridFunctionality();
            FAccountAndCostCentreLogicObject.RefreshBankAccountAndCostCentreData(FLoadAndFilterLogicObject);

            // if this form is readonly, then we need all codes, because old codes might have been used
            bool ActiveOnly = this.Enabled;

            SetupAccountAndCostCentreCombos(ActiveOnly);

            cmbDetailMethodOfPaymentCode.AddNotSetRow("", "");
            TFinanceControls.InitialiseMethodOfPaymentCodeList(ref cmbDetailMethodOfPaymentCode, ActiveOnly);

            TLedgerSelection.GetCurrentPostingRangeDates(FLedgerNumber,
                                                         out FStartDateCurrentPeriod,
                                                         out FEndDateLastForwardingPeriod,
                                                         out FDefaultDate);
            lblValidDateRange.Text = String.Format(Catalog.GetString("Valid between {0} and {1}"),
                                                   FStartDateCurrentPeriod.ToShortDateString(), FEndDateLastForwardingPeriod.ToShortDateString());

            FLoadAndFilterLogicObject.InitialiseDataSources(cmbDetailBankCostCentre, cmbDetailBankAccountCode);
        }
示例#26
0
        private Boolean CheckAccountCodeValueChanged()
        {
            String strNewDetailAccountCode = txtDetailAccountCode.Text;
            String strAccountShortDescr    = txtDetailEngAccountCodeShortDesc.Text;

            bool changeAccepted = false;

            if (strNewDetailAccountCode != FRecentlyUpdatedDetailAccountCode)
            {
                if (strNewDetailAccountCode != strOldDetailAccountCode)
                {
                    if (strOldDetailAccountCode.IndexOf(FNameForNewAccounts) < 0) // If they're just changing this from the initial value, don't show warning.
                    {
                        if (MessageBox.Show(String.Format(Catalog.GetString(
                                                              "You have changed the Account Code from '{0}' to '{1}'.\r\n\r\n" +
                                                              "Please confirm that you want to rename this account by choosing 'OK'.\r\n\r\n" +
                                                              "(Renaming will take a few moments, then the form will be re-loaded.)"),
                                                          strOldDetailAccountCode,
                                                          strNewDetailAccountCode),
                                            Catalog.GetString("Rename Account: Confirmation"), MessageBoxButtons.OKCancel,
                                            MessageBoxIcon.Warning) != DialogResult.OK)
                        {
                            txtDetailAccountCode.Text = strOldDetailAccountCode;
                            return(false);
                        }
                    }

                    this.Cursor = Cursors.WaitCursor;
                    this.Refresh();  // Just to get the Wait Cursor to display...

                    FRecentlyUpdatedDetailAccountCode = strNewDetailAccountCode;

                    changeAccepted = ProtectedChangeOfPrimaryKey(FCurrentAccount);

                    if (changeAccepted)
                    {
                        ucoAccountsTree.SetNodeLabel(strNewDetailAccountCode, strAccountShortDescr);

                        if (FCurrentAccount.IsNew)
                        {
                            // This is the code for changes in "un-committed" nodes:
                            // there are no references to this new row yet, apart from children nodes, so I can just change them here and carry on!
                            ucoAccountsTree.FixupChildrenAfterAccountNameChange();

                            strOldDetailAccountCode                  = strNewDetailAccountCode;
                            FPetraUtilsObject.HasChanges             = true;
                            ucoAccountAnalysisAttributes.AccountCode = strNewDetailAccountCode;
                        }
                        else
                        {
                            ShowStatus(Catalog.GetString("Updating Account Code change - please wait."));
                            TVerificationResultCollection VerificationResults;

                            // If this code was previously in the DB, I need to assume that there may be transactions posted to it.
                            // There's a server call I need to use, and after the call I need to re-load this page.
                            // (No other changes will be lost, because the txtDetailAccountCode_TextChanged would
                            // have disallowed the change if there were already changes.)
                            bool Success = TRemote.MFinance.Setup.WebConnectors.RenameAccountCode(strOldDetailAccountCode,
                                                                                                  strNewDetailAccountCode,
                                                                                                  FLedgerNumber,
                                                                                                  out VerificationResults); // This call takes ages..

                            if (Success)
                            {
                                FIAmUpdating++;
                                FMainDS.Clear();
                                FMainDS.Merge(TRemote.MFinance.Setup.WebConnectors.LoadAccountHierarchies(FLedgerNumber));      // and this also takes a while!
                                strOldDetailAccountCode = "";
                                FPetraUtilsObject.SuppressChangeDetection = true;
                                ucoAccountsTree.PopulateTreeView(FMainDS, FLedgerNumber, FSelectedHierarchy);
                                ucoAccountsList.PopulateListView(FMainDS, FLedgerNumber, FSelectedHierarchy);
                                ShowDetailsManual(null);
                                ClearStatus();
                                FIAmUpdating--;
                                FPetraUtilsObject.SuppressChangeDetection = false;
                                ucoAccountsTree.SelectNodeByName(FRecentlyUpdatedDetailAccountCode);

                                ShowStatus(String.Format(Catalog.GetString("Account Code changed to '{0}'."), strNewDetailAccountCode));
                                TDataCache.TMFinance.RefreshCacheableFinanceTable(Shared.TCacheableFinanceTablesEnum.AccountList, FLedgerNumber);
                            }
                            else
                            {
                                MessageBox.Show(VerificationResults.BuildVerificationResultString(), Catalog.GetString("Rename Account"));
                            }

                            changeAccepted = false; // Actually the change was accepted, but processed here, so there's nothing left to do.
                            FPetraUtilsObject.HasChanges = false;
                        }

                        btnRename.Visible = false;
                    } // if changeAccepted

                    this.Cursor = Cursors.Default;
                } // if changed
            }     // if not handling the same change as before (prevents this method running several times for a single change!)

            return(changeAccepted);
        }
        /// <summary>
        /// load the journals into the grid
        /// </summary>
        /// <param name="ACurrentBatchRow"></param>
        public void LoadJournals(ARecurringBatchRow ACurrentBatchRow)
        {
            FJournalsLoaded = false;

            FBatchRow = ACurrentBatchRow;

            if (FBatchRow == null)
            {
                return;
            }

            Int32 CurrentLedgerNumber = ACurrentBatchRow.LedgerNumber;
            Int32 CurrentBatchNumber  = ACurrentBatchRow.BatchNumber;

            bool FirstRun     = (FLedgerNumber != CurrentLedgerNumber);
            bool BatchChanged = (FBatchNumber != CurrentBatchNumber);

            if (FirstRun)
            {
                FLedgerNumber = CurrentLedgerNumber;
            }

            if (BatchChanged)
            {
                FBatchNumber = CurrentBatchNumber;
            }

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

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

                if (GetSelectedRowIndex() > 0)
                {
                    GetDetailsFromControls(GetSelectedDetailRow());
                }
            }
            else
            {
                // a different journal
                SetJournalDefaultView();
                FPreviouslySelectedDetailRow = null;

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

                //Ensure Last Batch Number is correct, needed to correct old Petra data
                if ((FBatchRow.LastJournal != FMainDS.ARecurringJournal.DefaultView.Count) &&
                    GLRoutines.UpdateRecurringBatchLastJournal(ref FMainDS, ref FBatchRow))
                {
                    FPetraUtilsObject.SetChangedFlag();
                }

                ShowData();

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

            int nRowToSelect = (BatchChanged || FirstRun) ? 1 : FPrevRowChangedRow;

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

            UpdateRecordNumberDisplay();
            FFilterAndFindObject.SetRecordNumberDisplayProperties();

            //Check for incorrect Exchange rate to base
            foreach (DataRowView drv in FMainDS.ARecurringJournal.DefaultView)
            {
                ARecurringJournalRow rjr = (ARecurringJournalRow)drv.Row;

                if (rjr.ExchangeRateToBase == 0)
                {
                    rjr.ExchangeRateToBase       = 1;
                    FPetraUtilsObject.HasChanges = true;
                }
            }

            FJournalsLoaded = true;

            //Check on batch totals
            if (GLRoutines.UpdateRecurringBatchTotals(ref FMainDS, ref FBatchRow))
            {
                FPetraUtilsObject.SetChangedFlag();
            }
        }
        private void ProcessNewlyAddedJournalRowForDeletion(int AJournalNumberToDelete)
        {
            GLBatchTDS BackupDS = (GLBatchTDS)FMainDS.Copy();

            BackupDS.Merge(FMainDS);

            try
            {
                // Delete the associated recurring transaction analysis attributes
                DataView attributesDV = new DataView(FMainDS.ARecurringTransAnalAttrib);
                attributesDV.RowFilter = string.Format("{0}={1} And {2}={3}",
                                                       ARecurringTransAnalAttribTable.GetBatchNumberDBName(),
                                                       FBatchNumber,
                                                       ARecurringTransAnalAttribTable.GetJournalNumberDBName(),
                                                       AJournalNumberToDelete
                                                       );

                foreach (DataRowView attrDRV in attributesDV)
                {
                    ARecurringTransAnalAttribRow attrRow = (ARecurringTransAnalAttribRow)attrDRV.Row;
                    attrRow.Delete();
                }

                // Delete the associated recurring transactions
                DataView transactionsDV = new DataView(FMainDS.ARecurringTransaction);
                transactionsDV.RowFilter = String.Format("{0}={1} And {2}={3}",
                                                         ARecurringTransactionTable.GetBatchNumberDBName(),
                                                         FBatchNumber,
                                                         ARecurringTransactionTable.GetJournalNumberDBName(),
                                                         AJournalNumberToDelete
                                                         );

                foreach (DataRowView transDRV in transactionsDV)
                {
                    ARecurringTransactionRow tranRow = (ARecurringTransactionRow)transDRV.Row;
                    tranRow.Delete();
                }

                // Delete the recurring journal
                DataView journalDV = new DataView(FMainDS.ARecurringJournal);
                journalDV.RowFilter = String.Format("{0}={1} And {2}={3}",
                                                    ARecurringJournalTable.GetBatchNumberDBName(),
                                                    FBatchNumber,
                                                    ARecurringJournalTable.GetJournalNumberDBName(),
                                                    AJournalNumberToDelete
                                                    );

                foreach (DataRowView journalDRV in journalDV)
                {
                    ARecurringJournalRow jrnlRow = (ARecurringJournalRow)journalDRV.Row;
                    jrnlRow.Delete();
                }

                //Renumber the journals, transactions and attributes
                DataView attributesDV2 = new DataView(FMainDS.ARecurringTransAnalAttrib);
                attributesDV2.RowFilter = string.Format("{0}={1} And {2}>{3}",
                                                        ARecurringTransAnalAttribTable.GetBatchNumberDBName(),
                                                        FBatchNumber,
                                                        ARecurringTransAnalAttribTable.GetJournalNumberDBName(),
                                                        AJournalNumberToDelete);
                attributesDV2.Sort = String.Format("{0} ASC", ARecurringTransAnalAttribTable.GetJournalNumberDBName());

                foreach (DataRowView attrDRV in attributesDV2)
                {
                    ARecurringTransAnalAttribRow attrRow = (ARecurringTransAnalAttribRow)attrDRV.Row;
                    attrRow.JournalNumber--;
                }

                DataView transactionsDV2 = new DataView(FMainDS.ARecurringTransaction);
                transactionsDV2.RowFilter = string.Format("{0}={1} And {2}>{3}",
                                                          ARecurringTransactionTable.GetBatchNumberDBName(),
                                                          FBatchNumber,
                                                          ARecurringTransactionTable.GetJournalNumberDBName(),
                                                          AJournalNumberToDelete);
                transactionsDV2.Sort = String.Format("{0} ASC", ARecurringTransactionTable.GetJournalNumberDBName());

                foreach (DataRowView transDRV in transactionsDV2)
                {
                    ARecurringTransactionRow tranRow = (ARecurringTransactionRow)transDRV.Row;
                    tranRow.JournalNumber--;
                }

                DataView journalDV2 = new DataView(FMainDS.ARecurringJournal);
                journalDV2.RowFilter = string.Format("{0}={1} And {2}>{3}",
                                                     ARecurringJournalTable.GetBatchNumberDBName(),
                                                     FBatchNumber,
                                                     ARecurringJournalTable.GetJournalNumberDBName(),
                                                     AJournalNumberToDelete);
                journalDV2.Sort = String.Format("{0} ASC", ARecurringJournalTable.GetJournalNumberDBName());

                foreach (DataRowView jrnlDRV in journalDV2)
                {
                    ARecurringJournalRow jrnlRow = (ARecurringJournalRow)jrnlDRV.Row;
                    jrnlRow.JournalNumber--;
                }
            }
            catch (Exception ex)
            {
                FMainDS.Merge(BackupDS);

                TLogging.LogException(ex, Utilities.GetMethodSignature());
                throw;
            }
        }
        /// <summary>
        /// Undo all changes to the specified batch ready to cancel it.
        ///  This avoids unecessary validation errors when cancelling.
        /// </summary>
        /// <param name="ACurrentBatch"></param>
        /// <param name="AJournalToDelete"></param>
        /// <param name="ARedisplay"></param>
        public void PrepareJournalDataForDeleting(Int32 ACurrentBatch, Int32 AJournalToDelete, Boolean ARedisplay)
        {
            //This code will only be called when the Batch tab is active.

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

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

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

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

            //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)
            {
                GLBatchTDSARecurringJournalRow journalRow = (GLBatchTDSARecurringJournalRow)JournalDV[0].Row;

                //No need to check for Added state as new batches 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 batch ready to delete/cancel
                FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringTransactionAndRelatedTablesForJournal(FLedgerNumber, ACurrentBatch,
                                                                                                                    AJournalToDelete));
            }
        }
        /// <summary>
        /// Deletes the current row and optionally populates a completion message
        /// </summary>
        /// <param name="ARowToDelete">the currently selected row to delete</param>
        /// <param name="ACompletionMessage">if specified, is the deletion completion message</param>
        /// <returns>true if row deletion is successful</returns>
        private bool DeleteRowManual(GLBatchTDSARecurringJournalRow ARowToDelete, ref string ACompletionMessage)
        {
            //Assign default value(s)
            bool DeletionSuccessful = false;

            ACompletionMessage = string.Empty;

            if (ARowToDelete == null)
            {
                return(DeletionSuccessful);
            }

            //Delete current row
            ARowToDelete.RejectChanges();
            ShowDetails(ARowToDelete);

            //Take a backup of FMainDS
            GLBatchTDS BackupMainDS = null;
            //Pass a copy of FMainDS to the server-side delete method.
            GLBatchTDS TempDS = (GLBatchTDS)FMainDS.Copy();

            TempDS.Merge(FMainDS);

            int  CurrentBatchNumber = ARowToDelete.BatchNumber;
            bool CurrentBatchJournalTransactionsLoadedAndCurrent = false;

            FJournalNumberToDelete = ARowToDelete.JournalNumber;
            int TopMostJrnlNo = FBatchRow.LastJournal;

            TFrmRecurringGLBatch FMyForm = (TFrmRecurringGLBatch)this.ParentForm;

            try
            {
                this.Cursor = Cursors.WaitCursor;
                FMyForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.DELETINGJOURNAL;

                //Backup the Dataset for reversion purposes
                BackupMainDS = (GLBatchTDS)FMainDS.GetChangesTyped(false);

                //Check if current batch transactions are loaded and being viewed in their tab
                CurrentBatchJournalTransactionsLoadedAndCurrent = (FMyForm.GetTransactionsControl().FBatchNumber == CurrentBatchNumber &&
                                                                   FMyForm.GetTransactionsControl().FJournalNumber == FJournalNumberToDelete);

                //Save and check for inactive values
                FPetraUtilsObject.SetChangedFlag();

                if (!FMyForm.SaveChangesManual(FMyForm.FCurrentGLBatchAction, false, !CurrentBatchJournalTransactionsLoadedAndCurrent))
                {
                    string msg = String.Format(Catalog.GetString("Recurring Journal {0} has not been deleted."),
                                               FJournalNumberToDelete);

                    MessageBox.Show(msg,
                                    Catalog.GetString("Recurring GL Batch Deletion"),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);

                    return(false);
                }

                //Remove any changes to current batch that may cause validation issues
                PrepareJournalDataForDeleting(CurrentBatchNumber, FJournalNumberToDelete, true);

                if (CurrentBatchJournalTransactionsLoadedAndCurrent)
                {
                    //Clear any transactions currently being edited in the Transaction Tab
                    FMyForm.GetTransactionsControl().ClearCurrentSelection(CurrentBatchNumber, FJournalNumberToDelete);
                }

                //Load all journals for this batch
                TempDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringJournalAndRelatedTablesForBatch(FLedgerNumber, FBatchNumber));
                TempDS.AcceptChanges();

                //Clear the transactions and load newly saved dataset
                FMainDS.ARecurringTransAnalAttrib.Clear();
                FMainDS.ARecurringTransaction.Clear();
                FMainDS.ARecurringJournal.Clear();

                FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.ProcessRecurrJrnlTransAttribForDeletion(TempDS, FLedgerNumber, FBatchNumber,
                                                                                                        TopMostJrnlNo, FJournalNumberToDelete));

                FPreviouslySelectedDetailRow = null;
                FPetraUtilsObject.SetChangedFlag();

                ACompletionMessage = String.Format(Catalog.GetString("Recurring Journal no.: {0} deleted successfully."),
                                                   FJournalNumberToDelete);

                DeletionSuccessful = true;
            }
            catch (Exception ex)
            {
                //Normally set in PostDeleteManual
                FMyForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.NONE;

                //Revert to previous state
                RevertDataSet(FMainDS, BackupMainDS);

                TLogging.LogException(ex, Utilities.GetMethodSignature());
                throw;
            }
            finally
            {
                SetJournalDefaultView();
                FFilterAndFindObject.ApplyFilter();
                this.Cursor = Cursors.Default;
            }

            return(DeletionSuccessful);
        }