Exemplo n.º 1
0
        private void BindQnA(int id)
        {
            DataSet dsQuestionNOptions = fpUserBo.GetQuestionAndOptions(id);
            DataSet dsGetquestionList  = new DataSet();

            dsGetquestionList = fpUserBo.GetRiskProfileQuestion(adviserVo.advisorId);
            int questionNo    = 0;
            int questioncount = 1;

            foreach (DataRow dr in dsGetquestionList.Tables[0].Rows)
            {
                //lbl1.Text = "asa";
                questionNo = Convert.ToInt32(dr["QM_QuestionId"].ToString());
                //PlaceHolder placeholder = new PlaceHolder();
                placeholder.Controls.Add(new LiteralControl("<div class=\"well\"><div class=\"row\"><div class=\"col-sm-2  form-group\"></div><div class=\"col-sm-8  form-group\"><p>" + questioncount.ToString() + "." + dr["QM_Question"].ToString()
                                                            + "</p></div><div class=\"col-sm-2\"></div></div><div class=\"row\"><div class=\"col-sm-3\"></div><div class=\"col-sm-3\"></div><div class=\"col-sm-6\">"));

                placeholder.Controls.Add(new LiteralControl("</div></div>"));

                DataSet ds = new DataSet();
                ds = fpUserBo.GetQuestionOption(Convert.ToInt32(dr["QM_QuestionId"].ToString()), adviserVo.advisorId);
                int optionNo = 1;
                foreach (DataRow droption in ds.Tables[0].Rows)
                {
                    optionNo = Convert.ToInt32(droption["QOM_OptionId"].ToString());
                    placeholder.Controls.Add(new LiteralControl("<div class=\"row\"><div class=\"col-sm-3  form-group\"></div><div class=\"col-sm-6  form-group\"><div class=\"radio radio-info radio-inline\">"));
                    RadioButton rbtn = new RadioButton();
                    rbtn.ID        = "rbtn" + questionNo.ToString() + optionNo.ToString();
                    rbtn.GroupName = questionNo.ToString();
                    //rbtn.AccessKey = optionNo.ToString();
                    rbtn.ValidationGroup = optionNo.ToString();
                    rbtn.Enabled         = false;
                    if (dsQuestionNOptions.Tables[0].Rows.Count > 0)
                    {
                        string expression;
                        expression = "AQM_QuestionId=" + questionNo.ToString();
                        DataRow[] foundRows;
                        foundRows = dsQuestionNOptions.Tables[0].Select(expression);
                        if (foundRows.Length > 0)
                        {
                            if (foundRows[0]["AQOM_OptionId"].ToString() == optionNo.ToString())
                            {
                                rbtn.Checked = true;
                            }
                        }
                    }
                    placeholder.Controls.Add(rbtn);
                    placeholder.Controls.Add(new LiteralControl("<label for=\"" + rbtn.ID + "\">" + droption["QOM_Option"].ToString()
                                                                + "</label></div></div><div class=\"col-sm-3\"></div></div>"));
                }
                questioncount++;
            }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            FPUserBO.CheckSession();
            userVo = (FPUserVo)Session["FPUserVo"];
            DataSet dsQuestionNOptions = fpUserBo.GetQuestionAndOptions(userVo.UserId);
            int     adviserId          = Convert.ToInt32(ConfigurationManager.AppSettings["ONLINE_ADVISER"]);
            DataSet dsGetquestionList  = new DataSet();

            dsGetquestionList = fpUserBo.GetRiskProfileQuestion(adviserId);
            int questionNo    = 0;
            int questioncount = 1;

            foreach (DataRow dr in dsGetquestionList.Tables[0].Rows)
            {
                questionNo = Convert.ToInt32(dr["QM_QuestionId"].ToString());
                PlaceHolder placeholder = new PlaceHolder();
                placeholder.Controls.Add(new LiteralControl("<div class=\"well\"><div class=\"row\"><div class=\"col-sm-2  form-group\"></div><div class=\"col-sm-8  form-group\"><p>" + dr["QM_Question"].ToString()
                                                            + "</p></div><div class=\"col-sm-2\"></div></div><div class=\"row\"><div class=\"col-sm-3\"></div><div class=\"col-sm-3\"></div><div class=\"col-sm-6\">"));
                CustomValidator customeValidator = new CustomValidator();
                customeValidator.ID              = "CustomValidator" + questionNo.ToString();
                customeValidator.ErrorMessage    = "Please select an option.";
                customeValidator.ValidationGroup = questionNo.ToString();
                customeValidator.ServerValidate += new ServerValidateEventHandler(cvRadioButtonGroup_ServerValidate);
                placeholder.Controls.Add(customeValidator);
                placeholder.Controls.Add(new LiteralControl("</div></div>"));

                DataSet ds = new DataSet();
                ds = fpUserBo.GetQuestionOption(Convert.ToInt32(dr["QM_QuestionId"].ToString()), adviserId);
                int optionNo = 1;
                foreach (DataRow droption in ds.Tables[0].Rows)
                {
                    optionNo = Convert.ToInt32(droption["QOM_OptionId"].ToString());
                    placeholder.Controls.Add(new LiteralControl("<div class=\"row\"><div class=\"col-sm-3  form-group\"></div><div class=\"col-sm-6  form-group\"><div class=\"radio radio-info radio-inline\">"));
                    RadioButton rbtn = new RadioButton();
                    rbtn.ID        = "rbtn" + questionNo.ToString() + optionNo.ToString();
                    rbtn.GroupName = questionNo.ToString();
                    //rbtn.AccessKey = optionNo.ToString();
                    rbtn.ValidationGroup = optionNo.ToString();
                    if (dsQuestionNOptions.Tables[0].Rows.Count > 0)
                    {
                        string expression;
                        expression = "AQM_QuestionId=" + questionNo.ToString();
                        DataRow[] foundRows;
                        foundRows = dsQuestionNOptions.Tables[0].Select(expression);
                        if (foundRows.Length > 0)
                        {
                            if (foundRows[0]["AQOM_OptionId"].ToString() == optionNo.ToString())
                            {
                                rbtn.Checked = true;
                            }
                        }
                    }
                    placeholder.Controls.Add(rbtn);
                    placeholder.Controls.Add(new LiteralControl("<label for=\"" + rbtn.ID + "\">" + droption["QOM_Option"].ToString()
                                                                + "</label></div></div><div class=\"col-sm-3\"></div></div>"));
                }
                placeholder.Controls.Add(new LiteralControl("<div class=\"row\"><div class=\"col-sm-3  form-group pull-left\">"));
                Button prevbtn = new Button();
                prevbtn.ID          = "btnprev" + questionNo.ToString();
                prevbtn.CommandName = "PrevView";
                prevbtn.Text        = "« Prev";
                prevbtn.CssClass    = "btn btn-info";
                if (questioncount != 1)
                {
                    placeholder.Controls.Add(prevbtn);
                }
                placeholder.Controls.Add(new LiteralControl(" </div><div class=\"col-sm-3  form-group  pull-right\">"));
                Button btnNext = new Button();
                btnNext.ID       = "btnNext" + questionNo.ToString();
                btnNext.Text     = "Next »";
                btnNext.CssClass = "btn btn-info";

                btnNext.ValidationGroup = questionNo.ToString();
                btnNext.Click          += new EventHandler(btnNext_click);

                Button btnSubmit = new Button();
                btnSubmit.ID              = "btnNext" + questionNo.ToString();
                btnSubmit.Text            = "Submit";
                btnSubmit.CssClass        = "btn btn-info";
                btnSubmit.ValidationGroup = questionNo.ToString();
                btnSubmit.Click          += new EventHandler(btnSubmit_click);

                if (questioncount != dsGetquestionList.Tables[0].Rows.Count)
                {
                    placeholder.Controls.Add(btnNext);
                }
                if (questioncount == dsGetquestionList.Tables[0].Rows.Count)
                {
                    placeholder.Controls.Add(btnSubmit);
                }
                placeholder.Controls.Add(new LiteralControl("</div></div><div class=\"row\"><div class=\"col-sm-4 text-primary\">Displaying Question " + questioncount.ToString() + " of " + dsGetquestionList.Tables[0].Rows.Count.ToString()
                                                            + "</div><div class=\"col-sm-4\"></div><div class=\"col-sm-4\"></div></div></div>"));
                View myView = new View();
                myView.ID = "View" + questionNo.ToString();
                myView.Controls.Add(placeholder);
                MultiView1.Views.Add(myView);
                MultiView1.ActiveViewIndex = 0;
                questioncount += 1;
            }
        }