Example #1
0
    //------------------------------------------------------------------//
    #region ---------------LoadData---------------
    //-----------------------------------------------
    //LoadData
    //-----------------------------------------------
    protected void LoadData()
    {
        int quesID = Convert.ToInt32(Request.QueryString["id"]);
        VoteQuestionsEntity voteQuestions = VoteQuestionsFactory.GetObject(quesID);

        if (voteQuestions != null)
        {
            /*
             * //Check Valid Language to avoid changing query string manualy
             * Languages langid = SiteSettings.GetCurrentLanguage();
             * if (langid != voteQuestions.LangID)
             * {
             *  Response.Redirect("default.aspx");
             * }
             */
            txtQuestionText.Text          = voteQuestions.QuestionText;
            ddlAnswersCount.SelectedValue = voteQuestions.AnswersCount.ToString();
            cbIsMain.Checked   = voteQuestions.IsMain;
            cbIsClosed.Checked = voteQuestions.IsClosed;
            if (SiteSettings.Languages_HasMultiLanguages)
            {
                ddlLanguages.SelectedValue = ((int)voteQuestions.LangID).ToString();
            }
            AnsewrsApperingControl(voteQuestions.AnswersCount);
            LoadAnswers(voteQuestions);
        }
        else
        {
            Response.Redirect("default.aspx");
        }
    }
Example #2
0
    //------------------------------------------------------------------//
    #region ---------------btnSave_Click---------------
    //-----------------------------------------------
    //btnSave_Click
    //-----------------------------------------------
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }

        int quesID = Convert.ToInt32(Request.QueryString["id"]);
        VoteQuestionsEntity voteQuestions = VoteQuestionsFactory.GetObject(quesID);

        if (voteQuestions != null)
        {
            voteQuestions.QuestionText = txtQuestionText.Text;
            voteQuestions.AnswersCount = Convert.ToInt32(ddlAnswersCount.SelectedValue);
            voteQuestions.IsMain       = cbIsMain.Checked;
            voteQuestions.IsClosed     = cbIsClosed.Checked;
            //---------------------------------------------------------------------
            bool result = VoteQuestionsFactory.Save(voteQuestions, SPOperation.Update);
            if (result)
            {
                int               answersCount = Convert.ToInt32(ddlAnswersCount.SelectedValue);
                TextBox           txt          = new TextBox();
                VoteAnswersEntity answer;
                for (int i = 1; i <= answersCount; i++)
                {
                    txt               = (TextBox)phAnswers.FindControl("txt" + i);
                    answer            = new VoteAnswersEntity();
                    answer.QuesID     = voteQuestions.QuesID;
                    answer.AnswerText = txt.Text;
                    VoteAnswersFactory.Create(answer);
                }
                Response.Redirect("default.aspx");
            }
            else
            {
                lblResult.CssClass = "operation_error";
                lblResult.Text     = Resources.AdminText.SavingDataFaild;
            }
        }
        else
        {
            Response.Redirect("default.aspx");
        }
    }