示例#1
0
        private void AddEvaluation_Click(object sender, EventArgs e)
        {
            AddEvaluation E1 = new AddEvaluation();

            E1.Show();
            this.Hide();
        }
        private void dataGridView1_CellContentClick_2(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)
            {
                AddEvaluation fe = new AddEvaluation(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;
                    string     deleteevaluation = "DELETE FROM Evaluation Where Id = @num";
                    string     deletegroupev    = "DELETE FROM GroupEvaluation Where EvaluationId = @num";
                    cmd1 = new SqlCommand(deleteevaluation, con);
                    cmd2 = new SqlCommand(deletegroupev, con);
                    cmd1.Parameters.AddWithValue("@num", id);
                    cmd2.Parameters.AddWithValue("@num", id);
                    cmd2.ExecuteNonQuery();
                    cmd1.ExecuteNonQuery();
                    con.Close();
                    MessageBox.Show("Record deleted succesfully");
                    ManageEvaluation f3 = new ManageEvaluation();
                    this.Close();
                    f3.Show();
                }
            }
        }