private void SetupAnalysisAttributeGrid(TSgrdDataGridPaged AGrid, ref SourceGrid.Cells.Editors.ComboBox AGridCombo)
        {
            AGrid.DataSource = null;
            GLBatchTDS        DS           = null;
            TCmbAutoPopulated AccountCombo = null;

            SourceGrid.Cells.Editors.ComboBox ATempCombo = null;

            if (AGrid.Name == grdFromAnalAttributes.Name)
            {
                FTempFromDS  = (GLBatchTDS)FMainDS.Clone();
                DS           = FTempFromDS;
                AccountCombo = cmbFromAccountCode;
            }
            else
            {
                DS           = FMainDS;
                AccountCombo = cmbDetailAccountCode;
            }

            if (AGrid.Columns.Count == 0)
            {
                ATempCombo              = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
                ATempCombo.EnableEdit   = true;
                ATempCombo.EditableMode = EditableMode.Focus;
                AGrid.Columns.Clear();
                AGrid.AddTextColumn(Catalog.GetString("Type"), FMainDS.ATransAnalAttrib.ColumnAnalysisTypeCode, 99);
                AGrid.AddTextColumn(Catalog.GetString("Value"),
                                    DS.ATransAnalAttrib.Columns[ATransAnalAttribTable.GetAnalysisAttributeValueDBName()], 150,
                                    ATempCombo);
            }

            FAnalysisAttributesLogic.SetTransAnalAttributeDefaultView(DS);
            DS.ATransAnalAttrib.DefaultView.AllowNew = false;
            AGrid.DataSource = new DevAge.ComponentModel.BoundDataView(DS.ATransAnalAttrib.DefaultView);
            AGrid.SetHeaderTooltip(0, Catalog.GetString("Type"));
            AGrid.SetHeaderTooltip(1, Catalog.GetString("Value"));

            AGrid.Selection.SelectionChanged += AnalysisAttributesGrid_RowSelected;

            //Prepare Analysis attributes grid to highlight inactive analysis codes
            // Create a cell view for special conditions
            SourceGrid.Cells.Views.Cell strikeoutCell2 = new SourceGrid.Cells.Views.Cell();
            strikeoutCell2.Font = new System.Drawing.Font(AGrid.Font, FontStyle.Strikeout);

            // Create a condition, apply the view when true, and assign a delegate to handle it
            SourceGrid.Conditions.ConditionView conditionAnalysisCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2);
            conditionAnalysisCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2)
            {
                DataRowView row2         = (DataRowView)itemRow2;
                string      analysisCode = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString();
                return(!FAnalysisAttributesLogic.AnalysisCodeIsActive(AccountCombo.GetSelectedString(), FCacheDS.AAnalysisAttribute, analysisCode));
            };

            // Create a condition, apply the view when true, and assign a delegate to handle it
            SourceGrid.Conditions.ConditionView conditionAnalysisAttributeValueActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2);
            conditionAnalysisAttributeValueActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2)
            {
                if (itemRow2 != null)
                {
                    DataRowView row2                   = (DataRowView)itemRow2;
                    string      analysisCode           = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString();
                    string      analysisAttributeValue = row2[ATransAnalAttribTable.ColumnAnalysisAttributeValueId].ToString();
                    return(!TAnalysisAttributes.AnalysisAttributeValueIsActive(ref ATempCombo,
                                                                               FCacheDS.AFreeformAnalysis,
                                                                               analysisCode,
                                                                               analysisAttributeValue));
                }
                else
                {
                    return(false);
                }
            };

            //Add conditions to columns
            int indexOfAnalysisCodeColumn           = 0;
            int indexOfAnalysisAttributeValueColumn = 1;

            AGrid.Columns[indexOfAnalysisCodeColumn].Conditions.Add(conditionAnalysisCodeActive);
            AGrid.Columns[indexOfAnalysisAttributeValueColumn].Conditions.Add(conditionAnalysisAttributeValueActive);

            AGridCombo = ATempCombo;
        }
示例#2
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;
                }
            }
        }
示例#3
0
        private void SubmitBatch(System.Object sender, EventArgs e)
        {
            if (FPreviouslySelectedDetailRow == null)
            {
                MessageBox.Show(Catalog.GetString("Please select a Batch before submitting."));
                return;
            }

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

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

            if (!LoadAllBatchData() || !AllowInactiveFieldValues(FPreviouslySelectedDetailRow.BatchNumber))
            {
                return;
            }

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

            try
            {
                ParentForm.ShowInTaskbar = false;

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

                submitRecurringDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringBatchAndContent(FLedgerNumber, currentBatch));

                SubmitForm.SubmitMainDS = submitRecurringDS;
                SubmitForm.ShowDialog();
            }
            finally
            {
                SubmitForm.Dispose();
                ParentForm.ShowInTaskbar = true;
            }
        }