Ejemplo n.º 1
0
        private void LoadQuestions()
        {
            classes.SQLCode mySQL = new classes.SQLCode();
            theseQuestions = mySQL.GetAllQuestions();
            SerializeQuestions(theseQuestions);
            ddlQuestions.Items.Clear();
            ListItem li = new ListItem();

            li.Text  = "New Question";
            li.Value = new Guid("00000000-0000-0000-0000-000000000000").ToString();
            ddlQuestions.Items.Add(li);
            foreach (classes.Question thisQuestion in theseQuestions)
            {
                li       = new ListItem();
                li.Text  = thisQuestion.QuestionText;
                li.Value = thisQuestion.QuestionID.ToString();
                ddlQuestions.Items.Add(li);
            }
            txtAnswerID.Text     = "";
            txtAnswerText.Text   = "";
            txtSortOrder.Text    = "";
            txtQuestionID.Text   = "";
            txtQuestionText.Text = "";
            lbAnswers.Items.Clear();
        }
Ejemplo n.º 2
0
        protected void btnUpdateQuestion_Click(object sender, EventArgs e)
        {
            classes.Question thisQuestion = new classes.Question();
            thisQuestion.QuestionID     = new Guid(txtQuestionID.Text);
            thisQuestion.QuestionText   = txtQuestionText.Text;
            thisQuestion.QuestionTypeID = new Guid(ddlQuestionType.SelectedValue.ToString());
            classes.SQLCode mySQL        = new classes.SQLCode();
            ListItem        li           = ddlQuestionType.SelectedItem;
            string          QuestionType = li.Text;

            theseAnswers = DeserializeAnswers();
            //when you add a free text question there is only one answer, which = the text of the question.  Since the answer editor controls are
            //disabled for free text questions this won't allow a user to create an answer, therefore: on create answer list is null and uneditable.
            if (QuestionType == "Free Text" && theseAnswers.Count < 1)
            {
                classes.Answer thisAnswer = new classes.Answer();
                Guid           g          = Guid.NewGuid();
                thisAnswer.AnswerID   = g;
                thisAnswer.QuestionID = thisQuestion.QuestionID;
                thisAnswer.AnswerText = thisQuestion.QuestionText;
                thisAnswer.SortOrder  = 1;
                theseAnswers.Add(thisAnswer);
            }
            else if (QuestionType == "Free Text" && theseAnswers.Count > 0)
            {
                theseAnswers[0].AnswerText = txtQuestionText.Text;
                theseAnswers[0].SortOrder  = 1;
            }

            mySQL.PostQuestion(thisQuestion, theseAnswers);
            LoadQuestions();
            Response.Write("Question added");
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserOK"] == null || Session["UserOK"].ToString() != "OK")
            {
                Response.Redirect("Logon.aspx");
            }

            if (Request.QueryString["SurveyID"] != null)
            {
                SurveyID = new Guid(Request.QueryString["SurveyID"].ToString());
            }
            else
            {
                Response.Redirect("Index.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();
            //}
        }
Ejemplo n.º 4
0
        private void LoadSurveyList()
        {
            ddlSurveys.Items.Clear();

            classes.SQLCode thisSQL = new classes.SQLCode();
            theseSurveys = thisSQL.GetAllSurveys();
            //serialize theseSurveys to string so we can stuff them in a hidden control
            XmlSerializer ser = new XmlSerializer(theseSurveys.GetType());

            using (StringWriter writer = new StringWriter())
            {
                ser.Serialize(writer, theseSurveys);
                surveyList.Value = writer.ToString();
            }
            ListItem li = new ListItem();

            li.Text  = "New Survey";
            li.Value = new Guid("00000000-0000-0000-0000-000000000000").ToString();
            ddlSurveys.Items.Add(li);
            foreach (classes.Survey thisSurveyListItem in theseSurveys)
            {
                li       = new ListItem();
                li.Text  = thisSurveyListItem.SurveyName;
                li.Value = thisSurveyListItem.SurveyID.ToString();
                ddlSurveys.Items.Add(li);
            }
        }
Ejemplo n.º 5
0
        protected void btnLoad_Click(object sender, EventArgs e)
        {
            ListItem li = ddlQuestions.SelectedItem;

            if (li.Text == "New Question")
            {
                //Initialize new question, clear theseAnswers and all extraneous text boxes;
                Guid gQuestionID = Guid.NewGuid();
                txtQuestionID.Text   = gQuestionID.ToString();
                txtQuestionText.Text = "";
                theseAnswers.Clear();
                answerList.Value     = "";
                txtAnswerID.Text     = "";
                txtAnswerText.Text   = "";
                txtSortOrder.Text    = "";
                lbAnswers.DataSource = theseAnswers;
                lbAnswers.DataBind();
            }
            else
            {
                theseQuestions = DeserialzeQuestions();
                classes.Question thisQuestion = theseQuestions.Find(delegate(classes.Question myQuestion) { return(myQuestion.QuestionID == new Guid(ddlQuestions.SelectedValue)); });
                if (thisQuestion != null)
                {
                    txtQuestionID.Text            = thisQuestion.QuestionID.ToString();
                    txtQuestionText.Text          = thisQuestion.QuestionText;
                    ddlQuestionType.SelectedValue = thisQuestion.QuestionTypeID.ToString();
                }
                classes.SQLCode mySQL = new classes.SQLCode();
                theseAnswers.Clear();
                //if we have a question, look for answers for that question
                if (!string.IsNullOrEmpty(txtQuestionID.Text))
                {
                    theseAnswers = mySQL.GetAnswers(thisQuestion.QuestionID);
                    SerializeAnswers(theseAnswers);
                    lbAnswers.DataSource     = theseAnswers;
                    lbAnswers.DataTextField  = "AnswerText";
                    lbAnswers.DataValueField = "AnswerID";
                    lbAnswers.DataBind();

                    /*
                     * ListItem li = new ListItem();
                     * li.Text = "New Answer";
                     * li.Value = new Guid("00000000-0000-0000-0000-000000000000").ToString();
                     * foreach (classes.Answer thisAnswer in theseAnswers)
                     * {
                     *  li = new ListItem();
                     *  li.Text = thisAnswer.AnswerText;
                     *  li.Value = thisAnswer.AnswerID.ToString();
                     *  ddlAnswers.Items.Add(li);
                     * }
                     * */
                }
            }
            txtAnswerText.Text = "";
            txtSortOrder.Text  = "";
        }
Ejemplo n.º 6
0
        private void LoadDataGrid()
        {
            classes.SQLCode             mySQL          = new classes.SQLCode();
            List <classes.PostedSurvey> thisSurveyData = mySQL.GetPostedSurveyData(SurveyID);

            //thisSurveyData = thisSurveyData.OrderBy(a => a.QuestionNumber).ToList();
            gvData.DataSource = thisSurveyData;
            gvData.DataBind();
        }
Ejemplo n.º 7
0
        private void LoadSurveyCounts()
        {
            classes.SQLCode             mySQL       = new classes.SQLCode();
            List <classes.SurveyCounts> theseCounts = mySQL.GetSurveyCounts();

            gvSurveyList.DataSource          = theseCounts;
            gvSurveyList.AutoGenerateColumns = true;
            gvSurveyList.DataBind();
        }
Ejemplo n.º 8
0
 protected void btnDeleteQuestion_Click(object sender, EventArgs e)
 {
     classes.Question thisQuestion = new classes.Question();
     thisQuestion.QuestionID     = new Guid(txtQuestionID.Text);
     thisQuestion.QuestionText   = txtQuestionText.Text;
     thisQuestion.QuestionTypeID = new Guid(ddlQuestionType.SelectedValue.ToString());
     classes.SQLCode mySQL = new classes.SQLCode();
     mySQL.DeleteQuestion(thisQuestion);
     LoadQuestions();
     Response.Write("Question deleted");
 }
Ejemplo n.º 9
0
 private void LoadSurveys()
 {
     classes.SQLCode mySQL = new classes.SQLCode();
     theseSurveys = mySQL.GetAllSurveys();
     foreach (classes.Survey thisSurvey in theseSurveys)
     {
         ListItem li = new ListItem();
         li.Text  = thisSurvey.SurveyName;
         li.Value = thisSurvey.SurveyID.ToString();
         ddlSurveys.Items.Add(li);
     }
 }
Ejemplo n.º 10
0
        private void LoadSurveyQuestions(Guid SurveyID)
        {
            classes.SQLCode         mySQL           = new classes.SQLCode();
            List <classes.Question> surveyQuestions = mySQL.GetQuestionsBySurvey(SurveyID);

            surveyQuestions = surveyQuestions.OrderBy(a => a.QuestionNumber).ToList();
            SerializeSurveyQuestions(surveyQuestions);

            lbCurrentQuestions.DataSource     = surveyQuestions;
            lbCurrentQuestions.DataTextField  = "QuestionText";
            lbCurrentQuestions.DataValueField = "QuestionID";
            lbCurrentQuestions.DataBind();
        }
Ejemplo n.º 11
0
        protected void btnPostSurveyDesign_Click(object sender, EventArgs e)
        {
            ListItem li       = ddlSurveys.SelectedItem;
            Guid     SurveyID = new Guid(li.Value.ToString());

            classes.SQLCode mySQL = new classes.SQLCode();
            surveyQuestions = DeserialzeSurveyQuestions();
            mySQL.PostSurveyDesign(SurveyID, surveyQuestions);
            surveyQuestions.Clear();
            lbCurrentQuestions.DataSource = surveyQuestions;
            lbCurrentQuestions.DataBind();
            Response.Write("Survey design posted");
        }
Ejemplo n.º 12
0
        protected void btnLoadurveyData_Click(object sender, EventArgs e)
        {
            ListItem li       = ddlSurveys.SelectedItem;
            Guid     surveyID = new Guid(li.Value.ToString());

            classes.SQLCode mySQL = new classes.SQLCode();
            DataTable       dt    = mySQL.GetLegend(surveyID);

            gvLegend.DataSource = dt;
            gvLegend.DataBind();
            DataTable dtData = mySQL.GetAnalytics(surveyID);

            gvData.DataSource = dtData;
            gvData.DataBind();
        }
Ejemplo n.º 13
0
        private void LoadSurveys()
        {
            ddlSurveys.Items.Clear();
            classes.SQLCode       mySQL      = new classes.SQLCode();
            List <classes.Survey> allSurveys = mySQL.GetAllSurveys();

            allSurveys = allSurveys.OrderBy(s => s.SurveyName).ToList <classes.Survey>();
            foreach (classes.Survey s in allSurveys)
            {
                ListItem li = new ListItem();
                li.Text  = s.SurveyName;
                li.Value = s.SurveyID.ToString();
                ddlSurveys.Items.Add(li);
            }
        }
Ejemplo n.º 14
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);
 }
Ejemplo n.º 15
0
        private void LoadQuestions()
        {
            classes.SQLCode mySQL = new classes.SQLCode();
            theseQuestions = mySQL.GetAllQuestions();
            SerializeQuestions(theseQuestions);
            ddlQuestions.Items.Clear();
            ListItem li = new ListItem();

            ddlQuestions.Items.Add(li);
            foreach (classes.Question thisQuestion in theseQuestions)
            {
                li       = new ListItem();
                li.Text  = thisQuestion.QuestionText;
                li.Value = thisQuestion.QuestionID.ToString();
                ddlQuestions.Items.Add(li);
            }
        }
Ejemplo n.º 16
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");
        }
Ejemplo n.º 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserOK"] == null || Session["UserOK"].ToString() != "OK")
            {
                Response.Redirect("Logon.aspx");
            }

            if (Request.QueryString["SurveyID"] != null)
            {
                SurveyID = new Guid(Request.QueryString["SurveyID"].ToString());
                //lblSurveyID.Text = SurveyID.ToString();
            }
            else
            {
                Response.Redirect("Index.aspx");
            }
            classes.SQLCode mySQL      = new classes.SQLCode();
            List <string>   surveyData = mySQL.GetSurveyName(SurveyID);

            lblSurveyName.Text = surveyData[0].ToString();
            LoadDataGrid();
        }
Ejemplo n.º 18
0
        private void LoadQuestionTypes()
        {
            classes.SQLCode mySQL = new classes.SQLCode();
            theseQuestionTypes = mySQL.GetQuestionTypes();
            XmlSerializer ser = new XmlSerializer(theseQuestionTypes.GetType());

            using (StringWriter writer = new StringWriter())
            {
                ser.Serialize(writer, theseQuestionTypes);
                questionTypesList.Value = writer.ToString();
            }
            ddlQuestionType.Items.Clear();
            ListItem li = new ListItem();

            li.Text  = "New Question";
            li.Value = new Guid("00000000-0000-0000-0000-000000000000").ToString();
            foreach (classes.QuestionType thisQuestionType in theseQuestionTypes)
            {
                li       = new ListItem();
                li.Text  = thisQuestionType.QuestionTypeName;
                li.Value = thisQuestionType.QuestionTypeID.ToString();
                ddlQuestionType.Items.Add(li);
            }
        }
Ejemplo n.º 19
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");
        }
Ejemplo n.º 20
0
 private void LoadQuestionTypes()
 {
     classes.SQLCode mySQL = new classes.SQLCode();
     theseQuestionTypes = mySQL.GetQuestionTypes();
     SerializeQuestionTypes(theseQuestionTypes);
 }