private void buttonProduct_Click(object sender, EventArgs e) { var newAdd = new AddNewProduct(); newAdd.Owner = this; newAdd.ShowDialog(); newAdd.BringToFront(); allItemBox.Items.Clear(); foreach (var item in Map) { allItemBox.Items.Add(item.Key); } }
private void buttonProduct_Click(object sender, EventArgs e) { var newAdd = new AddNewProduct(); newAdd.Owner = this; newAdd.ShowDialog(); newAdd.BringToFront(); allItemBox.Items.Clear(); bool flag = false; string key = string.Empty; textBasketPrice.Text = string.Empty; foreach (var item in Map) { allItemBox.Items.Add(item.Key); } for (int i = 0; i < listBasket.Items.Count; i++) { for (int j = 0; j < allItemBox.Items.Count; j++) { if (listBasket.Items[i] == allItemBox.Items[j]) { flag = true; key = allItemBox.Items[j].ToString(); if (textBasketPrice.Text.Length > 0) { textBasketPrice.Text = (int.Parse(textBasketPrice.Text) + Map[key]).ToString(); } else { textBasketPrice.Text = Map[key].ToString(); } break; } } if (!flag) { listBasket.Items.RemoveAt(i); i--; } flag = false; } allItemBox.SelectedIndex = 0; }