Example #1
0
    //------------------------------------------------------------------//
    #region ---------------btnSave_Click---------------
    //-----------------------------------------------
    //btnSave_Click
    //-----------------------------------------------
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }


        VoteQuestionsEntity voteQuestions = new VoteQuestionsEntity();

        voteQuestions.QuesID       = Convert.ToInt32(Request.QueryString["id"]);
        voteQuestions.QuestionText = txtQuestionText.Text;
        voteQuestions.AnswersCount = Convert.ToInt32(ddlAnswersCount.SelectedValue);
        voteQuestions.IsMain       = cbIsMain.Checked;
        //---------------------------------------------------------------------
        //Language
        //---------------------------------------------------------------------
        Languages langID = (Languages)SiteSettings.Languages_DefaultLanguageID;

        if (SiteSettings.Languages_HasMultiLanguages)
        {
            langID = (Languages)Convert.ToInt32(ddlLanguages.SelectedValue);
        }
        //--------------------------------------
        voteQuestions.LangID = langID;
        //---------------------------------------------------------------------
        bool result = VoteQuestionsFactory.Save(voteQuestions, SPOperation.Insert);

        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);
            }
            lblResult.CssClass = "operation_done";
            lblResult.Text     = Resources.AdminText.SavingDataSuccessfuly;
            ClearControls(voteQuestions.AnswersCount);
        }
        else
        {
            lblResult.CssClass = "operation_error";
            lblResult.Text     = Resources.AdminText.SavingDataFaild;
        }
    }
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");
        }
    }