public override ObservableCollection <DataField> GetDataFields(SettingDisplay displaySetting)
        {
            var fields = DataFieldHelper.Instance.GetDataFields(typeof(IWBPosInput), displaySetting);

            #region .  SKU filter  .
            var skuField = fields.FirstOrDefault(i => i.Name.EqIgnoreCase(IWBPosInput.SKUIDPropertyName));
            if (skuField != null)
            {
                skuField.LookupFilterExt = string.Empty;

                if (MandantId != null)
                {
                    skuField.LookupFilterExt = string.Format("mandantid = {0}", MandantId.Value);
                }

                if (!string.IsNullOrEmpty(Source.ArtCode))
                {
                    skuField.LookupFilterExt += string.IsNullOrEmpty(skuField.LookupFilterExt)
                        ? string.Format("upper(artcode_r)='{0}'", Source.ArtCode.ToUpper())
                        : string.Format(" and upper(artcode_r)='{0}'", Source.ArtCode.ToUpper());
                }
            }
            #endregion

            #region .  Factory filter  .
            var factoryField = fields.FirstOrDefault(i => i.Name.EqIgnoreCase(IWBPosInput.FACTORYID_RPropertyName));
            if (factoryField != null && MandantId != null)
            {
                factoryField.LookupFilterExt = string.Format("PartnerID_r = {0}", MandantId.Value);
            }
            #endregion

            #region .  TEType filter  .

            if (InPropertyEditMode)
            {
                var teTypeField = fields.FirstOrDefault(i => i.Name.EqIgnoreCase(IWBPosInput.TETypeCodePropertyName));
                var filter      = string.Format("1=1 or (TETYPECODE in (select TETYPECODE_R from wmssku2tte where wmssku2tte.SKUID_R in ({0}) group by TETYPECODE_R having count(*) = {1}))", string.Join(",", PropertyEditSource.Select(i => i.GetProperty(IWBPosInput.SKUIDPropertyName))), PropertyEditSource.Count());
                if (teTypeField != null)
                {
                    teTypeField.LookupFilterExt = string.IsNullOrEmpty(teTypeField.LookupFilterExt) ? filter : " and " + filter;
                }
            }

            #endregion

            // не даем редактировать, если SKU базовая
            var productCountField = fields.FirstOrDefault(i => i.Name.EqIgnoreCase(IWBPosInput.ProductCountPropertyName));
            if (productCountField != null)
            {
                productCountField.IsEnabled = InPropertyEditMode ? PropertyEditSource.FirstOrDefault(i => i.IsBaseSKU) == null : !Source.IsBaseSKU;
            }
            return(fields);
        }
Exemple #2
0
        public override ObservableCollection <DataField> GetDataFields(SettingDisplay displaySetting)
        {
            var fields = DataFieldHelper.Instance.GetDataFields(typeof(IWBPosInput), displaySetting);

            #region .  SKU filter  .
            var skuField = fields.FirstOrDefault(i => i.Name.EqIgnoreCase(IWBPosInput.SKUIDPropertyName));
            if (skuField != null)
            {
                skuField.LookupFilterExt = string.Empty;

                if (MandantId != null)
                {
                    skuField.LookupFilterExt = string.Format("mandantid = {0}", MandantId.Value);
                }

                if (!string.IsNullOrEmpty(Source.ArtCode))
                {
                    skuField.LookupFilterExt += string.IsNullOrEmpty(skuField.LookupFilterExt)
                        ? string.Format("upper(artcode_r)='{0}'", Source.ArtCode.ToUpper())
                        : string.Format(" and upper(artcode_r)='{0}'", Source.ArtCode.ToUpper());
                }
            }
            #endregion

            #region .  Factory filter  .
            var factoryField = fields.FirstOrDefault(i => i.Name.EqIgnoreCase(IWBPosInput.FACTORYID_RPropertyName));
            if (factoryField != null && MandantId != null)
            {
                factoryField.LookupFilterExt = string.Format("PartnerID_r = {0}", MandantId.Value);
            }
            #endregion

            #region .  TEType filter  .

            if (InPropertyEditMode)
            {
                var teTypeField = fields.FirstOrDefault(i => i.Name.EqIgnoreCase(IWBPosInput.TETypeCodePropertyName));
                var filter      = string.Format("1=1 or (TETYPECODE in (select TETYPECODE_R from wmssku2tte where wmssku2tte.SKUID_R in ({0}) group by TETYPECODE_R having count(*) = {1}))", string.Join(",", PropertyEditSource.Select(i => i.GetProperty(IWBPosInput.SKUIDPropertyName))), PropertyEditSource.Count());
                if (teTypeField != null)
                {
                    teTypeField.LookupFilterExt = string.IsNullOrEmpty(teTypeField.LookupFilterExt) ? filter : " and " + filter;
                }
            }

            #endregion

            #region . TE visible .
            var teField = fields.FirstOrDefault(i => i.Name.EqIgnoreCase(IWBPosInput.IWBPosTEPropertyName));
            if (teField != null && !teField.Visible)
            {
                teField.Visible = true;
            }
            #endregion

            #region .  Place add .
            var placeField = new DataFieldWithDomain
            {
                Name        = "Place",
                Visible     = true,
                IsEnabled   = true,
                Caption     = "Место",
                FieldName   = "Place",
                BindingPath = "Place",
                FieldType   = typeof(EntityReference),
                Domain      = new EntityRefDomain
                {
                    EntityRefDescriptor = new EntityRefDescriptor
                    {
                        EntityType = Place.EntityType,
                        Fields     = new List <EntityRefFieldDescriptor>
                        {
                            new EntityRefFieldDescriptor {
                                Name = "PlaceCode"
                            },
                            new EntityRefFieldDescriptor {
                                Name = "PlaceName"
                            }
                        },
                        Format = "{{=it.PlaceName}}"
                    }
                },
                SourceName = "Place"
            };
            fields.Add(placeField);
            #endregion

            // не даем редактировать, если SKU базовая
            var productCountField = fields.FirstOrDefault(i => i.Name.EqIgnoreCase(IWBPosInput.ProductCountPropertyName));
            if (productCountField != null)
            {
                productCountField.IsEnabled = InPropertyEditMode ? PropertyEditSource.FirstOrDefault(i => i.IsBaseSKU) == null : !Source.IsBaseSKU;
            }

            //Формат полей
            if (DisplayFieldsFormat != null)
            {
                foreach (var item in fields.Where(p => !string.IsNullOrEmpty(p.Name) && DisplayFieldsFormat.ContainsKey(p.Name)))
                {
                    item.DisplayFormat = DisplayFieldsFormat[item.Name];
                }
            }

            return(fields);
        }