private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { if ((AReportAction == TReportActionEnum.raGenerate) && (dtpFromDate.Date > dtpToDate.Date)) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("From date is later than to date."), Catalog.GetString("Please change from date or to date."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } ACalc.AddParameter("param_currency", "Base"); ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); // Set the values for accumulating the costs to 0 ACalc.AddParameter("CostCentreCredit", 0); ACalc.AddParameter("CostCentreDebit", 0); ACalc.AddParameter("AccountCodeCredit", 0); ACalc.AddParameter("AccountCodeDebit", 0); ACalc.AddParameter("TotalCredit", 0); ACalc.AddParameter("TotalDebit", 0); int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt(); // we need to know some indices of the columns for (int Counter = 0; Counter < MaxColumns; ++Counter) { String ColumnName = "param_column_" + ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString(); ACalc.AddParameter(ColumnName, Counter); } }
/// <summary> /// todoComment /// </summary> /// <param name="e"></param> /// <param name="AMainDS"></param> /// <param name="AVerificationResult"></param> /// <returns></returns> public static Boolean VerifyUnitData(DataColumnChangeEventArgs e, PartnerEditTDS AMainDS, out TVerificationResult AVerificationResult) { Boolean ReturnValue; AVerificationResult = null; if (e.Column.ColumnName == PUnitTable.GetUnitNameDBName()) { VerifyUnitNameChange(e, AMainDS, out AVerificationResult); } // any verification errors? if (AVerificationResult == null) { ReturnValue = true; } else { ReturnValue = false; // MessageBox.Show('VerifyUnitData: There was an error!'); } return ReturnValue; }
private string EvaluateVerificationResults(TVerificationResult AExpectedResult, TVerificationResult ATestResult) { TVerificationResultCollection Tmp; if (!TVerificationHelper.AreVerificationResultsIdentical(ATestResult, AExpectedResult)) { Tmp = new TVerificationResultCollection(); if (AExpectedResult != null) { Tmp.Add(AExpectedResult); } if (ATestResult != null) { Tmp.Add(ATestResult); } return TVerificationHelper.FormatVerificationCollectionItems(Tmp); } else { return String.Empty; } }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { if ((AReportAction == TReportActionEnum.raGenerate) && (rbtPartner.Checked && (txtRecipient.Text == "0000000000"))) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("No recipient selected."), Catalog.GetString("Please select a recipient."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } if ((AReportAction == TReportActionEnum.raGenerate) && rbtExtract.Checked && (txtExtract.Text == "")) { TVerificationResult VerificationMessage = new TVerificationResult( Catalog.GetString("Enter an extract name."), Catalog.GetString("No extract name entered!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationMessage); } ACalc.AddParameter("param_recipient_key", txtRecipient.Text); ACalc.AddParameter("param_extract_name", txtExtract.Text); ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { if ((AReportAction == TReportActionEnum.raGenerate) && (dtpFromDate.Date > dtpToDate.Date)) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("From date is later than to date."), Catalog.GetString("Please change from date or to date."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); ACalc.AddParameter("TransactionCount", 0); ACalc.AddParameter("TransactionCountAccount", 0); ACalc.AddParameter("SumDebitAccount", 0); ACalc.AddParameter("SumCreditAccount", 0); int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt(); for (int Counter = 0; Counter <= MaxColumns; ++Counter) { String ColumnName = ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString(); if (ColumnName == "Debits") { ACalc.AddParameter("param_debit_column", Counter); } if (ColumnName == "Credits") { ACalc.AddParameter("param_credit_column", Counter); } } }
private void ReadControlsVerify(TRptCalculator ACalc, TReportActionEnum AReportAction) { if (!FDirectRelationshipTable.Select(FDirectRelationshipTable.DefaultView.RowFilter).Any(r => (bool)r["Selection"]) && !FReciprocalRelationshipTable.Select(FReciprocalRelationshipTable.DefaultView.RowFilter).Any(r => (bool)r["Selection"])) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("Select at least one Relationship Type to run the report."), Catalog.GetString("No Relationship Type selected!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } }
/// <summary> /// Checks if a CheckedListBox has at least one checked item. /// </summary> /// <param name="ACheckedListBox">LisBbox Control that should be verified.</param> /// <returns>Null if if validation succeeded, otherwise a <see cref="TVerificationResult" /> /// is returned that contains details about the problem. /// </returns> public static TVerificationResult ValidateCheckedListBox(System.Windows.Forms.CheckedListBox ACheckedListBox) { TVerificationResult ReturnValue = null; if (ACheckedListBox.CheckedItems.Count == 0) { ReturnValue = new TVerificationResult(ACheckedListBox.Name, ErrorCodes.GetErrorInfo( CommonErrorCodes.ERR_INFORMATIONMISSING, StrItemNeedsToBeChecked)); } return ReturnValue; }
private void ReadControlsVerify(TRptCalculator ACalc, TReportActionEnum AReportAction) { if ((txtThisYear.Text == "0") || (txtLastYear.Text == "0")) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("No valid year entered."), Catalog.GetString("Please enter a valid year."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } }
/// <summary> /// Checks if a versatile CheckedListBox has at least one checked item. /// </summary> /// <param name="AClbVersatile">VersatileListBox Control that should be verified.</param> /// <returns>Null if if validation succeeded, otherwise a <see cref="TVerificationResult" /> /// is returned that contains details about the problem. /// </returns> public static TVerificationResult ValidateCheckedListBoxVersatile(TClbVersatile AClbVersatile) { TVerificationResult ReturnValue = null; if (AClbVersatile.CheckedItemsCount == 0) { ReturnValue = new TVerificationResult(AClbVersatile.Name, ErrorCodes.GetErrorInfo( CommonErrorCodes.ERR_INFORMATIONMISSING, StrItemNeedsToBeChecked)); } return ReturnValue; }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { if (chkOnlyTravelDay.Checked) { if (!dtpTravelDay.ValidDate(false)) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("Please insert a valid date in the \"Travel Selection\" Settings."), Catalog.GetString("No valid date."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } ACalc.AddParameter("param_dtpTravelDay", this.dtpTravelDay.Date); } }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); ACalc.AddParameter("param_recipient_key_n", txtPartnerKey.Text); if ((AReportAction == TReportActionEnum.raGenerate) && (txtPartnerKey.Text == "0000000000")) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("No recipient selected."), Catalog.GetString("Please select a recipient."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { if (AReportAction == TReportActionEnum.raGenerate) { // validate anniversaires (comma seperated integers) if (chkAnniversaries.Checked && (string.IsNullOrEmpty(txtAnniversaries.Text) || !Regex.IsMatch(txtAnniversaries.Text, @"^([0-9]+,)*[0-9]+$"))) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("Length of Commitment Report"), Catalog.GetString("Please enter a comma seperated list of anniversaires."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } } }
/// <summary> /// todoComment /// </summary> /// <param name="e"></param> /// <param name="AVerificationResultCollection"></param> /// <param name="AVerificationResult"></param> /// <param name="FDataColumnComparedTo"></param> /// <returns></returns> public static Boolean VerifySubscriptionData(DataColumnChangeEventArgs e, TVerificationResultCollection AVerificationResultCollection, out TVerificationResult AVerificationResult, out DataColumn FDataColumnComparedTo) { Boolean ReturnValue; AVerificationResult = null; DataColumn FDataColumnComparedTo2 = null; if ((e.Column.ColumnName == PSubscriptionTable.GetDateCancelledDBName()) || (e.Column.ColumnName == PSubscriptionTable.GetExpiryDateDBName()) || (e.Column.ColumnName == PSubscriptionTable.GetDateNoticeSentDBName()) || (e.Column.ColumnName == PSubscriptionTable.GetStartDateDBName()) || (e.Column.ColumnName == PSubscriptionTable.GetSubscriptionRenewalDateDBName()) || (e.Column.ColumnName == PSubscriptionTable.GetFirstIssueDBName()) || (e.Column.ColumnName == PSubscriptionTable.GetLastIssueDBName())) { VerifySubscriptionDates(e, AVerificationResultCollection, out AVerificationResult, out FDataColumnComparedTo2); } FDataColumnComparedTo = FDataColumnComparedTo2; // if (e.Column.Ordinal = (e.Column.Table as PPartnerLocationTable).ColumnEmailAddress.Ordinal) then // begin // VerifyEMailAddress(e, AVerificationResult); // end; if ((e.Column.ColumnName == PSubscriptionTable.GetPublicationCopiesDBName()) || (e.Column.ColumnName == PSubscriptionTable.GetNumberIssuesReceivedDBName()) || (e.Column.ColumnName == PSubscriptionTable.GetNumberComplimentaryDBName())) { VerifyInteger(e, out AVerificationResult); } // any verification errors? if (AVerificationResult == null) { ReturnValue = true; } else { ReturnValue = false; } return ReturnValue; }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { int ColumnCounter = 0; bool DatesAreValid = (dtpFromDate.ValidDate(false) && dtpToDate.ValidDate(false)); // Add the columns to the report ACalc.AddParameter("param_calculation", "Date", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ColumnCounter++; ACalc.AddParameter("param_calculation", "Total", ColumnCounter); ACalc.AddParameter("ColumnWidth", "3", ColumnCounter); ColumnCounter++; ACalc.AddParameter("param_calculation", "Actual", ColumnCounter); ACalc.AddParameter("ColumnWidth", "2", ColumnCounter); ColumnCounter++; ACalc.AddParameter("param_calculation", "Expected", ColumnCounter); ACalc.AddParameter("ColumnWidth", "2", ColumnCounter); ColumnCounter++; ACalc.AddParameter("param_calculation", "Children", ColumnCounter); ACalc.AddParameter("ColumnWidth", "2", ColumnCounter); ColumnCounter++; ACalc.AddParameter("MaxDisplayColumns", ColumnCounter); if ((AReportAction == TReportActionEnum.raGenerate) && DatesAreValid) { if (dtpFromDate.Date > dtpToDate.Date) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("Change From-Date or To-Date"), Catalog.GetString("From-Date must be earlier than To-Date"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } } if (!DatesAreValid) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("Enter valid From-Date and To-Date."), Catalog.GetString("Dates must be valid"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } }
/// <summary> /// Checks whether an Object is null. /// </summary> /// <param name="AValue">The Object to check.</param> /// <param name="ADescription">Description what the value is about (for the /// error message).</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <param name="AResultControl">Which <see cref="System.Windows.Forms.Control" /> is involved (can be null).</param> /// <returns>Null if <paramref name="AValue" /> is not null, /// otherwise a <see cref="TVerificationResult" /> is returned that /// contains details about the problem, with a message that uses <paramref name="ADescription" />.</returns> public static TVerificationResult ValueMustNotBeNull(object AValue, string ADescription, object AResultContext = null, System.Data.DataColumn AResultColumn = null, System.Windows.Forms.Control AResultControl = null) { TVerificationResult ReturnValue = null; String Description = THelper.NiceValueDescription(ADescription); // Check if (AValue == null) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_NONULL, StrValueMustNotBeNull, new string[] { Description })); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn, AResultControl); } } return ReturnValue; }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { if (AReportAction == TReportActionEnum.raGenerate) { TVerificationResult VerificationResult = null; long UnitKey = 0; try { UnitKey = Convert.ToInt64(txtPartnerKey.Text); } catch (Exception) { UnitKey = 0; } if (UnitKey == 0) { VerificationResult = new TVerificationResult("Insert a valid Key.", "No Unit Key selected!", TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } } int ColumnCounter; ColumnCounter = 0; ACalc.AddParameter("param_calculation", "UnitKey", ColumnCounter); ACalc.AddParameter("ColumnWidth", "3", ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "UnitType", ColumnCounter); ACalc.AddParameter("ColumnWidth", "4.5", ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "UnitName", ColumnCounter); ACalc.AddParameter("ColumnWidth", "12", ColumnCounter); ACalc.SetMaxDisplayColumns(3); ACalc.AddParameter("param_txtUnitCode", txtPartnerKey.Text); }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { if (txtMinAmount.NumberValueInt > txtMaxAmount.NumberValueInt) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("Gift Limit wrong."), Catalog.GetString("Minimum Amount can't be greater than Maximum Amount."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); ACalc.AddParameter("param_donorkey", txtDonor.Text); ACalc.AddParameter("param_extract_name", txtExtract.Text); //TODO: Calendar vs Financial Date Handling - Confirm that these should not be ledger dates, i.e. allowing for >12 periods and non-calendar period boundaries DateTime FromDateThisYear = new DateTime(DateTime.Today.Year, 1, 1); DateTime ToDatePreviousYear = new DateTime(DateTime.Today.Year - 1, 12, 31); DateTime FromDatePreviousYear = new DateTime(DateTime.Today.Year - 1, 1, 1); ACalc.AddParameter("param_to_date_this_year", DateTime.Today); ACalc.AddParameter("param_from_date_this_year", FromDateThisYear); ACalc.AddParameter("param_to_date_previous_year", ToDatePreviousYear); ACalc.AddParameter("param_from_date_previous_year", FromDatePreviousYear); ACalc.AddParameter("DonorAddress", ""); int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt(); for (int Counter = 0; Counter <= MaxColumns; ++Counter) { String ColumnName = ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString(); if (ColumnName == "Gift Amount") { ACalc.AddParameter("param_gift_amount_column", Counter); } } }
/// <summary> /// Checks whether an International Postal Type is valid. Null values are accepted. /// </summary> /// <param name="AInternatPostalTypeCode">The International Postal Type to check.</param> /// <param name="ADescription">Description what the value is about (for the /// error message).</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <param name="AResultControl">Which <see cref="System.Windows.Forms.Control" /> is involved (can be null).</param> /// <returns>Null if <paramref name="AInternatPostalTypeCode" /> is null, /// otherwise a <see cref="TVerificationResult" /> is returned that /// contains details about the problem, with a message that uses <paramref name="ADescription" />.</returns> public static TVerificationResult IsValidInternationalPostalCode(string AInternatPostalTypeCode, string ADescription = "", object AResultContext = null, System.Data.DataColumn AResultColumn = null, System.Windows.Forms.Control AResultControl = null) { TVerificationResult ReturnValue = null; Ict.Common.Data.TTypedDataTable IntPostalDT; if (AInternatPostalTypeCode != null) { if (AInternatPostalTypeCode != String.Empty) { TSharedValidationHelper.GetData(PInternationalPostalTypeTable.GetTableDBName(), null, out IntPostalDT); if (IntPostalDT.Rows.Find(new object[] { AInternatPostalTypeCode }) == null) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_INVALIDINTERNATIONALPOSTALCODE)); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn, AResultControl); } } } else { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_INVALIDINTERNATIONALPOSTALCODE)); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn, AResultControl); } } } return ReturnValue; }
/// <summary> /// todoComment /// </summary> /// <param name="e"></param> /// <param name="AVerificationResultCollection"></param> /// <param name="AVerificationResult"></param> /// <returns></returns> public static Boolean VerifyPartnerLocationData(DataColumnChangeEventArgs e, TVerificationResultCollection AVerificationResultCollection, out TVerificationResult AVerificationResult) { Boolean ReturnValue; AVerificationResult = null; // MessageBox.Show('Verifying DataRow...'); if ((e.Column.ColumnName == PPartnerLocationTable.GetDateEffectiveDBName()) || (e.Column.ColumnName == PPartnerLocationTable.GetDateGoodUntilDBName())) { VerifyDates(e, AVerificationResultCollection, out AVerificationResult); } if (e.Column.Ordinal == ((PPartnerLocationTable)e.Column.Table).ColumnEmailAddress.Ordinal) { VerifyEmailAddress(e, out AVerificationResult); } if (e.Column.Ordinal == ((PPartnerLocationTable)e.Column.Table).ColumnLocationType.Ordinal) { VerifyLocationType(e, out AVerificationResult); } // any verification errors? if (AVerificationResult == null) { ReturnValue = true; } else { ReturnValue = false; // MessageBox.Show('VerifyPartnerLocationData: There was an error!'); } return ReturnValue; }
private void ReadControlsVerify(TRptCalculator ACalc, TReportActionEnum AReportAction) { if (!dtpEndDate.ValidDate(false) || !dtpStartDate.ValidDate(false)) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("Date format problem"), Catalog.GetString("Please check the date entry."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } else { if (dtpStartDate.Date > dtpEndDate.Date) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("From date is later than to date."), Catalog.GetString("Please change from date or to date."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } } }
private void ReadControlsVerify(TRptCalculator ACalc, TReportActionEnum AReportAction) { if (!dtpEndDate.ValidDate(false) || !dtpStartDate.ValidDate(false)) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("No valid date."), Catalog.GetString("Please enter a valid date."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } else { if (dtpStartDate.Date > dtpEndDate.Date) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("From date is later than to date."), Catalog.GetString("Please change from date or to date."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } } if (rbtMiddleDonor.Checked) { int From = Convert.ToInt32(txtPercentage.Text); int To = Convert.ToInt32(txtToPercentage.Text); if (To > From) { // From must be biggern than to String TmpString = txtPercentage.Text; txtPercentage.Text = txtToPercentage.Text; txtToPercentage.Text = TmpString; } } }
/// <summary> /// Converts a String into a date time. /// </summary> /// <param name="AParseDate">String which contains the date that should be converted</param> /// <param name="ADescription">String about the conversion type that is performed. This is /// used to gather error messages.</param> /// <param name="AVerificationResult">If conversion fails it contains detailed information /// about the error. If conversion is successful: null</param> /// <param name="AShowVerificationError">True if a error message should be shown if conversion fails.</param> /// <returns>The converted date. If the conversion didn't succeed than it contains /// the Date Min value.</returns> public static DateTime LongDateStringToDateTime2(String AParseDate, String ADescription, out TVerificationResult AVerificationResult, Boolean AShowVerificationError) { DateTime ReturnValue; // DateConvertEventArgs: ConvertEventArgs; object ResultObj; ResultObj = null; AVerificationResult = null; /* Result := DateTime.MinValue; */ /* */ /* Convert TextBox's Text to Date */ /* DateConvertEventArgs := new ConvertEventArgs(AParseDate, System.Type.GetType('System.DateTime')); */ /* LongDateStringToDateTime(nil, DateConvertEventArgs); */ /* */ /* AVerificationResult := TDateChecks.IsValidDateTime( */ /* DateConvertEventArgs.Value.ToString, ''); */ /* */ /* if AVerificationResult = nil then */ /* begin */ /* Conversion was successful > return the Date */ /* Result := Convert.ToDateTime(DateConvertEventArgs.Value); */ /* end; */ if (LongDateStringToDateTimeInternal(AParseDate, ADescription, out ResultObj, AShowVerificationError)) { // MessageBox.Show('LongDateStringToDateTime2: date is valid: ' + ResultObj.ToString); if (ResultObj != DBNull.Value) { ReturnValue = Convert.ToDateTime(ResultObj); } else { ReturnValue = DateTime.MinValue; } } else { // MessageBox.Show('LongDateStringToDateTime2: date is INvalid!'); AVerificationResult = TDateChecks.IsValidDateTime(AParseDate, ADescription); ReturnValue = DateTime.MinValue; } return ReturnValue; }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { if ((AReportAction == TReportActionEnum.raGenerate) && (rbtPartner.Checked && (txtRecipient.Text == "0000000000"))) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("No recipient selected."), Catalog.GetString("Please select a recipient."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } if ((AReportAction == TReportActionEnum.raGenerate) && rbtExtract.Checked && (txtExtract.Text == "")) { TVerificationResult VerificationMessage = new TVerificationResult( Catalog.GetString("Enter an extract name."), Catalog.GetString("No extract name entered!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationMessage); } if ((AReportAction == TReportActionEnum.raGenerate) && rbtSelectedFields.Checked && (clbFields.GetCheckedStringList().Length == 0)) { TVerificationResult VerificationMessage = new TVerificationResult( Catalog.GetString("Please select at least one field."), Catalog.GetString("No fields selected!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationMessage); } if ((AReportAction == TReportActionEnum.raGenerate) && rbtSelectedTypes.Checked && (clbTypes.GetCheckedStringList().Length == 0)) { TVerificationResult VerificationMessage = new TVerificationResult( Catalog.GetString("Please select at least one type."), Catalog.GetString("No types selected!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationMessage); } ACalc.AddParameter("param_recipient_key", txtRecipient.Text); ACalc.AddParameter("param_extract_name", txtExtract.Text); ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); //TODO: Calendar vs Financial Date Handling - Confirm that these should not be ledger dates, i.e. allowing for >12 periods and non-calendar period boundaries DateTime FromDateThisYear = new DateTime(DateTime.Today.Year, 1, 1); DateTime ToDatePreviousYear = new DateTime(DateTime.Today.Year - 1, 12, 31); DateTime FromDatePreviousYear = new DateTime(DateTime.Today.Year - 1, 1, 1); ACalc.AddParameter("Year0", DateTime.Today.Year); ACalc.AddParameter("Year1", DateTime.Today.Year - 1); ACalc.AddParameter("Year2", DateTime.Today.Year - 2); ACalc.AddParameter("Year3", DateTime.Today.Year - 3); ACalc.AddParameter("param_to_date_0", DateTime.Today); ACalc.AddParameter("param_from_date_0", FromDateThisYear); ACalc.AddParameter("param_to_date_1", ToDatePreviousYear); ACalc.AddParameter("param_from_date_1", FromDatePreviousYear); ACalc.AddParameter("param_to_date_2", ToDatePreviousYear.AddYears(-1)); ACalc.AddParameter("param_from_date_2", FromDatePreviousYear.AddYears(-1)); ACalc.AddParameter("param_to_date_3", ToDatePreviousYear.AddYears(-2)); ACalc.AddParameter("param_from_date_3", FromDatePreviousYear.AddYears(-2)); int ColumnCounter = 0; ACalc.AddParameter("param_calculation", "PartnerKey", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "DonorName", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)6.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "DonorClass", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)3.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Year-0", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Year-1", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Year-2", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Year-3", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter); ++ColumnCounter; ACalc.SetMaxDisplayColumns(ColumnCounter); }
/// <summary> /// Constructor /// </summary> /// <param name="AVerificationResult"><see cref="TVerificationResult" /> which /// contains the basic data to which the <paramref name="AResultColumn" /> and /// <paramref name="AResultControl" /> are getting added.</param> /// <param name="AResultColumn">which column failed</param> /// <param name="AResultControl">which control is involved</param> /// <param name="ADataValidationRunID">A Data Validation Run ID that this instance should be associated with. Default: a new System.Guid instance.</param> public TScreenVerificationResult(TVerificationResult AVerificationResult, DataColumn AResultColumn, Control AResultControl, System.Guid ADataValidationRunID = new System.Guid()) { FResultContext = AVerificationResult.ResultContext; FResultColumn = AResultColumn; FResultText = AVerificationResult.ResultText; FResultTextCaption = AVerificationResult.ResultTextCaption; FResultCode = AVerificationResult.ResultCode; FResultControl = AResultControl; FResultSeverity = AVerificationResult.ResultSeverity; FControlValueUndoRequested = AVerificationResult.ControlValueUndoRequested; FDataValidationRunID = ADataValidationRunID; }
/// <summary> /// A Method to transform the exception message(s) into a /// TVerificationResultCollection /// </summary> /// <returns></returns> public TVerificationResultCollection ResultCollection() { TVerificationResultCollection collection = new TVerificationResultCollection(); TVerificationResult avrEntry; avrEntry = new TVerificationResult(this.Context, this.Message, "", this.ErrorCode, TResultSeverity.Resv_Critical); collection.Add(avrEntry); avrEntry = new TVerificationResult(Catalog.GetString("Exception has been thrown"), this.ToString(), "", this.ErrorCode, TResultSeverity.Resv_Critical); collection.Add(avrEntry); if (this.InnerException != null) { avrEntry = new TVerificationResult(Catalog.GetString("Inner Exception"), this.InnerException.ToString(), TResultSeverity.Resv_Critical); collection.Add(avrEntry); } return collection; }
/// <summary> /// Calls the <see cref="M:DataRow.SetColumnError(DataColumn, String)" /> Method of a /// DataRow's Column to the <see cref="TVerificationResult.ResultText" /> Property /// of the passed in <see cref="TVerificationResult" />. /// </summary> /// <param name="AEventArgs">An instance of DataColumnChangeEventArgs.</param> /// <param name="AVerificationResultEntry"><see cref="TVerificationResult" /> which has /// its <see cref="TVerificationResult.ResultText" /> Property set.</param> /// <param name="AControlName">Name of the Control to which the <see cref="TVerificationResult" /> /// is related.</param> /// <param name="AResetValue">Set this to true to retain the /// <see cref="DataColumnChangeEventArgs.ProposedValue" />.</param> public static void SetColumnErrorText(DataColumnChangeEventArgs AEventArgs, TVerificationResult AVerificationResultEntry, String AControlName, Boolean AResetValue) { object PreviousProposedValue = AEventArgs.ProposedValue; AEventArgs.Row.SetColumnError(AEventArgs.Column, AVerificationResultEntry.ResultText + "//[[" + AControlName + "]]"); /* * SetColumnError automatically resets the value of the DataColumn. * Therefore we need to re-assign it again if we don't want to reset the value. */ if (!AResetValue) { // MessageBox.Show("SetColumnErrorText: Before resetting the value: " + AEventArgs.ProposedValue.ToString()); AEventArgs.ProposedValue = PreviousProposedValue; // MessageBox.Show("SetColumnErrorText: After resetting the value: " + AEventArgs.ProposedValue.ToString()); } }
/// <summary> /// Checks whether two <see cref="TVerificationResult" />s are completely identical. The comparison /// takes all the data they hold into consideration. /// </summary> /// <param name="AVerificationResult1">First <see cref="TVerificationResult" />.</param> /// <param name="AVerificationResult2">Second <see cref="TVerificationResult" />.</param> /// <param name="ACompareResultContextsAsStrings">Set to true to compare the ResultContexts not as objects, but /// compare what a call of the .ToString() Method on the two object yields. (Default: false.)</param> /// <param name="ATreatUserControlAndFormContextsAsIdentical">Set to true to treat a UserControl and the Form /// where it is placed on as identical ResultContexts. (Default: false.)</param> /// <returns>True if the two <see cref="TVerificationResult" />s are completely identical, /// otherwise false.</returns> public static bool AreVerificationResultsIdentical(TVerificationResult AVerificationResult1, TVerificationResult AVerificationResult2, bool ACompareResultContextsAsStrings = false, bool ATreatUserControlAndFormContextsAsIdentical = false) { if ((AVerificationResult1 == null) || (AVerificationResult2 == null)) { if ((AVerificationResult1 == null) && (AVerificationResult2 == null)) { return true; } else { return false; } } else { if (AVerificationResult1.ResultCode != AVerificationResult2.ResultCode) { return false; } if (!ACompareResultContextsAsStrings) { if (ATreatUserControlAndFormContextsAsIdentical) { if ((AVerificationResult1.ResultContext is UserControl) || (AVerificationResult2.ResultContext is UserControl)) { if ((AVerificationResult1.ResultContext is UserControl) && (AVerificationResult2.ResultContext is Form)) { if (((UserControl)AVerificationResult1.ResultContext) != AVerificationResult2.ResultContext) { return false; } } else if ((AVerificationResult2.ResultContext is UserControl) && (AVerificationResult1.ResultContext is Form)) { if (((UserControl)AVerificationResult2.ResultContext).ParentForm != AVerificationResult1.ResultContext) { return false; } } } else if (AVerificationResult1.ResultContext != AVerificationResult2.ResultContext) { return false; } } else if (AVerificationResult1.ResultContext != AVerificationResult2.ResultContext) { return false; } } else { if (ATreatUserControlAndFormContextsAsIdentical) { if ((AVerificationResult1.ResultContext is UserControl) || (AVerificationResult2.ResultContext is UserControl)) { if ((AVerificationResult1.ResultContext is UserControl) && (AVerificationResult2.ResultContext is Form)) { if (((UserControl)AVerificationResult1.ResultContext).ParentForm.ToString() != AVerificationResult2.ResultContext.ToString()) { return false; } } else if ((AVerificationResult2.ResultContext is UserControl) && (AVerificationResult1.ResultContext is Form)) { if (((UserControl)AVerificationResult2.ResultContext).ParentForm.ToString() != AVerificationResult1.ResultContext.ToString()) { return false; } } } else if (AVerificationResult1.ResultContext.ToString() != AVerificationResult2.ResultContext.ToString()) { return false; } } else if (AVerificationResult1.ResultContext.ToString() != AVerificationResult2.ResultContext.ToString()) { return false; } } if (AVerificationResult1.ResultSeverity != AVerificationResult2.ResultSeverity) { return false; } if (AVerificationResult1.ResultText != AVerificationResult2.ResultText) { // There may be some specific result codes that can allow the result text to differ so long as everything else is ok. // This will happen when the result text changes with the user's INPUT (examples of this are rare!) // Normally result text is either constant or depends on the current database content which will be constant during a verification run. // But, for example, the result text for a duplicate record contains a hint indicating the entered data that might be wrong. // So if the user makes the same error twice but with two different attempts at making a non-duplicate, we need to accept the result // as the same but update the old text, replacing it with the latest. // Other examples of this behaviour may be created in the future, and can be OR'd with the ERR_DUPLICATE_RECORD case if (AVerificationResult1.ResultCode == CommonErrorCodes.ERR_DUPLICATE_RECORD) { // ensure that the ResultText is the most recent instance AVerificationResult1.OverrideResultText(AVerificationResult2.ResultText); } else { return false; } } if (AVerificationResult1.ResultTextCaption != AVerificationResult2.ResultTextCaption) { return false; } } return true; }
/// <summary> /// Calls either the <see cref="Add" /> or <see cref="AddOrRemove" /> Method. Which Method is /// called is determined by evaluating the Type of <paramref name="AContext" />: if it is /// <see cref="System.Windows.Forms.Form" /> then the <see cref="AddOrRemove" /> Method is /// called, otherwise the <see cref="Add" /> Method. /// </summary> /// <param name="AContext">Context that describes where the data verification failed.</param> /// <param name="AVerificationResult">An instance of <see cref="TVerificationResult" /> /// that is to be added/to be added or removed from the <see cref="TVerificationResultCollection" />.</param> /// <param name="AValidationColumn">The <see cref="DataRow" /> which holds the the data against which /// the validation was run. Only used if the <see cref="AddOrRemove" /> Methods is called.</param> /// <param name="ATreatUserControlAndFormContextsAsIdentical">Set to true to treat a UserControl and the Form /// where it is placed on as identical ResultContexts. (Default: false.)</param> /// <returns>True if the <see cref="TVerificationResult" /> got added, otherwise false.</returns> public bool Auto_Add_Or_AddOrRemove(object AContext, TVerificationResult AVerificationResult, DataColumn AValidationColumn, bool ATreatUserControlAndFormContextsAsIdentical = false) { bool ReturnValue = false; if ((AContext is System.Windows.Forms.Form) || (AContext is System.Windows.Forms.UserControl)) { ReturnValue = this.AddOrRemove(AVerificationResult, AValidationColumn, null, ATreatUserControlAndFormContextsAsIdentical); } else { if (AVerificationResult != null) { this.Add(AVerificationResult); ReturnValue = true; } } return ReturnValue; }
/// <summary> /// Adds a <see cref="TVerificationResult" /> for a <see cref="System.Data.DataColumn" /> /// specified with <paramref name="AResultColumn" />, or removes a /// <see cref="TVerificationResult" /> that is stored in the collection for the /// <see cref="System.Data.DataColumn" /> specified with <paramref name="AResultColumn" />. /// If <paramref name="AVerificationResult" /> isn't null, this Method will add it, if /// <paramref name="AVerificationResult" /> is null, this Method will remove *all* entries in /// the <see cref="TVerificationResultCollection" /> that are recorded for <paramref name="AResultColumn" />. /// </summary> /// <remarks> /// When adding a <see cref="TVerificationResult" />, a check is done if a <see cref="TVerificationResult" /> /// with exactly the same Property values is already stored. If this is the case, the /// <see cref="TVerificationResult" /> is not added a second time. /// </remarks> /// <param name="AVerificationResult">The <see cref="TVerificationResult" /> to add, /// or null if a <see cref="TVerificationResult" /> that is stored in the collection for the /// <see cref="System.Data.DataColumn" /> <paramref name="AResultColumn" /> should get removed.</param> /// <param name="AResultColumn">The <see cref="System.Data.DataColumn" /> to check for.</param> /// <param name="AResultContext">Considered only when <paramref name="AVerificationResult"></paramref> is null: /// removal from collection will only happen if <paramref name="AResultContext"></paramref>.ToString() matches an /// <see cref="TVerificationResult" />'s ResultContext.ToString() that is stored in the collection for the /// <see cref="System.Data.DataColumn" />. (Default: null.)</param> /// <param name="ATreatUserControlAndFormContextsAsIdentical">Set to true to treat a UserControl and the Form /// where it is placed on as identical ResultContexts. (Default: false.)</param> /// <returns>True if the <see cref="TVerificationResult" /> got added, otherwise false.</returns> public bool AddOrRemove(TVerificationResult AVerificationResult, DataColumn AResultColumn, object AResultContext = null, bool ATreatUserControlAndFormContextsAsIdentical = false) { List <TScreenVerificationResult>si = FindAllBy(AResultColumn); bool IdenticalVResultFound = false; bool ReturnValue = false; if (AVerificationResult != null) { if (si == null) { // If CurrentDataValidationRunID was set on this instance, set it on any AVerificationResult we add so it can be associated with a "run" of the Data Validation. if (CurrentDataValidationRunID != new System.Guid()) { AVerificationResult.DataValidationRunID = CurrentDataValidationRunID; } this.Add(AVerificationResult); ReturnValue = true; } else { // A TVerificationResult for the same AResultColumn was found: inspect it. foreach (TScreenVerificationResult SingleEntry in si) { if (TVerificationHelper.AreVerificationResultsIdentical(SingleEntry, AVerificationResult, false, ATreatUserControlAndFormContextsAsIdentical)) { // The existing TVerificationResult is identical to AVerificationResult: // update the existing TVerificationResult's DataValidationRunID to the current one as it will need to be // treated in further processing as if it was found in this run. SingleEntry.DataValidationRunID = CurrentDataValidationRunID; IdenticalVResultFound = true; break; } } if (!IdenticalVResultFound) { // The existing TVerificationResult is NOT identical to AVerificationResult: // if CurrentDataValidationRunID was set on this instance of TVerificationResultColleciont, set it on any // AVerificationResult we add so it can be associated with a 'run' of the Data Validation. if (CurrentDataValidationRunID != new System.Guid()) { AVerificationResult.DataValidationRunID = CurrentDataValidationRunID; } this.Add(AVerificationResult); ReturnValue = true; } } } else if (si != null) { foreach (TScreenVerificationResult SingleEntry in si) { // Only remove a VerificationResult if it hasn't been added in this "run" of Data Validation // - This allows multiple Data Validations in one run on a single DataColumn as it prevents the last successful // Data Validation from removing a Data Validation error/warning for the same DataColumn that was enlisted in // the same "run". if (SingleEntry.DataValidationRunID != this.CurrentDataValidationRunID) { if (AResultContext != null) { if (SingleEntry.ResultContext.ToString() == AResultContext.ToString()) { this.Remove(SingleEntry); } } else { this.Remove(SingleEntry); } } } } ClassifyExceptions(); return ReturnValue; }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { int Years = Convert.ToInt16(txtYears.Text); if ((AReportAction == TReportActionEnum.raGenerate) && ((Years > 4) || (Years < 1))) { TVerificationResult VerificationMessage = new TVerificationResult( Catalog.GetString("Set the year range between 1 and 4"), Catalog.GetString("Wrong year range entered"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationMessage); } ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); ACalc.AddParameter("param_YearBlock", DateTime.Today.Year); ACalc.AddParameter("param_NumberOfYears", Convert.ToInt32(txtYears.Text)); int ColumnCounter = 0; // ACalc.AddParameter("param_calculation", "MonthName", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2, ColumnCounter); ++ColumnCounter; // ACalc.AddParameter("param_calculation", "MonthWorker", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; // MonthWorkerTaxDeduct if (FTaxDeductiblePercentageEnabled) { ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; } // ACalc.AddParameter("param_calculation", "MonthWorkerCount", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)1, ColumnCounter); ++ColumnCounter; // ACalc.AddParameter("param_calculation", "MonthField", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; // MonthFieldTaxDeduct if (FTaxDeductiblePercentageEnabled) { ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; } // ACalc.AddParameter("param_calculation", "MonthFieldCount", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)1, ColumnCounter); ++ColumnCounter; // ACalc.AddParameter("param_calculation", "MonthTotal", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; // MonthTotalTaxDeduct if (FTaxDeductiblePercentageEnabled) { ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; } // ACalc.AddParameter("param_calculation", "MonthTotalCount", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)1, ColumnCounter); ++ColumnCounter; // ACalc.AddParameter("param_calculation", "YearMonthlyAverage", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)3.0, ColumnCounter); ++ColumnCounter; // ACalc.AddParameter("param_calculation", "YearMonthlyAverageCount", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); /* * ++ColumnCounter; * ACalc.SetMaxDisplayColumns(ColumnCounter); */ }