private void addButton_Click(object sender, EventArgs e) { var form = new DiscountForm(); if (form.ShowDialog() != DialogResult.OK) { return; } iDiscountBindingSource.Add(form.Discount); var index = iDiscountBindingSource.Count; WriteDiscountInfo(form.Discount, index - 1); }
private void modifyButton_Click(object sender, EventArgs e) { if (iDiscountBindingSource.Current == null) { return; } var form = new DiscountForm { Discount = iDiscountBindingSource.Current as IDiscount }; if (form.ShowDialog() != DialogResult.OK) { return; } var index = iDiscountBindingSource.IndexOf(iDiscountBindingSource.Current); iDiscountBindingSource.Insert(index, form.Discount); iDiscountBindingSource.RemoveAt(index + 1); WriteDiscountInfo(form.Discount, index); }