Beispiel #1
0
        protected void btnGo_Click(object sender, EventArgs e)
        {
            classes.Survey thisSurvey = new classes.Survey();
            if (string.IsNullOrEmpty(txtSurveyID.Text) || ddlSurveys.Text == "New Survey" || txtSurveyID.Text == "00000000-0000-0000-0000-000000000000")
            {
                thisSurvey.SurveyID = Guid.NewGuid();
            }
            else
            {
                thisSurvey.SurveyID = new Guid(txtSurveyID.Text);
            }
            thisSurvey.SurveyName  = txtSurveyName.Text;
            thisSurvey.CreatedBy   = txtCreatedBy.Text;
            thisSurvey.DateCreated = Convert.ToDateTime(txtDateCreated.Text);
            string   ModifiedBy;
            DateTime dtModified;

            if (!string.IsNullOrEmpty(txtModifiedBy.Text))
            {
                ModifiedBy = txtModifiedBy.Text;
            }
            else
            {
                ModifiedBy = txtCreatedBy.Text;
            }
            if (!string.IsNullOrEmpty(txtDateModified.Text))
            {
                dtModified = Convert.ToDateTime(txtDateModified.Text);
            }
            else
            {
                dtModified = Convert.ToDateTime(txtDateCreated.Text);
            }
            thisSurvey.ModifiedBy        = ModifiedBy;
            thisSurvey.DateModified      = dtModified;
            thisSurvey.SurveyNotes       = txtSurveyNotes.Text;
            thisSurvey.SurveyBoilerplate = txtSurveyBoilerplate.Text;
            classes.SQLCode thisSQL = new classes.SQLCode();
            thisSQL.PostSurvey(thisSurvey);
            LoadSurveyList();
            Response.Write("Survey data persisted");
        }
Beispiel #2
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.Write("Survey Posted");
        }