private void btn_assessment_component_Click(object sender, EventArgs e) { Assessment_Component t = new Assessment_Component(); this.Hide(); t.Show(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { SqlConnection Connection = new SqlConnection(ConectionString); Connection.Open(); if (e.ColumnIndex == dataGridView1.Columns["btn_Edit"].Index) { btn_Update.Show(); btn_add.Hide(); int row = e.RowIndex; int id = Convert.ToInt32(dataGridView1.Rows[row].Cells["Id"].Value); ID = id; string Get_Query = "select * FROM dbo.Assessment WHERE Id = '" + id + "'"; SqlCommand cmd = new SqlCommand(Get_Query, Connection); var myReader = cmd.ExecuteReader(); myReader.Read(); txt_title.Text = myReader[1].ToString(); txt_total_marks.Text = myReader.GetInt32(3).ToString(); txt_total_weightage.Text = myReader.GetInt32(4).ToString(); } else { } if (e.ColumnIndex == dataGridView1.Columns["btn_Delete"].Index) { DialogResult result = MessageBox.Show("Do You Want to delete?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result.Equals(DialogResult.OK)) { this.dataGridView1.Rows.RemoveAt(e.RowIndex); int row = e.RowIndex; int Id = Convert.ToInt32(dataGridView1.Rows[row].Cells["Id"].Value); string Delete_Query = "DELETE FROM dbo.Assessment WHERE Id = '" + Id + "'"; SqlCommand cmd = new SqlCommand(Delete_Query, Connection); cmd.ExecuteNonQuery(); MessageBox.Show("Data has been deleted!"); } } else { } if (e.ColumnIndex == dataGridView1.Columns["btn_Add_Component"].Index) { int row = e.RowIndex; int id = Convert.ToInt32(dataGridView1.Rows[row].Cells["Id"].Value); Assessment_Component a = new Assessment_Component(id); this.Hide(); a.Show(); } }