Esempio n. 1
0
        private void FieldSelectingOwnerOrWorkgroup <TField>(Events.FieldSelecting <TField> e) where TField : class, IBqlField
        {
            if (e.Row == null)
            {
                return;
            }

            bool isEnabled = true;

            PXView view = null;

            foreach (PXSelectorAttribute attribute in e.Cache.GetAttributesOfType <PXSelectorAttribute>(e.Row, typeof(FClassID).Name))
            {
                view = new PXView(Base, true, attribute.PrimarySelect);
            }
            if (view == null)
            {
                return;
            }

            string      classID = e.Cache.GetValue <FClassID>(e.Row) as string;
            CRBaseClass cls     = view.SelectSingle(classID) as CRBaseClass;

            if (cls == null)
            {
                return;
            }

            isEnabled = cls.DefaultOwner != CRDefaultOwnerAttribute.AssignmentMap ||
                        Object.Equals(e.Cache.GetValue <FClassID>(e.Row), e.Cache.GetValueOriginal <FClassID>(e.Row));

            e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, null, null, null, null, null, null, null, null, null, null, null, PXErrorLevel.Undefined,
                                                        isEnabled,
                                                        null, null, PXUIVisibility.Undefined, null, null, null);
        }
        protected override void FieldSelectingImpl(int attributeNumber, PXCache s, PXFieldSelectingEventArgs e, string fieldName)
        {
            var matrix = (EntryMatrix)e.Row;
            var ret    = PXFieldState.CreateInstance(e.ReturnState, typeof(bool), fieldName: fieldName);

            int?   inventoryId = GetValueFromArray(matrix?.InventoryIDs, attributeNumber);
            bool?  selected    = GetValueFromArray(matrix?.Selected, attributeNumber);
            string error       = GetValueFromArray(matrix?.Errors, attributeNumber);

            ret.Enabled    = (inventoryId == null && AllAdditionalAttributesArePopulated());
            ret.Error      = error;
            ret.ErrorLevel = string.IsNullOrEmpty(error) ? PXErrorLevel.Undefined : PXErrorLevel.Warning;

            var anyMatrixRow = matrix ?? this.GetFirstMatrixRow();

            if (attributeNumber < anyMatrixRow?.ColAttributeValueDescrs?.Length)
            {
                ret.DisplayName = anyMatrixRow.ColAttributeValueDescrs[attributeNumber] ?? anyMatrixRow.ColAttributeValues[attributeNumber];
                ret.Visibility  = PXUIVisibility.Visible;
                ret.Visible     = true;
            }
            else
            {
                ret.DisplayName = null;
                ret.Visibility  = PXUIVisibility.Invisible;
                ret.Visible     = false;
            }

            e.ReturnState = ret;
            e.ReturnValue = selected;
        }
        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 virtual void AttributeValueFieldSelecting(int attributeNumber, PXFieldSelectingEventArgs e, string fieldName)
        {
            PXFieldState state = PXFieldState.CreateInstance(e.ReturnState, typeof(string), false, true, 1, null, null, null, fieldName);

            e.ReturnState = state;

            if (attributeNumber < AdditionalAttributes.Current.ViewNames?.Length)
            {
                e.ReturnValue         = GetAttributeValue(e.Row, attributeNumber);
                state.DisplayName     = AdditionalAttributes.Current.AttributeDisplayNames[attributeNumber];
                state.Visible         = true;
                state.Visibility      = PXUIVisibility.Visible;
                state.Enabled         = true;
                state.ViewName        = AdditionalAttributes.Current.ViewNames[attributeNumber];
                state.DescriptionName = nameof(CSAttributeDetail.description);
                state.FieldList       = new string[] { nameof(CSAttributeDetail.valueID), nameof(CSAttributeDetail.description) };
                var attributeDetailCache = Base.Caches <CSAttributeDetail>();
                state.HeaderList = new string[] { PXUIFieldAttribute.GetDisplayName <CSAttributeDetail.valueID>(attributeDetailCache),
                                                  PXUIFieldAttribute.GetDisplayName <CSAttributeDetail.description>(attributeDetailCache) };
            }
            else
            {
                state.Value       = null;
                e.ReturnValue     = null;
                state.DisplayName = null;
                state.Visible     = false;
                state.Visibility  = PXUIVisibility.Invisible;
                state.Enabled     = false;
                state.ViewName    = null;
            }
        }
Esempio n. 5
0
        protected virtual void PMTask_CompletedPct_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            PMTask row = e.Row as PMTask;

            if (row != null)
            {
                PXSelectBase <PMProjectStatus> select = new PXSelectGroupBy <PMProjectStatus,
                                                                             Where <PMProjectStatus.projectID, Equal <Required <PMTask.projectID> >,
                                                                                    And <PMProjectStatus.projectTaskID, Equal <Required <PMTask.taskID> >,
                                                                                         And <PMProjectStatus.isProduction, Equal <True> > > >,
                                                                             Aggregate <GroupBy <PMProjectStatus.accountGroupID,
                                                                                                 GroupBy <PMProjectStatus.projectID,
                                                                                                          GroupBy <PMProjectStatus.projectTaskID,
                                                                                                                   GroupBy <PMProjectStatus.inventoryID,
                                                                                                                            Sum <PMProjectStatus.amount,
                                                                                                                                 Sum <PMProjectStatus.qty,
                                                                                                                                      Sum <PMProjectStatus.revisedAmount,
                                                                                                                                           Sum <PMProjectStatus.revisedQty,
                                                                                                                                                Sum <PMProjectStatus.actualAmount,
                                                                                                                                                     Sum <PMProjectStatus.actualQty> > > > > > > > > > > >(this);

                PMProjectStatus ps = select.Select(row.ProjectID, row.TaskID);

                if (ps != null)
                {
                    if (ps.RevisedQty > 0)
                    {
                        e.ReturnValue = Convert.ToInt32(100 * ps.ActualQty / ps.RevisedQty);
                        e.ReturnState = PXFieldState.CreateInstance(e.ReturnValue, typeof(decimal?), false, false, 0, 0, 0, 0, "CompletedPct", null, null, null, PXErrorLevel.Undefined, false, true, true, PXUIVisibility.Visible, null, null, null);
                    }
                }
            }
        }
Esempio n. 6
0
 protected virtual void AnyFieldSelecting(PXCache sender, PXFieldSelectingEventArgs e, string fieldName)
 {
     if (sender.GetFieldOrdinal(fieldName) < 0)
     {
         e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(string), visible: false);
     }
 }
        public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            if (!PXAccess.FeatureInstalled <FeaturesSet.gDPRCompliance>() || e.Row == null)
            {
                return;
            }

            var isOptedIn = sender.GetValue(e.Row, nameof(IConsentable.ConsentAgreement)) as bool?;

            var status = sender.GetStatus(e.Row);

            if (isOptedIn != true && status != PXEntryStatus.Inserted)
            {
                e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, null, null, null, null, null, null, null, null, null, null,
                                                            Messages.NoConsent,
                                                            PXErrorLevel.Warning,
                                                            null, null, null, PXUIVisibility.Undefined, null, null, null);
            }
            else
            {
                e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, null, null, null, null, null, null, null, null, null, null,
                                                            null,
                                                            PXErrorLevel.Undefined,
                                                            null, null, null, PXUIVisibility.Undefined, null, null, null);
            }
        }
Esempio n. 8
0
 private PXFieldState GetFieldState(PXFieldSelectingEventArgs args, string viewName, string[] fieldList,
                                    string[] headerList)
 {
     return(PXFieldState.CreateInstance(args.ReturnState, null, null, null,
                                        null, null, null, null, _FieldName, null, null, null, PXErrorLevel.Undefined, null, null, null,
                                        PXUIVisibility.Undefined, viewName, fieldList, headerList));
 }
Esempio n. 9
0
        private void DescriptionFieldSelecting(PXCache cache, PXFieldSelectingEventArgs args)
        {
            var info = GetDescription(cache, args.Row);

            args.ReturnState = PXFieldState.CreateInstance(info, typeof(string), null, null, null, null, null,
                                                           null, descriptionFieldName, null, descriptionFieldName, null, PXErrorLevel.Undefined, false,
                                                           !string.IsNullOrEmpty(info), null, PXUIVisibility.Invisible);
        }
Esempio n. 10
0
        private void GenerateDynamicColumns(CRMerge row)
        {
            var dacInfo = MergeMaint.ReadProperties(row);

            if (dacInfo == null)
            {
                return;
            }

            foreach (MergeMaint.FieldInfo field in dacInfo)
            {
                var fieldName = field.Name;
                if (typeof(DacBase.selected).Name.Equals(fieldName, StringComparison.OrdinalIgnoreCase) ||
                    Items.Cache.Fields.Contains(fieldName))
                {
                    continue;
                }

                var desciptionFieldName = fieldName + "_description";
                Items.Cache.Fields.Add(fieldName);
                Items.Cache.Fields.Add(desciptionFieldName);

                var displayName = field.Label;
                FieldSelecting.AddHandler(typeof(DacBase), fieldName,
                                          delegate(PXCache sender, PXFieldSelectingEventArgs e)
                {
                    e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(bool), null, null, null, null, null, null,
                                                                fieldName, desciptionFieldName, displayName, null, PXErrorLevel.Undefined, null, null, null, PXUIVisibility.Dynamic, null, null, null);
                });
                FieldSelecting.AddHandler(typeof(DacBase), desciptionFieldName,
                                          delegate(PXCache sender, PXFieldSelectingEventArgs e)
                {
                    //TODO: need implementation
                    e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(string), null, null, null, null, null, null,
                                                                desciptionFieldName, null, displayName, null, PXErrorLevel.Undefined, null, false, null, PXUIVisibility.Invisible, null, null, null);
                    e.ReturnValue = "test value";

                    /*SYData selRow = ((SYData)e.Row);
                     * if (selRow == null || selRow.LineNbr == null)
                     *      return;
                     * if (!this.splittedFieldValues.ContainsKey(selRow.LineNbr))
                     *      this.splittedFieldValues.Add(selRow.LineNbr, selRow.FieldValues.Split('\x0'));
                     * int index = Convert.ToInt32(currfname.Split('_')[1]);
                     * if (index < splittedFieldValues[selRow.LineNbr].Length)
                     *      e.ReturnValue = this.splittedFieldValues[selRow.LineNbr][index];*/
                });

                //TODO: need implementation

                /*this.FieldUpdating.AddHandler("PreparedData", currfname,
                 *      delegate(PXCache sender, PXFieldUpdatingEventArgs updE)
                 *      {
                 *              this.dynamicFieldValues[currfname] = updE.NewValue as string;
                 *      });*/
            }
        }
Esempio n. 11
0
        protected virtual void PMTask_CompletedPercent_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            PMTask row = e.Row as PMTask;

            if (row != null && row.CompletedPctMethod != PMCompletedPctMethod.Manual)
            {
                PXSelectBase <PMCostBudget> select = new PXSelectGroupBy <PMCostBudget,
                                                                          Where <PMCostBudget.projectID, Equal <Required <PMTask.projectID> >,
                                                                                 And <PMCostBudget.projectTaskID, Equal <Required <PMTask.taskID> >,
                                                                                      And <PMCostBudget.isProduction, Equal <True> > > >,
                                                                          Aggregate <
                                                                              GroupBy <PMCostBudget.accountGroupID,
                                                                                       GroupBy <PMCostBudget.inventoryID,
                                                                                                GroupBy <PMCostBudget.uOM,
                                                                                                         Sum <PMCostBudget.amount,
                                                                                                              Sum <PMCostBudget.qty,
                                                                                                                   Sum <PMCostBudget.curyRevisedAmount,
                                                                                                                        Sum <PMCostBudget.revisedQty,
                                                                                                                             Sum <PMCostBudget.actualAmount,
                                                                                                                                  Sum <PMCostBudget.actualQty> > > > > > > > > > >(this);

                PXResultset <PMCostBudget> ps = select.Select(row.ProjectID, row.TaskID);


                if (ps != null)
                {
                    double  percentSum    = 0;
                    Int32   recordCount   = 0;
                    decimal actualAmount  = 0;
                    decimal revisedAmount = 0;
                    foreach (PMCostBudget item in ps)
                    {
                        if (row.CompletedPctMethod == PMCompletedPctMethod.ByQuantity && item.RevisedQty > 0)
                        {
                            recordCount++;
                            percentSum += Convert.ToDouble(100 * item.ActualQty / item.RevisedQty);
                        }
                        else if (row.CompletedPctMethod == PMCompletedPctMethod.ByAmount)
                        {
                            recordCount++;
                            actualAmount  += item.CuryActualAmount.GetValueOrDefault(0);
                            revisedAmount += item.CuryRevisedAmount.GetValueOrDefault(0);
                        }
                    }
                    if (row.CompletedPctMethod == PMCompletedPctMethod.ByAmount)
                    {
                        e.ReturnValue = revisedAmount == 0 ? 0 : Convert.ToDecimal(100 * actualAmount / revisedAmount);
                    }
                    else
                    {
                        e.ReturnValue = Convert.ToDecimal(percentSum) == 0 ? 0 : Convert.ToDecimal(percentSum / recordCount);
                    }
                    e.ReturnState = PXFieldState.CreateInstance(e.ReturnValue, typeof(decimal?), false, false, 0, 2, 0, 0, nameof(PMTask.completedPercent), null, null, null, PXErrorLevel.Undefined, false, true, true, PXUIVisibility.Visible, null, null, null);
                }
            }
        }
        public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            if (e.Row == null || _Condition == null)
            {
                return;
            }

            e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, null, null, null, null, null, null, null, null, null, null, null, PXErrorLevel.Undefined,
                                                        GetConditionResult(sender, e.Row, Condition),
                                                        null, null, PXUIVisibility.Undefined, null, null, null);
        }
        private static void CreateCheckBoxControl(PXFieldSelectingEventArgs args,
                                                  CSAttributeGroup attributeGroup)
        {
            var required = attributeGroup.Required == true
                                ? 1
                                : -1;

            args.ReturnState = PXFieldState.CreateInstance(args.ReturnState, typeof(bool), false, null, required, null,
                                                           null, false, nameof(CSAnswers.value), null, null, null, PXErrorLevel.Undefined, null,
                                                           null, null);
        }
Esempio n. 14
0
        private void AttacheNewFields()
        {
            var cache = Details.Cache;

            cache.Fields.Add(_NAME_FIELD);
            var nameState = PXFieldState.CreateInstance(null, null, null, null, null,
                                                        null, null, null, _NAME_FIELD, null, Messages.Name, null, PXErrorLevel.Undefined, true, true, null,
                                                        PXUIVisibility.Undefined, null, null, null);

            FieldSelecting.AddHandler(cache.GetItemType(), _NAME_FIELD,
                                      (sender, args) =>
            {
                args.ReturnState = nameState;

                var sourceField = ((EPChangesetDetail)args.Row).With(_ => _.SourceField);
                if (string.IsNullOrEmpty(sourceField))
                {
                    return;
                }

                var entityType = GetCurrentEntityType();
                if (entityType == null)
                {
                    return;
                }

                var displayName  = (Caches[entityType].GetStateExt(null, sourceField) as PXFieldState).With(_ => _.DisplayName);
                args.ReturnValue = string.IsNullOrEmpty(displayName) ? sourceField : displayName;
            });
            cache.Fields.Add(_OLDVALUE_FIELD);
            var oldValueState = PXFieldState.CreateInstance(null, null, null, null, null,
                                                            null, null, null, _OLDVALUE_FIELD, null, Messages.OldValue, null, PXErrorLevel.Undefined, true, true, null,
                                                            PXUIVisibility.Undefined, null, null, null);

            FieldSelecting.AddHandler(cache.GetItemType(), _OLDVALUE_FIELD,
                                      (sender, args) =>
            {
                args.ReturnState = oldValueState;
                args.ReturnValue = GetValue(args.Row as EPChangesetDetail, typeof(EPChangesetDetail.oldValue).Name);
            });
            cache.Fields.Add(_NEWVALUE_FIELD);
            var newValueState = PXFieldState.CreateInstance(null, null, null, null, null,
                                                            null, null, null, _NEWVALUE_FIELD, null, Messages.NewValue, null, PXErrorLevel.Undefined, true, true, null,
                                                            PXUIVisibility.Undefined, null, null, null);

            FieldSelecting.AddHandler(cache.GetItemType(), _NEWVALUE_FIELD,
                                      (sender, args) =>
            {
                args.ReturnState = newValueState;
                args.ReturnValue = GetValue(args.Row as EPChangesetDetail, typeof(EPChangesetDetail.newValue).Name);
            });
        }
        protected override void PreliminaryFieldSelecting(PXCache s, PXFieldSelectingEventArgs e, string fieldName)
        {
            var matrix = (EntryMatrix)e.Row;
            var ret    = PXFieldState.CreateInstance(e.ReturnState, typeof(bool), fieldName: fieldName);

            ret.Enabled     = AllAdditionalAttributesArePopulated();
            ret.DisplayName = PXLocalizer.Localize(Messages.SelectRow);
            ret.Visibility  = PXUIVisibility.Visible;
            ret.Visible     = true;

            e.ReturnState = ret;
            e.ReturnValue = matrix?.AllSelected;
        }
        public void TaxCalcMode_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }
            bool?flagValue = (bool?)sender.GetValue(e.Row, _FieldOrdinal);

            if (flagValue == true)
            {
                e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(string), null, null, null, null, null, null, null,
                                                            null, null, null, PXErrorLevel.Undefined, false, null, null, PXUIVisibility.Undefined, null, null, null);
            }
        }
Esempio n. 17
0
        private static void TranID_CATran_BatchNbr_FieldSelectingHendler(PXCache sender, PXFieldSelectingEventArgs e)
        {
            if (e.Row == null || e.IsAltered)
            {
                string       ViewName = null;
                PXCache      cache    = sender.Graph.Caches[typeof(CATran)];
                PXFieldState state    = cache.GetStateExt <CATran.batchNbr>(null) as PXFieldState;
                if (state != null)
                {
                    ViewName = state.ViewName;
                }

                e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, null, false, false, 0, 0, null, null, null, null, null, null, PXErrorLevel.Undefined, false, true, true, PXUIVisibility.Visible, ViewName, null, null);
            }
        }
        public virtual void POOrderRS_CuryID_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            POOrderRS row = (POOrderRS)e.Row;
            APInvoice doc = Base.Document.Current;

            if (row != null && doc != null)
            {
                if (row.CuryID != doc.CuryID)
                {
                    string       fieldName = typeof(POOrderRS.curyID).Name;
                    PXErrorLevel msgLevel  = PXErrorLevel.RowWarning;
                    e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(String), false, null, null, null, null, null, fieldName,
                                                                null, null, AP.Messages.APDocumentCurrencyDiffersFromSourceDocument, msgLevel, null, null, null, PXUIVisibility.Undefined, null, null, null);
                    e.IsAltered = true;
                }
            }
        }
        public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            if (_AttributeLevel == PXAttributeLevel.Item || e.IsAltered)
            {
                object row           = e.Row;
                Type   conditionType = Condition;
                if (row == null || conditionType == null)
                {
                    return;
                }

                var persistingCheck = GetConditionResult(sender, row, conditionType) ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing;
                e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, null, null,
                                                            null, persistingCheck == PXPersistingCheck.Nothing ? (int?)null : 1, null, null,
                                                            null, _FieldName, null, null, null, PXErrorLevel.Undefined, null, null, null, PXUIVisibility.Undefined, null, null, null);
            }
        }
Esempio n. 20
0
        protected virtual void CarrierPluginDetail_Value_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            CarrierPluginDetail row = e.Row as CarrierPluginDetail;

            if (row != null)
            {
                string fieldName = typeof(CarrierPluginDetail.value).Name;

                switch (row.ControlType)
                {
                case CarrierPluginDetail.Combo:
                    List <string> labels = new List <string>();
                    List <string> values = new List <string>();
                    foreach (KeyValuePair <string, string> kv in row.GetComboValues())
                    {
                        values.Add(kv.Key);
                        labels.Add(kv.Value);
                    }
                    e.ReturnState = PXStringState.CreateInstance(e.ReturnState, CarrierDetail.ValueFieldLength, null, fieldName, false, 1, null,
                                                                 values.ToArray(), labels.ToArray(), true, null);
                    break;

                case CarrierPluginDetail.CheckBox:
                    e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(Boolean), false, null, -1, null, null, null, fieldName,
                                                                null, null, null, PXErrorLevel.Undefined, null, null, null, PXUIVisibility.Undefined, null, null, null);
                    break;

                case CarrierPluginDetail.Password:
                    if (e.ReturnState != null)
                    {
                        string strValue  = e.ReturnState.ToString();
                        string encripted = new string('*', strValue.Length);

                        e.ReturnState = PXFieldState.CreateInstance(encripted, typeof(string), false, null, -1, null, null, null, fieldName,
                                                                    null, null, null, PXErrorLevel.Undefined, null, null, null, PXUIVisibility.Undefined, null, null, null);
                    }
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 21
0
        public virtual void POReceiptLineS_ReceiptNbr_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            POReceiptLineS row = (POReceiptLineS)e.Row;
            APInvoice      doc = Base.Document.Current;

            if (row != null && doc != null)
            {
                POOrder order = PXSelect <POOrder, Where <POOrder.orderType, Equal <Required <POOrder.orderType> >, And <POOrder.orderNbr, Equal <Required <POOrder.orderNbr> > > > > .Select(Base, row.POType, row.PONbr);

                if (order != null && order.CuryID != doc.CuryID)
                {
                    string       fieldName = typeof(POReceipt.curyID).Name;
                    PXErrorLevel msgLevel  = PXErrorLevel.RowWarning;
                    e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(String), false, null, null, null, null, null, fieldName,
                                                                null, null, AP.Messages.APDocumentCurrencyDiffersFromSourceDocument, msgLevel, null, null, null, PXUIVisibility.Undefined, null, null, null);
                    e.IsAltered = true;
                }
            }
        }
Esempio n. 22
0
            public override void DescriptionFieldSelecting(
                PXCache sender,
                PXFieldSelectingEventArgs e,
                string alias)
            {
                object obj = sender.GetValue(e.Row, this._FieldName);

                base.DescriptionFieldSelecting(sender, e, alias);
                if (obj == null || e.ReturnValue != null)
                {
                    return;
                }
                using (new PXReadDeletedScope())
                {
                    SOLine soLine = (SOLine)PXSelectBase <SOLine, PXSelect <SOLine, Where <SOLine.noteID, Equal <Required <SOLine.noteID> > > > .Config> .SelectSingleBound(sender.Graph, new object[0], obj);

                    e.ReturnValue = soLine != null ? (object)soLine.OrderNbr : obj;
                    e.ReturnState = (object)PXFieldState.CreateInstance(e.ReturnState, typeof(string), new bool?(false), new bool?(true), fieldName: alias, error: PXLocalizer.Localize("Sales Order line was not found.", typeof(PX.Objects.SO.Messages).FullName), errorLevel: PXErrorLevel.Warning, enabled: new bool?(false), visibility: PXUIVisibility.Visible);
                }
            }
        public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            if (!PXAccess.FeatureInstalled <FeaturesSet.gDPRCompliance>() || e.Row == null)
            {
                return;
            }

            var thisValue = sender.GetValue(e.Row, FieldName);

            if (thisValue == null)
            {
                return;
            }

            var optedInValue = sender.GetValue(e.Row, nameof(IConsentable.ConsentAgreement));

            if (optedInValue == null)
            {
                return;
            }

            var isOptedIn      = (bool)optedInValue;
            var expirationDate = (DateTime?)thisValue;
            var status         = sender.GetStatus(e.Row);

            if (isOptedIn && expirationDate < sender.Graph.Accessinfo.BusinessDate && status != PXEntryStatus.Inserted)
            {
                e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, null, null, null, null, null, null, null, null, null, null,
                                                            Messages.ConsentExpired,
                                                            PXErrorLevel.Warning,
                                                            null, null, null, PXUIVisibility.Undefined, null, null, null);
            }
            else
            {
                e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, null, null, null, null, null, null, null, null, null, null,
                                                            null,
                                                            PXErrorLevel.Undefined,
                                                            null, null, null, PXUIVisibility.Undefined, null, null, null);
            }
        }
        public virtual void InventorySummaryEnquiryResult_LocationID_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e, Action <PXCache, PXFieldSelectingEventArgs> baseMethod)
        {
            string locationName = null;

            switch (e.ReturnValue)
            {
            case null:
                locationName = PXMessages.LocalizeNoPrefix(Messages.Unassigned);
                break;

            case InventorySummaryEnquiryResult.TotalLocationID:
                locationName = PXMessages.LocalizeNoPrefix(Messages.TotalLocation);
                break;

            default:
                locationName = INLocation.PK.Find(Base, e.ReturnValue as int?).With(loc => Base.IsMobile ? loc.Descr : loc.LocationCD);
                break;
            }

            if (locationName != null)
            {
                e.ReturnState = PXFieldState.CreateInstance(locationName, typeof(string), false, null, null, null, null, null,
                                                            nameof(InventorySummaryEnquiryResult.locationID), null, GetLocationDisplayName(), null, PXErrorLevel.Undefined, null, null, null, PXUIVisibility.Undefined, null, null, null);
                e.Cancel = true;
            }

            string GetLocationDisplayName()
            {
                var displayName = PXUIFieldAttribute.GetDisplayName <InventorySummaryEnquiryResult.locationID>(cache);

                if (displayName != null)
                {
                    displayName = PXMessages.LocalizeNoPrefix(displayName);
                }

                return(displayName);
            }
        }
Esempio n. 25
0
        public virtual void POReceipt_ReceiptNbr_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            POReceipt row = (POReceipt)e.Row;
            APInvoice doc = Base.Document.Current;

            if (row != null && doc != null)
            {
                PXResultset <POOrderReceiptLink> receiptLinks = PXSelectGroupBy <POOrderReceiptLink, Where <POOrderReceiptLink.receiptNbr, Equal <Required <POReceipt.receiptNbr> > >,
                                                                                 Aggregate <GroupBy <POOrderReceiptLink.curyID> > > .Select(Base, row.ReceiptNbr);

                if (receiptLinks.Count == 0)
                {
                    return;
                }
                else if (receiptLinks.Count > 1 || ((POOrderReceiptLink)receiptLinks.First()).CuryID != doc.CuryID)
                {
                    string       fieldName = typeof(POReceipt.curyID).Name;
                    PXErrorLevel msgLevel  = PXErrorLevel.RowWarning;
                    e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(String), false, null, null, null, null, null, fieldName,
                                                                null, null, AP.Messages.APDocumentCurrencyDiffersFromSourcePODocument, msgLevel, null, null, null, PXUIVisibility.Undefined, null, null, null);
                    e.IsAltered = true;
                }
            }
        }
        protected virtual void CCProcessingCenterDetail_Value_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            CCProcessingCenterDetail row = e.Row as CCProcessingCenterDetail;

            if (row != null)
            {
                string fieldName = typeof(CCProcessingCenterDetail.value).Name;

                switch (row.ControlType)
                {
                case ControlTypeDefintion.Combo:
                    List <string> labels = new List <string>();
                    List <string> values = new List <string>();
                    foreach (KeyValuePair <string, string> kv in row.GetComboValues())
                    {
                        values.Add(kv.Key);
                        labels.Add(kv.Value);
                    }
                    e.ReturnState = PXStringState.CreateInstance(e.ReturnState, CCProcessingCenterDetail.ValueFieldLength, null, fieldName, false, 1, null,
                                                                 values.ToArray(), labels.ToArray(), true, null);
                    break;

                case ControlTypeDefintion.CheckBox:
                    e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(Boolean), false, null, -1, null, null, null, fieldName,
                                                                null, null, null, PXErrorLevel.Undefined, null, null, null, PXUIVisibility.Undefined, null, null, null);
                    break;

                case ControlTypeDefintion.Password:
                    //handled by PXRSACryptStringWithConditional attribute
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 27
0
 protected override PXFieldState DefaultState(PXCache sender, PXFieldSelectingEventArgs e) => PXFieldState.CreateInstance(e.ReturnState, typeof(bool), fieldName: FieldName);
        private void ReadProperties()
        {
            _propertyNames  = new string[0];
            _propertyLabels = new string[0];
            _propertyStates = new PXFieldState[0];
            _numFields.Clear();
            _dateFields.Clear();
            _stringFields.Clear();

            var fieldStates =
                PXFieldState.GetFields(this, new[] { typeof(Contact) }, false)
                .Where(s => s.Name.EndsWith("_Attributes") || !s.Name.Contains('_')).ToList();

            fieldStates.AddRange(PXFieldState.GetFields(this, new[] { typeof(Address) }, false)
                                 .Where(state => !state.Name.Contains('_') && !fieldStates.Exists(e => e.Name == state.Name || e.DisplayName == state.DisplayName))
                                 .Select(state => PXFieldState.CreateInstance(state, null, null, null, null, null, null, null, typeof(Address).Name + "__" + state.Name, null, null, null, PXErrorLevel.Undefined, null, null, null, PXUIVisibility.Undefined, null, null, null)));

            var properties = new List <PXFieldState>();

            foreach (var state in fieldStates)
            {
                string fieldName = state.Name.Replace(typeof(Address).Name + "__", string.Empty);

                if (fieldName.EndsWith("_Attributes") ||
                    (state.Visibility != PXUIVisibility.Invisible &&
                     state.Visible && !string.IsNullOrEmpty(state.DisplayName) &&
                     !fieldName.Contains('_') &&
                     !properties.Exists(item => item.Name == fieldName || item.DisplayName == state.DisplayName)))
                {
                    properties.Add(state);

                    if (!string.IsNullOrEmpty(state.ViewName) && !Views.ContainsKey(state.ViewName))
                    {
                        Views.Add(state.ViewName, this.FilteredItems.View);
                    }
                    switch (Type.GetTypeCode(state.DataType))
                    {
                    case TypeCode.Byte:
                    case TypeCode.Int16:
                    case TypeCode.Int32:
                    case TypeCode.Int64:
                    case TypeCode.UInt16:
                    case TypeCode.UInt32:
                    case TypeCode.UInt64:
                    case TypeCode.Single:
                    case TypeCode.Double:
                    case TypeCode.Decimal:
                        _numFields.Add(state.Name);
                        break;

                    case TypeCode.DateTime:
                        _dateFields.Add(state.Name);
                        break;

                    case TypeCode.String:
                    case TypeCode.Char:
                        _stringFields.Add(state.Name);
                        break;
                    }
                }
            }
            _propertyNames  = new string[properties.Count];
            _propertyLabels = new string[properties.Count];
            _propertyStates = new PXFieldState[properties.Count];
            //properties.Sort((fs1, fs2) => String.Compare(String.Concat(fs1.DisplayName, "$", fs1.Name), String.Concat(fs2.DisplayName, "$", fs2.Name)));
            for (int i = 0; i < properties.Count; i++)
            {
                PXFieldState state = properties[i];
                _propertyNames[i]  = state.Name;
                _propertyLabels[i] = state.DisplayName;
                _propertyStates[i] = state;
            }

            MakeEqualLabelsDistinct();
        }
            public static PXFieldState CreateFieldState(string fieldName, string description, int ctype, string entryMask, string list)
            {
                uint   msgnum;
                string msgprefix;
                string displayName = string.Format("${0}$-{1}", PXMessages.Localize(ActionsMessages.Attributes, out msgnum, out msgprefix),
                                                   description);
                PXFieldState fs = null;

                switch (ctype)
                {
                case 1:
                {
                    fs             = PXStringState.CreateInstance(null, null, null, fieldName, null, null, entryMask, null, null, null, null);
                    fs.Visibility  = PXUIVisibility.Dynamic;
                    fs.DisplayName = displayName;
                    fs.Enabled     = false;
                    fs.Visible     = false;
                    break;
                }

                case 2:
                case 6:
                {
                    List <string> vals = new List <string>();
                    List <string> lbls = new List <string>();
                    if (!String.IsNullOrEmpty(list))
                    {
                        foreach (string elem in list.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            string[] pair = elem.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
                            if (pair.Length > 0)
                            {
                                vals.Add(pair[0]);
                                if (pair.Length > 1)
                                {
                                    lbls.Add(pair[1]);
                                }
                                else
                                {
                                    lbls.Add(pair[0]);
                                }
                            }
                        }
                    }
                    fs             = PXStringState.CreateInstance(null, null, null, fieldName, null, null, null, vals.ToArray(), lbls.ToArray(), true, null);
                    fs.Visibility  = PXUIVisibility.Dynamic;
                    fs.DisplayName = displayName;
                    fs.Enabled     = false;
                    fs.Visible     = false;
                    if (ctype == 6)
                    {
                        ((PXStringState)fs).MultiSelect = true;
                    }
                    break;
                }

                case 4:
                {
                    fs = PXFieldState.CreateInstance(null, typeof(Boolean), null, null, -1, null, null, null, fieldName, null, displayName, null, PXErrorLevel.Undefined, false, false, null, PXUIVisibility.Dynamic, null, null, null);
                    break;
                }

                case 5:
                {
                    fs             = PXDateState.CreateInstance(null, fieldName, null, null, "d", "d", null, null);
                    fs.Visibility  = PXUIVisibility.Dynamic;
                    fs.DisplayName = displayName;
                    fs.Enabled     = false;
                    fs.Visible     = false;
                    break;
                }
                }
                return(fs);
            }
Esempio n. 30
0
            private void AddNewInjection(PXCache target, string specificModule)
            {
                var graph = target.Graph;

                foreach (PX.SM.RelationGroup group in PXSelect <PX.SM.RelationGroup,
                                                                Where <PX.SM.RelationGroup.specificModule, Equal <Required <Dimension.specificModule> >,
                                                                       And <PX.SM.RelationGroup.specificType, Equal <Required <PX.SM.RelationGroup.specificType> > > > >
                         .Select(graph, specificModule, typeof(SegmentValue).FullName))
                {
                    string name = @group.GroupName;
                    byte[] mask = @group.GroupMask;
                    if (!target.Fields.Contains(name) && mask != null)
                    {
                        PXFieldSelecting fieldSelectingHandler = delegate(PXCache cache, PXFieldSelectingEventArgs a)
                        {
                            a.ReturnState = PXFieldState.CreateInstance(a.ReturnState, typeof(Boolean), null, null, null, null, null, null, name, null, null, null, PXErrorLevel.Undefined, null, null, null, PXUIVisibility.Dynamic, null, null, null);
                            SegmentValue value = (SegmentValue)a.Row;
                            if (value != null)
                            {
                                a.ReturnValue = false;
                                if (value.GroupMask != null)
                                {
                                    for (int i = 0; i < value.GroupMask.Length && i < mask.Length; i++)
                                    {
                                        if (mask[i] != 0x00 && (mask[i] & value.GroupMask[i]) == mask[i])
                                        {
                                            a.ReturnValue = true;
                                            return;
                                        }
                                    }
                                }
                            }
                        };
                        PXFieldUpdating fieldUpdatingHandler = delegate(PXCache cache, PXFieldUpdatingEventArgs a)
                        {
                            SegmentValue value = (SegmentValue)a.Row;
                            if (value != null && a.NewValue != null)
                            {
                                bool included = false;
                                if (a.NewValue is string)
                                {
                                    bool.TryParse((string)a.NewValue, out included);
                                }
                                else
                                {
                                    included = (bool)a.NewValue;
                                }
                                if (value.GroupMask == null)
                                {
                                    value.GroupMask = new byte[mask.Length];
                                }
                                else if (value.GroupMask.Length < mask.Length)
                                {
                                    byte[] arr = value.GroupMask;
                                    Array.Resize <byte>(ref arr, mask.Length);
                                    value.GroupMask = arr;
                                }
                                for (int i = 0; i < mask.Length; i++)
                                {
                                    if (mask[i] != 0x00)
                                    {
                                        if (included)
                                        {
                                            value.GroupMask[i] = (byte)(value.GroupMask[i] | mask[i]);
                                        }
                                        else
                                        {
                                            value.GroupMask[i] = (byte)(value.GroupMask[i] & ~mask[i]);
                                        }
                                        if (target.Locate(value) != null && target.GetStatus(value) == PXEntryStatus.Notchanged)
                                        {
                                            target.SetStatus(value, PXEntryStatus.Updated);
                                        }
                                        return;
                                    }
                                }
                            }
                        };
                        _items.Add(new Box(name, fieldSelectingHandler, fieldUpdatingHandler));
                        target.Fields.Add(name);
                        graph.FieldSelecting.AddHandler(typeof(SegmentValue), name, fieldSelectingHandler);
                        graph.FieldUpdating.AddHandler(typeof(SegmentValue), name, fieldUpdatingHandler);
                    }
                }
            }