private void btnBack_Click(object sender, EventArgs e)
        {
            frmAddRubricLevel addrubric = new frmAddRubricLevel();

            addrubric.Show();
            this.Hide();
        }
Exemplo n.º 2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int             index        = e.RowIndex;
            DataGridViewRow selected_row = dataGridView1.Rows[index];
            string          id           = selected_row.Cells[1].Value.ToString();

            Int32.TryParse(id, out MyClass.rubricId);

            if (e.ColumnIndex == 3)
            {
                if (DialogResult.Yes == MessageBox.Show("Do you want to edit the row?", "", MessageBoxButtons.YesNo))
                {
                    frmEditRubric cl = new frmEditRubric();
                    cl.Show();
                    this.Hide();
                }
            }
            else if (e.ColumnIndex == 4)
            {
                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        asscompId = "SELECT Id FROM RubricLevel Where RubricId = " + MyClass.rubricId;
                    SqlCommand    sqlCmd    = new SqlCommand(asscompId, conn1);
                    SqlDataReader myReader;
                    myReader = sqlCmd.ExecuteReader();
                    if (!myReader.Read())
                    {
                        int i = 0;
                    }
                    else
                    {
                        try
                        {
                            MyClass.rubriclevelId = Convert.ToInt32(myReader.GetValue(0).ToString());
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                    }

                    String std = "Delete FROM  StudentResult Where RubricMeasurementId = " + MyClass.rubriclevelId;
                    //SqlCommand cmd = new SqlCommand("SELECT * FROM Customer", conn);
                    SqlDataAdapter sqlDataAdap = new SqlDataAdapter(std, conn1);
                    sqlDataAdap.SelectCommand.ExecuteNonQuery();

                    String asscomp = "Delete FROM  AssessmentComponent Where RubricId = " + MyClass.rubricId;
                    //SqlCommand cmd = new SqlCommand("SELECT * FROM Customer", conn);
                    SqlDataAdapter sqlData = new SqlDataAdapter(asscomp, conn1);
                    sqlData.SelectCommand.ExecuteNonQuery();

                    String rublvl = "Delete FROM RubricLevel Where RubricId = " + MyClass.rubricId;
                    //SqlCommand cmd = new SqlCommand("SELECT * FROM Customer", conn);
                    SqlDataAdapter sqlDataAdapt = new SqlDataAdapter(rublvl, conn1);
                    sqlDataAdapt.SelectCommand.ExecuteNonQuery();

                    String cmd1 = "Delete FROM Rubric Where Rubric.Id = " + MyClass.rubricId;
                    //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");
                }
            }
            else if (e.ColumnIndex == 5)
            {
                frmAddRubricLevel r1 = new frmAddRubricLevel();
                r1.Show();
                this.Hide();
            }
        }