Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            AddRubric s = new AddRubric();

            this.Hide();
            s.Show();
        }
Exemplo n.º 2
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Edit")
     {
         Class1.id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value);
         this.Hide();
         AddRubric registerStudent = new AddRubric();
         registerStudent.Show();
     }
     if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Delete")
     {
         int stdId = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value);
         if (MessageBox.Show("Do you want to delete " + dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString() + "?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             con.Open();
             SqlCommand command = new SqlCommand("DELETE FROM Rubric WHERE Id  = '" + stdId + "'", con);
             command.ExecuteNonQuery();
             con.Close();
             this.rubricTableAdapter.Fill(this.projectBDataSet.Rubric);
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// This fn. is also in two parts. It also do two things one is that ifthe
        /// btn text is add than it adds the dta to the rubric table and if it
        /// is ipdate it updates the data.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection connection = new SqlConnection(constring);

            bool flag = false;

            if (button1.Text == "Add Rubric")
            {
                if (txtDetails.Text == "")
                {
                    MessageBox.Show("Rubric details cannot be null");
                    flag = true;
                }
                if (comboCloNo.Text == "")
                {
                    MessageBox.Show("CLOID cannot be null");
                    flag = true;
                }
                if (txtRubricId.Text == "")
                {
                    MessageBox.Show("Rubric ID cannot be null");
                    flag = true;
                }
                bool       isExist = false;
                string     query2  = "SELECT CloId, COUNT(CloId) FROM Rubric GROUP BY CloId HAVING COUNT(CloId) >= 4";
                SqlCommand cmd1    = new SqlCommand(query2, connection);
                connection.Open();
                SqlDataReader reader = cmd1.ExecuteReader();
                while (reader.Read())
                {
                    int id = Convert.ToInt32(comboCloNo.Text);
                    if (id == Convert.ToInt32(comboCloNo.Text))
                    {
                        isExist = true;
                        MessageBox.Show("More than 4 rubrics can't be added against 1 Clo");
                        break;
                    }
                }
                connection.Close();
                bool       isExist1 = false;
                string     query3   = "SELECT Id FROM Rubric";
                SqlCommand cmd2     = new SqlCommand(query3, connection);
                connection.Open();
                SqlDataReader reader1 = cmd2.ExecuteReader();
                while (reader1.Read())
                {
                    int id = Convert.ToInt32(txtRubricId.Text);
                    if (id == Convert.ToInt32(txtRubricId.Text))
                    {
                        isExist1 = true;
                        MessageBox.Show("Rubric Id should be Unique;");
                        break;
                    }
                }
                connection.Close();
                if (isExist == false && isExist1 == false && flag == false)
                {
                    string        qeury       = "insert into dbo.Rubric(Id, Details,CloId) values('" + this.txtRubricId.Text + "','" + txtDetails.Text + "','" + this.comboCloNo.Text + "')";
                    SqlConnection conDataBase = new SqlConnection(constring);
                    SqlCommand    cmdDataBase = new SqlCommand(qeury, conDataBase);
                    SqlDataReader myreader;
                    conDataBase.Open();
                    myreader = cmdDataBase.ExecuteReader();
                    MessageBox.Show("Rubric has been Saved");
                    txtRubricId.Text = "";
                    txtDetails.Text  = "";
                    comboCloNo.Text  = "";
                    while (myreader.Read())
                    {
                    }
                    using (SqlConnection sqlcon = new SqlConnection(constring))
                    {
                        sqlcon.Open();
                        SqlDataAdapter sqlDA = new SqlDataAdapter("Select * from dbo.Rubric", sqlcon);
                        DataTable      dtbl  = new DataTable();
                        sqlDA.Fill(dtbl);

                        dataRubric.DataSource = dtbl;
                    }
                    AddRubric.Hide();
                    tab2.Show();
                }
            }
            if (button1.Text == "Update")
            {
                connection.Open();
                string Qeury = "Update dbo.Rubric Set Id ='" + txtRubricId.Text + "',Details='" + txtDetails.Text + "',CLoId='" + comboCloNo.Text + "' Where Id ='" + id + "' ";

                SqlCommand cmd = new SqlCommand(Qeury, connection);
                cmd.ExecuteNonQuery();

                MessageBox.Show("Rubric is  Updated");
                button1.Text     = "Add Rubric";
                txtRubricId.Text = "";
                txtDetails.Text  = "";
                comboCloNo.Text  = "";
                AddRubric.Hide();
                tab2.Show();
                using (SqlConnection sqlcon = new SqlConnection(constring))
                {
                    sqlcon.Open();
                    SqlDataAdapter sqlDA = new SqlDataAdapter("Select * from dbo.Rubric", sqlcon);
                    DataTable      dtbl  = new DataTable();
                    sqlDA.Fill(dtbl);

                    dataRubric.DataSource = dtbl;
                }
            }
        }
Exemplo n.º 4
0
        private void dataRubric_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            SqlConnection connection = new SqlConnection(constring);

            connection.Open();
            if (e.ColumnIndex == dataRubric.Columns["Delete"].Index)
            {
                try
                {
                    int[] rubric_level         = new int[4];
                    int   j                    = 0;
                    int[] assessment_componenT = new int[100];


                    int row = e.RowIndex;
                    id = Convert.ToInt32(dataRubric.Rows[e.RowIndex].Cells[0].Value);
                    String     d    = "SELECT Id FROM dbo.RubricLevel where RubricId ='" + id + "'";
                    SqlCommand com1 = new SqlCommand(d, connection);
                    com1.Parameters.Add(new SqlParameter("0", 1));
                    SqlDataReader r2 = com1.ExecuteReader();
                    while (r2.Read())
                    {
                        rubric_level[j] = Convert.ToInt32(r2[0]);
                        j++;
                    }
                    r2.Close();
                    int        s     = rubric_level[0];
                    int        v     = rubric_level[1];
                    String     del   = "SELECT Id FROM dbo.AssessmentComponent where RubricId ='" + id + "'";
                    SqlCommand com11 = new SqlCommand(del, connection);
                    com11.Parameters.Add(new SqlParameter("0", 1));
                    SqlDataReader r3 = com11.ExecuteReader();
                    while (r3.Read())
                    {
                        assessment_componenT[j] = Convert.ToInt32(r3[0]);
                        j++;
                    }
                    r3.Close();

                    int s1 = assessment_componenT[1];
                    int s2 = assessment_componenT[0];
                    int s3 = assessment_componenT[2];

                    foreach (int a in rubric_level)

                    {
                        int        delete = a;
                        string     Qeury0 = "Delete from dbo.StudentResult where RubricMeasurementId = '" + a + "'";
                        SqlCommand cmd0   = new SqlCommand(Qeury0, connection);
                        cmd0.ExecuteNonQuery();
                    }
                    foreach (int a in assessment_componenT)

                    {
                        int        delete = a;
                        string     Qeury1 = "Delete from dbo.StudentResult where AssessmentComponentId = '" + a + "'";
                        SqlCommand cmd1   = new SqlCommand(Qeury1, connection);
                        cmd1.ExecuteNonQuery();
                    }
                    string     Qeury2 = "Delete from dbo.RubricLevel where RubricId = '" + id + "'";
                    SqlCommand cmd3   = new SqlCommand(Qeury2, connection);
                    cmd3.ExecuteNonQuery();


                    string     Qeury4 = "Delete from dbo.AssessmentComponent where RubricId = '" + id + "'";
                    SqlCommand cmd4   = new SqlCommand(Qeury4, connection);
                    cmd4.ExecuteNonQuery();

                    string     qeury5 = "Delete from dbo.Rubric where Id = '" + id + "'";
                    SqlCommand cmd5   = new SqlCommand(qeury5, connection);
                    cmd5.ExecuteNonQuery();

                    MessageBox.Show("Rubric Deleted");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            if (e.ColumnIndex == dataRubric.Columns["edit"].Index)
            {
                string temp = dataRubric.Rows[e.RowIndex].Cells[0].FormattedValue.ToString();
                id = Convert.ToInt32(temp);



                txtRubricId.Text = dataRubric.Rows[e.RowIndex].Cells[0].FormattedValue.ToString();
                comboCloNo.Text  = dataRubric.Rows[e.RowIndex].Cells[2].FormattedValue.ToString();
                txtDetails.Text  = dataRubric.Rows[e.RowIndex].Cells[1].FormattedValue.ToString();
                button1.Text     = "Update";
                tab2.Hide();

                AddRubric.Show();
            }
        }