/// <summary> /// To Edit the data of Student /// </summary> public void EditStdData() { if (DialogResult.Yes == MessageBox.Show("Do you want to edit the row?", "", MessageBoxButtons.YesNo)) { frmEditStdDetail EditStdDetail = new frmEditStdDetail(); EditStdDetail.Show(); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int index = e.RowIndex; DataGridViewRow selected_row = dataGridView1.Rows[index]; string id = selected_row.Cells[0].Value.ToString(); int x; Int32.TryParse(id, out x); MyClass.count = x; if (e.ColumnIndex == 7) { if (DialogResult.Yes == MessageBox.Show("Do you want to edit the row?", "", MessageBoxButtons.YesNo)) { frmEditStdDetail s2 = new frmEditStdDetail(); s2.Show(); this.Hide(); } } else if (e.ColumnIndex == 8) { if (DialogResult.Yes == MessageBox.Show("Do you want to delete the row?", "", MessageBoxButtons.YesNo)) { String conURL1 = "Data Source = DESKTOP-RPO4Q5R\\PARVEEN; Initial Catalog =ProjectB; User ID = mohsin; Password = mohsin123; MultipleActiveResultSets = True"; //String conURL = "Data Source = (local); Initial Catalog = MedicalEncyclopedia; Integrated Security = True; MultipleActiveResultSets = True"; SqlConnection conn1 = new SqlConnection(conURL1); conn1.Open(); String cmd1 = "Delete FROM Student Where Student.Id = " + MyClass.count; //SqlCommand cmd = new SqlCommand("SELECT * FROM Customer", conn); SqlDataAdapter cmd = new SqlDataAdapter(cmd1, conn1); cmd.SelectCommand.ExecuteNonQuery(); conn1.Close(); MessageBox.Show("Data Has been successfuly deleted"); } } }