Example #1
0
        private void btnAddRecord_Click(object sender, EventArgs e)
        {
            var addRentalRecord = new AddEditRentalRecord {
                MdiParent = this.MdiParent
            };

            addRentalRecord.Show();
        }
Example #2
0
        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 recoed
                var record = _db.CarRentalRecords.FirstOrDefault(q => q.id == id);

                var addEditRentalRecord = new AddEditRentalRecord(record);
                addEditRentalRecord.MdiParent = this.MdiParent;
                addEditRentalRecord.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"EditError: {ex.Message}");
            }
        }