private void dataGridView1_CellContentClick(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());
            string advemail           = dataGridView1.Rows[currentRow].Cells[4].Value.ToString();

            if (currentColumnIndex == 0)
            {
                var confirmResult = MessageBox.Show("Are you sure to delete this item ??",
                                                    "Confirm Delete!!",
                                                    MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    string     delete = "DELETE FROM ProjectAdvisor Where AdvisorId = @val1 AND ProjectId = @val2";
                    SqlCommand cmd    = new SqlCommand(delete, con);

                    string     email = string.Format("SELECT Id FROM Person WHERE Email = '{0}'", advemail);
                    SqlCommand cmd1  = new SqlCommand(email, con);
                    int        advid = (Int32)cmd1.ExecuteScalar();

                    cmd.Parameters.AddWithValue("@val1", advid);
                    cmd.Parameters.AddWithValue("@val2", flag);
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Record deleted succesfully");
                    ManageProjectAdvisors_2 form = new ManageProjectAdvisors_2(flag);
                    this.Close();
                    form.Show();
                }
            }
        }
Exemplo n.º 2
0
        private void dataGridView1_CellContentClick(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 prid = Convert.ToInt32(dataGridView1.Rows[currentRow].Cells[2].Value.ToString());

            if (currentColumnIndex == 0)
            {
                ManageProjectAdvisors_1 form = new ManageProjectAdvisors_1(prid);
                this.Close();
                form.Show();
            }

            if (currentColumnIndex == 1)
            {
                ManageProjectAdvisors_2 form1 = new ManageProjectAdvisors_2(prid);
                this.Close();
                form1.Show();
            }
        }