protected void btnSaveSubjects_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    DTOPersonalizeApplication tOPApplication = new DTOPersonalizeApplication();
                    tOPApplication.InstituteId = int.Parse(Session["InstituteID"].ToString());
                    tOPApplication.TheorySubjects = lstSubjectsTheory.Items.Cast<ListItem>().Select(x => x.Value).ToArray();
                    tOPApplication.LabSubjects = lstSubjectsLab.Items.Cast<ListItem>().Select(x => x.Value).ToArray();
                    tOPApplication.ClassId = int.Parse(ddlClass.SelectedValue.ToString());
                    if (Session["InstituteType"].ToString() == "S")
                    {
                        tOPApplication.Semester = "0";
                    }
                    else
                    {
                        tOPApplication.Semester = ddlSemester.SelectedValue.ToString();
                    }

                    if (new BOPersonalizeApplication().SaveSubjects(tOPApplication))
                    {
                        //string script = @"document.getElementById('" + divStatus.ClientID + "').innerHTML='Record inserted';var elem = document.createElement('img');elem.setAttribute('src', 'tick.jpg');document.getElementById('" + divStatus.ClientID + "').appendChild(elem);document.getElementById('" + divStatus.ClientID + "').style.color = 'Green';document.getElementById('" + divStatus.ClientID + "').style.fontSize = '1em' ;document.getElementById('" + divStatus.ClientID + "').style.fontWeight = 'bold' ;setTimeout(function(){document.getElementById('" + divStatus.ClientID + "').style.display='none';},4500);";
                        //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", script, true);
                        string alertScript = "jAlert('Subject Details Saved', 'Campus2Caretaker');";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript", alertScript, true);
                        RefreshGridView_();
                        clearSubjects();
                        RefreshClasses();
                    }
                    else
                    {
                        //string script = @"document.getElementById('" + divStatus.ClientID + "').innerHTML='Error';var elem = document.createElement('img');elem.setAttribute('src', 'cross.jpg');document.getElementById('" + divStatus.ClientID + "').appendChild(elem);document.getElementById('" + divStatus.ClientID + "').style.color = 'Red';document.getElementById('" + divStatus.ClientID + "').style.fontSize = '1em' ;document.getElementById('" + divStatus.ClientID + "').style.fontWeight = 'bold' ;setTimeout(function(){document.getElementById('" + divStatus.ClientID + "').style.display='none';},4500);";
                        //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", script, true);
                        string alertScript = "jAlert('Error', 'Campus2Caretaker');";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript", alertScript, true);
                    }
                }
                catch
                {

                }
            }
        }
        public bool SaveClasses(DTOPersonalizeApplication DTOPApplication)
        {
            try
            {
                Campus2CaretakerDataContext dbContext = new Campus2CaretakerDataContext();

                foreach (string _classname in DTOPApplication.Classes)
                {
                    tblBranchDetail brnchDetail = new tblBranchDetail();
                    brnchDetail.colBranchName = _classname;
                    brnchDetail.colInstituteId = DTOPApplication.InstituteId;
                    dbContext.tblBranchDetails.InsertOnSubmit(brnchDetail);
                }
                dbContext.SubmitChanges();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        public bool SaveSubjects(DTOPersonalizeApplication DTOPApplication)
        {
            try
            {
                Campus2CaretakerDataContext dbContext = new Campus2CaretakerDataContext();

                foreach (string _theorysubject in DTOPApplication.TheorySubjects)
                {
                    tblSubjectDetail subjDetail = new tblSubjectDetail();
                    subjDetail.colBranchId = DTOPApplication.ClassId;
                    subjDetail.colInstituteId = DTOPApplication.InstituteId;
                    subjDetail.colIsTheory = "Y";
                    subjDetail.colSubjectName = _theorysubject;
                    subjDetail.colSemester = DTOPApplication.Semester;
                    dbContext.tblSubjectDetails.InsertOnSubmit(subjDetail);
                }

                foreach (string _labsubject in DTOPApplication.LabSubjects)
                {
                    tblSubjectDetail subjDetail = new tblSubjectDetail();
                    subjDetail.colBranchId = DTOPApplication.ClassId;
                    subjDetail.colInstituteId = DTOPApplication.InstituteId;
                    subjDetail.colIsTheory = "N";
                    subjDetail.colSubjectName = _labsubject;
                    subjDetail.colSemester = DTOPApplication.Semester;
                    dbContext.tblSubjectDetails.InsertOnSubmit(subjDetail);
                }

                dbContext.SubmitChanges();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
 public bool SaveSubjects(DTOPersonalizeApplication DTOPApplication)
 {
     return new DAOPersonalizeApplication().SaveSubjects(DTOPApplication);
 }
 public bool SaveClasses(DTOPersonalizeApplication DTOPApplication)
 {
     return new DAOPersonalizeApplication().SaveClasses(DTOPApplication);
 }