Показать сообщение отдельно
Старый 15.08.2013, 01:16   #1  
Blog bot is offline
Blog bot
Участник
 
25,646 / 848 (80) +++++++
Регистрация: 28.10.2006
emeadaxsupport: Mask characters
Источник: http://blogs.msdn.com/b/axsupport/ar...8/14/mask.aspx
==============

Yesterday, I had a support request where customer wanted to set a fixed length for the main accounts and they did not want to specify a type of characters – they wanted to have a possibility to enter both numeric and alphabetic characters.

In the form Chart of accounts, you can specify your accounts format in the field Main account mask.



There you can use the following mask characters:

& - allow any alphabetic character

# - allows any numeric character

The problem was that there’s no literal mask character that allows alphanumeric or any characters.

For that purpose, we modified the table FinancialTagCategory method doesValueMatchMask adding the new mask character:

? - allow any symbol

Here’re the modifications:

X++:
public static boolean doesValueMatchMask(DimensionValue _value, DimensionValueMask _mask)
{
    #DEFINE.SymbolNumerals('#')
    #DEFINE.SymbolLetters('&')
    #DEFINE.AnySymbol('?')                               
    #DEFINE.FirstNumeral('0')
    #DEFINE.LastNumeral('9')
    #DEFINE.FirstLetter('A')
    #DEFINE.LastLetter('Z')
 
    int strLength;
    int i;
    char maskChar;
    char valueChar;
 
    // No mask allows any value
    if (!_mask)
    {
        return true;
    }
 
    // Value must be same length as the mask
    strLength = strlen(_value);
    if (strLength != strlen(_mask))
    {
        return false;
    }
 
    // Ensure each character matches the literal mask character or is appropriate for the wildcard (number/letter) specified
    for (i = 1; i  #LastNumeral))
                {
                    return false;
                }
                break;
 
            case #SymbolLetters:
                if ((valueChar < #FirstLetter) || (valueChar > #LastLetter))
                {
                    return false;
                }
                break;
 
            case #AnySymbol:                               
                break;                                     
 
            default:
                if (valueChar != maskChar)
                {
                    return false;
                }
                break;
        }
    }
 
    return true;
}
Disclaimer: This programming example is for illustration purposes only. Microsoft disclaims all warranties and conditions with regard to use of the programming example for other purposes. Microsoft shall not, at any time, be liable for any special, direct, indirect or consequential damages, whether in an action of contract, negligence or other action arising out of or in connection with the use or performance of the programming example. Nothing herein should be construed as constituting any kind of warranty.



This allowed us to enter any values and still control the length of the accounts.



I hope it helps some of you and highlights the general literal mask characters that, by the way, used across the product &ndash; for example, in the project module &ndash; the Subproject ID format field.





Have a good day,

Roman





Источник: http://blogs.msdn.com/b/axsupport/ar...8/14/mask.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.