/// <summary>
        /// Code to be run after the deletion process
        /// </summary>
        /// <param name="ARowToDelete">the row that was/was to be deleted</param>
        /// <param name="AAllowDeletion">whether or not the user was permitted to delete</param>
        /// <param name="ADeletionPerformed">whether or not the deletion was performed successfully</param>
        /// <param name="ACompletionMessage">if specified, is the deletion completion message</param>
        private void PostDeleteManual(ARecurringJournalRow ARowToDelete,
                                      bool AAllowDeletion,
                                      bool ADeletionPerformed,
                                      string ACompletionMessage)
        {
            /*Code to execute after the delete has occurred*/

            TFrmRecurringGLBatch FMyForm = (TFrmRecurringGLBatch)this.ParentForm;

            try
            {
                if (ADeletionPerformed)
                {
                    UpdateChangeableStatus();

                    if (!pnlDetails.Enabled)
                    {
                        ClearControls();
                    }

                    //Always update LastTransactionNumber first before updating totals
                    GLRoutines.UpdateRecurringBatchLastJournal(ref FMainDS, ref FBatchRow);
                    GLRoutines.UpdateRecurringBatchTotals(ref FMainDS, ref FBatchRow);
                    UpdateHeaderTotals(FBatchRow);

                    FMyForm.SaveChangesManual();

                    MessageBox.Show(ACompletionMessage,
                                    Catalog.GetString("Deletion Successful"),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                else if (!AAllowDeletion && (ACompletionMessage.Length > 0))
                {
                    //message to user
                    MessageBox.Show(ACompletionMessage,
                                    "Deletion not allowed",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else if (!ADeletionPerformed && (ACompletionMessage.Length > 0))
                {
                    //message to user
                    MessageBox.Show(ACompletionMessage,
                                    "Deletion failed",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            finally
            {
                FMyForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.NONE;
            }

            //Enable Transaction tab accordingly
            ((TFrmRecurringGLBatch)ParentForm).EnableTransactions((grdDetails.Rows.Count > 1));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Code to be run after the deletion process
        /// </summary>
        /// <param name="ARowToDelete">the row that was/was to be deleted</param>
        /// <param name="AAllowDeletion">whether or not the user was permitted to delete</param>
        /// <param name="ADeletionPerformed">whether or not the deletion was performed successfully</param>
        /// <param name="ACompletionMessage">if specified, is the deletion completion message</param>
        private void PostDeleteManual(ARecurringBatchRow ARowToDelete,
                                      bool AAllowDeletion,
                                      bool ADeletionPerformed,
                                      string ACompletionMessage)
        {
            /*Code to execute after the delete has occurred*/
            TFrmRecurringGLBatch FMyForm = (TFrmRecurringGLBatch)this.ParentForm;

            try
            {
                if (ADeletionPerformed && (ACompletionMessage.Length > 0))
                {
                    UpdateChangeableStatus();

                    if (!pnlDetails.Enabled)         //set by FocusedRowChanged if grdDetails.Rows.Count < 2
                    {
                        ClearControls();
                    }

                    FMyForm.SaveChangesManual();

                    //message to user
                    MessageBox.Show(ACompletionMessage,
                                    "Deletion Successful",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }

                ((TFrmRecurringGLBatch)ParentForm).EnableJournals((grdDetails.Rows.Count > 1));
                SetInitialFocus();
            }
            finally
            {
                FMyForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.NONE;
            }
        }
        /// <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);
        }
Exemplo n.º 4
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(ARecurringBatchRow ARowToDelete, ref string ACompletionMessage)
        {
            bool DeletionSuccessful = false;

            ACompletionMessage = string.Empty;

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

            //Notify of deletion process
            TFrmRecurringGLBatch MainForm = (TFrmRecurringGLBatch)this.ParentForm;

            int  CurrentBatchNumber = ARowToDelete.BatchNumber;
            bool CurrentBatchJournalsLoadedAndCurrent     = false;
            bool CurrentBatchTransactionsLoadedAndCurrent = false;

            //Backup the Dataset for reversion purposes
            GLBatchTDS BackupMainDS = null;

            //Reject any changes which may fail validation
            ARowToDelete.RejectChanges();
            ShowDetails(ARowToDelete);

            try
            {
                this.Cursor = Cursors.WaitCursor;
                MainForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.DELETING;

                //Backup the changes to allow rollback
                BackupMainDS = (GLBatchTDS)FMainDS.GetChangesTyped(false);

                //Don't run an inactive fields check on this batch
                MainForm.GetBatchControl().UpdateRecurringBatchDictionary(CurrentBatchNumber);

                //Check if current batch journals and transactions are loaded and being viewed in their tab
                CurrentBatchJournalsLoadedAndCurrent     = (MainForm.GetJournalsControl().FBatchNumber == CurrentBatchNumber);
                CurrentBatchTransactionsLoadedAndCurrent = (MainForm.GetTransactionsControl().FBatchNumber == CurrentBatchNumber);

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

                if (!MainForm.SaveChangesManual(MainForm.FCurrentGLBatchAction, !CurrentBatchJournalsLoadedAndCurrent,
                                                !CurrentBatchTransactionsLoadedAndCurrent))
                {
                    MainForm.GetBatchControl().UpdateRecurringBatchDictionary();

                    string msg = String.Format(Catalog.GetString("Recurring Batch {0} has not been deleted."),
                                               CurrentBatchNumber);

                    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
                PrepareBatchDataForDeleting(CurrentBatchNumber, true);

                //Clear the journal and trans tabs if current batch data is displayed there
                if (CurrentBatchJournalsLoadedAndCurrent)
                {
                    //Clear any transactions currently being edited in the Transaction Tab
                    MainForm.GetJournalsControl().ClearCurrentSelection(CurrentBatchNumber);
                }

                if (CurrentBatchTransactionsLoadedAndCurrent)
                {
                    //Clear any transactions currently being edited in the Transaction Tab
                    MainForm.GetTransactionsControl().ClearCurrentSelection(CurrentBatchNumber);
                }

                //Delete transactions
                MainForm.GetTransactionsControl().DeleteRecurringTransactionData(CurrentBatchNumber);
                //Delete Journals
                MainForm.GetJournalsControl().DeleteRecurringJournalData(CurrentBatchNumber);

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

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

                DeletionSuccessful = true;
            }
            catch (Exception ex)
            {
                MainForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.NONE;

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

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

            UpdateRecordNumberDisplay();

            return(DeletionSuccessful);
        }
Exemplo n.º 5
0
        private void SubmitBatch(System.Object sender, EventArgs e)
        {
            if ((GetSelectedRowIndex() < 0) || (FPreviouslySelectedDetailRow == null))
            {
                MessageBox.Show(Catalog.GetString("Please select a Recurring Batch before submitting!"));
                return;
            }

            TFrmRecurringGLBatch       MainForm   = (TFrmRecurringGLBatch)ParentForm;
            TFrmStatusDialog           dlgStatus  = new TFrmStatusDialog(FPetraUtilsObject.GetForm());
            TFrmRecurringGLBatchSubmit SubmitForm = null;

            bool LoadDialogVisible = false;

            try
            {
                Cursor = Cursors.WaitCursor;
                MainForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.SUBMITTING;

                dlgStatus.Show();
                LoadDialogVisible       = true;
                dlgStatus.Heading       = String.Format(Catalog.GetString("Recurring GL Batch {0}"), FSelectedBatchNumber);
                dlgStatus.CurrentStatus = Catalog.GetString("Loading journals and transactions ready for submitting...");

                if (!LoadAllBatchData())
                {
                    Cursor = Cursors.Default;
                    MessageBox.Show(Catalog.GetString("The Recurring GL Batch is empty!"),
                                    Catalog.GetString("Submit GL Batch"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Stop);

                    dlgStatus.Close();
                    LoadDialogVisible = false;
                    return;
                }

                dlgStatus.Close();
                LoadDialogVisible = false;

                //Make sure that all control data is in dataset
                MainForm.GetLatestControlData();

                //Save and check for inactive values
                if (FPetraUtilsObject.HasChanges)
                {
                    //Keep this conditional check separate from the one above so that it only gets called
                    // when necessary and doesn't result in the executon of the same method
                    if (!MainForm.SaveChangesManual(MainForm.FCurrentGLBatchAction))
                    {
                        return;
                    }
                }
                else
                {
                    //This has to be called here because if there are no changes then the DataSavingValidating
                    // method which calls the method below, will not run.
                    if (!MainForm.GetTransactionsControl().AllowInactiveFieldValues(FLedgerNumber,
                                                                                    FSelectedBatchNumber, MainForm.FCurrentGLBatchAction))
                    {
                        return;
                    }
                }

                if ((FPreviouslySelectedDetailRow.BatchControlTotal != 0) &&
                    (FPreviouslySelectedDetailRow.BatchDebitTotal != FPreviouslySelectedDetailRow.BatchControlTotal))
                {
                    MessageBox.Show(String.Format(Catalog.GetString(
                                                      "The recurring gl batch total ({0}) for batch {1} does not equal the hash total ({2})."),
                                                  FPreviouslySelectedDetailRow.BatchDebitTotal,
                                                  FPreviouslySelectedDetailRow.BatchNumber,
                                                  FPreviouslySelectedDetailRow.BatchControlTotal));

                    txtDetailBatchControlTotal.Focus();
                    txtDetailBatchControlTotal.SelectAll();
                    return;
                }

                SubmitForm = new TFrmRecurringGLBatchSubmit(FPetraUtilsObject.GetForm());

                ParentForm.ShowInTaskbar = false;

                GLBatchTDS submitRecurringDS = (GLBatchTDS)FMainDS.Clone();
                int        currentBatch      = FPreviouslySelectedDetailRow.BatchNumber;

                submitRecurringDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringBatchAndRelatedTables(FLedgerNumber, FSelectedBatchNumber));

                SubmitForm.SubmitMainDS = submitRecurringDS;
                SubmitForm.ShowDialog();
            }
            catch (Exception ex)
            {
                TLogging.LogException(ex, Utilities.GetMethodSignature());
                throw;
            }
            finally
            {
                if (LoadDialogVisible)
                {
                    dlgStatus.Close();
                    LoadDialogVisible = false;
                }

                if (SubmitForm != null)
                {
                    SubmitForm.Dispose();
                    ParentForm.ShowInTaskbar = true;
                }

                MainForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.NONE;
                Cursor = Cursors.Default;
            }

            if (FPetraUtilsObject.HasChanges)
            {
                // save first, then submit
                if (!((TFrmRecurringGLBatch)ParentForm).SaveChanges())
                {
                    // saving failed, therefore do not try to post
                    MessageBox.Show(Catalog.GetString(
                                        "The recurring batch was not submitted due to problems during saving; ") + Environment.NewLine +
                                    Catalog.GetString("Please fix the batch first and then submit it."),
                                    Catalog.GetString("Submit Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }