private void lecturehall_info_table_CellClick(object sender, DataGridViewCellEventArgs e) { databaseConnection.Open(); MySqlCommand cmd = new MySqlCommand("Select id from lecture_hall_info where lecture_hall = '" + this.lecturehall_info_table.CurrentRow.Cells[0].Value.ToString() + "'", databaseConnection); int id = Convert.ToInt32(cmd.ExecuteScalar()); databaseConnection.Close(); if (e.ColumnIndex == 3) { Add_Update_LectureHall add_update_lecture_hall = new Add_Update_LectureHall(id); add_update_lecture_hall.lecture_hall_textbox.Text = this.lecturehall_info_table.CurrentRow.Cells[0].Value.ToString(); add_update_lecture_hall.capacity_numeric.Value = (int)this.lecturehall_info_table.CurrentRow.Cells[1].Value; add_update_lecture_hall.update_btn.Visible = true; add_update_lecture_hall.add_hall_btn.Visible = false; add_update_lecture_hall.add_update_heading.Text = "Edit Lecture Hall"; add_update_lecture_hall.ShowDialog(); //Refresh LectureHall table this.lecture_hall_infoTableAdapter.Fill(this.dataSet_getLectureHallInfo.lecture_hall_info); } if (e.ColumnIndex == 4) { if (MessageBox.Show("Are you sure want to delete this record?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (e.RowIndex >= 0) { databaseConnection.Open(); DataGridViewRow row = lecturehall_info_table.Rows[e.RowIndex]; MySqlCommand cmd1 = new MySqlCommand("Delete from lecture_hall_info where lecture_hall = '" + row.Cells[0].Value.ToString() + "'", databaseConnection); cmd1.ExecuteNonQuery(); //remove from datatable lecturehallinfoBindingSource.RemoveCurrent(); //Refresh Module Table this.lecture_hall_infoTableAdapter.Fill(this.dataSet_getLectureHallInfo.lecture_hall_info); databaseConnection.Close(); } } } lecture_hall_name.Text = this.lecturehall_info_table.CurrentRow.Cells[0].Value.ToString(); hall_capacity.Text = this.lecturehall_info_table.CurrentRow.Cells[1].Value.ToString(); availability.Text = this.lecturehall_info_table.CurrentRow.Cells[2].Value.ToString(); if (lecturehall_info_table.CurrentRow.Cells[2].Value.ToString() == "Available") { guna2CirclePictureBox1.Image = Properties.Resources.available; groupBox1.Visible = false; } else { guna2CirclePictureBox1.Image = Properties.Resources.busy; groupBox1.Visible = true; } }
private void add_btn_Click(object sender, EventArgs e) { //Add_Update_LectureHall add_update_lecture_hall = new Add_Update_LectureHall(); //add_update_lecture_hall.update_btn.Visible = false; //add_update_lecture_hall.add_hall_btn.Visible = true; //add_update_lecture_hall.add_update_heading.Text = "Add Lecture Hall"; //add_update_lecture_hall.ShowDialog(); Add_Update_LectureHall add_update_lecture_hall = new Add_Update_LectureHall(); add_update_lecture_hall.ShowDialog(); }