Ejemplo n.º 1
0
        override protected async void DataGridViewOrders_SelectionChanged(object sender, EventArgs e)
        {
            base.DataGridViewOrders_SelectionChanged(sender, e);

            ChosenConsumables.Clear();

            var orderSelected = dataGridViewOrders.SelectedRows.Count > 0;

            if (orderSelected)
            {
                var selectedOrderId = Convert.ToInt32(textBoxOrderId.Text);
                var orderContent    = await _ordersRepository.GetOrdersContent(selectedOrderId);

                orderContent.ForEach(async x =>
                {
                    var consumable = new Consumables()
                    {
                        Id            = x.ConsumablesId,
                        Name          = (await _consumablesRepository.GetConsumable(x.ConsumablesId)).Name,
                        CurrentAmount = x.ConsumablesAmount
                    };
                    ChosenConsumables.Add(consumable);
                });
            }

            buttonFinishOrder.Enabled = orderSelected && textBoxOrderFinisher.Text.Equals("");

            UpdateDataGridViewOrderConsumables();
        }
Ejemplo n.º 2
0
        private void ButtonAddConsumablesToOrder_Click(object sender, EventArgs e)
        {
            var id = Convert.ToInt32(textBoxConsumablesId.Text);
            var existingConsumable = ChosenConsumables.FirstOrDefault(x => x.Id == id);

            if (existingConsumable != null)
            {
                return;
            }

            var consumable = new Consumables()
            {
                Id            = id,
                Name          = textBoxConsumablesName.Text,
                CurrentAmount = 0
            };

            ChosenConsumables.Add(consumable);
            UpdateDataGridViewOrderConsumables();
        }