private void btnAddParts_Click(object sender, EventArgs e) { ComputerPart part = new ComputerPart(); Form2 form2 = new Form2(part, true); if (form2.ShowDialog() == DialogResult.OK) { list.Add(part); updateSource(); } }
private void btnEditParts_Click(object sender, EventArgs e) { if (list.Count < 1) { MessageBox.Show("Список пуст!!!"); return; } ComputerPart part = (ComputerPart)ccmbBoxItems.SelectedItem; Form2 form2 = new Form2(part, false); if (form2.ShowDialog() == DialogResult.OK) { updateSource(); } }
public Form2(ComputerPart _part, bool _addNew) { InitializeComponent(); part = _part; addNew = _addNew; if (addNew == false) { txtName.Text = _part.Name; txtCharact.Text = _part.Characteristic; txtDescrip.Text = _part.Description; txtPrice.Text = _part.Price.ToString(); this.Text = "Редактирование товара"; } else { this.Text = "Добавление товара"; } }