Ejemplo n.º 1
0
        protected virtual void SegmentValue_Value_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
        {
            if (e.Row == null || cache.HasAttributes(e.Row))
            {
                Segment seg = Segment.Current as Segment;
                short   i;

                if (seg != null && seg.SegmentID != null)
                {
                    StringBuilder bld = new StringBuilder();

                    if (seg.AutoNumber != true)
                    {
                        bld.Append((seg.CaseConvert == 1) ? ">" : "");
                        bld.Append((seg.CaseConvert == 2) ? "<" : "");
                    }

                    for (i = 0; i < seg.Length; i++)
                    {
                        if (seg.AutoNumber == true)
                        {
                            bld.Append("C");
                        }
                        else
                        {
                            bld.Append(seg.EditMask);
                        }
                    }

                    e.ReturnState = PXStringState.CreateInstance(e.ReturnState, null, null, "Value", null, null, bld.ToString(), null, null, null, null);
                }
            }
        }
Ejemplo n.º 2
0
        public override void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            if (string.IsNullOrEmpty(InputMask))
            {
                InputMask = "### d\\ays ## hrs ## mins";
            }
            if (_AttributeLevel == PXAttributeLevel.Item || e.IsAltered)
            {
                string inputMask = _inputMasks[(int)this._Format];
                int    lenght    = _lengths[(int)this._Format];
                inputMask     = PXMessages.LocalizeNoPrefix(inputMask);
                e.ReturnState = PXStringState.CreateInstance(e.ReturnState, lenght, null, _FieldName, _IsKey, null, String.IsNullOrEmpty(inputMask) ? null : inputMask, null, null, null, null);
            }

            int maskLenght = 0;

            foreach (char c in InputMask)
            {
                if (c == '#' || c == '0')
                {
                    maskLenght += 1;
                }
            }

            if (e.ReturnValue != null)
            {
                int mins = 0;
                int.TryParse(e.ReturnValue.ToString(), out mins);
                TimeSpan span        = new TimeSpan(0, 0, mins, 0);
                int      hours       = (this._Format == TimeSpanFormatType.LongHoursMinutes) ? span.Days * 24 + span.Hours : span.Hours;
                var      returnValue = string.Format(_outputFormats[(int)this._Format], span.Days, hours, span.Minutes);
                e.ReturnValue = returnValue.Length < 0 ? (new String(' ', maskLenght - returnValue.Length)) + returnValue : returnValue;
            }
        }
        public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            CRFieldNewValues row = e.Row as CRFieldNewValues;

            if (row != null && _valuesDic.ContainsKey(row.DataField))
            {
                if (string.Compare(row.DataFieldType, typeof(bool).Name, true) == 0)
                {
                    e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(Boolean), false, null,
                                                                -1, null, null, null, base._FieldName, null, null, null,
                                                                PXErrorLevel.Undefined, null, null, PXUIVisibility.Undefined, null, null, null);
                }
                else
                if (!string.IsNullOrEmpty(row.SelectorViewName))
                {
                    e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(string), false, null,
                                                                -1, null, null, null, base._FieldName, row.SelectorDescriptionName, row.SelectorDescription, null, null,
                                                                PXErrorLevel.Undefined, null, null, PXUIVisibility.Undefined, row.SelectorViewName, null, null);
                }
                else
                {
                    string[] values = Array.ConvertAll <object, string>(_valuesDic[row.DataField], CRHelper.ObjectToString);
                    e.ReturnState = PXStringState.CreateInstance(e.ReturnState, null, base._FieldName, null,
                                                                 -1, null, values, _labelsDic.ContainsKey(row.DataField) ?
                                                                 _labelsDic[row.DataField] : values, (bool?)true);
                }
            }
        }
        protected PXFieldState CreateFieldStateForFieldName(object returnState, string entityType, string graphType, string cacheName)
        {
            Type type = GraphHelper.GetType(entityType);

            if (type != null)
            {
                Type gType = EntityHelper.GetPrimaryGraphType(this, type);
                if (!String.IsNullOrEmpty(graphType))
                {
                    gType = GraphHelper.GetType(graphType);
                }
                string viewName = null;
                if (gType != null)
                {
                    foreach (
                        CacheEntityItem view in
                        EMailSourceHelper.TemplateEntity(this, null, type.FullName, gType.FullName))
                    {
                        if (view.SubKey == cacheName)

                        {
                            viewName = view.Key;
                            break;
                        }
                    }
                }
                return(CreateFieldStateForFieldName(returnState, type, gType, viewName, EPRuleCondition.FieldLength));
            }
            return(PXStringState.CreateInstance(returnState, EPRuleCondition.FieldLength, null, _FIELDNAME_STR, false, 1, null,
                                                (new List <string>()).ToArray(), (new List <string>()).ToArray(), false, null));
        }
        private PXFieldState CreateFieldStateForEntity(object returnState, string entityType, string graphType)
        {
            List <string> allowedValues = new List <string>();
            List <string> allowedLabels = new List <string>();


            Type gType = null;

            if (graphType != null)
            {
                gType = GraphHelper.GetType(graphType);
            }
            else if (entityType != null)
            {
                Type eType = System.Web.Compilation.PXBuildManager.GetType(entityType, false);
                gType = (eType == null) ? null : EntityHelper.GetPrimaryGraphType(this, eType);
            }

            if (gType != null)
            {
                PXSiteMapNode node = PXSiteMap.Provider.FindSiteMapNodeUnsecure(gType);
                if (node != null)
                {
                    allowedValues.Add(entityType);
                    allowedLabels.Add(node.Title);
                }
            }

            return(PXStringState.CreateInstance(returnState, 60, null, "Entity", false, 1, null,
                                                allowedValues.ToArray(), allowedLabels.ToArray(), true, null));
        }
Ejemplo n.º 6
0
        protected virtual void ARDiscount_ApplicableTo_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            ARDiscount row = e.Row as ARDiscount;

            if (row != null)
            {
                if (row.Type == DiscountType.Document)
                {
                    e.ReturnState = PXStringState.CreateInstance(e.ReturnValue, 1, false, "ApplicableTo", false, 1, null,
                                                                 new string[] { DiscountTarget.Customer, DiscountTarget.CustomerAndBranch, DiscountTarget.CustomerPrice, DiscountTarget.CustomerPriceAndBranch, DiscountTarget.Unconditional },
                                                                 new string[] { Messages.Customer, Messages.CustomerAndBranch, Messages.CustomerPrice, Messages.CustomerPriceAndBranch, Messages.Unconditional }.Select(l => PXMessages.LocalizeNoPrefix(l)).ToArray(),
                                                                 true, DiscountTarget.Customer);
                    return;
                }
            }

            List <string> values = new List <string>();
            List <string> labels = new List <string>();

            values.AddRange(new string[] { DiscountTarget.Customer, DiscountTarget.Inventory, DiscountTarget.InventoryPrice, DiscountTarget.CustomerAndInventory, DiscountTarget.CustomerAndInventoryPrice, DiscountTarget.CustomerPrice, DiscountTarget.CustomerPriceAndInventory, DiscountTarget.CustomerPriceAndInventoryPrice });
            labels.AddRange(new string[] { Messages.Customer, Messages.Discount_Inventory, Messages.InventoryPrice, Messages.CustomerAndInventory, Messages.CustomerAndInventoryPrice, Messages.CustomerPrice, Messages.CustomerPriceAndInventory, Messages.CustomerPriceAndInventoryPrice });
            if (PXAccess.FeatureInstalled <FeaturesSet.warehouse>())
            {
                values.AddRange(new string[] { DiscountTarget.Warehouse, DiscountTarget.WarehouseAndInventory, DiscountTarget.WarehouseAndCustomer, DiscountTarget.WarehouseAndInventoryPrice, DiscountTarget.WarehouseAndCustomerPrice });
                labels.AddRange(new string[] { Messages.Warehouse, Messages.WarehouseAndInventory, Messages.WarehouseAndCustomer, Messages.WarehouseAndInventoryPrice, Messages.WarehouseAndCustomerPrice });
            }
            values.AddRange(new string[] { DiscountTarget.Branch, DiscountTarget.Unconditional });
            labels.AddRange(new string[] { Messages.Branch, Messages.Unconditional });

            e.ReturnState = PXStringState.CreateInstance(e.ReturnValue, 1, false, "ApplicableTo", false, 1, null, values.ToArray(), labels.ToArray().Select(l => PXMessages.LocalizeNoPrefix(l)).ToArray(), true, DiscountTarget.Inventory);
        }
Ejemplo n.º 7
0
        protected virtual void PMAllocationDetail_OffsetAccountGroupOrigin_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            PMAllocationDetail row = e.Row as PMAllocationDetail;

            if (row != null)
            {
                List <string> allowedValues = new List <string>();
                List <string> allowedLabels = new List <string>();

                allowedValues.Add(PMOrigin.Source);
                allowedValues.Add(PMOrigin.Change);

                allowedLabels.Add(Messages.GetLocal(Messages.Origin_Source));
                allowedLabels.Add(Messages.GetLocal(Messages.Origin_Change));

                if (row.UpdateGL == true)
                {
                    allowedValues.Add(PMOrigin.FromAccount);
                    allowedLabels.Add(Messages.GetLocal(Messages.Origin_FromAccount));
                }
                else
                {
                    allowedValues.Add(PMOrigin.None);
                    allowedLabels.Add(Messages.GetLocal(Messages.Origin_None));
                }

                e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 1, false, typeof(PMAllocationDetail.offsetAccountGroupOrigin).Name, false, 1, null,
                                                             allowedValues.ToArray(), allowedLabels.ToArray(), true, PMOrigin.Source);

                ((PXStringState)e.ReturnState).Enabled = row.UpdateGL != true;
            }
        }
Ejemplo n.º 8
0
        //From PX.Api.OData.Model.GIDataService
        public static object UnwrapValue(object value)
        {
            PXFieldState state = value as PXFieldState;

            if (state != null)
            {
                if (state.Value == null && state.DefaultValue != null) // for a case when field has PXDefault attribute, but null value because of inconsistency in DB
                {
                    state.Value = state.DefaultValue;
                }
                if (state.Value != null && !state.DataType.IsInstanceOfType(state.Value)) // for a case when, for example, some field of int type has PXSelectorAttribute with substitute field of string type, and PXSelectorAttribute can't find corresponding row for substitute field
                {
                    state.Value = Convert.ChangeType(state.Value, state.DataType);
                }
            }

            PXStringState strState = value as PXStringState;

            if (strState != null && strState.Value != null && strState.ValueLabelDic != null && strState.ValueLabelDic.ContainsKey((string)strState.Value))
            {
                return(strState.ValueLabelDic[(string)strState.Value]);
            }
            PXIntState intState = value as PXIntState;

            if (intState != null && intState.Value != null && intState.ValueLabelDic != null)
            {
                return(intState.ValueLabelDic.ContainsKey((int)intState.Value) ? intState.ValueLabelDic[(int)intState.Value] : intState.Value.ToString());
            }
            return(PXFieldState.UnwrapValue(value));
        }
        protected virtual void ContractTemplate_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            ContractTemplate row = e.Row as ContractTemplate;

            if (row != null)
            {
                ContractBillingSchedule schedule = new ContractBillingSchedule();
                schedule.ContractID = row.ContractID;
                Billing.Insert(schedule);

                PXStringState state = SLAMapping.Cache.GetStateExt <ContractSLAMapping.severity>(null) as PXStringState;
                if (state != null && state.AllowedValues != null && state.AllowedValues.Length > 0)
                {
                    foreach (string severity in state.AllowedValues)
                    {
                        ContractSLAMapping sla = new ContractSLAMapping();
                        sla.ContractID = row.ContractID;
                        sla.Severity   = severity;
                        SLAMapping.Insert(sla);
                    }
                }

                Billing.Cache.IsDirty    = false;
                SLAMapping.Cache.IsDirty = false;
            }
        }
Ejemplo n.º 10
0
        protected virtual void APDiscount_ApplicableTo_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            APDiscount row = e.Row as APDiscount;

            if (row != null)
            {
                if (row.Type == SO.DiscountType.Document)
                {
                    e.ReturnState = PXStringState.CreateInstance(e.ReturnValue, 1, false, "ApplicableTo", false, 1, null,
                                                                 new string[] { DiscountTarget.Vendor },
                                                                 new string[] { Messages.VendorUnconditional }.Select(l => PXMessages.LocalizeNoPrefix(l)).ToArray(),
                                                                 true, DiscountTarget.Unconditional);
                    return;
                }
            }
            if (!PXAccess.FeatureInstalled <FeaturesSet.accountLocations>())
            {
                e.ReturnState = PXStringState.CreateInstance(e.ReturnValue, 1, false, "ApplicableTo", false, 1, null,
                                                             new string[] { DiscountTarget.VendorAndInventory, DiscountTarget.VendorAndInventoryPrice, DiscountTarget.Vendor },
                                                             new string[] { Messages.VendorAndInventory, Messages.VendorInventoryPrice, Messages.VendorUnconditional }.Select(l => PXMessages.LocalizeNoPrefix(l)).ToArray(),
                                                             true, DiscountTarget.Inventory);
                return;
            }

            e.ReturnState = PXStringState.CreateInstance(e.ReturnValue, 1, false, "ApplicableTo", false, 1, null,
                                                         new string[] { DiscountTarget.VendorAndInventory, DiscountTarget.VendorAndInventoryPrice, DiscountTarget.VendorLocation, DiscountTarget.VendorLocationAndInventory, DiscountTarget.Vendor },
                                                         new string[] { Messages.VendorAndInventory, Messages.VendorInventoryPrice, Messages.Vendor_Location, Messages.VendorLocationaAndInventory, Messages.VendorUnconditional }.Select(l => PXMessages.LocalizeNoPrefix(l)).ToArray(),
                                                         true, DiscountTarget.Inventory);
        }
Ejemplo n.º 11
0
        private PXFieldState CreateFieldStateForFieldName(object returnState, Type type)
        {
            List <string> allowedValues = new List <string>();
            List <string> allowedLabels = new List <string>();

            Dictionary <string, string> fields = new Dictionary <string, string>();

            foreach (var field in PXCache.GetBqlTable(type)
                     .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                     .SelectMany(p => p.GetCustomAttributes(true).Where(atr => atr is PXMassMergableFieldAttribute), (p, atr) => p))
            {
                PXFieldState fs = this.Caches[type].GetStateExt(null, field.Name) as PXFieldState;
                if (!fields.ContainsKey(field.Name))
                {
                    fields[field.Name] = fs != null ? fs.DisplayName : field.Name;
                }
            }

            foreach (var item in fields.OrderBy(i => i.Value))
            {
                allowedValues.Add(item.Key);
                allowedLabels.Add(item.Value);
            }

            return(PXStringState.CreateInstance(returnState, 60, null, "FieldName", false, 1, null,
                                                allowedValues.ToArray(), allowedLabels.ToArray(), true, null));
        }
Ejemplo n.º 12
0
        public override void ProccessItem(PXGraph graph, TPrimary item)
        {
            PXCache  cache   = graph.Caches[typeof(TPrimary)];
            TPrimary newItem = (TPrimary)cache.CreateInstance();

            PXCache <TPrimary> .RestoreCopy(newItem, item);

            string entityType = CSAnswerType.GetAnswerType(cache.GetItemType());
            string entityID   = CSAnswerType.GetEntityID(cache.GetItemType());

            PXView primaryView = graph.Views[graph.PrimaryView];

            object[] searches    = new object[primaryView.Cache.BqlKeys.Count];
            string[] sortcolumns = new string[primaryView.Cache.BqlKeys.Count];
            for (int i = 0; i < cache.BqlKeys.Count(); i++)
            {
                sortcolumns[i] = cache.BqlKeys[i].Name;
                searches[i]    = cache.GetValue(newItem, sortcolumns[i]);
            }
            int startRow = 0, totalRows = 0;

            List <object> result = primaryView.Select(null, null, searches, sortcolumns, null, null, ref startRow, 1, ref totalRows);

            newItem = (TPrimary)cache.CreateCopy(PXResult.Unwrap <TPrimary>(result[0]));

            foreach (FieldValue fieldValue in Fields.Cache.Cached.Cast <FieldValue>().Where(o => o.AttributeID == null && o.Selected == true))
            {
                PXFieldState  state    = cache.GetStateExt(newItem, fieldValue.Name) as PXFieldState;
                PXIntState    intState = state as PXIntState;
                PXStringState strState = state as PXStringState;
                if ((intState != null && intState.AllowedValues != null && intState.AllowedValues.Length > 0 &&
                     intState.AllowedValues.All(v => v != int.Parse(fieldValue.Value)))
                    ||
                    (strState != null && strState.AllowedValues != null && strState.AllowedValues.Length > 0 &&
                     strState.AllowedValues.All(v => v != fieldValue.Value)))
                {
                    throw new PXSetPropertyException(ErrorMessages.UnallowedListValue, fieldValue.Value, fieldValue.Name);
                }
                if (state != null && !Equals(state.Value, fieldValue.Value))
                {
                    cache.SetValueExt(newItem, fieldValue.Name, fieldValue.Value);
                    cache.Update(newItem);
                }

                result  = primaryView.Select(null, null, searches, sortcolumns, null, null, ref startRow, 1, ref totalRows);
                newItem = (TPrimary)cache.CreateCopy(PXResult.Unwrap <TPrimary>(result[0]));
            }

            PXCache attrCache = cache.Graph.Caches[typeof(CSAnswers)];

            foreach (FieldValue attrValue in Attributes.Cache.Cached.Cast <FieldValue>().Where(o => o.AttributeID != null && o.Selected == true))
            {
                CSAnswers attr = (CSAnswers)attrCache.CreateInstance();
                attr.AttributeID = attrValue.AttributeID;
                attr.EntityID    = cache.GetValue(newItem, entityID) as int?;
                attr.EntityType  = entityType;
                attr.Value       = attrValue.Value;
                attrCache.Update(attr);
            }
        }
Ejemplo n.º 13
0
        protected virtual void ItemAttributeValueFieldSelecting(int attributeNumber, PXFieldSelectingEventArgs e, string fieldName)
        {
            var           row   = (MatrixInventoryItem)e.Row;
            PXStringState state = (PXStringState)PXStringState.CreateInstance(e.ReturnState, null, true, fieldName, false, null, null, null, null, null, null);

            state.Enabled = false;
            e.ReturnState = state;

            if (attributeNumber < MatrixItemsForCreation.Current?.AttributeIDs?.Length)
            {
                e.ReturnValue    = 0 <= attributeNumber && attributeNumber < row?.AttributeValues?.Length ? row.AttributeValues[attributeNumber] : null;
                state.Visible    = true;
                state.Visibility = PXUIVisibility.Visible;

                if (CRAttribute.Attributes.TryGetValue(MatrixItemsForCreation.Current.AttributeIDs[attributeNumber],
                                                       out CRAttribute.Attribute attribute))
                {
                    state.DisplayName   = attribute.Description;
                    state.AllowedValues = attribute.Values.Select(v => v.ValueID).ToArray();
                    state.AllowedLabels = attribute.Values.Select(v => v.Description).ToArray();
                }
            }
            else
            {
                state.Value       = null;
                e.ReturnValue     = null;
                state.DisplayName = null;
                state.Visible     = false;
                state.Visibility  = PXUIVisibility.Invisible;
            }
        }
        public override void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            if (e.Row != null)
            {
                string mask = this.FindMask(sender, e.Row);
                if (!string.IsNullOrEmpty(mask))
                {
                    if (!string.IsNullOrEmpty((string)e.ReturnValue))
                    {
                        string viewAs = mask.Replace("#", "0").Replace("-", "").Replace("/", "");
                        this.ViewAsString = viewAs;
                        base.FieldSelecting(sender, e);

                        PXStringState state = e.ReturnState as PXStringState;
                        if (state != null)
                        {
                            e.ReturnState = PXStringState.CreateInstance(e.ReturnState, _Length, null, _FieldName, _IsKey, null, mask, null, null, null, null);
                        }
                    }
                    else
                    {
                        e.ReturnState = PXStringState.CreateInstance(e.ReturnState, _Length, null, _FieldName, _IsKey, null, mask, null, null, null, null);
                    }
                }
                else
                {
                    base.FieldSelecting(sender, e);
                }
            }
            else
            {
                base.FieldSelecting(sender, e);
            }
        }
        private PXFieldState InitDefaultValueFieldSate()
        {
            var res = PXStringState.CreateInstance(null, null, null, typeof(PropertyValue.value).Name,
                                                   false, 0, null, null, null, null, null);

            res.DisplayName = Messages.PropertyValue;
            return(res);
        }
Ejemplo n.º 16
0
 protected virtual void GLBudgetTree_SubMask_FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
 {
     if (e.NewValue != null)
     {
         PXStringState strState = (PXStringState)sender.GetStateExt(null, typeof(GLBudgetTree.subID).Name);
         e.NewValue = ((string)e.NewValue).PadRight(strState.InputMask.Length - 1, '?').Replace(' ', '?');
     }
 }
Ejemplo n.º 17
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'));
        }
        private static void CreateStringControl(PXFieldSelectingEventArgs args, CSAttributeGroup attributeGroup)
        {
            var required = attributeGroup.Required == true
                                ? 1
                                : -1;

            args.ReturnState = PXStringState.CreateInstance(args.ReturnState, null, null,
                                                            nameof(CSAnswers.value), false, required, null, null, null, false, null);
        }
Ejemplo n.º 19
0
 protected void grid_RowDataBound(object sender, PXGridRowEventArgs e)
 {
     if (e.Row != null && e.Row.DataItem != null)
     {
         PXStringState state = this.ds.DataGraph.Caches[e.Row.DataItem.GetType()].GetStateExt(e.Row.DataItem, "Value") as PXStringState;
         if (state != null && state.InputMask == "*")
         {
             e.Row.Cells["Value"].IsPassword = true;
         }
     }
 }
 private void UpdateStringState(PXStringState stringState)
 {
     if (attribute.ControlType == CSAttribute.MultiSelectCombo)
     {
         stringState.MultiSelect = true;
     }
     stringState.Length        = CSAttributeDetail.ParameterIdLength;
     stringState.AllowedLabels = attributeDetails.Select(x => x.Description).ToArray();
     stringState.AllowedValues = attributeDetails.Select(x => x.ValueID).ToArray();
     stringState.IsUnicode     = true;
 }
Ejemplo n.º 21
0
        protected virtual void _(Events.FieldSelecting <PMBillingRule, PMBillingRule.accountSource> e)
        {
            if (e.Row != null)
            {
                IDictionary <string, string> accountSources = GetAccountSources(e.Row.Type);

                string[] allowedValues = accountSources.Keys.ToArray();
                string[] allowedLabels = accountSources.Values.ToArray();

                e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 1, false, typeof(PMBillingRule.accountSource).Name, true, 1, null, allowedValues, allowedLabels, true, allowedValues[0]);
            }
        }
Ejemplo n.º 22
0
        public override object Evaluate(PXCache cache, object item, Dictionary <Type, object> pars)
        {
            if (!cache.GetAttributesReadonly(item, OuterField.Name).Any(attr => attr is PXStringListAttribute))
            {
                return(null);
            }

            string        val   = (string)pars[typeof(StringlistValue)];
            PXStringState state = (PXStringState)cache.GetStateExt(item, OuterField.Name);

            return(new List <string>(state.AllowedValues).Exists(str => string.CompareOrdinal(str, val) == 0) ? val : null);
        }
Ejemplo n.º 23
0
        public override void Verify(PXCache cache, object item, List <object> pars, ref bool?result, ref object value)
        {
            if (!cache.GetAttributesReadonly(item, OuterField.Name).Exists(attr => attr is PXStringListAttribute))
            {
                return;
            }

            string        val   = (string)Calculate <StringlistValue>(cache, item);
            PXStringState state = (PXStringState)cache.GetStateExt(item, OuterField.Name);

            value = new List <string>(state.AllowedValues).Exists(str => String.CompareOrdinal(str, val) == 0) ? val : null;
        }
Ejemplo n.º 24
0
        private PXFieldState CreateFieldStateForFieldName(object returnState, string entityType, string graphType, string cacheName)
        {
            List <string> allowedValues = new List <string>();
            List <string> allowedLabels = new List <string>();

            Type type = GraphHelper.GetType(entityType);

            if (type != null)
            {
                Type gType = EntityHelper.GetPrimaryGraphType(this, type);
                if (!String.IsNullOrEmpty(graphType))
                {
                    gType = GraphHelper.GetType(graphType);
                }
                string viewName = null;
                if (gType != null)
                {
                    foreach (
                        CacheEntityItem view in
                        EMailSourceHelper.TemplateEntity(this, null, type.FullName, gType.FullName))
                    {
                        if (view.SubKey == cacheName)

                        {
                            viewName = view.Key;
                            break;
                        }
                    }
                }

                Dictionary <string, string> fields = new Dictionary <string, string>();
                foreach (CacheEntityItem e in
                         EMailSourceHelper.TemplateEntity(this, viewName, type.FullName, gType != null ? gType.FullName : null, true))
                {
                    fields[e.SubKey] = e.Name;
                }

                foreach (var item in fields.OrderBy(i => i.Value))
                {
                    if (!item.Key.EndsWith("_Attributes") && item.Key.Contains('_'))
                    {
                        continue;
                    }
                    allowedValues.Add(item.Key);
                    allowedLabels.Add(item.Value);
                }
            }


            return(PXStringState.CreateInstance(returnState, EPAssignmentRule.FieldLength, null, _FIELDNAME_STR, false, 1, null,
                                                allowedValues.ToArray(), allowedLabels.ToArray(), false, null));
        }
Ejemplo n.º 25
0
        public virtual IEnumerable showPreload(PXAdapter adapter)
        {
            GLBudgetTree parentNode = PXSelect <GLBudgetTree, Where <GLBudgetTree.groupID, Equal <Required <GLBudgetTree.groupID> > > > .Select(this, this.CurrentSelected.Group);

            PXStringState subStrState = (PXStringState)Details.Cache.GetStateExt(null, typeof(GLBudgetTree.subID).Name);
            string        subWildCard = new String('?', subStrState.InputMask.Length - 1);

            if (parentNode != null)
            {
                PreloadFilter.Current.AccountCDWildcard = SubCDUtils.CreateSubCDWildcard(parentNode != null ? parentNode.AccountMask : string.Empty, AccountAttribute.DimensionName);
                if (parentNode.AccountMask != null)
                {
                    Account AcctFrom = PXSelect <Account, Where <Account.active, Equal <True>,
                                                                 And <Account.accountCD, Like <Required <SelectedNode.accountMaskWildcard> > > >,
                                                 OrderBy <Asc <Account.accountCD> > > .SelectWindowed(this, 0, 1, PreloadFilter.Current.AccountCDWildcard);

                    Account AcctTo = PXSelect <Account, Where <Account.active, Equal <True>,
                                                               And <Account.accountCD, Like <Required <AccountsPreloadFilter.accountCDWildcard> > > >,
                                               OrderBy <Desc <Account.accountCD> > > .SelectWindowed(this, 0, 1, PreloadFilter.Current.AccountCDWildcard);

                    PreloadFilter.Current.FromAccount = AcctFrom != null ? AcctFrom.AccountID : null;
                    PreloadFilter.Current.ToAccount   = AcctTo != null ? AcctTo.AccountID : null;
                }
                else
                {
                    PreloadFilter.Current.FromAccount = null;
                    PreloadFilter.Current.ToAccount   = null;
                }
                PreloadFilter.Current.SubIDFilter = parentNode.SubMask ?? subWildCard;
            }
            else
            {
                PreloadFilter.Current.FromAccount = null;
                PreloadFilter.Current.ToAccount   = null;
                PreloadFilter.Current.SubIDFilter = subWildCard;
            }
            if (PreloadFilter.Current != null)
            {
                if (parentNode != null)
                {
                    if (parentNode.AccountMask != null && PreloadFilter.Current.FromAccount == null)
                    {
                        if (Details.Ask(Messages.BudgetTreePreloadArticlesTitle, String.Format(PXMessages.LocalizeNoPrefix(Messages.BudgetTreePreloadArticlesMessage), parentNode.AccountMask), MessageButtons.OK) == WebDialogResult.OK)
                        {
                            return(adapter.Get());
                        }
                    }
                }
            }
            Details.AskExt();
            return(adapter.Get());
        }
        public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            string perPost = e.ReturnValue as string;

            if (perPost != null && (e.Row == null || object.Equals(e.ReturnValue, sender.GetValue(e.Row, _FieldOrdinal))))
            {
                e.ReturnValue = FormatForDisplay(perPost);
            }
            if (_AttributeLevel == PXAttributeLevel.Item || e.IsAltered)
            {
                e.ReturnState = PXStringState.CreateInstance(e.ReturnState, FiscalPeriodUtils.FULL_LENGHT, null, _FieldName, null, null, CS_DISPLAY_MASK, null, null, null, null);
            }
        }
        private void CreateComboControl(CSAttributeGroup attributeGroup, PXFieldSelectingEventArgs args,
                                        bool isMultiSelect)
        {
            var details  = GetAttributeDetails(attributeGroup.AttributeID);
            var values   = details.ToDictionary(detail => detail.ValueID, detail => detail.Description);
            var required = attributeGroup.Required == true
                                ? 1
                                : -1;

            args.ReturnState = PXStringState.CreateInstance(args.ReturnState, 255, null,
                                                            nameof(CSAnswers.value), false, required, null, values.Keys.ToArray(),
                                                            values.Values.ToArray(), true, null);
            ((PXStringState)args.ReturnState).MultiSelect = isMultiSelect;
        }
Ejemplo n.º 28
0
        protected virtual void PMTask_Status_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            PMTask row = e.Row as PMTask;

            string status = GetStatusFromFlags(row);
            List <KeyValuePair <string, string> > list = GetValidStatusTargets(row, status);

            List <string> allowedValues = new List <string>();
            List <string> allowedLabels = new List <string>();

            foreach (var pair in list)
            {
                allowedValues.Add(pair.Key);
                allowedLabels.Add(Messages.GetLocal(pair.Value));
            }

            e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 1, false, nameof(PMTask.Status), false, 1, null, allowedValues.ToArray(), allowedLabels.ToArray(), true, allowedValues[0]);
        }
        protected PXFieldState CreateFieldStateForFieldName(object returnState, Type entityType, Type gType, string viewName, int?fieldLength)
        {
            List <string> allowedValues = new List <string>();
            List <string> allowedLabels = new List <string>();
            List <string> uniqueLabels  = new List <string>();

            if (entityType != null)
            {
                Dictionary <string, string> fields = new Dictionary <string, string>();
                foreach (CacheEntityItem c in
                         EMailSourceHelper.TemplateEntity(this, viewName,
                                                          entityType.FullName,
                                                          gType != null ? gType.FullName : null, false))
                {
                    fields[c.SubKey] = c.Name;
                }

                Action <string, string> addValueLabel = (value, label) =>
                {
                    allowedValues.Add(value);
                    allowedLabels.Add(label);
                    uniqueLabels.Add(label);
                };
                foreach (var item in fields.OrderBy(i => i.Value))
                {
                    if (!item.Key.EndsWith("_Attributes") && item.Key.Contains('_'))
                    {
                        continue;
                    }
                    if (!uniqueLabels.Contains(item.Value))
                    {
                        addValueLabel(item.Key, item.Value);
                    }
                    else
                    {
                        string label = string.Format("{0} - {1}", item.Key, item.Value);
                        addValueLabel(item.Key, label);
                    }
                }
            }

            return(PXStringState.CreateInstance(returnState, fieldLength, null, _FIELDNAME_STR, false, 1, null,
                                                allowedValues.ToArray(), allowedLabels.ToArray(), false, null));
        }
 public override void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
 {
     if (e.Row != null)
     {
         string mask = this.FindMask(sender, e.Row);
         if (!string.IsNullOrEmpty(mask))
         {
             e.ReturnState = PXStringState.CreateInstance(e.ReturnState, _Length, null, _FieldName, _IsKey, null, mask, null, null, null, null);
         }
         else
         {
             base.FieldSelecting(sender, e);
         }
     }
     else
     {
         base.FieldSelecting(sender, e);
     }
 }