private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { string colName = dataGridView1.Columns[e.ColumnIndex].Name; if (colName == "colEdit") { AddLocation addLocation = new AddLocation(this); addLocation.button3.Enabled = false; addLocation.button4.Enabled = true; addLocation.textBox2.Enabled = true; //addLocation.textBox2.Enabled = false; addLocation.textBox2.Text = _AddNo; addLocation.comboBox1.Text = _DepartmentName; addLocation.radioButton1.Checked = true; addLocation.radioButton2.Checked = true; addLocation.comboBox2.Text = _RoomName; addLocation.textBox1.Text = _Capacity; addLocation.ShowDialog(); } else if (colName == "colDelete") { if (MessageBox.Show("Are you sure you want to delete this record?", "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { cn.Open(); cm = new MySqlCommand("delete from location where AddNo like '" + _AddNo + "'", cn); cm.ExecuteNonQuery(); cn.Close(); MessageBox.Show("Record has been successfully deleted.", "Deleted Record", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadRecords(); } } }
private void button2_Click(object sender, EventArgs e) { AddLocation addLocation = new AddLocation(this); addLocation.textBox2.Enabled = true; addLocation.button3.Enabled = true; addLocation.button4.Enabled = false; this.Hide(); addLocation.ShowDialog(); }