示例#1
0
        private void AddAdvisor_Click(object sender, EventArgs e)
        {
            AddAdvisor E4 = new AddAdvisor();

            E4.Show();
            this.Hide();
        }
示例#2
0
        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());
            string     email = string.Format("SELECT Id FROM Person WHERE Email = '{0}'", dataGridView1.Rows[currentRow].Cells[6].Value.ToString());
            SqlCommand cmd3  = new SqlCommand(email, con);
            int        id    = (Int32)cmd3.ExecuteScalar();

            if (currentColumnIndex == 0)
            {
                AddAdvisor f2 = new AddAdvisor(id);
                f2.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 cmd4;
                    string     deleteperson    = "DELETE FROM Person Where Id = @num";
                    string     deleteadvisor   = "DELETE FROM Advisor Where Id = @num";
                    string     deletepradvisor = "DELETE FROM ProjectAdvisor Where AdvisorId = @num";
                    cmd1 = new SqlCommand(deleteadvisor, con);
                    cmd2 = new SqlCommand(deleteperson, con);
                    cmd4 = new SqlCommand(deletepradvisor, con);
                    cmd1.Parameters.AddWithValue("@num", id);
                    cmd2.Parameters.AddWithValue("@num", id);
                    cmd4.Parameters.AddWithValue("@num", id);
                    cmd4.ExecuteNonQuery();
                    cmd1.ExecuteNonQuery();
                    cmd2.ExecuteNonQuery();
                    con.Close();
                    MessageBox.Show("Record deleted succesfully");
                    ManageAdvisor f3 = new ManageAdvisor();
                    this.Close();
                    f3.Show();
                }
            }
        }