예제 #1
0
        protected void btnClone_Click(object sender, ImageClickEventArgs e)
        {
            var so = Survey.FetchObject(int.Parse(SID.Text));
            var sn = Survey.FetchObject(int.Parse(SID.Text));

            sn.SID    = 0;
            sn.Name   = txtNewName.Text;
            sn.Status = 1;
            sn.Insert();

            var ds1 = SurveyQuestion.GetAll(so.SID);

            foreach (DataRow r1 in ds1.Tables[0].Rows)
            {
                var QID = Convert.ToInt32(r1["QID"]);

                var q = SurveyQuestion.FetchObject(QID);
                q.SID = sn.SID;
                q.QID = 0;
                q.Insert();

                var ds2 = SQChoices.GetAll(QID);
                foreach (DataRow r2 in ds2.Tables[0].Rows)
                {
                    var SQCID = Convert.ToInt32(r2["SQCID"]);
                    var c     = SQChoices.FetchObject(SQCID);
                    c.SQCID = 0;
                    c.QID   = q.QID;
                    c.Insert();
                }

                var ds3 = SQMatrixLines.GetAll(QID);
                foreach (DataRow r3 in ds3.Tables[0].Rows)
                {
                    var SQMLID = Convert.ToInt32(r3["SQMLID"]);
                    var l      = SQMatrixLines.FetchObject(SQMLID);
                    l.SQMLID = 0;
                    l.QID    = q.QID;
                    l.Insert();
                }
            }
            Session["SID"] = sn.SID;
            Response.Redirect("SurveyList.aspx");
            Response.Redirect("SurveyAddEdit.aspx");
        }
예제 #2
0
        public string LoadQStats()
        {
            var q = DAL.SurveyQuestion.FetchObject(QID);

            var line1 = "<tr><td colspan=3>{0}</td></tr>";
            var line2 =
                "<tr><td style='padding-left: 10px;' valign=top align=left  width='33%'><b>Minimum Details: </b></td>" +
                "<td style='padding-right: 50px;' valign=top align=left  width='33%'><b>Medium Details</b> <a style='float:right;' class='ml{3}' href='javascript: showhide(\"ml{3}\", \"mt{3}\")'>show</a></td>" +
                "<td style='padding-right: 50px;' valign=top align=left  width='33%'><b>Full Details</b> <a style='float:right;' class='fl{3}' href='javascript: showhide(\"fl{3}\", \"ft{3}\")'>show</a></td></tr>" +
                "<tr><td style='padding-left: 10px;'valign=top align=left>{0}</td><td valign=top align=left>{1}</td><td>{2}</td></tr>";
            var line3 =
                "<tr><td style='padding-left: 10px;'valign=top align=left colspan=3>{0}</td></tr>";
            var line4 = "<tr><td colspan=3><hr></td></tr>";

            var line5 = "<tr><td style='padding-left: 10px;' valign=top align=left colspan=3>{0}</td></tr>";
            var ret   = "";

            if (QType == 2) // multiple choice
            {
                ret = string.Format(line1, q.QText);
                var ds          = SurveyResults.GetQStatsSimple(SID, QID, SQMLID, SourceType, SourceID);
                var header      = "<tr><td ><b>Answer</b></td><td width='100px' align=right><b>Count</td></tr>";
                var data        = "<tr><td>{0}</td><td align=right>{1}</td></tr>";
                var min         = "";
                var grDataTmplt = "['{0}', {1}],";
                var grData      = "";
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    min = string.Format("{0}{1}{2}", min, "\n", string.Format(data, row["ChoiceText"], row["Count"]));
                    if (Graphs)
                    {
                        grData = string.Format("{0}{1}{2}", grData, "\n", string.Format(grDataTmplt, row["ChoiceText"], row["Count"]));
                    }
                }
                if (grData.Length > 0)
                {
                    grData = grData.Substring(0, grData.Length - 1);
                    min    = min + getGraph("_s", QID, SQMLID, grData);
                }

                ds = SurveyResults.GetQStatsMedium(SID, QID, SQMLID, SourceType, SourceID);
                var med = "";
                grData = "";
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    med = string.Format("{0}{1}{2}", med, "\n", string.Format(data, row["ChoiceText"], row["Count"]));
                    if (Graphs)
                    {
                        grData = string.Format("{0}{1}{2}", grData, "\n", string.Format(grDataTmplt, row["ChoiceText"], row["Count"]));
                    }
                }
                if (grData.Length > 0)
                {
                    grData = grData.Substring(0, grData.Length - 1);
                    med    = med + getGraph("_m", QID, SQMLID, grData);
                }

                var header2 = "<tr><td><b>Answer AND Clarifications</b></td><td  width='100px' align=right><b>Count</td>";
                var data2   = "<tr><td valigh=top>{0}</td><td align=right valigh=top>{1}</td></tr>";
                var data3   = "<tr><td valigh=top colspan=2 style='padding-left:20px;'>{0}</td></tr>";
                var max     = "";
                grData = "";
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    var ds2 = SurveyResults.GetQClarifications(SID, QID, SQMLID, SourceType, SourceID, row["ChoiceTextORIGINAL"].ToString());

                    var clText = "";
                    foreach (DataRow cl in ds2.Tables[0].Rows)
                    {
                        clText = clText + (clText.Length == 0 ? "" : "<br>") + cl["ClarificationText"].ToString();
                    }

                    max = string.Format("{0}{1}{2}", max, "\n", string.Format(data2, row["ChoiceText"], row["Count"]));
                    if (clText != "")
                    {
                        max = string.Format("{0}{1}{2}", max, "\n", string.Format(data3, clText));
                    }

                    if (Graphs)
                    {
                        grData = string.Format("{0}{1}{2}", grData, "\n", string.Format(grDataTmplt, row["ChoiceText"], row["Count"]));
                    }
                }
                if (grData.Length > 0)
                {
                    grData = grData.Substring(0, grData.Length - 1);
                    max    = max + getGraph("_f", QID, SQMLID, grData);
                }

                line2 = string.Format(line2, "<table>" + header + min + "</table>",
                                      "<table id='mt" + QID + "' style='display:none;'>" + header + med + "</table>",
                                      "<table id='ft" + QID + "' style='display:none;'>" + header + max + "</table>", QID);
                ret = ret + line2;
            }
            if (QType == 3) //free form
            {
                ret = string.Format(line1, q.QText);

                var ds2 = SurveyResults.GetQFreeForm(SID, QID, SQMLID, SourceType, SourceID);

                var clText = "";
                foreach (DataRow cl in ds2.Tables[0].Rows)
                {
                    clText = clText + (clText.Length == 0 ? "" : "<br>") + cl["FreeFormAnswer"].ToString();
                }
                line3 = string.Format(line2, clText);
                ret   = ret + line3;
            }

            var line6 =
                "<tr><td style='padding-left: 20px;' valign=top align=left  width='33%'><b>Minimum Details: </b></td>" +
                "<td style='padding-right: 50px;' valign=top align=left  width='33%'><b>Medium Details</b> <a style='float:right;' class='ml{3}_{4}' href='javascript: showhide(\"ml{3}_{4}\", \"mt{3}_{4}\")'>show</a></td>" +
                "<td style='padding-right: 50px;' valign=top align=left  width='33%'><b>Full Details</b> <a style='float:right;' class='fl{3}_{4}' href='javascript: showhide(\"fl{3}_{4}\", \"ft{3}_{4}\")'>show</a></td></tr>" +
                "<tr><td style='padding-left: 20px;'valign=top align=left>{0}</td><td valign=top align=left>{1}</td><td>{2}</td></tr>";

            if (QType == 4) //matrix
            {
                if (ShowQText == 1)
                {
                    ret = string.Format(line1, q.QText);
                }

                var ln = SQMatrixLines.FetchObject(SQMLID);
                ret = ret + string.Format(line5, ln.LineText);
                var grDataTmplt = "['{0}', {1}],";
                var grData      = "";

                var ds     = SurveyResults.GetQStatsSimple(SID, QID, SQMLID, SourceType, SourceID);
                var header = "<tr><td ><b>Answer</b></td><td width='100px' align=right><b>Count</td></tr>";
                var data   = "<tr><td>{0}</td><td align=right>{1}</td></tr>";
                var min    = "";
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    min = string.Format("{0}{1}{2}", min, "\n", string.Format(data, row["ChoiceText"], row["Count"]));
                    if (Graphs)
                    {
                        grData = string.Format("{0}{1}{2}", grData, "\n", string.Format(grDataTmplt, row["ChoiceText"], row["Count"]));
                    }
                }
                if (grData.Length > 0)
                {
                    grData = grData.Substring(0, grData.Length - 1);
                    min    = min + getGraph("_s", QID, SQMLID, grData);
                }

                ds = SurveyResults.GetQStatsMedium(SID, QID, SQMLID, SourceType, SourceID);
                var med = "";
                grData = "";
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    med = string.Format("{0}{1}{2}", med, "\n", string.Format(data, row["ChoiceText"], row["Count"]));
                    if (Graphs)
                    {
                        grData = string.Format("{0}{1}{2}", grData, "\n", string.Format(grDataTmplt, row["ChoiceText"], row["Count"]));
                    }
                }
                if (grData.Length > 0)
                {
                    grData = grData.Substring(0, grData.Length - 1);
                    med    = med + getGraph("_m", QID, SQMLID, grData);
                }

                var header2 = "<tr><td><b>Answer AND Clarifications</b></td><td  width='100px' align=right><b>Count</td>";
                var data2   = "<tr><td valigh=top>{0}</td><td align=right valigh=top>{1}</td></tr>";
                var data3   = "<tr><td valigh=top colspan=2 style='padding-left:20px;'>{0}</td></tr>";
                var max     = "";
                grData = "";
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    var ds2 = SurveyResults.GetQClarifications(SID, QID, SQMLID, SourceType, SourceID, row["ChoiceTextORIGINAL"].ToString());

                    var clText = "";
                    foreach (DataRow cl in ds2.Tables[0].Rows)
                    {
                        clText = clText + (clText.Length == 0 ? "" : "<br>") + cl["ClarificationText"].ToString();
                    }

                    max = string.Format("{0}{1}{2}", max, "\n", string.Format(data2, row["ChoiceText"], row["Count"]));
                    if (clText != "")
                    {
                        max = string.Format("{0}{1}{2}", max, "\n", string.Format(data3, clText));
                    }
                    if (Graphs)
                    {
                        grData = string.Format("{0}{1}{2}", grData, "\n", string.Format(grDataTmplt, row["ChoiceText"], row["Count"]));
                    }
                }
                if (grData.Length > 0)
                {
                    grData = grData.Substring(0, grData.Length - 1);
                    max    = max + getGraph("_f", QID, SQMLID, grData);
                }

                line6 = string.Format(line6, "<table>" + header + min + "</table>",
                                      "<table id='mt" + QID + "_" + SQMLID + "' style='display:none;'>" + header + med + "</table>",
                                      "<table id='ft" + QID + "_" + SQMLID + "' style='display:none;'>" + header + max + "</table>", QID, SQMLID);
                ret = ret + line6;



                //ret = ret + string.Format(line5, "<hr>");
            }
            return(ret + line4);
        }
        public string DisplayAnswers(int QType, int QID, int SQMLID, string ChoiceAnswerIDs, string ChoiceAnswerText, string ClarificationText, bool MXShowChoices)
        {
            var displayString = string.Empty;

            if (QType == 2) // Multiple Choice
            {
                string[] separators = { "~|~" };
                var      mcIDs      = ChoiceAnswerIDs.Split(',');
                var      mcTXs      = ChoiceAnswerIDs.Split(separators, StringSplitOptions.None);
                var      mcCLs      = ClarificationText.Split(separators, StringSplitOptions.None);

                var ds4 = SQChoices.GetAll(QID);
                foreach (DataRow dr4 in ds4.Tables[0].Rows)
                {
                    var idx4      = -1;
                    var match     = FindAnswer(ChoiceAnswerIDs, mcIDs, (int)dr4["SQCID"], out idx4);
                    var ansString = string.Format("<tr><td valign='top'><b>{2}</b></td><td valign='top' nowrap>{0}</td><td nowrap style='padding-right: 5px;' align='right' valign='top'>({1} pts)</td><td style='padding-left:10px;' valign='top'>{3}</td></tr>"
                                                  , dr4["ChoiceText"].ToString(), ((int)dr4["Score"])
                                                  , match ? " X " : ""
                                                  , match ? mcCLs[idx4] : ""

                                                  );
                    displayString = string.Format("{0}{1}", displayString, ansString);
                }

                displayString = string.Format("<table cellpadding=5> {0} </table>", displayString);
            }

            if (QType == 4) // Matrix
            {
                string[] separators = { "~|~" };
                var      mcIDs      = ChoiceAnswerIDs.Split(',');
                var      mcTXs      = ChoiceAnswerIDs.Split(separators, StringSplitOptions.None);
                var      mcCLs      = ClarificationText.Split(separators, StringSplitOptions.None);


                var ds4 = SQChoices.GetAll(QID);
                var ml  = SQMatrixLines.FetchObject(SQMLID);

                displayString = string.Format("<tr><td valign='top' style='padding-right: 5px;' width='50%'>{0}</td>", ml.LineText);
                var w = (int)(50 / ds4.Tables[0].Rows.Count);

                if (MXShowChoices)
                {
                    foreach (DataRow dr4 in ds4.Tables[0].Rows)
                    {
                        var idx4      = -1;
                        var match     = FindAnswer(ChoiceAnswerIDs, mcIDs, (int)dr4["SQCID"], out idx4);
                        var ansString = string.Format("<td valign='top' align='center' width='{4}%' >{0} ({1} pts) <br> <b>{2}</b> <br> <div style='text-align: left;'>{3}</div></td>"
                                                      , dr4["ChoiceText"].ToString()
                                                      , ((int)dr4["Score"])
                                                      , match ? " X " : ""
                                                      , match ? mcCLs[idx4] : ""
                                                      , w
                                                      );
                        displayString = string.Format("{0}{1}", displayString, ansString);
                    }
                }
                else
                {
                    foreach (DataRow dr4 in ds4.Tables[0].Rows)
                    {
                        var idx4      = -1;
                        var match     = FindAnswer(ChoiceAnswerIDs, mcIDs, (int)dr4["SQCID"], out idx4);
                        var ansString = string.Format("<td valign='top' align='center' width='{2}%' ><b>{0}</b> <br> <div style='text-align: left;'>{1}</div></td>"
                                                      , match ? " X " : ""
                                                      , match ? mcCLs[idx4] : ""
                                                      , w
                                                      );
                        displayString = string.Format("{0}{1}", displayString, ansString);
                    }
                }

                displayString = string.Format("<table cellpadding=5 width='100%'> {0} </tr></table>", displayString);
            }

            return(displayString);
        }
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Setup/SurveyQuestionList.aspx";

            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(returnURL);
            }
            if (e.CommandName.ToLower() == "refresh")
            {
                try
                {
                    odsData.DataBind();
                    dv.DataBind();
                    dv.ChangeMode(DetailsViewMode.Edit);

                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                    {
                        masterPage.PageMessage = SRPResources.RefreshOK;
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
            if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback")
            {
                try
                {
                    if (Save((DetailsView)sender))
                    {
                        if (e.CommandName.ToLower() == "saveandback")
                        {
                            Response.Redirect(returnURL);
                        }

                        odsData.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        MasterPage.PageMessage = SRPResources.SaveOK;
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }

            if (e.CommandName.ToLower() == "moveup21")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQChoices.MoveUp(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Up!";

                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType2Answers");
                p4 = (Panel)p4.FindControl("Panel1");
                var gv = (GridView)p4.FindControl("gv21");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "movedn21")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQChoices.MoveDn(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType2Answers");
                p4 = (Panel)p4.FindControl("Panel1");
                var gv = (GridView)p4.FindControl("gv21");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "deleterecord21")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                var obj = SQChoices.FetchObject(key);
                obj.Delete();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType2Answers");
                p4 = (Panel)p4.FindControl("Panel1");
                var gv = (GridView)p4.FindControl("gv21");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "addrecord21")
            {
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                var p4   = (Panel)tab2.FindControl("pnlType2Answers");

                var obj = new SQChoices();
                obj.QID                   = int.Parse(lblPK.Text);
                obj.ChoiceText            = ((TextBox)p4.FindControl("ChoiceText2")).Text;
                obj.Score                 = ((TextBox)p4.FindControl("Score2")).Text.SafeToInt();
                obj.JumpToQuestion        = ((DropDownList)p4.FindControl("JumpToQuestion2")).Text.SafeToInt();
                obj.AskClarification      = ((CheckBox)p4.FindControl("AskClarification2")).Checked;
                obj.ClarificationRequired = ((CheckBox)p4.FindControl("ClarificationRequired2")).Checked;
                obj.Insert();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                odsData41.DataBind();
                p4 = (Panel)p4.FindControl("Panel1");
                var gv = (GridView)p4.FindControl("gv21");
                gv.DataBind();
            }


            if (e.CommandName.ToLower() == "moveup41")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQChoices.MoveUp(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Up!";

                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv41");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "movedn41")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQChoices.MoveDn(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv41");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "deleterecord41")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                var obj = SQChoices.FetchObject(key);
                obj.Delete();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv41");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "addrecord41")
            {
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                var p4   = (Panel)tab2.FindControl("pnlType4Answers");

                var obj = new SQChoices();
                obj.QID            = int.Parse(lblPK.Text);
                obj.ChoiceText     = ((TextBox)p4.FindControl("ChoiceText4")).Text;
                obj.Score          = ((TextBox)p4.FindControl("Score4")).Text.SafeToInt();
                obj.JumpToQuestion = ((DropDownList)p4.FindControl("JumpToQuestion4")).Text.SafeToInt();

                obj.Insert();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                odsData41.DataBind();
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv41");
                gv.DataBind();
            }



            if (e.CommandName.ToLower() == "moveupl")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQMatrixLines.MoveUp(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Up!";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData42.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv42");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "movednl")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQMatrixLines.MoveDn(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData42.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv42");
                gv.DataBind();
            }



            if (e.CommandName.ToLower() == "deleterecordl")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                var obj = SQMatrixLines.FetchObject(key);
                obj.Delete();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData42.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv42");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "addrecordl")
            {
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");

                var p4 = (Panel)tab2.FindControl("pnlType4Answers");

                var obj = new SQMatrixLines();
                obj.QID      = int.Parse(lblPK.Text);
                obj.LineText = ((TextBox)p4.FindControl("LineText4")).Text;

                obj.Insert();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";

                odsData42.DataBind();
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv42");
                gv.DataBind();
            }
        }