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

            TSharedPartnerValidation_Partner.ValidateAddressBlockSetup(this, ARow, ref VerificationResultCollection,
                                                                       FPetraUtilsObject.ValidationControlsDict, FAddressBlockElements);
        }
        private void ShowDetailsManual(PAddressBlockRow ARow)
        {
            if (!FPetraUtilsObject.SecurityReadOnly)
            {
                btnCopy.Enabled = (ARow != null);

                btnInsert.Enabled     = (cmbAddressBlockElement.Count > 0);
                btnInsertLine.Enabled = btnInsert.Enabled;
            }
        }
        private void NewRowManual(ref PAddressBlockRow ARow)
        {
            // We don't guess at new codes - we force the user to select them from the lists
            if (FCreateAsCopy)
            {
                ARow.AddressBlockText  = FPreviouslySelectedDetailRow.AddressBlockText;
                ARow.AddressLayoutCode = FPreviouslySelectedDetailRow.AddressLayoutCode;
            }
            else
            {
                ARow.AddressBlockText  = String.Empty;
                ARow.AddressLayoutCode = String.Empty;
            }

            ARow.CountryCode = String.Empty;
        }
示例#4
0
        public static String BuildAddressBlock(TFormDataPartner AFormData,
                                               String AAddressLayoutCode,
                                               TPartnerClass APartnerClass,
                                               TDBTransaction ATransaction)
        {
            PAddressBlockTable AddressBlockTable;
            String             AddressLayoutBlock = "";

            if ((AAddressLayoutCode == null) ||
                (AAddressLayoutCode == ""))
            {
                // this should not happen but just in case we use SMLLABEL as default layout code
                AddressBlockTable = PAddressBlockAccess.LoadByPrimaryKey(AFormData.CountryCode, "SMLLABEL", ATransaction);

                if (AddressBlockTable.Count == 0)
                {
                    // if no address block layout could be found for given country then try to retrieve for default "99"
                    AddressBlockTable = PAddressBlockAccess.LoadByPrimaryKey("99", "SMLLABEL", ATransaction);
                }
            }
            else
            {
                AddressBlockTable = PAddressBlockAccess.LoadByPrimaryKey(AFormData.CountryCode, AAddressLayoutCode, ATransaction);

                if (AddressBlockTable.Count == 0)
                {
                    // if no address block layout could be found for given country then try to retrieve for default "99"
                    AddressBlockTable = PAddressBlockAccess.LoadByPrimaryKey("99", AAddressLayoutCode, ATransaction);
                }
            }

            if (AddressBlockTable.Count == 0)
            {
                return("");
            }
            else
            {
                PAddressBlockRow AddressBlockRow = (PAddressBlockRow)AddressBlockTable.Rows[0];
                AddressLayoutBlock = AddressBlockRow.AddressBlockText;
            }

            return(BuildAddressBlock(AddressLayoutBlock, AFormData, APartnerClass, ATransaction));
        }
示例#5
0
        /// <summary>
        /// Validates the MPartner Address Layout Setup screen data.
        /// </summary>
        /// <param name="AContext">Context that describes where the data validation failed.</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="AValidationControlsDict">A <see cref="TValidationControlsDict" /> containing the Controls that
        /// display data that is about to be validated.</param>
        /// <param name="AAddressElementTable">A table of all available Address Block Elements</param>
        public static void ValidateAddressBlockSetup(object AContext, PAddressBlockRow ARow,
            ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict,
            PAddressBlockElementTable AAddressElementTable)
        {
            DataColumn ValidationColumn;
            TValidationControlsData ValidationControlsData;
            TVerificationResult VerificationResult = null;

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

            // Do validation on the address block text
            ValidationColumn = ARow.Table.Columns[PAddressBlockTable.ColumnAddressBlockTextId];

            if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData))
            {
                // Address Block Text must not be empty
                VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.AddressBlockText, ValidationControlsData.ValidationControlLabel,
                    AContext, ValidationColumn, ValidationControlsData.ValidationControl);

                if (VerificationResult == null)
                {
                    // Text must contain at least one replaceable parameter and parameter must exist
                    // Start by parsing the text
                    string s = ARow.AddressBlockText;
                    List <string>allElements = new List <string>();
                    int posStart = 0;
                    int posEnd = -2;

                    while (posStart >= 0)
                    {
                        posStart = s.IndexOf("[[", posEnd + 2);

                        if (posStart != -1)
                        {
                            posEnd = s.IndexOf("]]", posStart);

                            if (posEnd > posStart)
                            {
                                // get the placeholder text
                                string item = s.Substring(posStart + 2, posEnd - posStart - 2);

                                if ((item == "CapsOn") && allElements.Contains("CapsOff"))
                                {
                                    allElements.Remove("CapsOff");
                                }

                                if (!allElements.Contains(item))
                                {
                                    allElements.Add(item);
                                }
                            }
                            else
                            {
                                // No matching tag
                                VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext,
                                        ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_ADDRESS_BLOCK_HAS_MISMATCHED_TAGS)),
                                    ValidationColumn, ValidationControlsData.ValidationControl);
                                break;
                            }
                        }
                    }

                    if (VerificationResult == null)
                    {
                        // Check there is at least one data element
                        if (allElements.Count == 0)
                        {
                            // No elements
                            VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext,
                                    ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_ADDRESS_BLOCK_HAS_NO_DATA_PLACEHOLDERS)),
                                ValidationColumn, ValidationControlsData.ValidationControl);
                        }
                        else
                        {
                            // Check that the elements exist and that at least one is not a directive
                            bool bFoundNonDirective = false;

                            foreach (string e in allElements)
                            {
                                PAddressBlockElementRow row = (PAddressBlockElementRow)AAddressElementTable.Rows.Find(e);

                                if (row == null)
                                {
                                    // Unknown element
                                    VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext,
                                            ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_ADDRESS_BLOCK_HAS_UNKNOWN_PLACEHOLDER)),
                                        ValidationColumn, ValidationControlsData.ValidationControl);

                                    break;
                                }
                                else if (row.IsDirective == false)
                                {
                                    bFoundNonDirective = true;
                                }
                            }

                            if ((VerificationResult == null) && (bFoundNonDirective == false))
                            {
                                // We got elements but they were all directives
                                VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext,
                                        ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_ADDRESS_BLOCK_ONLY_HAS_DIRECTIVE_PLACEHOLDERS)),
                                    ValidationColumn, ValidationControlsData.ValidationControl);
                            }

                            if (VerificationResult == null)
                            {
                                // All good so far.  If there is a CapsOn there must be a CapsOff
                                if (allElements.Contains("CapsOn") && !allElements.Contains("CapsOff"))
                                {
                                    VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext,
                                            ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_ADDRESS_BLOCK_HAS_NO_MATCHING_CAPS_OFF)),
                                        ValidationColumn, ValidationControlsData.ValidationControl);
                                }
                            }
                        }
                    }
                }

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
            }
        }
 private void ShowDetailsManual(PAddressBlockRow ARow)
 {
     btnCopy.Enabled       = (ARow != null);
     btnInsert.Enabled     = (cmbAddressBlockElement.Count > 0);
     btnInsertLine.Enabled = btnInsert.Enabled;
 }
        private void ValidateDataDetailsManual(PAddressBlockRow ARow)
        {
            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            TSharedPartnerValidation_Partner.ValidateAddressBlockSetup(this, ARow, ref VerificationResultCollection,
                FPetraUtilsObject.ValidationControlsDict, FAddressBlockElements);
        }
 private void ShowDetailsManual(PAddressBlockRow ARow)
 {
     btnCopy.Enabled = (ARow != null);
     btnInsert.Enabled = (cmbAddressBlockElement.Count > 0);
     btnInsertLine.Enabled = btnInsert.Enabled;
 }
        private void NewRowManual(ref PAddressBlockRow ARow)
        {
            // We don't guess at new codes - we force the user to select them from the lists
            if (FCreateAsCopy)
            {
                ARow.AddressBlockText = FPreviouslySelectedDetailRow.AddressBlockText;
                ARow.AddressLayoutCode = FPreviouslySelectedDetailRow.AddressLayoutCode;
            }
            else
            {
                ARow.AddressBlockText = String.Empty;
                ARow.AddressLayoutCode = String.Empty;
            }

            ARow.CountryCode = String.Empty;
        }