Exemplo n.º 1
0
        /// <summary>
        /// function creates a new object of viewCLo form and close the current form
        /// </summary>
        /// <param name="sender">sender is the object sender that raised the event.</param>
        /// <param name="e"> e is the Event Argument of the object and basically contains the event data</param>
        private void button2_Click(object sender, EventArgs e)
        {
            ViewClo vc = new ViewClo();

            this.Hide();
            vc.Show();
        }
Exemplo n.º 2
0
        /// <summary>
        /// function Edit the CLO
        /// Function also delete the sleected CLO and Rubrics againast the CLO
        /// and Rubriclevel and Assesment component against that Rubric According to user permission
        /// </summary>
        /// <param name="sender">sender is the object sender that raised the event.</param>
        /// <param name="e"> e is the Event Argument of the object and basically contains the event data</param>
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            ///checks if e.columnindex is equal to the edit column index
            if (e.ColumnIndex == dataGridView1.Columns["Edit"].Index)
            {
                SqlConnection con = new SqlConnection(connection);
                con.Open();
                if (con.State == ConnectionState.Open)
                {
                    int    ID   = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value);
                    string name = (dataGridView1.Rows[e.RowIndex].Cells["Name"].Value).ToString();

                    EditClo frm = new EditClo(ID, name);
                    this.Hide();
                    frm.Show();
                }
            }
            ///checks if e.columnindex is equal to delete index
            if (e.ColumnIndex == dataGridView1.Columns["Delete"].Index)
            {
                SqlConnection con = new SqlConnection(connection);
                con.Open();
                if (con.State == ConnectionState.Open)
                {
                    ///Confirms from the user
                    if (MessageBox.Show("Deleting this item will cause other items to delete. Are You Sure you Want to Delete?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        //Delete the whole hierarchy
                        int        ID   = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value);
                        SqlCommand comm = new SqlCommand("SELECT Id FROM dbo.Rubric Where  CloId = '" + ID + "' ", con);

                        SqlDataReader reader = comm.ExecuteReader();
                        List <string> str    = new List <string>();
                        int           i      = 0;
                        while (reader.Read())
                        {
                            str.Add(reader.GetValue(i).ToString());
                            i++;
                        }
                        reader.Close();
                        for (int j = 0; j < str.Count; j++)
                        {
                            SqlCommand com = new SqlCommand("SELECT Id FROM dbo.RubricLevel Where  RubricId = '" + str[j] + "' ", con);

                            SqlDataReader reader1 = com.ExecuteReader();
                            List <string> str1    = new List <string>();
                            int           k       = 0;
                            while (reader1.Read())
                            {
                                str1.Add(reader1.GetValue(k).ToString());
                                k++;
                            }
                            reader1.Close();
                            for (int f = 0; f < str1.Count; f++)
                            {
                                string     query4 = "DELETE FROM dbo.StudentResult WHERE RubricMeasurementId = '" + str1[f] + "'";
                                SqlCommand cmd4   = new SqlCommand(query4, con);
                                cmd4.ExecuteNonQuery();
                            }

                            string     query2 = "DELETE FROM dbo.RubricLevel WHERE RubricId = '" + str[j] + "'";
                            SqlCommand cmd3   = new SqlCommand(query2, con);
                            cmd3.ExecuteNonQuery();
                        }
                        for (int j = 0; j < str.Count; j++)
                        {
                            string     query2 = "DELETE FROM dbo.AssessmentComponent WHERE RubricId = '" + str[j] + "'";
                            SqlCommand cmd3   = new SqlCommand(query2, con);
                            cmd3.ExecuteNonQuery();
                        }
                        string     query1 = "DELETE FROM dbo.Rubric WHERE CloId = '" + ID + "'";
                        SqlCommand cmd1   = new SqlCommand(query1, con);
                        cmd1.ExecuteNonQuery();
                        string     query = "DELETE FROM dbo.Clo WHERE Id = '" + ID + "'";
                        SqlCommand cmd   = new SqlCommand(query, con);
                        cmd.ExecuteNonQuery();
                        ViewClo frm = new ViewClo();
                        this.Hide();
                        frm.Show();
                        MessageBox.Show("Date Deleted");
                    }
                }
            }
        }