Esempio n. 1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string value = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString();

            if (value == "Edit")
            {
                string id1 = dataGridView1.Rows[e.RowIndex].Cells[0].FormattedValue.ToString();
                id                       = Convert.ToInt32(id1);
                txt_Name.Text            = dataGridView1.Rows[e.RowIndex].Cells[1].FormattedValue.ToString();
                cmb_AssessmentTitle.Text = dataGridView1.Rows[e.RowIndex].Cells[2].FormattedValue.ToString();
                cmb_RubricDetails.Text   = dataGridView1.Rows[e.RowIndex].Cells[3].FormattedValue.ToString();
                txt_TotalMarks.Text      = dataGridView1.Rows[e.RowIndex].Cells[6].FormattedValue.ToString();

                btn_Update.Enabled = true;
                btn_Add.Enabled    = false;
            }
            else if (value == "Delete")
            {
                string id1 = dataGridView1.Rows[e.RowIndex].Cells[0].FormattedValue.ToString();
                id = Convert.ToInt32(id1);

                AssessmentComponents ass = new AssessmentComponents();
                ass.Delete(id);

                DataTable dt    = ass.ShowInGrid();
                int       count = dt.Rows.Count;
                dataGridView1.DataSource = dt;
                for (int i = 0; i < count; i++)
                {
                    string s  = ass.getAssessmentTitleFromId(Convert.ToInt32(dt.Rows[i][6]));
                    string s1 = ass.getRubricDetailFromId(Convert.ToInt32(dt.Rows[i][2]));

                    dataGridView1.Rows[i].Cells[3].Value = s1;
                    dataGridView1.Rows[i].Cells[2].Value = s;
                }
            }
        }