コード例 #1
0
        private void DoAlterations(Operation op, Order order)
        {
            switch (op)
            {
            case Operation.New:
                LvAddDelegate lvAdd  = itemListView.Items.Add;
                ListViewItem  lvItem = new ListViewItem(new[]
                {
                    order.Id.ToString(), order.Product.Description, order.Product.Price.ToString(),
                    order.Quantity.ToString(), order.State.ToString()
                });
                lvItem.BackColor = Color.LightSalmon;
                BeginInvoke(lvAdd, lvItem);
                break;

            case Operation.Change:
                ChangeStateDelegate changeState = ChangeAnOrder;
                BeginInvoke(changeState, order);
                break;

            case Operation.Remove:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(op), op, null);
            }
        }
コード例 #2
0
        private void DoAlterations(Operation op, Order order)
        {
            if (order.Product.Type != _barKitchenController._productType)
            {
                return;
            }

            switch (op)
            {
            case Operation.New:
                LvAddDelegate lvAdd  = notPickedListView.Items.Add;
                ListViewItem  lvItem = new ListViewItem(new[]
                {
                    order.Id.ToString(), order.Product.Description, order.Quantity.ToString(),
                    order.State.ToString()
                });
                BeginInvoke(lvAdd, lvItem);
                break;

            case Operation.Change:
                ChangeStateDelegate changeState = ChangeAnOrder;
                BeginInvoke(changeState, order);
                break;

            case Operation.Remove:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(op), op, null);
            }
        }
コード例 #3
0
        /* Event handler for the remote AlterEvent subscription and other auxiliary methods */

        private void CalculateStatistics(Operation op, Invoice invoice)
        {
            invoice.Orders.ForEach(order =>
            {
                if (_statisticsController.ProductQuantity.ContainsKey(order.Product.Id))
                {
                    _statisticsController.ProductQuantity[order.Product.Id] += order.Quantity;

                    ChangeProductQuantityDelegate change = ChangeProductQuantity;
                    BeginInvoke(change,
                                order.Product.Id,
                                _statisticsController.ProductQuantity[order.Product.Id]);
                }
                else
                {
                    _statisticsController.ProductQuantity.TryAdd(order.Product.Id, order.Quantity);

                    LvAddDelegate lvAdd = productsListView.Items.Add;
                    ListViewItem lvItem = new ListViewItem(new[]
                    {
                        order.Product.Id.ToString(), order.Product.Type.ToString(), order.Product.Description,
                        order.Product.Price.ToString(), order.Quantity.ToString()
                    });
                    BeginInvoke(lvAdd, lvItem);
                }
            });

            if (_statisticsController.AmountByDay.ContainsKey(invoice.Date.ToShortDateString()))
            {
                _statisticsController.AmountByDay[invoice.Date.ToShortDateString()] += invoice.TotalInvoice;
            }
            else
            {
                _statisticsController.AmountByDay.TryAdd(invoice.Date.ToShortDateString(), invoice.TotalInvoice);
            }

            _statisticsController.TotalInvoices++;
            SetTextCallback d = SetTotalInvoices;

            BeginInvoke(d);
        }