示例#1
0
        private void PaymentTable_Load(object sender, EventArgs e)
        {
            List <Order> orders = _paymentController.ConsultTable(_tableId);

            orders.ForEach(order =>
            {
                ListViewItem lvItem = new ListViewItem(new[]
                {
                    order.Id.ToString(), order.Product.Description, order.Product.Price.ToString(),
                    order.Quantity.ToString(), order.State.ToString()
                });

                switch (order.State)
                {
                case OrderState.NotPicked:
                    lvItem.BackColor = Color.LightSalmon;
                    break;

                case OrderState.InPreparation:
                    lvItem.BackColor = Color.Yellow;
                    break;

                case OrderState.Ready:
                    lvItem.BackColor = Color.LightGreen;
                    break;

                case OrderState.Delivered:
                    lvItem.BackColor = Color.Cyan;
                    break;

                case OrderState.Paid:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                itemListView.Items.Add(lvItem);
            });
        }