Exemplo n.º 1
0
        /// <summary>
        /// Creates the edit field.
        /// </summary>
        /// <returns><see cref="UPMEditField"/></returns>
        public override UPMEditField CreateEditField()
        {
            var field = new UPMRecordSelectorEditField(this.FieldIdentifier);

            this.ApplyAttributesOnEditFieldConfig(field, this.FieldConfig);
            if (this.Selector != null)
            {
                field.SelectorArray = new List <UPRecordSelector> {
                    this.Selector
                };
                field.Delegate = this;
            }

            field.ContinuousUpdate = true;
            this.Catalog           = null;
            if (this.FieldConfig.Field.FieldType == "K")
            {
                this.Catalog = UPCRMDataStore.DefaultStore.CatalogForVariableCatalogId(this.FieldConfig.Field.CatNo);
            }
            else if (this.FieldConfig.Field.FieldType == "X")
            {
                this.Catalog = UPCRMDataStore.DefaultStore.CatalogForFixedCatalogId(this.FieldConfig.Field.CatNo);
            }

            return(field);
        }
        /// <summary>
        /// Users the did change record selector edit field call depth.
        /// </summary>
        /// <param name="field">
        /// The field.
        /// </param>
        /// <param name="callDepth">
        /// The call depth.
        /// </param>
        public void UserDidChangeRecordSelectorEditFieldCallDepth(UPMRecordSelectorEditField field, int callDepth)
        {
            var selector    = field.CurrentSelector;
            var crmLinkInfo = selector?.LinkInfo;

            if (crmLinkInfo == null)
            {
                return;
            }

            var link = !string.IsNullOrEmpty(field.ResultRows.RootRecordIdentification)
                           ? new UPCRMLink(field.ResultRows.RootRecordIdentification, crmLinkInfo.LinkId)
                           : new UPCRMLink(crmLinkInfo.TargetInfoAreaId, crmLinkInfo.LinkId, false);

            var key = this.LinkKeyForInfoAreaIdLinkId(crmLinkInfo.TargetInfoAreaId, crmLinkInfo.LinkId);

            if (this.changedLinks != null)
            {
                this.changedLinks.SetObjectForKey(link, key);
            }
            else
            {
                this.changedLinks = new Dictionary <string, UPCRMLink> {
                    { key, link }
                };
            }
        }
        private void UserDidChangeRecordSelectorEditField(UPMRecordSelectorEditField field)
        {
            UPRecordSelector            selector   = field.CurrentSelector;
            Dictionary <string, object> copyValues = field.ResultRows != null ? field.ResultRows.FunctionValues : selector.ValuesFromResultRow(null);

            string linkRecordIdentification = field.ResultRows.RootRecordIdentification;
            string linkKey = selector.LinkKey;

            if (!selector.NoLink && !string.IsNullOrEmpty(linkKey))
            {
                if (!string.IsNullOrEmpty(linkRecordIdentification))
                {
                    if (this.linkDictionary != null)
                    {
                        this.linkDictionary[linkKey] = linkRecordIdentification;
                    }
                    else
                    {
                        this.linkDictionary = new Dictionary <string, string> {
                            { linkKey, linkRecordIdentification }
                        };
                    }
                }
                else if (!string.IsNullOrEmpty(linkKey) && this.linkDictionary.ContainsKey(linkKey))
                {
                    this.linkDictionary.Remove(linkKey);
                }
            }

            List <UPMEditField> changedFields = this.ApplyCopyValuesRecordSelectorEditField(copyValues, field);

            foreach (UPMEditField editField in changedFields)
            {
                this.SimpleChangedValue(editField);
            }

            if (changedFields.Count > 0)
            {
                this.Delegate.ForceRedraw(this);
            }
        }
        /// <summary>
        /// Records the selector page model controller for field.
        /// </summary>
        /// <param name="editField">The edit field.</param>
        /// <returns></returns>
        public UPRecordSelectorPageModelController RecordSelectorPageModelControllerForField(UPMRecordSelectorEditField editField)
        {
            ViewReference viewRef = editField.CurrentSelector.SearchViewReference;

            viewRef = viewRef?.ViewReferenceWith(editField.ContextRecord);

            UPRecordSelectorPageModelController searchPageController = new UPRecordSelectorPageModelController(viewRef);

            return(searchPageController);
        }
        private List <UPMEditField> ApplyCopyValuesRecordSelectorEditField(Dictionary <string, object> copyValues, UPMRecordSelectorEditField field)
        {
            List <UPMEditField> changedFields = new List <UPMEditField>();

            if (copyValues != null && field.EditFieldsContext != null)
            {
                UPEditPageContext fieldEditPageContext = (UPEditPageContext)field.EditFieldsContext;
                foreach (UPEditFieldContext fieldContext in fieldEditPageContext.EditFields.Values)
                {
                    if (!string.IsNullOrEmpty(fieldContext.FieldFunction))
                    {
                        string value = copyValues[fieldContext.FieldFunction] as string;
                        if (value != null)
                        {
                            fieldContext.Value = value;
                            fieldContext.SetChanged(true);
                            if (fieldContext.EditField != null)
                            {
                                changedFields.Add(fieldContext.EditField);
                            }
                        }
                    }
                }
            }

            return(changedFields);
        }