private void btnAdd_Click(object sender, EventArgs e) { rtbLogMain.Clear(); var addEditInformation = new AddEditInformation(0, "a"); addEditInformation.FormClosing += AddEditInformation_FormClosing; addEditInformation.ShowDialog(); addEditInformation.FormClosing -= AddEditInformation_FormClosing; }
private void btnEdit_Click(object sender, EventArgs e) { rtbLogMain.Clear(); if (dgvHrInfo.SelectedRows.Count == 0) { rtbLogMain.AppendText($"Error message from {DateTime.Now.ToString()}: " + $"Please select the employee you want to edit {Environment.NewLine}"); return; } var addEditInformation = new AddEditInformation((Convert.ToInt32(dgvHrInfo.SelectedRows[0].Cells["Id"].Value)), "e"); addEditInformation.FormClosing += AddEditInformation_FormClosing; addEditInformation.ShowDialog(); addEditInformation.FormClosing -= AddEditInformation_FormClosing; }