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); }
public bool IsMergedPropery(string propertyName) { var editable = Source as IEditable; if (editable == null) { throw new DeveloperException("source must implement IEditable"); } if (editable.GetPropertyIsDirty(propertyName)) { return(true); } return(PropertyEditSource.Cast <WMSBusinessObject>().DistinctBy(i => i.GetProperty(propertyName)).ToArray().Length == 1); }
private List <TModel> GetSource(IBaseManager <TModel> mgr) { // очищаем кэш mgr.ClearCache(); if (InPropertyEditMode) { var values = new List <TModel>(); var filterList = FilterHelper.GetArrayFilterIn(typeof(TModel), (IEnumerable <object>)PropertyEditSource); foreach (var filter in filterList) { values.AddRange(mgr.GetFiltered(filter).ToArray()); } if (values.Count() != PropertyEditSource.Count()) { var diff = PropertyEditSource.Where( p => values.Cast <IKeyHandler>() .FirstOrDefault(i => i.GetKey().Equals(((IKeyHandler)p).GetKey())) == null) .ToList(); if (diff.Any()) { throw new OperationException("Объекты были удалены: {0}", string.Join(",", diff.Cast <IKeyHandler>().Select(i => i.GetKey()))); } } return(values); } // получаем данные var keyHandler = Source as IKeyHandler; if (keyHandler == null) { throw new DeveloperException("Source is not IKeyHandler."); } var result = mgr.Get(keyHandler.GetKey()); return(new List <TModel>(new[] { result })); // обновляем все связанные списки //mgr.RiseManagerChanged(); }
protected override void OnSourceChanged() { Source.LastSkuId = Source.SKUID; Source.IwbPosCountDouble = Source.IWBPosCount; Source.ProductCountSkuDouble = Source.ProductCountSKU; Source.CheckIsBaseSKU(); if (InPropertyEditMode) { foreach (var item in PropertyEditSource) { item.LastSkuId = item.SKUID; item.IwbPosCountDouble = item.IWBPosCount; item.ProductCountSkuDouble = item.ProductCountSKU; } Source.DisableCalculate = PropertyEditSource.DistinctBy(i => i.SKUID).Count() > 1; if (Source.DisableCalculate) { Source.OverrideSKU2TTEQuantityMax = PropertyEditSource.Min(i => i.SKU2TTEQuantityMax); } } base.OnSourceChanged(); }
protected override bool CanCloseInternal() { if (Check()) { return(base.CanCloseInternal()); } if (!InPropertyEditMode) { return(RejectChanges()); } foreach (var editableItem in PropertyEditSource.Select(editItem => editItem as IEditable)) { if (editableItem == null) { throw new DeveloperException(DeveloperExceptionResources.CantRejectChangesInNonEditableObject); } editableItem.RejectChanges(); } return(RejectChanges()); }
protected override void SourceObjectPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.SourceObjectPropertyChanged(sender, e); if (Source == null) { return; } var editable = Source as IEditable; if (editable.IsInRejectChanges) { return; } if (e.PropertyName.EqIgnoreCase(IWBPosInput.SKUIDPropertyName)) { if (InPropertyEditMode || Source.LastSkuId.HasValue && Source.SKUID.HasValue && Source.LastSkuId != Source.SKUID) { decimal skuIndex1 = 1; decimal skuIndex2 = 1; try { using (var mgr = IoC.Instance.Resolve <IBPProcessManager>()) { //INFO: коэффициент пересчета по документу skuIndex1 = (Source.LastSkuId.HasValue & Source.SKUID.HasValue) ? mgr.ConvertSKUtoSKU(Source.LastSkuId.Value, Source.SKUID.Value, 1, (decimal)(Source.IWBPosCount * Source.ProductCount)) : 1; //INFO: коэффициент пересчета принятых skuIndex2 = (Source.LastSkuId.HasValue & Source.SKUID.HasValue) ? mgr.ConvertSKUtoSKU(Source.LastSkuId.Value, Source.SKUID.Value, 0, 1) : 1; if (InPropertyEditMode) { foreach (var item in PropertyEditSource) { var itemSkuIndex1 = (item.LastSkuId.HasValue & Source.SKUID.HasValue) ? mgr.ConvertSKUtoSKU(item.LastSkuId.Value, Source.SKUID.Value, 1, (decimal)(item.IWBPosCount * item.ProductCount)) : 1; var itemSkuIndex2 = (item.LastSkuId.HasValue & Source.SKUID.HasValue) ? mgr.ConvertSKUtoSKU(item.LastSkuId.Value, Source.SKUID.Value, 0, 1) : 1; CalculateSkuIndex(item, itemSkuIndex1, itemSkuIndex2); item.LastSkuId = Source.SKUID; } } } } catch (Exception ex) { _log.Warn(ex.Message); _log.Debug(ex); GetViewService() .ShowDialog("Внимание", "Проверьте настройки единиц учета по принимаемому артикулу.", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); } if (InPropertyEditMode) { Source.DisableCalculate = Source.SKUID.HasValue == false && PropertyEditSource.DistinctBy(i => i.SKUID).Count() > 1; if (Source.DisableCalculate) { Source.OverrideSKU2TTEQuantityMax = PropertyEditSource.Min(i => i.SKU2TTEQuantityMax); } else { Source.OverrideSKU2TTEQuantityMax = null; } if (PropertyEditSource.DistinctBy(i => i.SKUID).Count() == 1) { CalculateSkuIndex(Source, skuIndex1, skuIndex2); } } else { CalculateSkuIndex(Source, skuIndex1, skuIndex2); } Source.LastSkuId = Source.SKUID; Source.CheckIsBaseSKU(); RefreshView(); } } // обновим доступность кнопки разбора batch-ей if (e.PropertyName.EqIgnoreCase(IWBPosInput.IWBPosInputBatchCodePropertyName)) { BatchProcessCommand.RaiseCanExecuteChanged(); } }
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); }