예제 #1
0
        void Expand(SalePreViewModel saleToShow)
        {
            var windowManager = base.GetService <IWindowManager>();

            Predicate <ViewModelBase> predicate = (ViewModelBase wsvm) =>
            {
                if (!(wsvm is OfflineSaleViewModel))
                {
                    return(false);
                }

                OfflineSaleViewModel svm = (OfflineSaleViewModel)wsvm;

                return(svm.SaleId == saleToShow.SaleId);
            };

            if (windowManager.Exists(predicate))
            {
                windowManager.Activate(predicate);
            }
            else
            {
                OfflineSaleViewModel sovm = new OfflineSaleViewModel(appvm, saleToShow.SaleId, OnRemoved, OnModified);
                windowManager.ShowChildWindow(sovm, appvm);
            }
        }
예제 #2
0
        //public DateTime FromDate { get; set; }
        //public DateTime ToDate { get; set; }

        //public void ChangeDay(DateTime date)
        //{
        //    this.workingDate = date;

        //    inventoryService.CreateInventorySnapshot(date);

        //    FindSales();
        //}

        public void FindSales()
        {
            //unsubscribe events
            //foreach (var item in valeModels)
            //{
            //    item.PropertyChanged -= vale_PropertyChanged;
            //    //item.RemoveEvents();
            //}
            //clear vales
            visibleSales.Clear();

            //DateTime toDatePlusOne = toDate.AddDays(1);

            //gives error if comparing date directly
            //var queryResult = from o in appvm.Context.Orders.OfType<Sale>()
            //                  where o.Date >= fromDate && o.Date < toDatePlusOne
            //                  //where o.Waiter.Name=="Diango"
            //                  select o;

            using (var unitOfWOrk = base.GetNewUnitOfWork())
            {
                var queryResult = unitOfWOrk.OrderRepository.QuerySalesByWorkDate(fromDate, toDate);

                foreach (var item in queryResult)
                {
                    //Action<SaleViewModel> showOrder = x =>
                    //{
                    //    ShowingSale = true;
                    //    //SelectedOrder = x;
                    //};
                    //Action<List<InventoryItem>> updateMessage = x =>
                    //{
                    //    UpdateProductsUnavailableMessage(x);
                    //};
                    //SaleViewModel sovm = new SaleViewModel(appvm, item, updateMessage);
                    SalePreViewModel vm = new SalePreViewModel(item);
                    visibleSales.Add(vm);

                    //sovm.PropertyChanged += new PropertyChangedEventHandler(vale_PropertyChanged);
                }
            }

            //if (icvAvailableTables != null) icvAvailableTables.Refresh();

            //if (valeModels.Count > 0) SelectedOrder = valeModels[0];
        }
예제 #3
0
        void OnModified(int saleId)
        {
            var target = visibleSales.FirstOrDefault(x => x.SaleId == saleId);

            if (target != null)
            {
                int index = visibleSales.IndexOf(target);

                visibleSales.RemoveAt(index);

                using (var unitOfWork = base.GetNewUnitOfWork())
                {
                    var spvm = new SalePreViewModel(unitOfWork.OrderRepository.GetById(saleId));

                    visibleSales.Insert(index, spvm);
                }
            }
        }
예제 #4
0
        void loadReportWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            pdvm.IsBusy = false;

            var windowManager = base.GetService <IWindowManager>();

            windowManager.Close(pdvm);

            if (e.Error != null)
            {
                var msgBox = base.GetService <IMessageBoxService>();
                msgBox.ShowMessage(e.Error.Message);
            }
            else
            {
                //foreach (var item in productsCreated)
                //{
                //    //appvm.ProductsOC.Add(item);
                //    //appvm.GlobalEventsManager.FireProductCreated(item);
                //}

                int saleResultId = (int)e.Result;

                using (var unitOfWork = base.GetNewUnitOfWork())
                {
                    SalePreViewModel pvm = new SalePreViewModel(unitOfWork.OrderRepository.GetById(saleResultId));

                    visibleSales.Add(pvm);
                }

                OfflineSaleViewModel vm = new OfflineSaleViewModel(appvm, saleResultId, OnRemoved, OnModified);
                windowManager.ShowChildWindow(vm, appvm);
            }

            loadReportWorker.DoWork             -= loadReportWorker_DoWork;
            loadReportWorker.ProgressChanged    -= loadReportWorker_ProgressChanged;
            loadReportWorker.RunWorkerCompleted -= loadReportWorker_RunWorkerCompleted;
            loadReportWorker = null;
        }