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; } } }