private void AddProject_Click(object sender, EventArgs e) { AddProject E5 = new AddProject(); E5.Show(); this.Hide(); }
private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e) { SqlConnection con = new SqlConnection(conURL); con.Open(); int currentRow = int.Parse(e.RowIndex.ToString()); int currentColumnIndex = int.Parse(e.ColumnIndex.ToString()); int id = Convert.ToInt32(dataGridView1.Rows[currentRow].Cells[2].Value.ToString()); if (currentColumnIndex == 0) { AddProject fe = new AddProject(id); fe.Show(); this.Hide(); } if (currentColumnIndex == 1) { var confirmResult = MessageBox.Show("Are you sure to delete this item ??", "Confirm Delete!!", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { SqlCommand cmd1; SqlCommand cmd2; SqlCommand cmd3; string deleteproject = "DELETE FROM Project Where Id = @num"; string deleteprojectadv = "DELETE FROM ProjectAdvisor Where ProjectId = @num"; string deletegrouppr = "DELETE FROM GroupProject Where ProjectId = @num"; cmd1 = new SqlCommand(deleteproject, con); cmd2 = new SqlCommand(deleteprojectadv, con); cmd3 = new SqlCommand(deletegrouppr, con); cmd1.Parameters.AddWithValue("@num", id); cmd2.Parameters.AddWithValue("@num", id); cmd3.Parameters.AddWithValue("@num", id); cmd3.ExecuteNonQuery(); cmd2.ExecuteNonQuery(); cmd1.ExecuteNonQuery(); con.Close(); MessageBox.Show("Record deleted succesfully"); ManageProject fm = new ManageProject(); this.Close(); fm.Show(); } } }