public DataTable GetInternalsChartDetails(DTOInternals toint)
 {
     using (Campus2CaretakerDataContext dbContext = new Campus2CaretakerDataContext())
     {
         int _year = int.Parse(toint.Year);
         return dbContext.GetBarChartInternalsDetails(toint.InstituteId, toint.Month, _year).ToDataTable();
     }
 }
        public bool SaveUpdateInternals(DTOInternals toInt)
        {
            Campus2CaretakerDataContext dbContext = new Campus2CaretakerDataContext();
            try
            {
                if (dbContext.tblInternalMarks.Where(x => x.colStudentId == toInt.StudentId && x.colMonth == toInt.Month && x.colYear == toInt.Year && x.colSubjectId == toInt.SubjectId).ToList().Count > 0)
                {
                    tblInternalMark InternalMarks = dbContext.tblInternalMarks.Where(x => x.colStudentId == toInt.StudentId && x.colMonth == toInt.Month && x.colYear == toInt.Year && x.colSubjectId == toInt.SubjectId).FirstOrDefault();
                    InternalMarks.colBranchId = toInt.BranchId;
                    InternalMarks.colSemesterId = toInt.SemesterId;
                    InternalMarks.colMonth = toInt.Month;
                    InternalMarks.colYear = toInt.Year;
                    InternalMarks.colInstituteId = toInt.InstituteId;
                    InternalMarks.colMarksScored = toInt.MarksScored;
                    InternalMarks.colMaxMarks = toInt.MaxMarks;
                    InternalMarks.colMinMarks = toInt.MinMarks;
                    InternalMarks.colStudentId = toInt.StudentId;
                    InternalMarks.colSubjectId = toInt.SubjectId;
                    InternalMarks.colRemarks = toInt.Remarks;
                    InternalMarks.colDescription = toInt.Description;

                    dbContext.SubmitChanges();
                    return true;
                }
                else
                {
                    tblInternalMark InternalMarks = new tblInternalMark();
                    InternalMarks.colBranchId = toInt.BranchId;
                    InternalMarks.colSemesterId = toInt.SemesterId;
                    InternalMarks.colMonth = toInt.Month;
                    InternalMarks.colYear = toInt.Year;
                    InternalMarks.colInstituteId = toInt.InstituteId;
                    InternalMarks.colMarksScored = toInt.MarksScored;
                    InternalMarks.colMaxMarks = toInt.MaxMarks;
                    InternalMarks.colMinMarks = toInt.MinMarks;
                    InternalMarks.colStudentId = toInt.StudentId;
                    InternalMarks.colSubjectId = toInt.SubjectId;
                    InternalMarks.colRemarks = toInt.Remarks;
                    InternalMarks.colDescription = toInt.Description;

                    dbContext.tblInternalMarks.InsertOnSubmit(InternalMarks);
                    dbContext.SubmitChanges();
                    return true;
                }
            }
            catch
            {
                return false;
            }
        }
 protected void btnGetStudentsList_Click(object sender, EventArgs e)
 {
     DTOInternals toInt = new DTOInternals();
     toInt.BranchId = int.Parse(ddlClass.SelectedValue);
     if (Session["InstituteType"].ToString() == "S")
     {
         toInt.SemesterId = 0;
     }
     else
     {
         toInt.SemesterId = int.Parse(ddlSemester.SelectedValue);
     }
     toInt.InstituteId = int.Parse(Session["InstituteID"].ToString());
     toInt.SubjectId = int.Parse(ddlSubjects.SelectedValue);
     toInt.Month = ddlMonth.SelectedValue;
     toInt.Year = ddlYear.SelectedValue;
     ViewState["CurrentTable"] = null;
     SetInitialRow();
     AddRowsToGrid(new BOInternals().GetStudentsList(toInt));
 }
 public DataTable GetStudentsListEdit(DTOInternals toint)
 {
     Campus2CaretakerDataContext dbContext = new Campus2CaretakerDataContext();
     if (toint.SemesterId > 0)
     {
         return dbContext.GetStudentsInternalsDetailsEdit(toint.InstituteId,
                                                          toint.SubjectId,
                                                          toint.Month,
                                                          toint.Year,
                                                          toint.SemesterId,
                                                          toint.BranchId).ToDataTable();
     }
     // create stored procedure for schools without semester
     return dbContext.GetStudentsInternalsDetailsEdit(toint.InstituteId,
                                                          toint.SubjectId,
                                                          toint.Month,
                                                          toint.Year,
                                                          0,
                                                          toint.BranchId).ToDataTable();
 }
        protected void btnSaveInternals_Click(object sender, EventArgs e)
        {
            for (int index = 0; index < gvInternals.Rows.Count - 1; index++)
            {
                if (int.Parse(((TextBox)gvInternals.Rows[index].FindControl("txtMarksScored")).Text) > 0)
                {
                    DTOInternals toInt = new DTOInternals();
                    toInt.BranchId = int.Parse(ddlClass.SelectedValue);
                    if (Session["InstituteType"].ToString() == "S")
                    {
                        toInt.SemesterId = 0;
                    }
                    else
                    {
                        toInt.SemesterId = int.Parse(ddlSemester.SelectedValue);
                    }
                    toInt.Month = ddlMonth.SelectedValue;
                    toInt.Year = ddlYear.SelectedValue;
                    toInt.SubjectId = int.Parse(ddlSubjects.SelectedValue);
                    toInt.Description = txtDescription.Text;

                    Label lblStudentID = (Label)gvInternals.Rows[index].FindControl("lblStudentID");
                    Label lblStudentName = (Label)gvInternals.Rows[index].FindControl("lblStudentName");
                    TextBox txtMaxMarks = (TextBox)gvInternals.Rows[index].FindControl("txtMaxMarks");
                    TextBox txtMinMarks = (TextBox)gvInternals.Rows[index].FindControl("txtMinMarks");
                    TextBox txtMarksScored = (TextBox)gvInternals.Rows[index].FindControl("txtMarksScored");
                    TextBox txtReMarks = (TextBox)gvInternals.Rows[index].FindControl("txtRemarks");

                    toInt.InstituteId = int.Parse(Session["InstituteID"].ToString());
                    toInt.MarksScored = decimal.Parse(txtMarksScored.Text);
                    toInt.MaxMarks = decimal.Parse(txtMaxMarks.Text);
                    toInt.MinMarks = decimal.Parse(txtMinMarks.Text);
                    toInt.StudentId = int.Parse(lblStudentID.Text);
                    toInt.Remarks = txtReMarks.Text;

                    DTOStudentRegistration tostu = new DTOStudentRegistration();
                    tostu.StudentId = int.Parse(lblStudentID.Text);
                    DataTable dtStudDet = new BOStudentRegistration().GetStudentDetails(tostu);

                    if (new BOInternals().SaveUpdateInternals(toInt))
                    {
                        #region SMS
                        string _messageTemplate = new BOSms().GetSMSTemplate("INTERNALMARKSINTIMATION");
                        C2CSMS.SendSMS(_messageTemplate.Replace("##STUDENTNAME##", dtStudDet.Rows[0][0].ToString()).Replace("##INTERNALSMARKS##", String.Concat(toInt.MarksScored, " Out of ", toInt.MaxMarks)).Replace("##SUBJECTNAME##", ddlSubjects.SelectedItem.Text).Replace("##MONTHYEAR##", String.Concat(ddlMonth.SelectedItem.Text, string.Empty, ddlYear.SelectedItem.Text)).Replace("##InstituteName##", Session["InstituteName"].ToString()), dtStudDet.Rows[0][9].ToString());
                        #endregion

                        #region E-Mail

                        //Send mail
                        if (!string.IsNullOrEmpty(dtStudDet.Rows[0][12].ToString()))
                        {
                            string s_subject = "Information From Campus2Caretaker";
                            string s_msg = String.Concat("Greetings from Campus2Caretaker.", Environment.NewLine, Environment.NewLine, _messageTemplate.Replace("##STUDENTNAME##", dtStudDet.Rows[0][0].ToString()).Replace("##INTERNALSMARKS##", String.Concat(toInt.MarksScored, " Out of ", toInt.MaxMarks)).Replace("##SUBJECTNAME##", ddlSubjects.SelectedItem.Text).Replace("##MONTHYEAR##", String.Concat(ddlMonth.SelectedItem.Text, string.Empty, ddlYear.SelectedItem.Text)).Replace("##InstituteName##", Session["InstituteName"].ToString())) + Environment.NewLine + Environment.NewLine;

                            C2CEmail.SendC2CMail(s_msg, s_subject, string.Empty, dtStudDet.Rows[0][12].ToString(), null, null);
                        }

                        #endregion

                        //string script = @"document.getElementById('" + divStatus.ClientID + "').innerHTML='Record updated';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('Internals Details Saved Successfully', 'Campus2Caretaker');";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript", alertScript, true);
                    }
                    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);
                    }
                }
            }

            clear();
        }
 public DataTable GetInternalsChartDetails(DTOInternals toint)
 {
     return new DAOInternals().GetInternalsChartDetails(toint);
 }
 public DataTable GetStudentsListEdit(DTOInternals toInt)
 {
     return new DAOInternals().GetStudentsListEdit(toInt);
 }
 public bool SaveUpdateInternals(DTOInternals toInt)
 {
     return new DAOInternals().SaveUpdateInternals(toInt);
 }