private void button5_Click(object sender, EventArgs e) { AddSessionRooms addSessionRooms = new AddSessionRooms(this); addSessionRooms.comboBox1.Enabled = true; addSessionRooms.button3.Enabled = true; addSessionRooms.button4.Enabled = false; addSessionRooms.ShowDialog(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { string colName = dataGridView1.Columns[e.ColumnIndex].Name; if (colName == "colEdit") { AddSessionRooms addSessionRooms = new AddSessionRooms(this); addSessionRooms.button3.Enabled = false; addSessionRooms.button4.Enabled = true; addSessionRooms.comboBox1.Enabled = false; addSessionRooms.comboBox1.Text = _ID; addSessionRooms.textBox1.Enabled = false; addSessionRooms.textBox2.Enabled = false; addSessionRooms.textBox3.Enabled = false; addSessionRooms.textBox4.Enabled = false; addSessionRooms.textBox5.Enabled = false; addSessionRooms.textBox6.Enabled = false; addSessionRooms.textBox7.Enabled = false; addSessionRooms.textBox8.Enabled = false; addSessionRooms.textBox1.Text = _Lecturer1; addSessionRooms.textBox2.Text = _Lecturer2; addSessionRooms.textBox3.Text = _SubjectCode; addSessionRooms.textBox4.Text = _SubjectName; addSessionRooms.textBox5.Text = _GroupID; addSessionRooms.textBox6.Text = _Tag; addSessionRooms.textBox7.Text = _StudentCount; addSessionRooms.textBox8.Text = _Duration; addSessionRooms.comboBox2.Text = _RoomName; addSessionRooms.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 session_Room where ID like '" + _ID + "'", cn); cm.ExecuteNonQuery(); cn.Close(); MessageBox.Show("Record has been successfully deleted.", "Deleted Record", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadRecords(); } } }