Пример #1
0
        protected virtual void GLBudgetTree_IsGroup_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            PXStringState strState = (PXStringState)sender.GetStateExt(null, typeof(GLBudgetTree.accountID).Name);

            PXDBStringAttribute.SetInputMask(sender, typeof(GLBudgetTree.accountMask).Name, strState.InputMask.Replace('#', 'C'));
            strState = (PXStringState)sender.GetStateExt(null, typeof(GLBudgetTree.subID).Name);
            PXDBStringAttribute.SetInputMask(sender, typeof(GLBudgetTree.subMask).Name, strState.InputMask.Replace('A', 'C'));
        }
        public WZFinPeriodAttribute(Type SourceType, Type SearchType)
        {
            _Attributes.Clear();            // = new List<PXEventSubscriberAttribute>();
            PXDBStringAttribute dbstr = new PXDBStringAttribute(FiscalPeriodUtils.FULL_LENGHT);

            dbstr.IsFixed = true;
            _Attributes.Add(dbstr);
            _Attributes.Add(new WZFinPeriodIDFormattingAttribute(SourceType, SearchType));

            _SearchType = SearchType;
            _SourceType = SourceType;
        }
        public override void CacheAttached(PXCache sender)
        {
            base.CacheAttached(sender);

            if (costCodeField != null)
            {
                sender.Graph.FieldDefaulting.AddHandler(sender.GetItemType(), FieldName, FieldDefaulting);
            }

            PXDBStringAttribute dbStringAttribute = DBAttribute as PXDBStringAttribute;

            if (dbStringAttribute != null && dbStringAttribute.IsKey)
            {
                // Working with selectors without a SubstituteKey as key fields presents some issues. When the selector is a key field,
                // the input mask for the field gets cleared in CacheAttached. We need to manually set it back here
                // to ensure the selector field works correctly with free-form input.
                StringBuilder inputMask = new StringBuilder(">");
                for (int i = 0; i < dbStringAttribute.Length; i++)
                {
                    inputMask.Append("a");
                }
                PXDBStringAttribute.SetInputMask(sender, _FieldName, inputMask.ToString());
            }
        }
Пример #4
0
 public override void Initialize()
 {
     PXDBStringAttribute.SetInputMask <APInvoice.docDesc>(Base.Document.Cache, ">CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC");
 }
Пример #5
0
        public static string DumpAsTable <TItem>(this IReadOnlyCollection <TItem> items, PXCache cache)
        {
            PropertyInfo[] propertyInfos = typeof(TItem).GetProperties(BindingFlags.Instance | BindingFlags.Public)
                                           .Where(info => !ignoredFields.Contains(info.Name))
                                           .ToArray();

            Dictionary <string, int> maxValueLengths = new Dictionary <string, int>();

            foreach (PropertyInfo propertyInfo in propertyInfos)
            {
                int maxValueLength = 0;

                if (typeof(decimal?).IsAssignableFrom(propertyInfo.PropertyType))
                {
                    maxValueLength = decimal.MinValue.ToString(CultureInfo.InvariantCulture).Length;
                }
                else if (typeof(int?).IsAssignableFrom(propertyInfo.PropertyType))
                {
                    maxValueLength = int.MinValue.ToString(CultureInfo.InvariantCulture).Length;
                }
                else if (typeof(bool?).IsAssignableFrom(propertyInfo.PropertyType))
                {
                    maxValueLength = 5;
                }
                else if (propertyInfo.PropertyType == typeof(string))
                {
                    PXDBStringAttribute dbAttr = cache.GetAttributes(propertyInfo.Name).OfType <PXDBStringAttribute>().SingleOrDefault();

                    if (dbAttr != null)
                    {
                        maxValueLength = dbAttr.Length;
                    }
                    else
                    {
                        PXStringAttribute attr = cache.GetAttributes(propertyInfo.Name).OfType <PXStringAttribute>().SingleOrDefault();

                        if (attr != null)
                        {
                            maxValueLength = attr.Length;
                        }
                    }
                }
                else
                {
                    throw new Exception("Unexpected type");
                }

                maxValueLengths[propertyInfo.Name] = maxValueLength;
            }

            KeyValuePair <string, int>[] fieldsWithUnknownLength = maxValueLengths.Where(kvp => kvp.Value == 0).ToArray();

            string[] fieldsList = propertyInfos.Select(info => info.Name).ToArray();

            if (!fieldsWithUnknownLength.Any())
            {
                return(DumpAsTable <TItem>(items, cache, fieldsList, maxValueLengths));
            }

            foreach (TItem item in items)
            {
                foreach (KeyValuePair <string, int> kvp in fieldsWithUnknownLength)
                {
                    int?length = cache.GetValue(item, kvp.Key)?.ToString().Length;

                    if (length > maxValueLengths[kvp.Key])
                    {
                        maxValueLengths[kvp.Key] = length.Value;
                    }
                }
            }

            return(DumpAsTable <TItem>(items, cache, fieldsList, maxValueLengths));
        }