public BaseOrderViewModel()
        {
            IsCurrentSelected = new NotifyValue <bool>(true);
            IsSentSelected    = new NotifyValue <bool>();
            IsDeletedSelected = new NotifyValue <bool>();
            Begin             = new NotifyValue <DateTime>(DateTime.Today.AddMonths(-3).FirstDayOfMonth());
            End          = new NotifyValue <DateTime>(DateTime.Today);
            BeginEnabled = IsSentSelected.ToValue();
            EndEnabled   = IsSentSelected.ToValue();

            IsCurrentSelected.Subscribe(_ => NotifyOfPropertyChange("CanPrint"));
            IsCurrentSelected.Subscribe(_ => NotifyOfPropertyChange(nameof(CanExport)));
            SessionValue(Begin, "Begin");
            SessionValue(End, "End");
        }
Exemplo n.º 2
0
        protected override void OnInitialize()
        {
            base.OnInitialize();

            ProductInfo  = new ProductInfo(this, CurrentLine.OfType <BaseOffer>());
            OrderWarning = new InlineEditWarning(UiScheduler, Manager);

            //если это отправленный заказ редактор не должен работать
            var currentOrderLine = new NotifyValue <OrderLine>();

            if (IsCurrentOrder)
            {
                currentOrderLine = CurrentLine.Select(v => (OrderLine)v).ToValue();
                currentOrderLine.Subscribe(v => CurrentLine.Value = v);
            }
            editor             = new Editor(OrderWarning, Manager, currentOrderLine, Lines.Cast <IList>().ToValue());
            OnlyWarningVisible = new NotifyValue <bool>(User.IsPreprocessOrders && IsCurrentOrder);
            CurrentLine.OfType <BaseOffer>()
            .Throttle(Consts.LoadOrderHistoryTimeout, Scheduler)
            .Select(x => RxQuery(s => BaseOfferViewModel.LoadOrderHistory(s, Cache, Settings.Value, x, Address)))
            .Switch()
            .Subscribe(HistoryOrders, CloseCancellation.Token);

            FilterItems.Select(p => p.Changed()).Merge().Throttle(Consts.FilterUpdateTimeout, UiScheduler)
            .Select(_ => Filter())
            .Subscribe(Lines, CloseCancellation.Token);
        }
Exemplo n.º 3
0
 public Editor(InlineEditWarning warning, WindowManager manager,
               NotifyValue <OrderLine> current,
               NotifyValue <IList> lines)
 {
     this.warning = warning;
     this.manager = manager;
     this.current = current;
     this.lines   = lines;
     current.Subscribe(x => lastEditCountCandidate = x?.Count ?? 0);
 }
Exemplo n.º 4
0
        public Awaited()
        {
            DisplayName = "Ожидаемые позиции";
            Items       = new NotifyValue <ObservableCollection <AwaitedItem> >();
            CurrentItem = new NotifyValue <AwaitedItem>();
            CanDelete   = CurrentItem.Select(i => i != null).ToValue();
            ActivePrint = new NotifyValue <string>();
            ActivePrint.Subscribe(ExcelExporter.ActiveProperty);

            PrintMenuItems = new ObservableCollection <MenuItem>();
            IsView         = true;
        }
Exemplo n.º 5
0
        public Batch()
        {
            NavigateOnShowCatalog = true;
            DisplayName           = "АвтоЗаказ";
            AddressSelector       = new AddressSelector(this);
            Filter = new[] {
                "Все",
                "Заказано",
                "   Минимальные",
                "   Не минимальные",
                "   Присутствующие в замороженных заказах",
                "   Ограничен лимитом",
                "Не заказано",
                "   Нет предложений",
                "   Нулевое количество",
                "   Прочее",
                "   Не сопоставлено",
                "   Лимит исчерпан"
            };
            CurrentFilter  = new NotifyValue <string>("Все");
            SearchBehavior = new SearchBehavior(this);
            Lines          = new NotifyValue <ObservableCollection <BatchLineView> >(new ObservableCollection <BatchLineView>());
            ReportLines    = new NotifyValue <ObservableCollection <BatchLineView> >(() => {
                var query = Lines.Value.Where(l => l.Product.CultureContains(SearchBehavior.ActiveSearchTerm.Value) &&
                                              (l.OrderLine != null || !l.BatchLine.Status.HasFlag(ItemToOrderStatus.Ordered)));
                if (CurrentFilter.Value == Filter[1])
                {
                    query = query.Where(l => !l.IsNotOrdered);
                }
                else if (CurrentFilter.Value == Filter[2])
                {
                    query = query.Where(l => !l.IsNotOrdered && l.IsMinCost);
                }
                else if (CurrentFilter.Value == Filter[3])
                {
                    query = query.Where(l => !l.IsNotOrdered && !l.IsMinCost);
                }
                else if (CurrentFilter.Value == Filter[4])
                {
                    query = query.Where(l => !l.IsNotOrdered && l.ExistsInFreezed);
                }
                else if (CurrentFilter.Value == Filter[5])
                {
                    query = query.Where(l => l.IsSplitByLimit);
                }
                else if (CurrentFilter.Value == Filter[6])
                {
                    query = query.Where(l => l.IsNotOrdered);
                }
                else if (CurrentFilter.Value == Filter[7])
                {
                    query = query.Where(l => l.IsNotOrdered && !l.BatchLine.Status.HasFlag(ItemToOrderStatus.OffersExists));
                }
                else if (CurrentFilter.Value == Filter[8])
                {
                    query = query.Where(l => l.IsNotOrdered && l.BatchLine.Quantity == 0);
                }
                else if (CurrentFilter.Value == Filter[9])
                {
                    query = query.Where(l => l.IsNotOrdered && l.BatchLine.Quantity > 0 &&
                                        l.BatchLine.ProductId != null &&
                                        l.BatchLine.Status.HasFlag(ItemToOrderStatus.OffersExists));
                }
                else if (CurrentFilter.Value == Filter[10])
                {
                    query = query.Where(l => l.IsNotOrdered && l.BatchLine.ProductId == null);
                }
                else if (CurrentFilter.Value == Filter[11])
                {
                    query = query.Where(l => l.IsLimited);
                }
                return(query.OrderBy(l => l.Product).ToObservableCollection());
            }, CurrentFilter, SearchBehavior.ActiveSearchTerm);
            CurrentReportLine   = new NotifyValue <BatchLineView>();
            CanDelete           = CurrentReportLine.Select(l => l != null).ToValue();
            SelectedReportLines = new List <BatchLineView>();
            CanClear            = Lines.CollectionChanged()
                                  .Select(e => e.Sender as ObservableCollection <BatchLineView>)
                                  .Select(v => v != null && v.Count > 0).ToValue();
            CanReload = Lines.CollectionChanged()
                        .Select(e => e.Sender as ObservableCollection <BatchLineView>)
                        .Select(v => CanUpload && v != null && v.Count > 0).ToValue();
            WatchForUpdate(CurrentReportLine.Select(l => l?.BatchLine));
            ActivePrint = new NotifyValue <string>();
            ActivePrint.Subscribe(ExcelExporter.ActiveProperty);
            CurrentFilter.Subscribe(_ => SearchBehavior.ActiveSearchTerm.Value = "");
            ReportEditor = new ReportEditor(this);

            PrintMenuItems = new ObservableCollection <MenuItem>();
            IsView         = true;
        }
Exemplo n.º 6
0
        public OrderLinesViewModel()
        {
            DisplayName = "Сводный заказ";

            InitFields();
            Lines             = new NotifyValue <ObservableCollection <OrderLine> >(new ObservableCollection <OrderLine>());
            SentLines         = new NotifyValue <List <SentOrderLine> >(new List <SentOrderLine>());
            IsCurrentSelected = new NotifyValue <bool>(true);
            Begin             = new NotifyValue <DateTime>(DateTime.Today.AddMonths(-3).FirstDayOfMonth());
            End             = new NotifyValue <DateTime>(DateTime.Today);
            AddressSelector = new AddressSelector(this);

            FilterItems = new List <Selectable <Tuple <string, string> > >();
            FilterItems.Add(new Selectable <Tuple <string, string> >(Tuple.Create("InFrozenOrders", "Позиции присутствуют в замороженных заказах")));
            FilterItems.Add(new Selectable <Tuple <string, string> >(Tuple.Create("IsMinCost", "Позиции по мин.ценам")));
            FilterItems.Add(new Selectable <Tuple <string, string> >(Tuple.Create("IsNotMinCost", "Позиции не по мин.ценам")));
            FilterItems.Add(new Selectable <Tuple <string, string> >(Tuple.Create("OnlyWarning", "Только позиции с корректировкой")));

            CanDelete    = CurrentLine.CombineLatest(IsCurrentSelected, (l, s) => l != null && s).ToValue();
            BeginEnabled = IsSentSelected.ToValue();
            EndEnabled   = IsSentSelected.ToValue();

            IsCurrentSelected.Subscribe(_ => NotifyOfPropertyChange(nameof(CanPrint)));
            IsCurrentSelected.Subscribe(_ => NotifyOfPropertyChange(nameof(CanExport)));

            Sum = new NotifyValue <decimal>(() => {
                if (IsCurrentSelected)
                {
                    return(Lines.Value.Sum(l => l.MixedSum));
                }
                return(SentLines.Value.Sum(l => l.MixedSum));
            }, SentLines, Lines, IsCurrentSelected);

            OrderWarning = new InlineEditWarning(UiScheduler, Manager);
            QuickSearch  = new QuickSearch <OrderLine>(UiScheduler,
                                                       s => Lines.Value.FirstOrDefault(l => l.ProductSynonym.IndexOf(s, StringComparison.CurrentCultureIgnoreCase) >= 0),
                                                       CurrentLine);
            QuickSearch2 = new QuickSearch <SentOrderLine>(UiScheduler,
                                                           s => SentLines.Value.FirstOrDefault(l => l.ProductSynonym.IndexOf(s, StringComparison.CurrentCultureIgnoreCase) >= 0),
                                                           SelectedSentLine);
            Editor = new Editor(OrderWarning, Manager, CurrentLine, Lines.Cast <IList>().ToValue());

            var currentLinesChanged = this.ObservableForProperty(m => m.CurrentLine.Value.Count)
                                      .Throttle(Consts.RefreshOrderStatTimeout, UiScheduler)
                                      .Select(e => new Stat(Address));

            OnCloseDisposable.Add(Bus.RegisterMessageSource(currentLinesChanged));
            OnCloseDisposable.Add(currentLinesChanged.Subscribe(_ => Sum.Recalculate()));

            Settings.Subscribe(_ => CalculateOrderLine());

            if (Session != null)
            {
                Prices = Session.Query <Price>().OrderBy(p => p.Name).ToList()
                         .Select(p => new Selectable <Price>(p))
                         .ToList();
            }
            else
            {
                Prices = new List <Selectable <Price> >();
            }

            MatchedWaybills = new MatchedWaybills(this, SelectedSentLine, IsSentSelected);
            IsCurrentSelected
            .Select(v => v ? "Lines" : "SentLines")
            .Subscribe(ExcelExporter.ActiveProperty);

            Observable.Merge(IsCurrentSelected.Select(x => (object)x), Lines, SentLines, currentLinesChanged)
            .Select(_ => {
                if (IsCurrentSelected)
                {
                    return(Lines.Value?.Count ?? 0);
                }
                return(SentLines.Value?.Count ?? 0);
            })
            .Subscribe(LinesCount);
            IsLoading = new NotifyValue <bool>();
            IsCurrentSelected.Where(v => v)
            .Select(_ => false)
            .Subscribe(IsLoading);

            SessionValue(Begin, GetType().Name + ".Begin");
            SessionValue(End, GetType().Name + ".End");
            SessionValue(IsSentSelected, GetType().Name + ".IsSentSelected");
            Persist(IsExpanded, "IsExpanded");

            PrintMenuItems = new ObservableCollection <MenuItem>();
            IsView         = true;
        }
Exemplo n.º 7
0
 public Sign(ActionPayload payload)
     : base(payload)
 {
     if (ReqRevocationSign)
     {
         OperationName.Value = "Аннулирование документа";
     }
     else
     {
         OperationName.Value = "Подписание Документа";
     }
     Torg12TitleVisible = Payload.Entity.AttachmentType == AttachmentType.XmlTorg12 && !ReqRevocationSign;
     RcvFIO.Value       = $"{SignerSureName} {SignerFirstName} {SignerPatronimic}";
     RcvJobTitle.Value  = Settings.Value.DiadokSignerJobTitle;
     RcvDate.Value      = DateTime.Now;
     LikeReciever.Subscribe(x => {
         if (x)
         {
             AcptFirstName.Value  = SignerFirstName;
             AcptSurename.Value   = SignerSureName;
             AcptPatronimic.Value = SignerPatronimic;
             AcptJobTitle.Value   = RcvJobTitle.Value;
         }
     });
     ByAttorney.Subscribe(x => {
         if (!x)
         {
             AtrNum.Value          = "";
             AtrOrganization.Value = "";
             AtrSurename.Value     = "";
             AtrFirstName.Value    = "";
             AtrPatronymic.Value   = "";
             AtrAddInfo.Value      = "";
         }
     });
     CurrentAutoSave = new NotifyValue <SignTorg12Autosave>();
     CurrentAutoSave.Subscribe(x => {
         if (x != null)
         {
             RcvJobTitle.Value = x.SignerJobTitle;
             if (x.LikeReciever)
             {
                 LikeReciever.Value = true;
             }
             else
             {
                 AcptFirstName.Value  = x.AcptFirstName;
                 AcptSurename.Value   = x.AcptSurename;
                 AcptPatronimic.Value = x.AcptPatronimic;
                 AcptJobTitle.Value   = x.AcptJobTitle;
             }
             if (x.ByAttorney)
             {
                 ByAttorney.Value      = true;
                 AtrNum.Value          = x.AtrNum;
                 AtrDate.Value         = x.AtrDate;
                 AtrOrganization.Value = x.AtrOrganization;
                 AtrJobTitle.Value     = x.AtrJobTitle;
                 AtrSurename.Value     = x.AtrSurename;
                 AtrFirstName.Value    = x.AtrFirstName;
                 AtrPatronymic.Value   = x.AtrPatronymic;
                 AtrAddInfo.Value      = x.AtrAddInfo;
             }
             else
             {
                 ByAttorney.Value      = false;
                 AtrNum.Value          = "";
                 AtrDate.Value         = null;
                 AtrOrganization.Value = "";
                 AtrJobTitle.Value     = "";
                 AtrSurename.Value     = "";
                 AtrFirstName.Value    = "";
                 AtrPatronymic.Value   = "";
                 AtrAddInfo.Value      = "";
             }
             Comment.Value = x.Comment;
         }
     });
     Comment.Subscribe(x => {
         if (!String.IsNullOrEmpty(x))
         {
             CommentVisibility.Value = true;
         }
         else
         {
             CommentVisibility.Value = false;
         }
     });
 }