private void ValidateDataDetailsManual(ARecurringJournalRow ARow)
        {
            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            TSharedFinanceValidation_GL.ValidateRecurringGLJournalManual(this, ARow, ref VerificationResultCollection,
                                                                         FValidationControlsDict);

            //TODO: remove this once database definition is set for Batch Description to be NOT NULL
            // Description is mandatory then make sure it is set
            if (txtDetailJournalDescription.Text.Length == 0)
            {
                DataColumn          ValidationColumn;
                TVerificationResult VerificationResult = null;
                object ValidationContext;

                ValidationColumn  = ARow.Table.Columns[ARecurringJournalTable.ColumnJournalDescriptionId];
                ValidationContext = String.Format("Recurring Batch no.: {0}, Journal no.: {1}",
                                                  ARow.BatchNumber,
                                                  ARow.JournalNumber);

                VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.JournalDescription,
                                                                        "Description of " + ValidationContext,
                                                                        this, ValidationColumn, null);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn, true);
            }
        }
        private void ValidateDataDetailsManual(ABatchRow ARow)
        {
            if ((ARow == null) || (ARow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED))
            {
                return;
            }

            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            ParseHashTotal(ARow);

            TSharedFinanceValidation_GL.ValidateGLBatchManual(this, ARow, ref VerificationResultCollection,
                                                              FValidationControlsDict, FStartDateCurrentPeriod, FEndDateLastForwardingPeriod);

            //TODO: remove this once database definition is set for Batch Description to be NOT NULL
            // Description is mandatory then make sure it is set
            if (txtDetailBatchDescription.Text.Length == 0)
            {
                DataColumn          ValidationColumn;
                TVerificationResult VerificationResult = null;
                object ValidationContext;

                ValidationColumn  = ARow.Table.Columns[ABatchTable.ColumnBatchDescriptionId];
                ValidationContext = String.Format("Batch number {0}",
                                                  ARow.BatchNumber);

                VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.BatchDescription,
                                                                        "Description of " + ValidationContext,
                                                                        this, ValidationColumn, null);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn, true);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Additional manual validation for Form Design Setup
        /// </summary>
        /// <param name="AContext">Context that describes what I'm validating.</param>
        /// <param name="ARow">DataRow with the the data I'm validating</param>
        /// <param name="AVerificationResultCollection">Will be filled with TVerificationResult items if data validation errors occur.</param>
        /// <param name="AValidationControlsDict">A <see cref="TValidationControlsDict" /> containing the Controls that
        /// display data that is about to be validated.</param>
        public static void ValidateFormDesignManual(object AContext, PFormRow ARow,
                                                    ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict)
        {
            // Don't validate deleted DataRows
            if (ARow.RowState == DataRowState.Deleted)
            {
                return;
            }

            TValidationControlsData ValidationControlsData;
            TVerificationResult     VerificationResult;

            //  FormTypeCode must not be blank
            DataColumn ValidationColumn = ARow.Table.Columns[PFormTable.ColumnFormTypeCodeId];

            if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData))
            {
                VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.FormTypeCode, ValidationControlsData.ValidationControlLabel,
                                                                        AContext, ValidationColumn, ValidationControlsData.ValidationControl);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
            }

            // MinimumAmount must be zero or positive
            ValidationColumn = ARow.Table.Columns[PFormTable.ColumnMinimumAmountId];

            if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData))
            {
                VerificationResult = TNumericalChecks.IsPositiveOrZeroDecimal(ARow.MinimumAmount, ValidationControlsData.ValidationControlLabel,
                                                                              AContext, ValidationColumn, ValidationControlsData.ValidationControl);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
            }

            //  Description must not be blank
            ValidationColumn = ARow.Table.Columns[PFormTable.ColumnFormDescriptionId];

            if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData))
            {
                VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.FormDescription, ValidationControlsData.ValidationControlLabel,
                                                                        AContext, ValidationColumn, ValidationControlsData.ValidationControl);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
            }

            // Formality level must be between 1 and 6
            ValidationColumn = ARow.Table.Columns[PFormTable.ColumnFormalityLevelId];

            if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData))
            {
                VerificationResult = TNumericalChecks.IsInRange(ARow.FormalityLevel, 1, 6, ValidationControlsData.ValidationControlLabel,
                                                                AContext, ValidationColumn, ValidationControlsData.ValidationControl);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
            }
        }
Esempio n. 4
0
        private void ValidateDataDetailsManual(ARecurringGiftBatchRow ARow)
        {
            if (ARow == null)
            {
                return;
            }

            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            //Hash total special case in view of the textbox handling
            ParseHashTotal(ARow);

            TSharedFinanceValidation_Gift.ValidateRecurringGiftBatchManual(this, ARow, ref VerificationResultCollection,
                                                                           FValidationControlsDict);

            //TODO: remove this once database definition is set for Batch Description to be NOT NULL
            // Description is mandatory then make sure it is set
            if (txtDetailBatchDescription.Text.Length == 0)
            {
                DataColumn          ValidationColumn;
                TVerificationResult VerificationResult = null;
                object ValidationContext;

                ValidationColumn  = ARow.Table.Columns[ARecurringGiftBatchTable.ColumnBatchDescriptionId];
                ValidationContext = String.Format("Recurring Batch number {0}",
                                                  ARow.BatchNumber);

                VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.BatchDescription,
                                                                        "Description of " + ValidationContext,
                                                                        this, ValidationColumn, null);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn, true);
            }
        }
        private void ValidateDataDetailsManual(GLBatchTDSATransactionRow ARow)
        {
            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            TSharedFinanceValidation_GL.ValidateAllocationJournalDialog(this, ARow, rbtAmountOption.Checked, txtTotalAmount.NumberValueDecimal,
                                                                        ref VerificationResultCollection, FPetraUtilsObject.ValidationControlsDict);

            if (!FAnalysisAttributesLogic.AccountAnalysisAttributeCountIsCorrect(ARow.TransactionNumber, ARow.AccountCode, FMainDS))
            {
                DataColumn          ValidationColumn;
                TVerificationResult VerificationResult = null;
                object ValidationContext;

                ValidationColumn  = ARow.Table.Columns[ATransactionTable.ColumnAccountCodeId];
                ValidationContext = "unused because of OverrideResultText";

                // This code is only running because of failure, so cause an error to occur.
                VerificationResult = TStringChecks.StringMustNotBeEmpty("",
                                                                        ValidationContext.ToString(),
                                                                        this, ValidationColumn, null);
                VerificationResult.OverrideResultText(String.Format(Catalog.GetString(
                                                                        "A value must be entered for the 'Analysis Attribute' for the 'From Allocation's' Account Code {0}."),
                                                                    ARow.AccountCode));

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(grdToAnalAttributes, VerificationResult, ValidationColumn, true);
            }

            String ValueRequiredForType;

            if (!FAnalysisAttributesLogic.AccountAnalysisAttributesValuesExist(ARow.TransactionNumber, ARow.AccountCode, FMainDS,
                                                                               out ValueRequiredForType))
            {
                DataColumn          ValidationColumn;
                TVerificationResult VerificationResult = null;
                object ValidationContext;

                ValidationColumn  = ARow.Table.Columns[ATransactionTable.ColumnAccountCodeId];
                ValidationContext = String.Format("Analysis code {0} for Account Code {1}",
                                                  ValueRequiredForType,
                                                  ARow.AccountCode);

                // This code is only running because of failure, so cause an error to occur.
                VerificationResult = TStringChecks.StringMustNotBeEmpty("",
                                                                        ValidationContext.ToString(),
                                                                        this, ValidationColumn, null);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn, true);
            }

            if ((VerificationResultCollection.Count == 0) && FValidateEverything)
            {
                ValidateEverything();
            }
        }
Esempio n. 6
0
        private void ValidateDataDetailsManual(AGiftBatchRow ARow)
        {
            if ((ARow == null) || (ARow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED))
            {
                return;
            }

            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            //Hash total special case in view of the textbox handling
            ParseHashTotal(ARow);

            //Check if the user has made a Bank Cost Centre or Account Code inactive
            //this was removed because of speed issues!
            //TODO: Revisit this
            //RefreshBankCostCentreAndAccountCodes();

            TSharedFinanceValidation_Gift.ValidateGiftBatchManual(this, ARow, ref VerificationResultCollection,
                                                                  FValidationControlsDict, FAccountTable, FCostCentreTable);

            //TODO: remove this once database definition is set for Batch Description to be NOT NULL
            // Description is mandatory then make sure it is set
            if (txtDetailBatchDescription.Text.Length == 0)
            {
                DataColumn          ValidationColumn;
                TVerificationResult VerificationResult = null;
                object ValidationContext;

                ValidationColumn  = ARow.Table.Columns[AGiftBatchTable.ColumnBatchDescriptionId];
                ValidationContext = String.Format("Batch number {0}",
                                                  ARow.BatchNumber);

                VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.BatchDescription,
                                                                        "Description of " + ValidationContext,
                                                                        this, ValidationColumn, null);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn, true);
            }
        }
        private void ValidateDataDetailsManual(PDataLabelRow ARow)
        {
            // For this validation we have to validate the UsedBy data here in the manual code.
            // This is because it is not backed directly by a row in a data table.
            // Nor is the control associated with a column in any data table
            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;
            DataColumn          ValidationColumn;
            TVerificationResult VerificationResult = null;

            // Personnel context is bound to be valid because it has no UsedBy UI
            if ((CurrentContext == Context.Partner) || (CurrentContext == Context.Application))
            {
                // The added column at the end of the table, which is a concatenated string of checkedListBox entries, must not be empty
                ValidationColumn   = ARow.Table.Columns[UsedByColumnOrdinal];
                VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow[UsedByColumnOrdinal].ToString(),
                                                                        GUIUsedBy,
                                                                        this, ValidationColumn, clbUsedBy);

                if (VerificationResult != null)
                {
                    if (CurrentContext == Context.Partner)
                    {
                        VerificationResult.OverrideResultText(Catalog.GetString("You must check at least one box in the list of Partner classes."));
                    }
                    else if (CurrentContext == Context.Application)
                    {
                        VerificationResult.OverrideResultText(Catalog.GetString("You must check at least one box in the list of Application types."));
                    }
                }

                // Handle addition to/removal from TVerificationResultCollection.
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn, false);
            }

            // Now call the central validation routine for the other verification tasks
            TSharedValidation_CacheableDataTables.ValidateLocalDataFieldSetup(this, ARow, ref VerificationResultCollection,
                                                                              FPetraUtilsObject.ValidationControlsDict);
        }
Esempio n. 8
0
        private void ValidateDataDetailsManual(SSystemDefaultsRow ARow)
        {
            if (FShowingSysAdminCodes)
            {
                return;
            }

            TVerificationResultCollection verificationResults = FPetraUtilsObject.VerificationResultCollection;
            DataColumn          validationColumn   = ARow.Table.Columns[SSystemDefaultsTable.ColumnDefaultValueId];
            TVerificationResult verificationResult = null;

            // First we need to validate that there were no errors setting up the controls for this row
            if (!FControlsDataTable.Validate(ARow.DefaultValue, validationColumn, this, verificationResults))
            {
                // No point in carrying on with other validations because the controls are all messed up
                return;
            }

            // Individual rows can be validated to check that settings code values are ok.
            if (string.Compare(ARow.DefaultCode, SharedConstants.SYSDEFAULT_LOCALISEDCOUNTYLABEL, true) == 0)
            {
                Control[] validationControl = pnlValues.Controls.Find("cValue_0", true);

                if (validationControl.Length > 0)
                {
                    verificationResult = TStringChecks.StringMustNotBeEmpty(ARow.DefaultValue, "",
                                                                            this, validationColumn, validationControl[0]);

                    if (verificationResult != null)
                    {
                        verificationResult.OverrideResultText(CommonResourcestrings.StrSettingCannotBeEmpty);
                    }
                }

                verificationResults.Auto_Add_Or_AddOrRemove(this, verificationResult, validationColumn);
            }
        }
        /// <summary>
        /// save the changes
        /// </summary>
        /// <returns></returns>
        public bool SaveChanges()
        {
            Boolean Result            = false;
            String  CheckedStringList = clbSites.GetCheckedStringList();

            String[]     SiteKeyArray       = CheckedStringList.Split(',');
            Int32        Counter            = 0;
            List <Int64> AddedSiteKeyList   = new List <Int64>();
            List <Int64> RemovedSiteKeyList = new List <Int64>();
            Int64        RemovedSiteKey;
            String       RemovedSiteName;
            Boolean      AnySiteRemoved = false;
            String       UserMessage    = Catalog.GetString(
                "Are you sure you want to remove access to following sites? You will not be able to create Partner Keys for them any longer! \r\n");

            TVerificationResultCollection VerificationResultCollection = new TVerificationResultCollection();
            TVerificationResult           VerificationResult           = TStringChecks.StringMustNotBeEmpty(cmbDefaultSite.Text,
                                                                                                            lblDefaultSite.Text);

            // Handle addition/removal to/from TVerificationResultCollection
            VerificationResultCollection.Auto_Add_Or_AddOrRemove(null, VerificationResult, null);

            if (!TDataValidation.ProcessAnyDataValidationErrors(false, VerificationResultCollection, this.GetType()))
            {
                return(false);
            }

            // save site keys selected for possible use
            for (Counter = 0; Counter < SiteKeyArray.Length; Counter++)
            {
                AddedSiteKeyList.Add(Convert.ToInt64(SiteKeyArray[Counter]));
            }

            // create list of site keys that have been removed and double check with user
            foreach (DataRow SiteRow in AvailableSitesTable.Rows)
            {
                if (!Convert.ToBoolean(SiteRow[SharedConstants.SYSMAN_AVAILABLE_SITES_COLUMN_IS_PARTNER_LEDGER]))
                {
                    // check if previously checked site is now no longer checked
                    RemovedSiteKey = Convert.ToInt64(SiteRow[PUnitTable.GetPartnerKeyDBName()]);

                    if (OriginallyCheckedSites.Contains(RemovedSiteKey))
                    {
                        AnySiteRemoved = true;
                        RemovedSiteKeyList.Add(RemovedSiteKey);
                        RemovedSiteName = SiteRow[PUnitTable.GetUnitNameDBName()].ToString();
                        UserMessage    += "\r\n" + String.Format("{0:0000000000}", RemovedSiteKey) + " - " + RemovedSiteName;
                    }
                }
            }

            if (AnySiteRemoved)
            {
                if (MessageBox.Show(UserMessage, Catalog.GetString("Remove access to Sites"), MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return(false);
                }
            }

            // save default site key
            if (cmbDefaultSite.SelectedValue != null)
            {
                TSystemDefaults.SetSystemDefault(SharedConstants.SYSDEFAULT_SITEKEY, cmbDefaultSite.SelectedValue.ToString());
            }

            Result = TRemote.MSysMan.WebConnectors.SaveSiteKeys(AddedSiteKeyList, RemovedSiteKeyList);

            if (Result)
            {
                // reload data from server here so the list is sorted by check box value first and then site name (consider doing this
                // on client in the future if performance issues)
                LoadSitesData();

                FPetraUtilsObject.DisableSaveButton();

                // We don't have unsaved changes anymore
                FPetraUtilsObject.HasChanges = false;
            }

            return(Result);
        }
        /// validate all data not in a DataRow
        private void ValidateEverything()
        {
            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;
            TScreenVerificationResult     VerificationResult;

            // Validate Reference
            if (!string.IsNullOrEmpty(txtFromReference.Text) && (txtFromReference.Text.Length > 100))
            {
                // 'Reference' must not contain more than 100 characters
                VerificationResult = new TScreenVerificationResult(TStringChecks.StringLengthLesserOrEqual(txtFromReference.Text, 100,
                                                                                                           "Reference", txtFromReference), null, txtFromReference);

                // Handle addition to/removal from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(txtFromReference, VerificationResult, null);
            }
            else if (string.IsNullOrEmpty(txtFromReference.Text))
            {
                // 'Reference' must not be empty
                VerificationResult = new TScreenVerificationResult(TStringChecks.StringMustNotBeEmpty(txtFromReference.Text,
                                                                                                      "Reference", txtFromReference), null, txtFromReference);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(txtFromReference, VerificationResult, null);
            }

            // Validate Narrative
            if (!string.IsNullOrEmpty(txtFromNarrative.Text) && (txtFromNarrative.Text.Length > 500))
            {
                // 'Narrative' must not contain more than 100 characters
                VerificationResult = new TScreenVerificationResult(TStringChecks.StringLengthLesserOrEqual(txtFromNarrative.Text, 500,
                                                                                                           "Narrative", txtFromNarrative), null, txtFromNarrative);

                // Handle addition to/removal from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(txtFromNarrative, VerificationResult, null);
            }

            // Validate FromCostCentreCode
            if (string.IsNullOrEmpty(cmbFromCostCentreCode.GetSelectedString()))
            {
                // 'Cost Centre Code' must not be empty
                VerificationResult = new TScreenVerificationResult(TStringChecks.StringMustNotBeEmpty(cmbFromCostCentreCode.Text,
                                                                                                      "Cost Centre Code", cmbFromCostCentreCode), null, cmbFromCostCentreCode);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(cmbFromCostCentreCode, VerificationResult, null);
            }

            // Validate FromAccountCode
            if (string.IsNullOrEmpty(cmbFromAccountCode.GetSelectedString()))
            {
                // 'Account Code' must not be empty
                VerificationResult = new TScreenVerificationResult(TStringChecks.StringMustNotBeEmpty(cmbFromAccountCode.Text,
                                                                                                      "Account Code", cmbFromAccountCode), null, cmbFromAccountCode);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(cmbFromAccountCode, VerificationResult, null);
            }

            // Validate TotalAmount
            if (string.IsNullOrEmpty(txtTotalAmount.Text) || (Convert.ToDecimal(txtTotalAmount.Text) <= 0))
            {
                if (string.IsNullOrEmpty(txtTotalAmount.Text))
                {
                    txtTotalAmount.NumberValueDecimal = 0;
                }

                // From Amount must not = 0
                VerificationResult = new TScreenVerificationResult(TNumericalChecks.IsPositiveDecimal(Convert.ToDecimal(txtTotalAmount.Text),
                                                                                                      "Amount", txtTotalAmount), null, txtTotalAmount);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(txtTotalAmount, VerificationResult, null);
            }
            else
            {
                // Validate Allocations' amounts
                if (rbtAmountOption.Checked)
                {
                    if (GetAmountTotal() != Convert.ToDecimal(txtTotalAmount.Text))
                    {
                        VerificationResult = new TScreenVerificationResult(this, null,
                                                                           Catalog.GetString(
                                                                               "The amounts entered do not match the total amount of the Allocation. Please check the amounts entered."),
                                                                           txtTotalAmount, TResultSeverity.Resv_Critical);

                        // Handle addition/removal to/from TVerificationResultCollection
                        VerificationResultCollection.Auto_Add_Or_AddOrRemove(txtTotalAmount, VerificationResult, null);
                    }
                }
                // Validate Allocations' percentages
                else
                {
                    if (GetPercentageTotal() != 100)
                    {
                        VerificationResult = new TScreenVerificationResult(this, null,
                                                                           Catalog.GetString("The percentages entered must add up to 100%."),
                                                                           txtDetailPercentage, TResultSeverity.Resv_Critical);

                        // Handle addition/removal to/from TVerificationResultCollection
                        VerificationResultCollection.Auto_Add_Or_AddOrRemove(txtDetailPercentage, VerificationResult, null);
                    }
                }
            }

            if (grdDetails.Rows.Count <= 2)
            {
                VerificationResult = new TScreenVerificationResult(this, null,
                                                                   Catalog.GetString("You must include at least 2 destination allocations."),
                                                                   btnNew, TResultSeverity.Resv_Critical);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(btnNew, VerificationResult, null);
            }
            else if (grdDetails.Rows.Count > 11)
            {
                VerificationResult = new TScreenVerificationResult(this, null,
                                                                   Catalog.GetString("You must include no more than 10 destination allocations."),
                                                                   btnDeleteAllocation, TResultSeverity.Resv_Critical);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(btnDeleteAllocation, VerificationResult, null);
            }

            if (!FAnalysisAttributesLogic.AccountAnalysisAttributeCountIsCorrect(FJournal.LastTransactionNumber + 1,
                                                                                 cmbFromAccountCode.GetSelectedString(), FTempFromDS))
            {
                VerificationResult = new TScreenVerificationResult(this, null,
                                                                   String.Format(Catalog.GetString(
                                                                                     "A value must be entered for the 'Analysis Attribute' for the 'From Allocation's' Account Code {0}."),
                                                                                 cmbFromAccountCode.GetSelectedString()),
                                                                   grdFromAnalAttributes, TResultSeverity.Resv_Critical);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(grdFromAnalAttributes, VerificationResult, null);
            }

            String ValueRequiredForType;

            if (!FAnalysisAttributesLogic.AccountAnalysisAttributesValuesExist(
                    FJournal.LastTransactionNumber + 1, cmbFromAccountCode.GetSelectedString(), FTempFromDS, out ValueRequiredForType))
            {
                VerificationResult = new TScreenVerificationResult(this, null,
                                                                   String.Format(Catalog.GetString(
                                                                                     "A value must be entered for the 'Analysis code {0} for Account Code {1}."),
                                                                                 ValueRequiredForType, cmbFromAccountCode.GetSelectedString()),
                                                                   grdFromAnalAttributes, TResultSeverity.Resv_Critical);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(grdFromAnalAttributes, VerificationResult, null);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Validates the recurring GL Detail data.
        /// </summary>
        /// <param name="AContext">Context that describes where the data validation failed.</param>
        /// <param name="ABatchRow">Manually added to bring over some GL Batch fields</param>
        /// <param name="ARow">The <see cref="DataRow" /> which holds the the data against which the validation is run.</param>
        /// <param name="AVerificationResultCollection">Will be filled with any <see cref="TVerificationResult" /> items if
        /// data validation errors occur.</param>
        /// <returns>True if the validation found no data validation errors, otherwise false.</returns>
        public static bool ValidateRecurringGLDetailManual(object AContext,
                                                           ARecurringBatchRow ABatchRow,
                                                           ARecurringTransactionRow ARow,
                                                           ref TVerificationResultCollection AVerificationResultCollection)
        {
            DataColumn          ValidationColumn;
            TVerificationResult VerificationResult = null;
            object ValidationContext;
            int    VerifResultCollAddedCount = 0;

            // Don't validate deleted DataRows
            if (ARow.RowState == DataRowState.Deleted)
            {
                return(true);
            }

            //TransactionAmount is not in the dictionary so had to pass the control directly
            //  also needed to handle reference
            if (true)
            {
                // 'GL amount must be non-zero
                ValidationColumn  = ARow.Table.Columns[ARecurringTransactionTable.ColumnTransactionAmountId];
                ValidationContext = String.Format("Transaction number {0} (batch:{1} journal:{2})",
                                                  ARow.TransactionNumber,
                                                  ARow.BatchNumber,
                                                  ARow.JournalNumber);

                VerificationResult = TNumericalChecks.IsPositiveDecimal(ARow.TransactionAmount,
                                                                        "Amount of " + ValidationContext,
                                                                        AContext, ValidationColumn);

                if (VerificationResult != null)
                {
                    VerificationResult.SuppressValidationToolTip = true;
                }

                // Handle addition/removal to/from TVerificationResultCollection
                if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult))
                {
                    VerifResultCollAddedCount++;
                }

                return(VerifResultCollAddedCount == 0);
            }

            // Narrative must not be empty
            ValidationColumn  = ARow.Table.Columns[ARecurringTransactionTable.ColumnNarrativeId];
            ValidationContext = String.Format("Transaction number {0} (batch:{1} journal:{2})",
                                              ARow.TransactionNumber,
                                              ARow.BatchNumber,
                                              ARow.JournalNumber);

            if (true)
            {
                VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.Narrative,
                                                                        "Narrative of " + ValidationContext,
                                                                        AContext, ValidationColumn);

                // Handle addition/removal to/from TVerificationResultCollection
                if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult))
                {
                    VerifResultCollAddedCount++;
                }
            }

            if (true)
            {
                ValidationColumn  = ARow.Table.Columns[ARecurringTransactionTable.ColumnReferenceId];
                ValidationContext = String.Format("Transaction number {0} (batch:{1} journal:{2})",
                                                  ARow.TransactionNumber,
                                                  ARow.BatchNumber,
                                                  ARow.JournalNumber);

                if (true)
                {
                    VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.Reference,
                                                                            "Reference of " + ValidationContext,
                                                                            AContext, ValidationColumn);

                    // Handle addition/removal to/from TVerificationResultCollection
                    if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult))
                    {
                        VerifResultCollAddedCount++;
                    }
                }
            }

            return(VerifResultCollAddedCount == 0);
        }
Esempio n. 12
0
        /// <summary>
        /// Validates the GL Detail data.
        /// </summary>
        /// <param name="AContext">Context that describes where the data validation failed.</param>
        /// <param name="ABatchRow">Manually added to bring over some GL Batch fields</param>
        /// <param name="ARow">The <see cref="DataRow" /> which holds the the data against which the validation is run.</param>
        /// <param name="AVerificationResultCollection">Will be filled with any <see cref="TVerificationResult" /> items if
        /// data validation errors occur.</param>
        /// <param name="AValidationCostCentreTable">REQUIRED for importing.  A reference to a cost centre table so that inputs can be validated.</param>
        /// <param name="AvalidationAccountTable">REQUIRED for importing.  A reference to an account table so that inputs can be validated.</param>
        /// <returns>True if the validation found no data validation errors, otherwise false.</returns>
        public static bool ValidateGLDetailManual(object AContext, ABatchRow ABatchRow, ATransactionRow ARow,
                                                  ref TVerificationResultCollection AVerificationResultCollection,
                                                  ACostCentreTable AValidationCostCentreTable = null, AAccountTable AvalidationAccountTable = null)
        {
            DataColumn          ValidationColumn;
            TVerificationResult VerificationResult = null;
            object ValidationContext;
            int    VerifResultCollAddedCount = 0;

            // Don't validate deleted DataRows or non-unposted batches
            if ((ABatchRow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED) || (ARow.RowState == DataRowState.Deleted))
            {
                return(true);
            }

            bool isImporting = AContext.ToString().Contains("Importing");

            // When used by the GUI TransactionAmount is not in the dictionary so had to pass the control directly
            // But when importing we do have a dictionary entry
            if (isImporting)
            {
                // 'GL amount must be non-zero and positive
                ValidationColumn = ARow.Table.Columns[ATransactionTable.ColumnTransactionAmountId];

                if (true)
                {
                    VerificationResult = TNumericalChecks.IsPositiveDecimal(ARow.TransactionAmount,
                                                                            String.Empty,
                                                                            AContext, ValidationColumn);

                    // Handle addition/removal to/from TVerificationResultCollection
                    if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult))
                    {
                        VerifResultCollAddedCount++;
                    }
                }
            }
            else
            {
                if (true)
                {
                    // 'GL amount must be non-zero and positive
                    ValidationColumn  = ARow.Table.Columns[ATransactionTable.ColumnTransactionAmountId];
                    ValidationContext = String.Format("Transaction number {0} (batch:{1} journal:{2})",
                                                      ARow.TransactionNumber,
                                                      ARow.BatchNumber,
                                                      ARow.JournalNumber);

                    VerificationResult = TNumericalChecks.IsPositiveOrZeroDecimal(ARow.TransactionAmount,
                                                                                  "Amount of " + ValidationContext,
                                                                                  AContext, ValidationColumn);

                    if (VerificationResult != null)
                    {
                        VerificationResult.SuppressValidationToolTip = true;
                    }

                    // Handle addition/removal to/from TVerificationResultCollection
                    if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult))
                    {
                        VerifResultCollAddedCount++;
                    }

                    return(VerifResultCollAddedCount == 0);
                }
            }

            // 'Narrative must not be empty
            ValidationColumn  = ARow.Table.Columns[ATransactionTable.ColumnNarrativeId];
            ValidationContext = String.Format("Transaction number {0} (batch:{1} journal:{2})",
                                              ARow.TransactionNumber,
                                              ARow.BatchNumber,
                                              ARow.JournalNumber);

            if (true)
            {
                VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.Narrative,
                                                                        (isImporting) ? String.Empty : "Narrative of " + ValidationContext,
                                                                        AContext, ValidationColumn);

                // Handle addition/removal to/from TVerificationResultCollection
                if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult))
                {
                    VerifResultCollAddedCount++;
                }
            }

            // 'Entered From Date' must be valid
            ValidationColumn  = ARow.Table.Columns[ATransactionTable.ColumnTransactionDateId];
            ValidationContext = String.Format("Transaction number {0} (batch:{1} journal:{2})",
                                              ARow.TransactionNumber,
                                              ARow.BatchNumber,
                                              ARow.JournalNumber);

            if (true)
            {
                DateTime StartDatePeriod;
                DateTime EndDatePeriod;
                TSharedFinanceValidationHelper.GetValidPeriodDates(ARow.LedgerNumber, ABatchRow.BatchYear, 0, ABatchRow.BatchPeriod,
                                                                   out StartDatePeriod,
                                                                   out EndDatePeriod);

                VerificationResult = (TScreenVerificationResult)TDateChecks.IsDateBetweenDates(ARow.TransactionDate,
                                                                                               StartDatePeriod,
                                                                                               EndDatePeriod,
                                                                                               (isImporting) ? String.Empty : "Transaction Date for " + ValidationContext.ToString(),
                                                                                               TDateBetweenDatesCheckType.dbdctUnspecific,
                                                                                               TDateBetweenDatesCheckType.dbdctUnspecific,
                                                                                               AContext,
                                                                                               ValidationColumn);

                // Handle addition/removal to/from TVerificationResultCollection
                if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult))
                {
                    VerifResultCollAddedCount++;
                }
            }

            if (true)
            {
                // "Reference" is mandatory
                ValidationColumn  = ARow.Table.Columns[ATransactionTable.ColumnReferenceId];
                ValidationContext = String.Format("Transaction number {0} (batch:{1} journal:{2})",
                                                  ARow.TransactionNumber,
                                                  ARow.BatchNumber,
                                                  ARow.JournalNumber);

                if (true)
                {
                    VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.Reference,
                                                                            (isImporting) ? String.Empty : "Reference of " + ValidationContext,
                                                                            AContext, ValidationColumn);

                    // Handle addition/removal to/from TVerificationResultCollection
                    if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult))
                    {
                        VerifResultCollAddedCount++;
                    }
                }
            }

            // 'CostCentre' must be valid
            ValidationColumn  = ARow.Table.Columns[ATransactionTable.ColumnCostCentreCodeId];
            ValidationContext = String.Format("Transaction number {0} (batch:{1} journal:{2})",
                                              ARow.TransactionNumber,
                                              ARow.BatchNumber,
                                              ARow.JournalNumber);

            if (true)
            {
                if ((AValidationCostCentreTable != null) && !ARow.IsCostCentreCodeNull())
                {
                    // Code must exist in the cost centre table
                    ACostCentreRow foundRow = (ACostCentreRow)AValidationCostCentreTable.Rows.Find(
                        new object[] { ARow.LedgerNumber, ARow.CostCentreCode });

                    if ((foundRow == null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove(
                            ValidationContext,
                            new TVerificationResult(ValidationContext,
                                                    String.Format(Catalog.GetString("Cost centre code '{0}' does not exist."), ARow.CostCentreCode),
                                                    TResultSeverity.Resv_Critical)))
                    {
                        VerifResultCollAddedCount++;
                    }

                    // cost centre must be a posting cost centre
                    if ((foundRow != null) && !foundRow.PostingCostCentreFlag)
                    {
                        if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(ValidationContext,
                                                                                  new TVerificationResult(ValidationContext,
                                                                                                          String.Format(Catalog.GetString("Cost centre code '{0}' is not a posting cost centre."), ARow.CostCentreCode),
                                                                                                          TResultSeverity.Resv_Critical)))
                        {
                            VerifResultCollAddedCount++;
                        }
                    }

                    //TODO: Maybe add a user preference to determine what to do with inactive values on importing
                    // cost centre must not be inactive
                    //if ((foundRow != null) && !foundRow.CostCentreActiveFlag)
                    //{
                    //    if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(ValidationContext,
                    //            new TVerificationResult(ValidationContext,
                    //                String.Format(Catalog.GetString("Cost centre code '{0}' is an inactive cost centre."), ARow.CostCentreCode),
                    //                TResultSeverity.Resv_Critical),
                    //            ValidationColumn))
                    //    {
                    //        VerifResultCollAddedCount++;
                    //    }
                    //}
                }
            }

            // 'Account code' must be valid
            ValidationColumn  = ARow.Table.Columns[ATransactionTable.ColumnAccountCodeId];
            ValidationContext = String.Format("Transaction number {0} (batch:{1} journal:{2})",
                                              ARow.TransactionNumber,
                                              ARow.BatchNumber,
                                              ARow.JournalNumber);

            if (true)
            {
                if ((AvalidationAccountTable != null) && !ARow.IsAccountCodeNull())
                {
                    // Code must exist in the account table
                    AAccountRow foundRow = (AAccountRow)AvalidationAccountTable.Rows.Find(
                        new object[] { ARow.LedgerNumber, ARow.AccountCode });

                    if ((foundRow == null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove(
                            ValidationContext,
                            new TVerificationResult(ValidationContext,
                                                    String.Format(Catalog.GetString("Account code '{0}' does not exist."), ARow.AccountCode),
                                                    TResultSeverity.Resv_Critical)))
                    {
                        VerifResultCollAddedCount++;
                    }

                    // Account code must be a posting Account code
                    if ((foundRow != null) && !foundRow.PostingStatus)
                    {
                        if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(ValidationContext,
                                                                                  new TVerificationResult(ValidationContext,
                                                                                                          String.Format(Catalog.GetString("Account code '{0}' is not a posting account."), ARow.AccountCode),
                                                                                                          TResultSeverity.Resv_Critical)))
                        {
                            VerifResultCollAddedCount++;
                        }
                    }

                    //TODO: Maybe add a user preference to determine what to do with inactive values on importing
                    // Account code must not be inactive
                    //if ((foundRow != null) && !foundRow.AccountActiveFlag)
                    //{
                    //    if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(ValidationContext,
                    //            new TVerificationResult(ValidationContext,
                    //                String.Format(Catalog.GetString("Account code '{0}' is an inactive account."), ARow.AccountCode),
                    //                TResultSeverity.Resv_Critical),
                    //            ValidationColumn))
                    //    {
                    //        VerifResultCollAddedCount++;
                    //    }
                    //}
                }
            }

            return(VerifResultCollAddedCount == 0);
        }