예제 #1
0
 private void LoadQuestions(Guid SurveyID)
 {
     classes.SQLCode mySQL = new classes.SQLCode();
     theseQuestions = mySQL.GetQuestionsBySurvey(SurveyID);
     foreach (classes.Question thisQuestion in theseQuestions)
     {
         List <classes.Answer> qAnswers = mySQL.GetAnswers(thisQuestion.QuestionID);
         foreach (classes.Answer thisAnswer in qAnswers)
         {
             theseAnswers.Add(thisAnswer);
         }
     }
     SerializeQuestions(theseQuestions);
     SerializeAnswers(theseAnswers);
 }
예제 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["SurveyID"] != null)
     {
         SurveyID = new Guid(Request.QueryString["SurveyID"].ToString());
     }
     else
     {
         Response.Redirect("Survey.aspx");
     }
     //if (!Page.IsPostBack)
     //{
     LoadQuestionTypes();
     LoadQuestions(SurveyID);
     classes.SQLCode mySQL    = new classes.SQLCode();
     classes.Survey  mySurvey = mySQL.GetSurvey(SurveyID);
     lblSurveyName.Text     = mySurvey.SurveyName;
     lblSurveyName.CssClass = "surveyName";
     pnlBoilerplate.Controls.Add(new LiteralControl("<label>" + mySurvey.SurveyBoilerplate + "</label>"));
     LayoutPage();
     //}
 }
예제 #3
0
        protected void btnPost_Click(object sender, EventArgs e)
        {
            classes.SQLCode mySQL = new classes.SQLCode();
            //string answers = "";
            //Generate a PostedSurveyID, we'll use this in the database to identify all the answers associated with a discrete posted survey
            Guid PostedSurveyID = Guid.NewGuid();

            mySQL.PostSurvey(PostedSurveyID, SurveyID);
            foreach (Control c in pnlQuestions.Controls)
            {
                if (c is TextBox)
                {
                    //answers += "TextBox: " + c.ID + " : " + ((TextBox)c).Text + Environment.NewLine;
                    mySQL.PostAnswer(PostedSurveyID, new Guid(c.ID.ToString()), 3, ((TextBox)c).Text);
                }
                if (c is Calendar)
                {
                    mySQL.PostAnswer(PostedSurveyID, new Guid(c.ID.ToString()), 3, ((Calendar)c).SelectedDate.ToString());
                }
                if (c is RadioButtonList)
                {
                    RadioButtonList rbl = (RadioButtonList)c;
                    foreach (ListItem li in rbl.Items)
                    {
                        int checkedVal = 0;
                        if (li.Selected == true)
                        {
                            checkedVal = 1;
                        }
                        mySQL.PostAnswer(PostedSurveyID, new Guid(li.Value.ToString()), checkedVal, "NT");
                    }

                    /*
                     * //answers += "RadioButton: " + c.ID + " : CHECKED: " + ((RadioButton)c).Checked + Environment.NewLine;
                     * int checkedVal = 0;
                     * if(((RadioButton)c).Checked == true)
                     * {
                     *  checkedVal = 1;
                     * }
                     * mySQL.PostAnswer(PostedSurveyID, new Guid(c.ID.ToString()), checkedVal, "NT");
                     * */
                }
                if (c is DropDownList)
                {
                    DropDownList ddl = (DropDownList)c;
                    int          i   = ddl.SelectedIndex;
                    ListItem     li  = ddl.Items[i];
                    foreach (ListItem liLoop in ddl.Items)
                    {
                        if (liLoop == li)
                        {
                            mySQL.PostAnswer(PostedSurveyID, new Guid(liLoop.Value.ToString()), 1, "NT");
                        }
                        else
                        {
                            mySQL.PostAnswer(PostedSurveyID, new Guid(liLoop.Value.ToString()), 0, "NT");
                        }
                    }
                }
                if (c is ListBox)
                {
                    ListBox lb = (ListBox)c;
                    foreach (ListItem li in lb.Items)
                    {
                        int checkedVal = 0;
                        if (li.Selected == true)
                        {
                            checkedVal = 1;
                        }
                        mySQL.PostAnswer(PostedSurveyID, new Guid(li.Value.ToString()), checkedVal, "NT");
                    }
                }
                if (c is CheckBoxList)
                {
                    CheckBoxList cbl = (CheckBoxList)c;
                    foreach (ListItem li in cbl.Items)
                    {
                        int checkedVal = 0;
                        if (li.Selected == true)
                        {
                            checkedVal = 1;
                        }
                        mySQL.PostAnswer(PostedSurveyID, new Guid(li.Value.ToString()), checkedVal, "NT");
                    }

                    /*
                     * //answers += "CheckBox: " + c.ID + " : CHECKED: " + ((CheckBox)c).Checked + Environment.NewLine;
                     * int checkedVal = 0;
                     * if (((CheckBox)c).Checked == true)
                     * {
                     *  checkedVal = 1;
                     * }
                     * mySQL.PostAnswer(PostedSurveyID, new Guid(c.ID.ToString()), checkedVal, "NT");
                     */
                }
            }
            Response.Redirect("ThankYou.aspx");
        }
예제 #4
0
 private void LoadQuestionTypes()
 {
     classes.SQLCode mySQL = new classes.SQLCode();
     theseQuestionTypes = mySQL.GetQuestionTypes();
     SerializeQuestionTypes(theseQuestionTypes);
 }