예제 #1
0
    public void UpdateIntervention(int aid, int rlst)
    {
        try
        {
            Assessment ass = new Assessment();
            ass = ass.GetAssessmentByOID(aid);

            ResultLetterDetail letterDetail = null;
            ResultLetter resultLetter = new ResultLetter();
            resultLetter = resultLetter.GetResultLetterByAOID(aid);

            Collection<Student> studentList = new Student().GetAllStudentByResultLetterSentTimes(rlst);

            StringBuilder sb = new StringBuilder();
            string dateStr = System.DateTime.Today.ToString();
            foreach (Student student in studentList)
            {
                sb.Append("<table cellpadding='0px' cellspacing='0px' style='width:100%; page-break-after: always; margin:0px 20px 0px 20px'>");

                sb.Append("<tr>");
                sb.Append("<td> " + dateStr + "</td>");
                sb.Append("</tr>");

                sb.Append("<tr>");
                sb.Append("<td> " + student.FullName + "</td>");
                sb.Append("</tr>");

                sb.Append("<tr>");
                sb.Append("<td> " + student.AddressOne + "</td>");
                sb.Append("</tr>");

                sb.Append("<tr>");
                sb.Append("<td> " + student.AddressTwo + "</td>");
                sb.Append("</tr>");

                sb.Append("<tr>");
                sb.Append("<td> " + student.AddressThree + "</td>");
                sb.Append("</tr>");

                sb.Append("<tr>");
                sb.Append("<td align='right'> Student ID: " + student.StudentID + "</td>");
                sb.Append("</tr>");

                sb.Append("<tr>");
                sb.Append("<td> Dear " + student.FirstName + ":</td>");
                sb.Append("</tr>");

                if (resultLetter != null)
                {
                    sb.Append("<tr>");
                    sb.Append("<td>" + resultLetter.Header + "</td>");
                    sb.Append("</tr>");
                }

                sb.Append("<tr>");
                sb.Append("<td>");
                sb.Append("<table cellpadding='0px' cellspacing='0px' style='width:100%;'>");
                sb.Append("<tr>");
                sb.Append("<td style='background-color:Gray; width:30%; border: thin solid #000000;'>CATEGORY</td>");
                sb.Append("<td style='background-color:Gray; width:70%; border: thin solid #000000;'>DEFINITION</td>");
                sb.Append("</tr>");

                //Collection<StudentRank> studentRankList_ = new StudentRank().GetStudentRankBySOIDandAOID(student.StudentOID, ass.AssessmentOID);

                foreach (Section s in ass.SectionList)
                {
                    string definition = "", starValue = "";
                    if (resultLetter != null)
                    {
                        if (resultLetter.LetterDetail != null)
                        {
                            var tmp = from detail in resultLetter.LetterDetail
                                      where detail.SectionOID == s.SectionOID
                                      select detail;
                            letterDetail = tmp != null ? tmp.First() : null;
                        }
                    }

                    sb.Append("<tr>");

                    //foreach (StudentRank SR in studentRankList)
                    //{
                    //    if (SR.SectionOID == s.SectionOID)
                    //    {
                    //        if (SR.Rank < s.Flag)
                    //        {
                    //            starValue = " *";
                    //            break;
                    //        }
                    //        else
                    //        { starValue = ""; }
                    //    }
                    //}

                    sb.Append("<td style='width:30%; border: thin solid #000000'>" + s.SectionName + starValue + "</td>");
                    definition = (letterDetail != null) ? letterDetail.SectionDefinition : "";

                    sb.Append("<td style='width:70%; border: thin solid #000000'>" + definition + "</td>");
                    sb.Append("</tr>");
                }
                sb.Append("</table>");

                if (resultLetter != null)
                {
                    sb.Append("<tr>");
                    sb.Append("<td>" + resultLetter.ShowAboveResult + "</td>");
                    sb.Append("</tr>");
                }

                sb.Append("</td>");
                sb.Append("</tr>");
                sb.Append("</table>");
            }
            //print_div1.InnerHtml = sb.ToString();
            Response.Write(sb.ToString());
            return;
        }
        catch (Exception ex)
        {

        }
    }
예제 #2
0
    public void PrintIntervention(int aid, int rlst,string riskName)
    {
        try
        {
            Assessment ass = new Assessment();
            ass = ass.GetAssessmentByOID(aid);

            ResultLetterDetail letterDetail = null;
            ResultLetter resultLetter = new ResultLetter();
            resultLetter = resultLetter.GetResultLetterByAOID(aid);

            Collection<Answer> answers = new Answer().GetAnswerByAOIDAndRLST_ForPrintResultLetter(aid, rlst);

            //Collection<Student> studentList = new Student().GetAllStudentByResultLetterSentTimes(rlst);
            Collection<Student> studentList = new Collection<Student>();// new Student().GetAllStudentByResultLetterSentTimes(rlst);
            foreach (Answer answer in answers)
            {
                //Student student = new Student();
                Student student = new Student().GetStudentByStudentOID(answer.BannerID.ToString());
                RiskCalculation riskCalculation = new RiskCalculation();
                if (student != null)
                {
                    riskCalculation = riskCalculation.GetRiskCalculationByAOIDAndSOIDAndRiskName(aid, student.StudentOID,riskName);

                }

                // if (student.StudentOID == 0) break ;
                bool isContain = false;
                foreach (Student std in studentList)
                {
                    if (student.StudentOID == std.StudentOID)
                    {
                        isContain = true;
                    }
                }

                  if (!isContain && riskCalculation != null && student != null)
                  //if (!isContain && riskCalculation != null)

                    {
                        answer.UpdateAnswer_ForNumberofPrinted(aid, rlst, Convert.ToInt32(student.StudentOID));
                        answer.UpdateScoreDetailsTable_ForNumberofPrinted(aid, rlst, Convert.ToInt32(student.StudentOID));
                        studentList.Add(student);

                    }

            }

           // bool updateStatus = new Student().UpdateAllStudentByResultLetterSentTimes(rlst);

            List<ScoreDetailTable> scoreDetailTableList = new ScoreDetailTable().GetScoreDetailTableByAOID(ass.AssessmentOID);
            //List<ScoreDetailTable> scoreDetailTableList = new List<ScoreDetailTable>();
            StringBuilder sb = new StringBuilder();
            string dateStr = System.DateTime.Today.ToLongDateString();
            foreach (Student student in studentList)
            {
                //sb.Append("<table cellpadding='0' cellspacing='0'  style='page-break-after:always; width:90%; margin:0px 0px 0px 0px;' >");
                #region Header
                sb.Append("<table cellpadding='0' cellspacing='0'   style='width:100%; margin:10px 10px 5px 10px;font-size:12px; page-break-after:always; height:100%'>");

                sb.Append("<tr>");
                sb.Append("<td> " + dateStr + "</td>");
                sb.Append("</tr>");

                sb.Append("<tr>");
                sb.Append("<td> <br/>" + student.FullName + "</td>");
                sb.Append("</tr>");

                sb.Append("<tr>");
                sb.Append("<td> " + student.AddressOne + "</td>");
                sb.Append("</tr>");

                sb.Append("<tr>");
                sb.Append("<td> ");

                sb.Append("<table cellpadding='0' cellspacing='0' style='width:100%;'>");
                sb.Append("<tr>");
                sb.Append("<td align='left' style='font-size:12px'>");

                if (!string.IsNullOrEmpty(student.City))
                {
                    sb.Append(student.City);
                }
                if (!string.IsNullOrEmpty(student.State))
                {
                    sb.Append(", " + student.State);
                }
                if (!string.IsNullOrEmpty(student.ZIPCode))
                {
                    sb.Append(", " + student.ZIPCode);
                }

                sb.Append("</td> ");
                sb.Append("<td align='right'> Student ID: " + student.StudentID + "</td>");
                sb.Append("<tr>");
                sb.Append("</table>");

                sb.Append("</td>");
                sb.Append("</tr>");
                #endregion

                #region StudentName
                string studentFirstName = student.FullName;
                if (!string.IsNullOrEmpty(studentFirstName))
                {
                    try
                    {
                        if (studentFirstName.Contains(','))
                        {
                            studentFirstName = studentFirstName.Split(',')[1];
                        }
                    }
                    catch
                    { }
                }
                #endregion

                sb.Append("<tr>");
                sb.Append("<td><br/>Dear " + studentFirstName + ":</td>");
                sb.Append("</tr>");
               // sb.Append("</br><div id='Header' style='height:150px;position: relative;vertical-align:top;border:1px solid red'>");
                if (resultLetter != null)
                {

                    sb.Append("<tr>");

                    sb.Append("<td style='font-size:12px;border:1px''>" + resultLetter.Header + "</td>");
                    sb.Append("</tr>");

                }
               // sb.Append("</div>");
                sb.Append("<tr>");
                sb.Append("<td><br/>");
                sb.Append("<table cellpadding='0' cellspacing='0' style='width:98%;'>");
                sb.Append("<tr>");
                sb.Append("<td style='background:#d7d7d7; width:29%; border: thin solid #999; padding:8px;font-family:Calibri;font-size:10px;'><b>CATEGORY</b></td>");
                sb.Append("<td style='background:#d7d7d7; width:69%; border: thin solid #999; padding:8px;font-family:Calibri;font-size:10px;'><b>DEFINITION</b></td>");
                sb.Append("</tr>");

                //Collection<StudentRank> studentRankList_ = new StudentRank().GetStudentRankBySOIDandAOID(student.StudentOID, ass.AssessmentOID);

                #region SectionList
                foreach (Section s in ass.SectionList)
                {
                    if (s.SectionName == "NoScore") continue;
                    string definition = "", starValue = "";
                    if (resultLetter != null)
                    {
                        if (resultLetter.LetterDetail != null)
                        {
                            var tmp = from detail in resultLetter.LetterDetail
                                      where detail.SectionOID == s.SectionOID
                                      select detail;
                            letterDetail = tmp != null ? tmp.First() : null;
                        }
                    }
                #endregion
                    sb.Append("<tr>");
                    #region unused
                    //foreach (StudentRank SR in studentRankList)
                    //{
                    //    if (SR.SectionOID == s.SectionOID)
                    //    {
                    //        if (SR.Rank < s.Flag)
                    //        {
                    //            starValue = " *";
                    //            break;
                    //        }
                    //        else
                    //        { starValue = ""; }
                    //    }
                    //}
                    //scoreDetailTableList
                    #endregion

                    #region Star
                    foreach (ScoreDetailTable SR in scoreDetailTableList)
                    {
                        if ((SR.StudentOID == student.StudentOID) && (SR.SectionOID == s.SectionOID))
                        {
                            //if ((SR.Score*s.TotalQuestion) < s.Flag)
                            if ((SR.Rank) < s.Flag)
                            {
                                starValue = " *";
                                break;
                            }
                            else
                            {
                                starValue = "";
                                break;
                            }
                        }
                    }
                    #endregion

                    sb.Append("<td style='width:29%; border: thin solid #999; padding:8px;font-family:Calibri;font-size:10px;'><b>" + s.SectionName + starValue + "</b></td>");
                    definition = (letterDetail != null) ? letterDetail.SectionDefinition : "";

                    sb.Append("<td style='width:69%; border: thin solid #999; padding:8px; text-align:left; font-family:Calibri;font-size:10px;'>" + definition + "</td>");

                }

                sb.Append("</table>");
                //sb.Append("<div id='Footer' style='height:150px;position: relative;vertical-align:top;border:1px solid red'>");
                if (resultLetter != null)
                {
                    sb.Append("<tr>");
                    sb.Append("<td style='valign:top;font-size:12px;border:1px''><br/>" + resultLetter.ShowAboveResult + "</td>");
                    sb.Append("</tr>");
                }

                //sb.Append("</div>");

                sb.Append("</td>");
                sb.Append("</tr>");
                sb.Append("</table>");
                sb.Append("</table>");

            }
            ////print_div1.InnerHtml = sb.ToString();
            Response.Write(sb.ToString());
            return;
        }
        catch (Exception ex)
        {

        }
    }
예제 #3
0
    public bool SendLetterEmail()
    {
        bool result = false;
        try
        {
            StringBuilder html = new StringBuilder();
            ResultLetter resultLetter = new ResultLetter();
            resultLetter = resultLetter.GetResultLetterByAOID(this.AssessmentOID);
            if (resultLetter != null)
            {
                html.Append("<table border='0' cellspacing='0' cellpadding='0'><tr>    <td bgcolor='#000000'>");
                html.Append("<table bgcolor='#000000' cellspacing='1' cellpadding='0'  >");
                html.Append("<tr>");
                html.Append("<td bgcolor='#FFFFFF'>Category</td><td bgcolor='#FFFFFF'>&nbsp;</td>");
                html.Append("</tr>");
                //Section Detail
                foreach(ResultLetterDetail ld in resultLetter.LetterDetail)
                {
                    html.Append("<tr>");
                    html.Append("<td>" + ld.SectionOID.ToString() + "</td>" + "<td>" + ld.SectionDefinition + "</td>");

                    html.Append("</tr>");
                }

                //html.Append("</tr>");
                //END third
                html.Append("</table>");
                html.Append(" </td></tr></table>");
            }
        }
        catch (Exception ex)
        { }
        return result;
    }
예제 #4
0
    public ResultLetter GetResultLetterByOID(int OID)
    {
        ResultLetter resultLetter = null;
        using (OdbcConnection connection = new OdbcConnection(connectionString))
        {
            using (OdbcCommand command = new OdbcCommand())
            {

                command.Connection = connection;
                command.CommandText = "{CALL ResultLetter_ByOID(?)}";
                command.CommandType = CommandType.StoredProcedure;
                command.CommandTimeout = 999;

                //Set Parameter Value
                command.Parameters.AddWithValue("@LetterOID", OID);

                //Open connection
                connection.Open();
                //Read using reader
                using (OdbcDataReader dataReader = command.ExecuteReader())
                {

                    ResultLetterDetail lDetail = new ResultLetterDetail();
                    if (dataReader.Read())
                    {
                        resultLetter = new ResultLetter();

                        resultLetter.AssessmentOID = Convert.ToInt32(dataReader["AssessmentOID"]);
                        resultLetter.AssessmentResultLetter = Convert.ToInt32(dataReader["AssessmentResultLetter"]);
                        resultLetter.CreatedBy = Convert.ToInt32(dataReader["CreatedBy"]);
                        resultLetter.CreatedDate = Convert.ToDateTime(dataReader["CreatedDate"]);
                        resultLetter.Header = Convert.ToString(dataReader["Header"]);
                        resultLetter.LastModifiedBy = Convert.ToInt32(dataReader["LastModifiedBy"]);
                        resultLetter.LastModifiedDate = Convert.ToDateTime(dataReader["LastModifiedDate"]);
                        resultLetter.ShowAboveResult = Convert.ToString(dataReader["ShowAboveResult"]);
                        resultLetter.LetterDetail = lDetail.GetLetterDetailByLetterOID(resultLetter.AssessmentResultLetter); ;
                    }
                }

            }
        }
        return resultLetter;
    }
예제 #5
0
    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        int aid = 0;
        try
        {
            User user = (User)Session["CurrentUser"];
            if (user == null) return;
            aid = (Session["aid"] != null) ? (Convert.ToInt32(Session["aid"])) : 0;
            Assessment ass = new Assessment();
            ass = ass.GetAssessmentByOID(aid);

            Collection<ResultLetterDetail> _list = new Collection<ResultLetterDetail>();
            ResultLetterDetail letterDetail = null;
            ResultLetter resultLetter = new ResultLetter();

            //resultLetter = resultLetter.GetResultLetterByOID();

            resultLetter.AssessmentOID = aid;
            resultLetter.CreatedBy = user.UserOID;
            resultLetter.LastModifiedBy = user.UserOID;

            //resultLetter.Header = TextBoxHeader.Text;
            //resultLetter.ShowAboveResult = TextBoxShowAboveResult.Text;

            resultLetter.Header = TextBoxHeaderHtml;
            resultLetter.ShowAboveResult = TextBoxShowAboveResultHtml;

            //resultLetter.Header = TextBoxShowAboveResult.Text;
            int HeaderTextLength = Convert.ToInt32(System.Web.Configuration.WebConfigurationManager.AppSettings["ResultLetterHeaderTextLenth"].ToString());
            int FooterTextLength = Convert.ToInt32(System.Web.Configuration.WebConfigurationManager.AppSettings["ResultLetterFooterTextLenth"].ToString());
            if (TextBoxHeaderHtml.Length < HeaderTextLength && TextBoxShowAboveResultHtml.Length < FooterTextLength)
            {

                string val = "";
                foreach (Section s in ass.SectionList)
                {
                    if (s.SectionName == "NoScore") continue;
                    letterDetail = new ResultLetterDetail();

                    val = Request.Form["txt" + s.SectionOID.ToString()];

                    //identifier = "txt" + s.SectionOID.ToString();
                    //txt = (TextBox)PlaceHolderSectionDefinition.FindControl(identifier);
                    //if (txt == null) continue;
                    letterDetail.SectionDefinition = val;
                    letterDetail.SectionOID = s.SectionOID;
                    letterDetail.LastModifiedBy = user.UserOID;
                    letterDetail.CreatedBy = user.UserOID;

                    _list.Add(letterDetail);
                }

                resultLetter.LetterDetail = _list;

                //check whether it is existing or not

                ResultLetter rletter = resultLetter.GetResultLetterByAOID(aid);
                if (rletter == null)
                {
                    if (resultLetter.AddResultLetter())
                    {
                        LabelMessage.Text = "Saved Successfully.";
                    }
                    else
                    {
                        LabelMessage.Text = "Saved Failed.";
                    }
                }
                else
                {
                    resultLetter.AssessmentResultLetter = rletter.AssessmentResultLetter;
                    for (int i = 0; i < resultLetter.LetterDetail.Count; i++)
                    {
                        try
                        {
                            resultLetter.LetterDetail[i].ResultLetterSectionCommentOID = rletter.LetterDetail[i].ResultLetterSectionCommentOID;
                        }
                        catch
                        {
                            resultLetter.LetterDetail[i].ResultLetterSectionCommentOID = -1;
                            resultLetter.LetterDetail[i].AssessmentLetterOID = rletter.AssessmentResultLetter;
                        }
                    }
                    if (resultLetter.UpdateResultLetter())
                    {
                        LabelMessage.Text = "Update Successfully.";
                        //LabelMessage .Text ="Header:"+TextBoxHeaderHtml.Length .ToString ()+"And Footer :"+TextBoxShowAboveResultHtml.Length .ToString ();
                    }
                    else
                    {
                        LabelMessage.Text = "Update Failed.";
                    }
                }

                TextBoxHeaderHtml = "";
                TextBoxShowAboveResultHtml = "";

                //Initialize(aid);

            }
            else
            {
                LabelMessage.Text = "Sorry! can't Save. Header Length Must Be Less than 1000 Characters and Footer Length must be Less than 1500 Characters";
                LabelMessage.ForeColor = Color.Red;
                LabelMessage.Width = 350;
            }
            Initialize(aid);

        }
        catch (Exception ex)
        {
            Initialize(aid);
        }
    }
예제 #6
0
    private void Initialize(int aid)
    {
        try
        {
            Assessment ass = new Assessment();
            ass = ass.GetAssessmentByOID(aid);
            TextBox txtBox;

            Label lbl ;//= new Label();

            ResultLetterDetail letterDetail = null;
            ResultLetter resultLetter = new ResultLetter();
            resultLetter = resultLetter.GetResultLetterByAOID(aid);

            if (resultLetter != null)
            {
                //TextBoxHeader.Text = resultLetter.Header;
                //TextBoxShowAboveResult.Text = resultLetter.ShowAboveResult;
                TextBoxHeaderHtml = resultLetter.Header;
                TextBoxShowAboveResultHtml = resultLetter.ShowAboveResult;

            }

            foreach (Section s in ass.SectionList)
            {
                if (s.SectionName == "NoScore") continue;
                if (resultLetter != null)
                {
                    try
                    {
                        if (resultLetter.LetterDetail != null)
                        {
                            var tmp = from detail in resultLetter.LetterDetail
                                      where detail.SectionOID == s.SectionOID
                                      select detail;
                            letterDetail = tmp != null ? tmp.First() : null;
                        }
                    }
                    catch (Exception ex)
                    {
                        letterDetail = null;
                    }
                }

                PlaceHolderSectionDefinition.Controls.Add(InsertLineBreaks(1));
                txtBox = new TextBox();
                txtBox.Height = 20;
                lbl = new Label();
                txtBox.ID = "txt" + s.SectionOID.ToString();
                txtBox.Width = 630;
                //txtBox.Height = 60;
                //txtBox.TextMode = TextBoxMode.MultiLine;
                txtBox.Text = (letterDetail != null) ? letterDetail.SectionDefinition : "";
                lbl.ID = "lbl" + s.SectionOID.ToString();
                lbl.Text = s.SectionName+" : Definition";
                PlaceHolderSectionDefinition.Controls.Add(lbl);
           //     PlaceHolderSectionDefinition.Controls.Add(InsertSpace(3));
                PlaceHolderSectionDefinition.Controls.Add(InsertLineBreaks(1));
                PlaceHolderSectionDefinition.Controls.Add(txtBox);
                PlaceHolderSectionDefinition.Controls.Add(InsertLineBreaks(1));

            }
        }
        catch (Exception ex)
        { }
    }