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