Ejemplo n.º 1
0
        private void BuildGoodsItems()
        {
            _goodsItems = new List <GoodsItems>();

            var _data  = dbHelper.GetTableData("GoodsItems", _conn);
            int _count = _data.Count / 9;
            int _indx  = 0;

            for (int i = 0; i < _count; i++)
            {
                var _gi = new GoodsItems();
                _gi.GoodsId                = int.Parse(_data[_indx++]);
                _gi.ItemId                 = int.Parse(_data[_indx++]);
                _gi.ItemQuantity           = int.Parse(_data[_indx++]);
                _gi.ItemExpirationType     = int.Parse(_data[_indx++]);
                _gi.ItemExpireAt           = _data[_indx++];
                _gi.ItemExpirationDuration = _data[_indx++];
                _gi.ItemData               = _data[_indx++];
                _gi.DeliveryPriority       = int.Parse(_data[_indx++]);
                _gi.LimitedGameServerMask  = _data[_indx++];
                _gi.IsSelectableItem       = _data[_indx++];
                _goodsItems.Add(_gi);
                if (_indx + 1 > _data.Count)
                {
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public GameStoreViewModel(IDispatcherService dispatcherService, string functionTag,
                                  IDialogService dialogService, ScoreInfoService scoreInfoService, GoodsService goodsService) : base(dispatcherService, functionTag)
        {
            _dialogService    = dialogService;
            _scoreInfoService = scoreInfoService;
            _goodsService     = goodsService;

            DataGridItemChanged = new RelayCommand <DataGridItemChangedEventArgs>(OnDataGridItemChanged);

            RefreshList = new RelayCommand(PrivateRefreshList);

            RemoveItem = new RelayCommand(() =>
            {
                if (_dialogService.ShowOKCancel("确定删除选中数据吗?"))
                {
                    _ = _goodsService.RemoveAsync(SelectedItem);
                    GoodsItems.Remove(SelectedItem);
                }
            }, () => { return(SelectedItem != null); });

            RemoveAll = new RelayCommand(() =>
            {
                if (_dialogService.ShowOKCancel("确定删除所有数据吗?"))
                {
                    _          = _goodsService.RemoveAllAsync();
                    GoodsItems = null;
                }
            }, () => { return(GoodsItems != null); });

            AddData = new RelayCommand(() =>
            {
                if (string.IsNullOrEmpty(BuyCmd))
                {
                    _dialogService.ShowInformation("购买命令不能为空");
                    return;
                }
                if (GoodsItems.FirstOrDefault(p => p.BuyCmd == BuyCmd) != null)
                {
                    _dialogService.ShowInformation("购买命令重复");
                    return;
                }

                var dto = new GoodsDto()
                {
                    GoodsName = GoodsName,
                    BuyCmd    = BuyCmd,
                    Content   = Content,
                    Amount    = Amount,
                    Quality   = Quality,
                    Price     = Price,
                    GoodsType = GoodsType
                };
                _ = _goodsService.AddAsync(dto);
                GoodsItems.Add(dto);
            });

            AddAvailableVariables();

            PrivateRefreshList();
        }
Ejemplo n.º 3
0
        private void OnDataGridItemChanged(DataGridItemChangedEventArgs eventArgs)
        {
            if (eventArgs.IsChanged == false)
            {
                return;
            }

            if (eventArgs.NewItem is GoodsDto newItem && eventArgs.OldItem is GoodsDto oldItem)
            {
                if (GoodsItems.FirstOrDefault(p => p.BuyCmd == newItem.BuyCmd && object.Equals(p, newItem) == false) != null)
                {
                    _dialogService.ShowInformation("购买命令重复");
                    newItem.BuyCmd = oldItem.BuyCmd;// 此时新值还未更新至ui
                }
                else
                {
                    _ = _goodsService.UpdateAsync(newItem);
                }
            }
        }
        public async Task Refresh()
        {
            _receiptItems.Clear();
            _goodsItems.Clear();

            List <AlbumItem> receipts = await _azure.GetAllImages(CurrentTransaction.ID, true);

            foreach (AlbumItem t in receipts)
            {
                Receipts.Add(t);
            }

            receipts.Add(new AlbumItem {
                IsAddButton = true, IsReceipt = true
            });
            int            i       = 0;
            ImageListItems tempILI = new ImageListItems();

            foreach (AlbumItem t in receipts)
            {
                //RESET temp class for next ListEntry
                if (tempILI == null)
                {
                    tempILI = new ImageListItems();
                }

                //Add Image
                tempILI.ItemImages.Add(t);

                //Add ListEntry content and reset for next Entry
                if (i >= 3)
                {
                    ReceiptItems.Add(tempILI);
                    tempILI = null;
                    i       = 0;
                }
                i++;
            }

            //Fill aditional spaces with filler image
            if (tempILI != null)
            {
                for (int j = tempILI.ItemImages.Count; j < 3; j++)
                {
                    tempILI.ItemImages.Add(new AlbumItem());
                }
                ReceiptItems.Add(tempILI);
            }

            //Reset Values to refresh Goods
            tempILI = null;
            i       = 0;


            List <AlbumItem> goods = await _azure.GetAllImages(CurrentTransaction.ID, false);

            foreach (AlbumItem t in goods)
            {
                Goods.Add(t);
            }

            goods.Add(new AlbumItem {
                IsAddButton = true, IsReceipt = false
            });
            foreach (AlbumItem t in goods)
            {
                if (tempILI == null)
                {
                    tempILI = new ImageListItems();
                }

                tempILI.ItemImages.Add(t);
                if (i >= 3)
                {
                    GoodsItems.Add(tempILI);
                    tempILI = null;
                    i       = 0;
                }
                i++;
            }

            //Fill aditional spaces with filler image
            if (tempILI != null)
            {
                for (int j = tempILI.ItemImages.Count; j < 3; j++)
                {
                    tempILI.ItemImages.Add(new AlbumItem());
                }
                GoodsItems.Add(tempILI);
            }
            HockeyApp.MetricsManager.TrackEvent("Images Page Loaded");
        }
Ejemplo n.º 5
0
        public async Task Refresh()
        {
            // NEED TO REWORK FOR THE NEW VIEW - OUTDATED

            IsLoading = true;

            #region Receipts
            Receipts.Clear();
            List <AlbumItem> receipts = await _azure.GetAllImages(CurrentTransaction.ID, true);

            foreach (AlbumItem t in receipts)
            {
                Receipts.Add(t);
            }

            receipts.Add(new AlbumItem {
                IsAddButton = true, IsReceipt = true
            });
            int            i       = 0;
            ImageListItems tempILI = new ImageListItems();

            //ClearItems before applying new items
            ReceiptItems.Clear();
            foreach (AlbumItem t in receipts)
            {
                //RESET temp class for next ListEntry
                if (tempILI == null)
                {
                    tempILI = new ImageListItems();
                }

                //Add Image
                tempILI.ItemImages.Add(t);

                //Add ListEntry content and reset for next Entry
                if (i >= 3)
                {
                    ReceiptItems.Add(tempILI);
                    tempILI = null;
                    i       = 0;
                }
                i++;
            }

            //Fill aditional spaces with filler image
            if (tempILI != null)
            {
                for (int j = tempILI.ItemImages.Count; j < 3; j++)
                {
                    tempILI.ItemImages.Add(new AlbumItem());
                }
                ReceiptItems.Add(tempILI);
            }
            #endregion

            //Reset Values to refresh Goods
            tempILI = null;
            i       = 0;

            #region Goods
            Goods.Clear();
            List <AlbumItem> goods = await _azure.GetAllImages(CurrentTransaction.ID, false);

            foreach (AlbumItem t in goods)
            {
                Goods.Add(t);
            }

            goods.Add(new AlbumItem {
                IsAddButton = true, IsReceipt = false
            });
            //ClearItems before applying new items
            GoodsItems.Clear();
            foreach (AlbumItem t in goods)
            {
                if (tempILI == null)
                {
                    tempILI = new ImageListItems();
                }

                tempILI.ItemImages.Add(t);
                if (i >= 3)
                {
                    GoodsItems.Add(tempILI);
                    tempILI = null;
                    i       = 0;
                }
                i++;
            }

            //Fill aditional spaces with filler image
            if (tempILI != null)
            {
                for (int j = tempILI.ItemImages.Count; j < 3; j++)
                {
                    tempILI.ItemImages.Add(new AlbumItem());
                }
                GoodsItems.Add(tempILI);
            }
            #endregion

            List <AlbumItem> images = await _azure.GetAllImages(CurrentTransaction.ID);

            foreach (AlbumItem image in images)
            {
                Images.Add(image);
            }

            if (!IsUnitTesting)
            {
                HockeyApp.MetricsManager.TrackEvent("Images Page Loaded");
            }

            IsLoading = false;
        }