//created an array which holds all the values of semIDs
        //public Array insertSubSemGridToDb()
        //{
        //    int[] semID = new int[dgvSemesterSubject.RowCount];
        //    int[] subID = new int[dgvSemesterSubject.RowCount];

        //    foreach (DataGridViewRow dr in dgvSemesterSubject.Rows)
        //    {
        //        for (int i =0;  i < dgvSemesterSubject.RowCount; i++)
        //        {
        //            int semesterID = Convert.ToInt32(dr.Cells[0].Value);
        //            semID[i] = i;
        //        }

        //        for (int x =0;  x < dgvSemesterSubject.RowCount; x++)
        //        {
        //            int subjectID = Convert.ToInt32(dr.Cells[0].Value);
        //            subID[x] = x;
        //        }

        //    }

        //    return semID;
        //}

        private void btnUpdateDatabse_Click(object sender, EventArgs e)
        {
            try
            {
                List <SemesterSubject> saveList = (List <SemesterSubject>)dgvSemesterSubject.DataSource;

                if (saveList.Count != 0)
                {
                    systemManager objsystemManager = new systemManager();

                    Subjects        objSubjects = null;
                    List <Subjects> lstSubjects = new List <Subjects>();
                    foreach (var item in saveList)
                    {
                        objSubjects = new Subjects();
                        objSubjects.ObjSemesters            = new Semesters();
                        objSubjects.SubjectID               = item.SubjectID;
                        objSubjects.ObjSemesters.SemesterID = item.SemesterID;
                        lstSubjects.Add(objSubjects);
                    }
                    bool res = objsystemManager.insertSubSem(lstSubjects);
                    if (res)
                    {
                        MessageBox.Show("Saved Successfully");
                        dgvSemesterSubject.DataSource = null;
                    }
                }

                else
                {
                    MessageBox.Show("No records has found....\nPlease set values to the feilds before update", "System warning");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }