private void ADD_Click(object sender, EventArgs e)
        {
            try
            {
                AssessmentComClass ACC = new AssessmentComClass();

                if (ASSName.Text == "" || TotalMarks.Text == "")
                {
                    MessageBox.Show("please fillall the fields first");
                }
                else
                {
                    string Rubric     = RubricSelection.Text;
                    string assessment = AssessmentSelection.Text;
                    ACC.ASSCOM_ADD(ASSName.Text, Rubric, assessment, Convert.ToInt32(TotalMarks.Text), DateCreated.Value, DateUpdated.Value);
                    MessageBox.Show("Data has been added successfully");
                    RubricSelection.DataSource = null;
                    ASSName.Text             = "";
                    RubricSelection.Text     = "";
                    AssessmentSelection.Text = "";
                    TotalMarks.Text          = "";
                    DateCreated.ResetText();
                    DateUpdated.ResetText();
                    My_Own_Load();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Data insertion Fail,Try again with valid input");
                return;
            }
        }
 /// <summary>
 /// This function used to insert the AssessmentComponent Record in AssessmentComList
 /// </summary>
 /// <param name="query">Query to retrieve the data from database</param>
 public void AssCRecord(string query)
 {
     try
     {
         SqlCommand command = new SqlCommand(query, conn);
         conn.Open();
         SqlDataReader reader;
         reader = command.ExecuteReader();
         if (reader.HasRows)
         {
             ListofClasses Lt1 = new ListofClasses();
             Lt1.RemoveFromASSCom();
             while (reader.Read())
             {
                 AssessmentComClass ASS = new AssessmentComClass();
                 ASS.Id1           = Convert.ToInt32(reader[0]);
                 ASS.Name1         = reader[1].ToString();
                 ASS.RubricId1     = Convert.ToInt32(reader[2]);
                 ASS.TotalMarks1   = Convert.ToInt32(reader[3]);
                 ASS.DateCreated1  = Convert.ToDateTime(reader[4]);
                 ASS.DateUpdated1  = Convert.ToDateTime(reader[5]);
                 ASS.AssessmentId1 = Convert.ToInt32(reader[6]);
                 Lt1.AddASSComList(ASS);
             }
         }
     }
     catch (Exception ex)
     {
         throw (ex);
     }
     finally
     {
         conn.Close();
     }
 }
        private void My_Own_Load()
        {
            AssessmentComClass Acc = new AssessmentComClass();
            ListofClasses      lt1 = new ListofClasses();

            Acc.AssComRecord();
            AssessmentRecord.DataSource = null;
            AssessmentSelection.Text    = "";
            AssessmentRecord.DataSource = lt1.ASSCom1;
            comoboxvalues();
        }
        private void AssessmentRecord_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            AssessmentComClass ACC = new AssessmentComClass();
            ListofClasses      lt  = new ListofClasses();
            int index = AssessmentRecord.CurrentCell.RowIndex;

            DataGridViewRow r  = AssessmentRecord.Rows[index];
            int             id = Convert.ToInt32(r.Cells[0].Value);

            if (AssessmentRecord.Columns[e.ColumnIndex].Name == "Delete")
            {
                DialogResult result = MessageBox.Show("Do You Want to delete data against the id ?" + id, "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (result.Equals(DialogResult.OK))
                {
                    ACC.Delete(id);
                    MessageBox.Show("Data Has been deleted successfully");
                    AssessmentRecord.DataSource = null;
                    My_Own_Load();
                    if (ADD.Visible == false)
                    {
                        ADD.Visible = true;
                    }
                }
                else
                {
                    return;
                }
            }
            if (AssessmentRecord.Columns[e.ColumnIndex].Name == "Edit")
            {
                AssessmentComClass acc = new AssessmentComClass();
                comoboxvalues();
                ASSName.Text = r.Cells[1].Value.ToString();

                int rubricid = Convert.ToInt32(r.Cells[2].Value);
                RubricSelection.SelectedText = acc.NameofRubricId(rubricid);
                int ASSid = Convert.ToInt32(r.Cells[6].Value);
                AssessmentSelection.SelectedText = acc.NameofASSId(ASSid);
                TotalMarks.Text   = r.Cells[3].Value.ToString();
                DateCreated.Value = Convert.ToDateTime(r.Cells[4].Value);
                DateUpdated.Value = Convert.ToDateTime(r.Cells[5].Value);

                globalindex = id;
                if (ADD.Visible)
                {
                    ADD.Visible = false;
                }
            }
        }
        public void comoboxvalues()
        {
            AssessmentComClass Rub = new AssessmentComClass();
            ListofClasses      lt1 = new ListofClasses();

            Rub.addRubricname();
            int length = lt1.Cloname.Count();

            RubricSelection.Items.Clear();

            for (int i = 0; i < length; i++)
            {
                RubricSelection.Items.Add(lt1.Cloname.ElementAt(i));
            }
        }
 private void Save_Click(object sender, EventArgs e)
 {
     try
     {
         string             Rubric     = RubricSelection.Text;
         string             assessment = AssessmentSelection.Text;
         AssessmentComClass Rub        = new AssessmentComClass();
         Rub.Edit(globalindex, ASSName.Text, Rubric, assessment, Convert.ToInt32(TotalMarks.Text), DateCreated.Value, DateUpdated.Value);
         AssessmentRecord.DataSource = null;
         ASSName.Text             = "";
         RubricSelection.Text     = "";
         AssessmentSelection.Text = "";
         TotalMarks.Text          = "";
         DateCreated.ResetText();
         DateUpdated.ResetText();
         My_Own_Load();
         ADD.Visible = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Data can,t be update,please enter valid data");
     }
 }
 /// <summary>
 /// this function used to Add tne  AssessmentComponent in the Assessment Component ClassList
 /// </summary>
 /// <param name="ACC">Indicate the object of the Assessmentcomponent class type</param>
 public void AddASSComList(AssessmentComClass ACC)
 {
     ASSCom.Add(ACC);
 }