Example #1
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");
        }
Example #2
0
/**
 */
        private void imgContinue_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            classes.Question tmpQ = (classes.Question)Session["QItem"];

            //show error panel if the object goes null.  If so, then that really sux.
            if (tmpQ == null)
            {
                ErrorLog.ErrorRoutine(false, "Error: BoardItem obj NULL!");
                ErrorLog.ErrorRoutine(false, "SessionID: " + Session.SessionID);

                pnlError.Visible = true;
                return;
            }
            else
            {
                ErrorLog.ErrorRoutine(false, "QItem OK!");
            }

            tmpQ.Tags        = Global.CheckString(tmpQ.Tags);
            tmpQ.StrQuestion = Global.CheckString(tmpQ.StrQuestion);

            if (tmpQ.QId != (int)-1)
            {
                //Update
                if (tmpQ.UpdateItem())
                {
                    Response.Redirect("FinishQ.aspx", false);
                }
                else
                {
                    lblStatus.Text = "Error updating question.";
                }
            }
            else
            {
                //New or Edit-new

                //Set the date.  All other fields should be ok since we're only viewing on this page
                tmpQ.CreateDate = DateTime.Now;


                //Save entry
                //write entry to db
                if (tmpQ.SaveNewItem())
                {
                    //TODO: Decide if we're going to count
                    //if (UpdateEntryCount(tmpQ.IUser.ToString()))
                    //{
                    //    Response.Redirect("FinishQ.aspx");
                    //}
                    Response.Redirect("FinishQ.aspx", false);
                }
                else
                {
                    lblStatus.Text = "Error Posting Question!";
                    return;
                }
            }
        }
Example #3
0
 protected void imgGoBack_Click2(object sender, ImageClickEventArgs e)
 {
     //Set edit mode and load up the session variable with the class object
     classes.Question tQ = (classes.Question)Session["QItem"];
     tQ.EditMode      = true;
     Session["QItem"] = tQ;
     Response.Redirect("PostQ.aspx", false);
 }
Example #4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                classes.Question tQ = (classes.Question)Session["QItem"];

                if (tQ == null)
                {
                    return;
                }

                // Put user code to initialize the page here
                Global.AuthenticateUser();

                lnkSignIn.Text = Global.SetLnkSignIn( );
                lnkSignUp.Text = Global.SetLnkSignUp( );

                string entryId;

                //display the correct entry id: Update or New?
                if (tQ.QId == (int)-1)
                {
                    entryId = GetNewEntryId();
                }
                else
                {
                    entryId = tQ.QId.ToString();
                }

                // Put user code to initialize the page here
                lblMessage.Text = "You're done!";

                string eLink = System.Configuration.ConfigurationSettings.AppSettings["serverURL"].ToString() + "/Qna/QDetails.aspx?q=" + entryId;

                lnkPostItem.Text        = eLink;
                lnkPostItem.NavigateUrl = eLink;

                string[] eLinkArr = new string[1];
                eLinkArr[0] = eLink;

                //email only if new
                if (tQ.QId == (int)-1)
                {
                    classes.Email.SendEmail("Thanks for Asking", Session["EmailId"].ToString(), 4, eLinkArr);
                }

                Session["QItem"] = null;

                ////////////////////

                //hdnEntryVal.Value = entryId;
                //lnkPostItem.Attributes.Add("href", "mailto:" + "?subject=See My Boardhunt Posting&body=" + eLink);
                //lnkPostItem.NavigateUrl = "surfboard.aspx?iD=" + entryId + "&uId=" + tmpBoardItem.IUser + "&iCat=" + tmpBoardItem.Category;

                //txtEntryLink.Text = eLink;
                //txtEntryLink.ReadOnly = true;
            }
        }
Example #5
0
 protected void lbCurrentQuestions_SelectedIndexChanged(object sender, EventArgs e)
 {
     surveyQuestions = DeserialzeSurveyQuestions();
     classes.Question foundQuestion = surveyQuestions.Find(delegate(classes.Question thisQuestion) { return(thisQuestion.QuestionID == new Guid(lbCurrentQuestions.SelectedValue.ToString())); });
     if (foundQuestion != null)
     {
         txtQuestionOrder.Text = foundQuestion.QuestionNumber.ToString();
     }
 }
Example #6
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  = "";
        }
Example #7
0
/**
 */
        //private void lnkSell_Click(object sender, System.EventArgs e)
        //{
        //    Global.NavigatePage(lnkSignIn.Text);
        //}

/*
 */
        protected void imgNext_Click1(object sender, ImageClickEventArgs e)
        {
            if (txtQuestion.Text.Length < 1)
            {
                return;
            }

            classes.Question tmpQ = new classes.Question();

            //tmpQ.Category = Convert.ToInt32(cboCategory.SelectedItem.Value);

            string tmpString;

            tmpString = txtQuestion.Text;

            //Add question mark if missing at the end
            if (tmpString.LastIndexOf("?", tmpString.Length) == (int)-1)
            {
                tmpString += "?";
            }

            //remove characters after 200.
            if (tmpString.Length > 200)
            {
                tmpString = tmpString.Remove(200, tmpString.Length - 200);
            }

            tmpQ.StrQuestion = tmpString;

            //space or question mark?
            tmpQ.Tags = txtTags.Text;


            //reset the edit mode
            tmpQ.EditMode = false;

            //get userId
            tmpQ.User = Convert.ToInt32(Session["userId"].ToString());

            //If updating a Question...we'll need the ID
            if (hdnEditNew.Value != "1" && hdnQId.Value != "-1")
            {
                //assign update id
                tmpQ.QId = Convert.ToInt32(hdnQId.Value);
            }
            else
            {
                tmpQ.QId = (int)-1;
            }

            //Save object to session variable
            Session["QItem"] = tmpQ;

            //to next wizard page
            Response.Redirect("PreviewQ.aspx", false);
        }
Example #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");
 }
Example #9
0
/**
 */
        //public void BindData()
        //{
        //    //declare variables
        //    string strSQL;
        //    string myConnectString;

        //    //Create connect string
        //    myConnectString = ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;;
        //    SqlConnection myConnection = new SqlConnection(myConnectString);

        //    try
        //    {

        //        //Build SQL statement
        //        strSQL = "SELECT * FROM LK_QCat";

        //        // Read sample item info from SQL into a DataSet
        //        DataSet dsItems = new DataSet();

        //        SqlDataAdapter objAdapter = new SqlDataAdapter(strSQL, myConnection);

        //        objAdapter.TableMappings.Add("Table", "tblQCat");

        //        objAdapter.Fill(dsItems);

        //        //cboCategory.DataSource = dsItems;
        //        //cboCategory.DataMember = "tblQCat";
        //        //cboCategory.DataTextField = "Category";
        //        //cboCategory.DataValueField = "iD";
        //        //cboCategory.DataBind();
        //        //cboCategory.SelectedIndex = (int)0;
        //    }
        //    catch (Exception ex)
        //    {
        //        ErrorLog.ErrorRoutine(false, "PostQ:Error getting category values: " + ex.Message);
        //    }
        //    finally
        //    {
        //        myConnection.Close();
        //    }
        //}

/**
 */
        protected void LoadForEdit()
        {
            classes.Question tQuestion = new classes.Question();

            tQuestion        = (classes.Question)Session["QItem"];
            txtQuestion.Text = tQuestion.StrQuestion;
            txtTags.Text     = tQuestion.Tags;
            if (tQuestion.NotifyFlg == 1)
            {
                chkNotify.Checked = true;
            }
        }
Example #10
0
 protected void btnUpdateSelected_Click(object sender, EventArgs e)
 {
     surveyQuestions = DeserialzeSurveyQuestions();
     classes.Question foundQuestion = surveyQuestions.Find(delegate(classes.Question thisQuestion) { return(thisQuestion.QuestionID == new Guid(lbCurrentQuestions.SelectedValue.ToString())); });
     if (foundQuestion != null)
     {
         foundQuestion.QuestionNumber = Convert.ToInt32(txtQuestionOrder.Text);
     }
     lbCurrentQuestions.DataSource     = surveyQuestions;
     lbCurrentQuestions.DataTextField  = "QuestionText";
     lbCurrentQuestions.DataValueField = "QuestionID";
     lbCurrentQuestions.DataBind();
     SerializeSurveyQuestions(surveyQuestions);
 }
Example #11
0
/**
 * Display the data the user has entered from the (previous) post_item page.  The data now resides in a general entry item object
 * Show the general info then display board specfic detail
 */
        private void BindData(classes.Question qItem)
        {
            ErrorLog.ErrorRoutine(false, "PreviewQ:Binding Data");

            lblQuestion.Text = qItem.StrQuestion;
            //lblCategory.Text = qItem.Category.ToString();

            //show today's date
            lblDateData.Text  = String.Format("{0:MM/dd}", DateTime.Now);
            lnkEmailData.Text = ParseEmail(Session["EmailId"]);
            lblTags.Text      = qItem.Tags;

            ErrorLog.ErrorRoutine(false, "PreviewQ:Done");
        }
Example #12
0
        protected void btnAddQuestion_Click(object sender, EventArgs e)
        {
            ListItem li         = ddlQuestions.SelectedItem;
            Guid     QuestionID = new Guid(li.Value.ToString());

            theseQuestions  = DeserialzeQuestions();
            surveyQuestions = DeserialzeSurveyQuestions();
            classes.Question foundQuestion = surveyQuestions.Find(delegate(classes.Question thisQuestion) { return(thisQuestion.QuestionID == QuestionID); });
            if (foundQuestion != null)
            {
                Response.Write("Question already associated with this survey");
                return;
            }
            else
            {
                classes.Question selQuestion = theseQuestions.Find(delegate(classes.Question thisQuestion) { return(thisQuestion.QuestionID == QuestionID); });
                if (selQuestion != null)
                {
                    int  numVal;
                    bool result = Int32.TryParse(txtQuestionOrder.Text, out numVal);
                    if (!result)
                    {
                        txtQuestionOrder.BackColor = System.Drawing.Color.Red;
                        txtQuestionOrder.Text      = "Please enter a valid number";
                        return;
                    }
                    else
                    {
                        txtQuestionOrder.BackColor = System.Drawing.Color.White;
                    }
                    selQuestion.QuestionNumber = numVal;
                    selQuestion.QuestionStatus = "KEEP";
                    surveyQuestions.Add(selQuestion);
                }
                else
                {
                    Response.Write("Couldn't find question");
                }
            }
            lbCurrentQuestions.DataSource     = surveyQuestions;
            lbCurrentQuestions.DataTextField  = "QuestionText";
            lbCurrentQuestions.DataValueField = "QuestionID";
            lbCurrentQuestions.DataBind();
            SerializeSurveyQuestions(surveyQuestions);
        }
Example #13
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            ErrorLog.ErrorRoutine(false, "PreviewQ:PageLoad");

            //BoardItem tmpBoardItem = (BoardItem)Session["Item"];
            classes.Question tempQ = (classes.Question)Session["QItem"];

            if (!Page.IsPostBack)
            {
                ErrorLog.ErrorRoutine(false, "PreviewQ:FirstTime");

                // Put user code to initialize the page here
                lnkSignIn.Text = Global.SetLnkSignIn( );
                lnkSignUp.Text = Global.SetLnkSignUp( );

                //Load up display data and show a preview of the posting
                BindData(tempQ);
            }
        }
Example #14
0
 protected void btnRemoveQuestion_Click(object sender, EventArgs e)
 {
     surveyQuestions = DeserialzeSurveyQuestions();
     classes.Question foundQuestion = surveyQuestions.Find(delegate(classes.Question thisQuestion) { return(thisQuestion.QuestionID == new Guid(lbCurrentQuestions.SelectedValue.ToString())); });
     if (foundQuestion == null)
     {
         Response.Write("Couldn't find question");
         return;
     }
     else
     {
         foundQuestion.QuestionStatus = "REMOVE";
         foundQuestion.QuestionText  += " REMOVED";
     }
     lbCurrentQuestions.DataSource     = surveyQuestions;
     lbCurrentQuestions.DataTextField  = "QuestionText";
     lbCurrentQuestions.DataValueField = "QuestionID";
     lbCurrentQuestions.DataBind();
     SerializeSurveyQuestions(surveyQuestions);
 }
Example #15
0
/*
 */
        public void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                //instantiate Q class
                classes.Question oQuestion = new classes.Question();

                //iterate list control and set values
                if (dlEntryList.Items.Count > 0)
                {
                    foreach (DataListItem item in dlEntryList.Items)
                    {
                        CheckBox pubNotify = item.FindControl("chkNotify") as CheckBox;
                        if (pubNotify.Checked == true)
                        {
                            //find the id and publish it
                            HiddenField hdnVal = item.FindControl("hdnItemVal") as HiddenField;
                            oQuestion.UpdateNotifyValue(hdnVal.Value, "1");
                        }
                        else
                        {
                            //find the id and un-publish it
                            HiddenField hdnVal = item.FindControl("hdnItemVal") as HiddenField;
                            oQuestion.UpdateNotifyValue(hdnVal.Value, "0");
                        }
                    }
                }

                ItemsGet();
            }
            catch (Exception ex)
            {
                ErrorLog.ErrorRoutine(false, "Error Updating Blog for Publish: " + ex.Message);
                return;
            }

            finally { }
        }