private void btn_Update_Click(object sender, EventArgs e)
        {
            Assessments a = new Assessments();

            lbl_ErrorTitle.Text      = a.ValidTitle(txt_Title.Text);
            lbl_ErrorTitle.ForeColor = System.Drawing.Color.Red;
            lbl_ErrorTitle.Refresh();


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


            lbl_ErrorTotalWeightage.Text      = a.ValidTotalWeight(txt_TotalWeightage.Text);
            lbl_ErrorTotalWeightage.ForeColor = System.Drawing.Color.Red;
            lbl_ErrorTotalWeightage.Refresh();

            if (lbl_ErrorTitle.Text == "" && lbl_ErrorTotalMarks.Text == "" && lbl_ErrorTotalWeightage.Text == "")
            {
                a.title          = txt_Title.Text;
                a.totalMarks     = Convert.ToInt32(txt_TotalMarks.Text);
                a.totalWeightage = Convert.ToInt32(txt_TotalWeightage.Text);

                a.Edit(id);
                DataTable dt = a.ShowInGrid();
                dataGridView1.DataSource = dt;
                txt_Title.Clear();
                txt_TotalMarks.Clear();
                txt_TotalWeightage.Clear();
                btn_Update.Enabled = false;
                btn_Add.Enabled    = true;
            }
        }
        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_Title.Text          = dataGridView1.Rows[e.RowIndex].Cells[1].FormattedValue.ToString();
                txt_TotalMarks.Text     = dataGridView1.Rows[e.RowIndex].Cells[3].FormattedValue.ToString();
                txt_TotalWeightage.Text = dataGridView1.Rows[e.RowIndex].Cells[4].FormattedValue.ToString();
            }
            else if (value == "Delete")
            {
                string id1 = dataGridView1.Rows[e.RowIndex].Cells[0].FormattedValue.ToString();
                id = Convert.ToInt32(id1);

                Assessments a = new Assessments();
                a.Delete(id);
                DataTable dt = a.ShowInGrid();
                dataGridView1.DataSource = dt;
            }
            btn_Add.Enabled    = false;
            btn_Update.Enabled = true;
        }
        private void btn_Add_Click(object sender, EventArgs e)
        {
            Assessments a = new Assessments();

            lbl_ErrorTitle.Text      = a.ValidTitle(txt_Title.Text);
            lbl_ErrorTitle.ForeColor = System.Drawing.Color.Red;
            lbl_ErrorTitle.Refresh();


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


            lbl_ErrorTotalWeightage.Text      = a.ValidTotalWeight(txt_TotalWeightage.Text);
            lbl_ErrorTotalWeightage.ForeColor = System.Drawing.Color.Red;
            lbl_ErrorTotalWeightage.Refresh();

            if (lbl_ErrorTitle.Text == "" && lbl_ErrorTotalMarks.Text == "" && lbl_ErrorTotalWeightage.Text == "")
            {
                if (a.TitleAlreadyExist(txt_Title.Text) == "")
                {
                    a.title          = txt_Title.Text;
                    a.totalMarks     = Convert.ToInt32(txt_TotalMarks.Text);
                    a.totalWeightage = Convert.ToInt32(txt_TotalWeightage.Text);

                    a.Add();
                    txt_Title.Clear();
                    txt_TotalMarks.Clear();
                    txt_TotalWeightage.Clear();
                    DataTable dt = a.ShowInGrid();
                    dataGridView1.DataSource = dt;
                }
                else
                {
                    MessageBox.Show("Title already exist");
                }
            }
        }