private void editOfdDataButton_Click(object sender, EventArgs e) { if (ofdDataGridView.SelectedRows.Count > 0) { int index = ofdDataGridView.SelectedRows[0].Index; int id; bool converted = int.TryParse(ofdDataGridView[0, index].Value.ToString(), out id); if (!converted) { return; } var ofds = from t in controller.Elements where t.ID == id select t; OFD ofd = ofds.First(); OfdForm ofdForm = new OfdForm(); ofdForm.fullNameTextBox.Text = ofd.FullName; ofdForm.tinTextBox.Text = ofd.TIN; DialogResult dialogResult = ofdForm.ShowDialog(this); if (dialogResult == DialogResult.Cancel) { return; } ofd.FullName = ofdForm.fullNameTextBox.Text; ofd.TIN = ofdForm.tinTextBox.Text; controller.UpdateElement(ofd); ofdDataGridView.DataSource = controller.Elements; } }
private void addOfdDataButton_Click(object sender, EventArgs e) { OfdForm ofdAddForm = new OfdForm(); DialogResult dialogResult = ofdAddForm.ShowDialog(this); if (dialogResult == DialogResult.Cancel) { return; } var newOfd = new OFD(ofdAddForm.tinTextBox.Text, ofdAddForm.fullNameTextBox.Text); controller.AddElement(newOfd); ofdDataGridView.DataSource = controller.Elements; }