コード例 #1
0
ファイル: GLBudgetTreeMaint.cs プロジェクト: mperry246/CAMP
        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'));
        }
コード例 #2
0
        protected virtual void EPAssignmentRule_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            EPAssignmentRule oldRow = e.OldRow as EPAssignmentRule;
            EPAssignmentRule newRow = e.Row as EPAssignmentRule;

            if (oldRow != null && newRow != null)
            {
                if (!String.Equals(newRow.Entity, oldRow.Entity, StringComparison.OrdinalIgnoreCase))
                {
                    newRow.FieldName = newRow.FieldValue = null;
                }
                if (!String.Equals(newRow.FieldName, oldRow.FieldName, StringComparison.OrdinalIgnoreCase))
                {
                    newRow.FieldValue = null;
                }
                EPAssignmentRule row = e.Row as EPAssignmentRule;

                if (row.Condition == null || (PXCondition)row.Condition == PXCondition.ISNULL || (PXCondition)row.Condition == PXCondition.ISNOTNULL)
                {
                    newRow.FieldValue = null;
                }
                if (newRow.FieldValue == null)
                {
                    PXFieldState state = sender.GetStateExt <EPAssignmentRule.fieldValue>(newRow) as PXFieldState;
                    newRow.FieldValue = state != null && state.Value != null?state.Value.ToString() : null;
                }
            }
        }
コード例 #3
0
        protected virtual void CSAttribute_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            CSAttribute row = e.Row as CSAttribute;

            if (row != null)
            {
                if (string.IsNullOrEmpty(row.Description))
                {
                    if (sender.RaiseExceptionHandling <CSAttribute.description>(e.Row, row.Description, new PXSetPropertyException(Data.ErrorMessages.FieldIsEmpty, typeof(CSAttribute.description).Name)))
                    {
                        throw new PXSetPropertyException(typeof(CSAttribute.description).Name, null, Data.ErrorMessages.FieldIsEmpty, typeof(CSAttribute.description).Name);
                    }
                }
                if (!ValidateAttributeID(sender, row))
                {
                    var displayName = ((PXFieldState)sender.GetStateExt(row, typeof(CSAttribute.attributeID).Name)).DisplayName;
                    if (string.IsNullOrEmpty(displayName))
                    {
                        displayName = typeof(CSAttribute.attributeID).Name;
                    }
                    throw new PXSetPropertyException(
                              string.Concat(displayName, ": ", PXUIFieldAttribute.GetError <CSAttribute.attributeID>(sender, row)));
                }
            }
        }
コード例 #4
0
        private PXFieldState GetPXFieldState(Type cachetype, string fieldName)
        {
            PXCache cache = this.Caches[cachetype];

            PXDBAttributeAttribute.Activate(cache);
            return(cache.GetStateExt(null, fieldName) as PXFieldState);
        }
コード例 #5
0
        private string GetSublevelName(Guid?refNoteID)
        {
            EntityHelper entityHelper     = new EntityHelper(this);
            object       entityRow        = entityHelper.GetEntityRow(refNoteID, true);
            Type         primaryGraphType = entityHelper.GetPrimaryGraphType(entityRow, false);

            if (primaryGraphType == null || entityRow == null)
            {
                return(null);
            }

            var     screenID    = PXSiteMap.Provider.FindSiteMapNode(primaryGraphType).ScreenID;
            PXCache entityCache = this.Caches[entityRow.GetType()];

            var folderNameBuilder = new StringBuilder();
            var fieldGroupings    = FieldsGroupingByScreenID.Select(screenID).Select(x => (BoxScreenGroupingFields)x);

            if (!fieldGroupings.Any())
            {
                return(null);
            }

            foreach (var field in fieldGroupings)
            {
                var value = entityCache.GetStateExt(entityRow, field.FieldName);
                folderNameBuilder.Append(ScreenUtils.UnwrapValue(value)).Append(' ');
            }

            var subLevelName = folderNameBuilder.ToString().Trim();

            return(string.IsNullOrEmpty(subLevelName) ? Messages.UndefinedGrouping : subLevelName);
        }
コード例 #6
0
        public static Tuple <IEnumerable <string>, IEnumerable <string> > GetPossibleValues <T>(PXGraph graph, IEnumerable <T> entities, string fieldName)
            where T : IBqlTable
        {
            PXCache cache = graph.Caches[typeof(T)];

            return(entities.Cast <object>()
                   .Select(entity => cache.GetStateExt(entity, fieldName))
                   .Cast <PXFieldState>()
                   .Select(st =>
            {
                string value = null;
                string label = string.Empty;

                if (st != null)
                {
                    var stringState = st as PXStringState;
                    value = st.Value != null ? st.Value.ToString() : null;

                    if (stringState != null && stringState.AllowedValues != null)
                    {
                        int i = Array.IndexOf(stringState.AllowedValues, value);
                        label = (i == -1) ? value : stringState.AllowedLabels[i];
                    }
                }

                return new[] { value != null ? new Tuple <string, string>(value, label) : new Tuple <string, string>(null, string.Empty) };
            })
                   .SelectMany(z => z.Select(entry => entry))
                   .GroupBy(z => z.Item1)
                   .Select(g => new Tuple <string, string>(g.Key, g.First(z => z.Item1 == g.Key).Item2))
                   .OrderBy(pair => pair.Item1)
                   .UnZip());
        }
コード例 #7
0
        protected virtual void EPRuleEmployeeCondition_FieldName_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            EPRuleEmployeeCondition row = e.Row as EPRuleEmployeeCondition;

            if (row == null)
            {
                return;
            }

            Type cachetype = GraphHelper.GetType(row.Entity);

            if (cachetype == null)
            {
                return;
            }

            PXCache cache = this.Caches[cachetype];

            PXDBAttributeAttribute.Activate(cache);
            PXFieldState state = cache.GetStateExt(null, e.NewValue.ToString()) as PXFieldState;

            if (state == null)
            {
                throw new PXException(Messages.FieldCannotBeFound);
            }
        }
コード例 #8
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);
            }
        }
        private static Dictionary <string, List <string> > GetPropertyLabelsPairs(PXCache cache, Dictionary <string, List <object> > valuesDic, Type valuesType)
        {
            PXCache       propertiesCache = cache.BqlTable == valuesType ? cache : cache.Graph.Caches[valuesType];
            List <string> properties      = propertiesCache.Fields;
            Dictionary <string, List <string> > labelsDic =
                new Dictionary <string, List <string> >(properties.Count);

            CRListAttributesHelper currentListHelper;

            foreach (string field in properties)
            {
                PXFieldState state = propertiesCache.GetStateExt(null, field) as PXFieldState;
                if (state == null || !state.Enabled)
                {
                    continue;
                }

                if (!labelsDic.ContainsKey(field) && valuesDic.ContainsKey(field) &&
                    (currentListHelper = CRListAttributesHelper.CreateFrom(cache.Graph, propertiesCache, field)) != null)
                {
                    labelsDic.Add(field, currentListHelper.GetLabels(valuesDic[field]));
                }
            }
            return(labelsDic);
        }
コード例 #10
0
    public override object Evaluate(PXCache cache, object item,
                                    Dictionary <Type, object> pars)
    {
        PXFieldState fState = cache.GetStateExt <StringField>(item) as PXFieldState;

        return(GetSortOrderValueExt(Convert.ToString(fState.Value)));
    }
コード例 #11
0
ファイル: GLBudgetTreeMaint.cs プロジェクト: mperry246/CAMP
 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(' ', '?');
     }
 }
コード例 #12
0
        public static void CheckReportSettingsEditableAndSetWarningTo <TVendorIDField>(PXGraph graph, PXCache cache, object row, int?vendorID)
            where TVendorIDField : IBqlField
        {
            if (TaxYearMaint.PrepearedTaxPeriodForVendorExists(graph, vendorID))
            {
                var bAccIDfieldState = (PXFieldState)cache.GetStateExt <TVendorIDField>(row);

                cache.RaiseExceptionHandling <TVendorIDField>(row, bAccIDfieldState.Value,
                                                              new PXSetPropertyException(Messages.TheTaxReportSettingsCannotBeModified, PXErrorLevel.Warning));
            }
        }
コード例 #13
0
        protected override List <Tuple <string, object> > CollectValues(PXCache sender, PXRowSelectedEventArgs e)
        {
            PXCache <FieldValue> fvcache = sender.Graph.Caches <FieldValue>();

            return((fvcache.Inserted.OfType <FieldValue>()
                    .Where(f => f.Hidden != true && f.Selected == true)
                    .OrderBy(f => f.Order)
                    .Select(field => new { field, state = fvcache.GetStateExt <FieldValue.value>(field) as PXFieldState })
                    .Where(@t => @t.state != null)
                    .Select(@t => new Tuple <string, object>(@t.field.DisplayName, StateValue(@t.state as PXStringState) ?? StateValue(@t.state as PXIntState) ?? @t.state.Value))).ToList());
        }
コード例 #14
0
        public static bool IsHigherErrorLevelExist <T>(PXCache cache, object row, PXErrorLevel errorLevel)
            where T : IBqlField
        {
            PXFieldState state = (PXFieldState)cache.GetStateExt <T>(row);

            if (state.ErrorLevel > errorLevel)
            {
                return(true);
            }

            return(false);
        }
コード例 #15
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);
        }
コード例 #16
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;
        }
コード例 #17
0
        protected virtual void APPayment_RowUpdating(PXCache sender, PXRowUpdatingEventArgs e)
        {
            APPayment row = e.NewRow as APPayment;

            if (row != null && row.Selected == true)
            {
                PXFieldState state = (PXFieldState)sender.GetStateExt <APPayment.extRefNbr>(row);
                if (state != null && !string.IsNullOrEmpty(state.Error))
                {
                    row.Selected = false;
                }
            }
        }
コード例 #18
0
        public static int GetRowMessages(PXCache cache, object row, List <string> errors, List <string> warnings, bool includeRowInfo)
        {
            if (cache == null || row == null)
            {
                return(0);
            }

            int          errorCount = 0;
            PXFieldState fieldState;

            foreach (string field in cache.Fields)
            {
                try
                {
                    fieldState = (PXFieldState)cache.GetStateExt(row, field);
                }
                catch
                {
                    fieldState = null;
                }

                if (fieldState != null && fieldState.Error != null)
                {
                    if (errors != null)
                    {
                        if (fieldState.ErrorLevel != PXErrorLevel.RowWarning &&
                            fieldState.ErrorLevel != PXErrorLevel.Warning &&
                            fieldState.ErrorLevel != PXErrorLevel.RowInfo
                            )
                        {
                            errors.Add(fieldState.Error);
                            errorCount++;
                        }
                    }

                    if (warnings != null)
                    {
                        if (fieldState.ErrorLevel == PXErrorLevel.RowWarning ||
                            fieldState.ErrorLevel == PXErrorLevel.Warning ||
                            (fieldState.ErrorLevel == PXErrorLevel.RowInfo && includeRowInfo == true)
                            )
                        {
                            warnings.Add(fieldState.Error);
                        }
                    }
                }
            }

            return(errorCount);
        }
コード例 #19
0
        protected virtual void SimpleCase_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            var row = e.Row as SimpleCase;

            if (row == null)
            {
                return;
            }

            row.StatusDescription = "unknown";
            if (!string.IsNullOrEmpty(row.Status))
            {
                var statusState = cache.GetStateExt(row, typeof(SimpleCase.status).Name) as PXStringState;
                if (statusState != null && statusState.AllowedLabels != null && statusState.AllowedValues != null)
                {
                    var index = Array.FindIndex(statusState.AllowedValues, 0, s => string.Compare(s, row.Status, StringComparison.OrdinalIgnoreCase) == 0);
                    if (index > -1)
                    {
                        row.StatusDescription = statusState.AllowedLabels[index];
                    }
                }
            }

            row.ResolutionDescription = string.Empty;
            if (!string.IsNullOrEmpty(row.Resolution))
            {
                var resolutionState = cache.GetStateExt(row, typeof(SimpleCase.resolution).Name) as PXStringState;
                if (resolutionState != null && resolutionState.AllowedLabels != null && resolutionState.AllowedValues != null)
                {
                    var index = Array.FindIndex(resolutionState.AllowedValues, 0, s => string.Compare(s, row.Status, StringComparison.OrdinalIgnoreCase) == 0);
                    if (index > -1)
                    {
                        row.ResolutionDescription = resolutionState.AllowedLabels[index];
                    }
                }
            }
        }
コード例 #20
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);
            }
        }
コード例 #21
0
        private static void DatesSwapper <TExport, TImport>(PXCache cache, PXFieldUpdatedEventArgs e)
            where TExport : IBqlField
            where TImport : IBqlField
        {
            EMailSyncAccount row = e.Row as EMailSyncAccount;

            if (row == null)
            {
                return;
            }

            var state = cache.GetStateExt(row, typeof(TExport).Name) as PXFieldState;

            cache.SetValue <TImport>(row, state?.Value);
        }
コード例 #22
0
        public static IEnumerable <FieldValue> GetAttributeProperties(PXGraph graph, ref int firstSortOrder, List <string> suffixes)
        {
            int order = firstSortOrder;

            GetAttributeSuffixes(graph, ref suffixes);

            List <FieldValue> res   = new List <FieldValue>();
            PXCache           cache = graph.Caches[typeof(TMain)];

            foreach (string field in cache.Fields)
            {
                if (!suffixes.Any(suffix => field.EndsWith(string.Format("_{0}", suffix))))
                {
                    continue;
                }

                PXFieldState state = cache.GetStateExt(null, field) as PXFieldState;

                if (state == null)
                {
                    continue;
                }

                string displayName = state.DisplayName;
                string attrID      = field;
                string local       = field;

                foreach (string suffix in suffixes.Where(suffix => local.EndsWith(string.Format("_{0}", suffix))))
                {
                    attrID      = field.Replace(string.Format("_{0}", suffix), string.Empty);
                    displayName = state.DisplayName.Replace(string.Format("${0}$-", suffix), string.Empty);
                    break;
                }

                res.Add(new FieldValue
                {
                    Selected    = false,
                    CacheName   = typeof(TMain).FullName,
                    Name        = field,
                    DisplayName = displayName,
                    AttributeID = attrID,
                    Order       = order++ + 1000
                });
            }

            firstSortOrder = order;
            return(res);
        }
コード例 #23
0
        static string GetFieldDescription(PXCache cache, object row, Type fieldType, object[] keys)
        {
            string description = cache.DisplayName;

            if (keys.Any())
            {
                description += KeysSeparator + string.Join(KeysSeparator, keys);
            }

            description += FieldSeparator;

            PXFieldState state = (PXFieldState)cache.GetStateExt(row, fieldType.Name);

            description += state.DisplayName;

            return(description);
        }
コード例 #24
0
        public virtual void GLTran_RowSelected(PXCache sender, PXRowSelectedEventArgs e, Batch batch)
        {
            var tran = e.Row as GLTran;

            JournalEntry.SetReclassTranWarningsIfNeed(sender, tran);

            SetGLTranRefNbrRequired(tran, batch);

            if (ShouldCreateTaxTrans(batch))
            {
                PXFieldState state = (PXFieldState)sender.GetStateExt <GLTran.taxID>(tran);                //Needed to prevent error from being overriden by warning
                if (String.IsNullOrEmpty(state.Error) || state.IsWarning == true)
                {
                    WarnIfMissingTaxID(tran);
                }
            }

            tran.IncludedInReclassHistory = JournalEntry.CanShowReclassHistory(tran, batch.BatchType);
        }
コード例 #25
0
        private void updateOtherSiblings(PXCache sender, object row)
        {
            bool needRefresh = false;

            if (_parentAttribute == null)
            {
                return;
            }
            PXFieldState state = (PXFieldState)sender.GetStateExt(row, _FieldName);

            if (state.DataType != typeof(bool))
            {
                return;
            }
            if ((bool?)sender.GetValue(row, _FieldName) == false)
            {
                return;
            }
            foreach (object sibling in PXParentAttribute.SelectSiblings(sender, row, _parentAttribute.ParentType))
            {
                if (!sender.ObjectsEqual(sibling, row))
                {
                    if ((bool?)sender.GetValue(sibling, _FieldName) == true)
                    {
                        sender.SetValue(sibling, _FieldName, false);
                        sender.Update(sibling);
                        needRefresh = true;
                    }
                }
            }

            if (needRefresh)
            {
                foreach (var kvp in sender.Graph.Views)
                {
                    PXView view = kvp.Value;
                    if (_BqlTable.IsAssignableFrom(view.GetItemType()))
                    {
                        view.RequestRefresh();
                    }
                }
            }
        }
コード例 #26
0
        protected virtual void INUnit_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            INUnit       row   = (INUnit)e.Row;
            PXFieldState state = (PXFieldState)sender.GetStateExt <INUnit.fromUnit>(row);
            uint         msgNbr;
            String       msqPrefix;

            if (Item.Current != null && row.ToUnit == Item.Current.BaseUnit && (state.Error == null || state.Error == PXMessages.Localize(Messages.BaseUnitNotSmallest, out msgNbr, out msqPrefix) || state.ErrorLevel == PXErrorLevel.RowInfo))
            {
                if (row.UnitMultDiv == MultDiv.Multiply && row.UnitRate < 1 || row.UnitMultDiv == MultDiv.Divide && row.UnitRate > 1)
                {
                    sender.RaiseExceptionHandling <INUnit.fromUnit>(row, row.FromUnit, new PXSetPropertyException(Messages.BaseUnitNotSmallest, PXErrorLevel.RowWarning));
                }
                else
                {
                    sender.RaiseExceptionHandling <INUnit.fromUnit>(row, row.FromUnit, null);
                }
            }
        }
コード例 #27
0
        public static IEnumerable <FieldValue> GetMarkedProperties(PXGraph graph, ref int firstSortOrder)
        {
            PXCache           cache = graph.Caches[typeof(TPrimary)];
            int               order = firstSortOrder;
            List <FieldValue> res   = (cache.Fields.Where(
                                           fieldname => cache.GetAttributesReadonly(fieldname).OfType <TMarkAttribute>().Any())
                                       .Select(fieldname => new { fieldname, state = cache.GetStateExt(null, fieldname) as PXFieldState })
                                       .Where(@t => @t.state != null)
                                       .Select(@t => new FieldValue()
            {
                Selected = false,
                CacheName = typeof(TPrimary).FullName,
                Name = @t.fieldname,
                DisplayName = @t.state.DisplayName,
                AttributeID = null,
                Order = order++
            })).ToList();

            firstSortOrder = order;
            return(res);
        }
コード例 #28
0
        public static void SetValueExtIfDifferent <Field>(this PXCache cache, object data, object newValue, bool verifyAcceptanceOfNewValue = true)
            where Field : IBqlField
        {
            object currentValue = cache.GetValue <Field>(data);

            if ((currentValue == null && newValue != null) ||
                (currentValue != null && newValue == null) ||
                (currentValue != null && currentValue.Equals(newValue) == false))
            {
                cache.SetValueExt <Field>(data, newValue);

                if (verifyAcceptanceOfNewValue)
                {
                    currentValue = cache.GetValue <Field>(data);

                    if (AreEquivalentValues(currentValue, newValue) == false)
                    {
                        PXFieldState fieldState;
                        string       fieldMessage = string.Empty;

                        try
                        {
                            fieldState = (PXFieldState)cache.GetStateExt <Field>(data);
                        }
                        catch
                        {
                            fieldState = null;
                        }

                        if (fieldState != null && fieldState.Error != null)
                        {
                            fieldMessage = fieldState.Error;
                        }

                        throw new PXException(TX.Messages.ERROR_TRYING_TO_SET_A_NEWVALUE, PXUIFieldAttribute.GetDisplayName <Field>(cache), fieldMessage);
                    }
                }
            }
        }
コード例 #29
0
        private PXFieldState CreateFieldStateForFieldValue(object returnState, string entityType, string cacheName, string fieldName)
        {
            Type type = GraphHelper.GetType(entityType);

            if (type != null)
            {
                Type cachetype = GraphHelper.GetType(cacheName);
                if (cachetype == null)
                {
                    return(null);
                }

                PXCache cache = this.Caches[cachetype];
                PXDBAttributeAttribute.Activate(cache);
                PXFieldState state = cache.GetStateExt(null, fieldName) as PXFieldState;
                if (state != null)
                {
                    if (returnState == null)
                    {
                        object item = cache.CreateInstance();
                        object newValue;
                        cache.RaiseFieldDefaulting(fieldName, item, out newValue);
                        if (newValue != null)
                        {
                            cache.RaiseFieldSelecting(fieldName, item, ref newValue, false);
                        }
                        state.Value = newValue;
                    }
                    else
                    {
                        state.Value = returnState;
                    }
                    state.Enabled = true;
                }
                return(state);
            }
            return(null);
        }
コード例 #30
0
        protected virtual void EPRuleCondition_FieldName_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            EPRuleCondition condition = (EPRuleCondition)e.Row;

            Type type = GraphHelper.GetType(AssigmentMap.Current.EntityType);

            if (type != null)
            {
                Type cachetype = GraphHelper.GetType(condition.Entity);
                if (cachetype == null)
                {
                    return;
                }

                PXCache cache = this.Caches[cachetype];
                PXDBAttributeAttribute.Activate(cache);
                PXFieldState state = cache.GetStateExt(null, e.NewValue.ToString()) as PXFieldState;
                if (state == null)
                {
                    throw new PXException(Messages.FieldCannotBeFound);
                }
            }
        }