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(); }
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(); }