private void LoadPriceTagPreview()
 {
     if (!MarkupAddress.HasValue)
     {
         return;
     }
     RxQuery(s => PriceTag.LoadOrDefault(s.Connection, TagType.PriceTag, MarkupAddress.Value))
     .Subscribe(x => PriceTagPreview.Value = x.Preview());
 }
Пример #2
0
 protected override void OnInitialize()
 {
     base.OnInitialize();
     address = address ?? Address;
     RxQuery(s => PriceTag.LoadOrDefault(s.Connection, TagType.PriceTag, address))
     .Subscribe(x => priceTag = x);
     RxQuery(s => PriceTag.LoadOrDefault(s.Connection, TagType.RackingMap, null))
     .Subscribe(x => rackingMap = x);
     this.priceTagSettings      = Settings.Value.PriceTags.First(r => r.Address?.Id == address?.Id);
 }
        protected override void OnInitialize()
        {
            base.OnInitialize();

            RxQuery(s => PriceTag.LoadOrDefault(s.Connection, tagType, address)).Subscribe(Tag);
        }
 private void LoadRackingMapPreview()
 {
     RxQuery(s => PriceTag.LoadOrDefault(s.Connection, TagType.RackingMap, null))
     .Subscribe(x => RackingMapPreview.Value = x.Preview());
 }
Пример #5
0
        protected override void OnInitialize()
        {
            base.OnInitialize();

            OnCloseDisposable.Add(Shell.SpecialMarkupProducts.Subscribe(_ => Calculate()));

            if (Session == null)
            {
                return;
            }

            Waybill = Session.Get <Waybill>(id);
            if (Waybill == null)
            {
                return;
            }
            Waybill.Settings = Settings;
            Waybill.ObservableForProperty(x => x.Status, skipInitial: false)
            .Select(x => x.Value == DocStatus.NotPosted).Subscribe(CanStock);
            Waybill.ObservableForProperty(x => x.Status, skipInitial: false)
            .Select(x => x.Value == DocStatus.NotPosted && Waybill.SupplierSum == null).Subscribe(CanEditSum);

            Waybill.ObservableForProperty(m => (object)m.Status, skipInitial: false)
            .Merge(Waybill.ObservableForProperty(m => (object)m.IsCreatedByUser))
            .Select(_ => !User.IsStockEnabled && Waybill.Status == DocStatus.NotPosted && !Waybill.IsCreatedByUser)
            .Subscribe(CanToEditable);

            Waybill.ObservableForProperty(m => (object)m.Status, skipInitial: false)
            .Merge(Waybill.ObservableForProperty(m => (object)m.IsCreatedByUser))
            .Select(_ => Waybill.Status == DocStatus.NotPosted && Waybill.IsCreatedByUser)
            .Subscribe(CanAddFromCatalog);

            if (Waybill.IsNew)
            {
                Waybill.IsNew = false;
                if (Shell.NewDocsCount.Value > 0)
                {
                    Shell.NewDocsCount.Value--;
                }
            }

            Calculate();

            var stockids = Waybill.Lines.Where(x => x.StockId != null).Select(x => x.StockId).ToArray();

            RxQuery(s => s.Query <Stock>().Where(x => stockids.Contains(x.ServerId)).ToDictionary(x => x.ServerId))
            .ObserveOn(UiScheduler)
            .Subscribe(x => {
                Waybill.Lines.Each(y => {
                    y.Stock = x.GetValueOrDefault(y.StockId);
                });
            });

            Lines.Value = new ListCollectionView(Waybill.Lines.OrderBy(l => l.Product).ToList());
            Taxes       = new List <ValueDescription <int?> > {
                new ValueDescription <int?>("Все", -1),
            };
            Taxes.AddRange(Lines.Value.Cast <WaybillLine>().Select(l => l.Nds).Distinct()
                           .OrderBy(t => t)
                           .Select(t => new ValueDescription <int?>(((object)t ?? "Нет значения").ToString(), t)));
            CurrentTax.Value = Taxes.FirstOrDefault();
            Reject           = CurrentWaybillLine
                               .Throttle(Consts.ScrollLoadTimeout, Scheduler)
                               .Select(v => RxQuery(s => {
                if (v?.RejectId == null)
                {
                    return(null);
                }
                return(s.Get <Reject>(v.RejectId.Value));
            }))
                               .Switch()
                               .ToValue(CloseCancellation);
            IsRejectVisible = Reject.Select(r => r != null).ToValue();
            if (Waybill.IsCreatedByUser)
            {
                EmptyLabelVisibility   = EmptyLabelVisibility.Select(s => Visibility.Collapsed).ToValue();
                OrderDetailsVisibility = OrderDetailsVisibility.Select(s => Visibility.Collapsed).ToValue();
            }

            RxQuery(s => PriceTag.LoadOrDefault(s.Connection, TagType.PriceTag, Waybill.Address))
            .Subscribe(x => priceTag = x);
            RxQuery(s => PriceTag.LoadOrDefault(s.Connection, TagType.RackingMap, Waybill.Address))
            .Subscribe(x => rackingMap = x);
        }