private void btnChange_Click(object sender, EventArgs e) { Toy toy = GetSelectedToy(); if (toy == null) { return; } FormToy formToy = new FormToy(toy); if (formToy.ShowDialog() == DialogResult.OK) { Toy fToy = formToy.toy; toy.Change(fToy.Type, fToy.Age, fToy.Price); RefreshGrid(); ListIsChanged = true; } }
private void btnDelete_Click(object sender, EventArgs e) { Toy toy = GetSelectedToy(); if (toy == null) { return; } DialogResult result = MessageBox.Show("Are you sure you want to delete this record?", "Deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.No) { return; } toys.Remove(toy); RefreshGrid(); ListIsChanged = true; }
public FormToy(Toy toy = null) { InitializeComponent(); this.toy = toy; InitFields(); }