private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { string colName = dataGridView1.Columns[e.ColumnIndex].Name; if (colName == "colEdit") { AddLec frm = new AddLec(); frm.button1.Enabled = false; frm.btnupdate.Enabled = true; frm.textBox1.Text = _id; frm.textBox2.Text = _name; frm.comboBox1.Text = _faculty; frm.comboBox2.Text = _department; frm.comboBox3.Text = _building; frm.comboBox4.Text = _center; frm.textBox7.Text = _rank; frm.comboBox5.Text = _level; frm.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 tbllecturer where id like'" + _id + "'", cn); cm.ExecuteNonQuery(); cn.Close(); MessageBox.Show("Record has been Successfully deleted !", "Deleted Record", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadRecord(); } } }
/* private void button2_Click(object sender, EventArgs e) * { * this.Hide(); * Dashboard f2 = new Dashboard(); * f2.Show(); * }*/ private void button1_Click(object sender, EventArgs e) { this.Hide(); AddLec f2 = new AddLec(); f2.Show(); }