示例#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;
        }
    }
示例#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");
        }
    }
示例#3
0
            //---------------------------------------
            protected void rAnswers_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                if (TotalHits > 0)
                {
                    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                    {
                        VoteAnswersEntity answer = answersList[e.Item.ItemIndex];
                        /*double MaxLength = SiteSettings.Vote_ImageMaxLength;*/
                        double imageWidth = (100 * (answer.HitsCount / TotalHits));
                        //double MinLength = SiteSettings.Vote_ImageMinLength;
                        decimal roundWidth = Math.Round((decimal)imageWidth, 2);
                        //if (imageWidth < 1 && answer.HitsCount > 0)
                        //    imageWidth = MinLength;
                        //Image imgAnswerImage = (Image)e.Item.FindControl("imgAnswerImage");
                        //imgAnswerImage.Style.Add(HtmlTextWriterStyle.Width, roundWidth.ToString());
                        Label lblImage = (Label)e.Item.FindControl("lblImage");
                        lblImage.Style.Add(HtmlTextWriterStyle.Width, roundWidth.ToString() + "%");

                        Label lblRate = (Label)e.Item.FindControl("lblRate");
                        lblRate.Text = roundWidth.ToString() + "%";
                    }
                }
            }