public void LoadInstruments() { dataGridViewInstrument.Rows.Clear(); foreach (Instrument instrument in DBObjectController.GetAllInstruments()) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dataGridViewInstrument, new object[] { Name = instrument.Name }); row.Tag = instrument; dataGridViewInstrument.Rows.Add(row); } }
private void buttonSave_Click(object sender, EventArgs e) { if (dataGridViewInstrument.CurrentRow != null) { SimpleTextValidation(textBoxCurrentInstrumentName, new CancelEventArgs()); if (NoErrorProviderMsg()) { string name = textBoxCurrentInstrumentName.Text; dataGridViewInstrument.CurrentRow.Cells[0].Value = name; ((Instrument)dataGridViewInstrument.CurrentRow.Tag).Name = name; DBObjectController.StoreObject((Instrument)dataGridViewInstrument.CurrentRow.Tag); } } }
private void buttonAdd_Click(object sender, EventArgs e) { if (ValidateChildren() && string.IsNullOrEmpty(errorProviderInstrument.GetError(textBoxInstrument))) { string name = textBoxInstrument.Text; Instrument instrument = new Instrument() { Name = name }; DBObjectController.StoreObject(instrument); DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dataGridViewInstrument, new object[] { Name = instrument.Name }); row.Tag = instrument; dataGridViewInstrument.Rows.Add(row); textBoxInstrument.Clear(); } }
private void dataGridViewInstrument_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { DBObjectController.DeleteObject((Instrument)dataGridViewInstrument.CurrentRow.Tag); }