Example #1
0
        private void AssessmentComponent_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'projectBDataSet5.AssessmentComponent' table. You can move, or remove it, as needed.
            this.assessmentComponentTableAdapter1.Fill(this.projectBDataSet5.AssessmentComponent);
            // TODO: This line of code loads data into the 'projectBDataSet4.AssessmentComponent' table. You can move, or remove it, as needed.
            this.assessmentComponentTableAdapter.Fill(this.projectBDataSet4.AssessmentComponent);
            btn_AssessmentComponent.BackColor = Color.Gray;
            btn_AssessmentComponent.Enabled   = false;
            btn_Update.Enabled = false;
            btn_Add.Enabled    = true;

            AssessmentComponents ass = new AssessmentComponents();

            ass.AddAssessmentTitleToCombobox(cmb_AssessmentTitle);
            ass.AddRubricDetailsToCombobox(cmb_RubricDetails);



            DataTable dt    = ass.ShowInGrid();
            int       count = dt.Rows.Count;

            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;
            }
        }
Example #2
0
        private void btn_Update_Click(object sender, EventArgs e)
        {
            AssessmentComponents ass = new AssessmentComponents();

            lbl_ErrorName.Text      = ass.ValidName(txt_Name.Text);
            lbl_ErrorName.ForeColor = System.Drawing.Color.Red;
            lbl_ErrorName.Refresh();

            lbl_ErrorTotalMarks.Text      = ass.ValidTotalMarks(txt_TotalMarks.Text);
            lbl_ErrorTotalMarks.ForeColor = System.Drawing.Color.Red;
            lbl_ErrorTotalMarks.Refresh();

            if (lbl_ErrorName.Text == "" || lbl_ErrorTotalMarks.Text == "")
            {
                ass.name       = txt_Name.Text;
                ass.totalMarks = Convert.ToInt32(txt_TotalMarks.Text);

                ass.AssessmentId = ass.getAssessmentIdFromTitle(cmb_AssessmentTitle.Text);
                ass.RubricId     = ass.getRubricIdFromDetails(cmb_RubricDetails.Text);

                ass.Edit(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;
                }
                txt_Name.Clear();
                txt_TotalMarks.Clear();
                cmb_AssessmentTitle.Text = "";
                cmb_RubricDetails.Text   = "";

                btn_Add.Enabled    = true;
                btn_Update.Enabled = false;
            }
        }
Example #3
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;
                }
            }
        }