private void btnAddRecord_Click(object sender, EventArgs e) { var addRentalRecord = new AddEditRentalRecord { MdiParent = this.MdiParent }; addRentalRecord.Show(); }
private void addRentalRecordToolStripMenuItem_Click(object sender, EventArgs e) { if (!Utils.FormIsOpen("AddEditRentalRecord")) { var addRentalRecord = new AddEditRentalRecord(); addRentalRecord.ShowDialog(); addRentalRecord.MdiParent = this; } }
private void btnEditRecord_Click(object sender, EventArgs e) { try { // Get Id of selected row var id = (int)gvRecordList.SelectedRows[0].Cells["id"].Value; // Query database for record var record = _db.CarRentalRecord.FirstOrDefault(q => q.id == id); AddEditRentalRecord addEditRentalRecord = new AddEditRentalRecord(record); addEditRentalRecord.MdiParent = this.MdiParent; addEditRentalRecord.Show(); } catch (Exception ex) { MessageBox.Show($"Error: {ex.Message}"); } }