showvote.aspx.cs

来自「一个开源企业网站」· CS 代码 · 共 70 行

CS
70
字号
using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ShowVote : System.Web.UI.Page
{
    int voteTotal = 0;
    protected void Page_Load(object sender, EventArgs e)
    {

        SetVoteTotal();
        if (!Page.IsPostBack)
        {
            BindVoteListData();

            VoteMessage.Text = "总票数为:" + voteTotal.ToString();
        }
    }

    private void SetVoteTotal()
    {

        GetContent content = new GetContent();
        OleDbDataReader dr = content.SetVote();
        while (dr.Read())
        {
            voteTotal += Int32.Parse(dr["VoteCount"].ToString());
        }
        dr.Close();
    }

    private void BindVoteListData()
    {
        GetContent content = new GetContent();
        OleDbDataReader dr1 = content.BindVote();
        VoteList.DataSource = dr1;
        VoteList.DataBind();
        dr1.Close();
    }

    public int FormatVoteCount(String voteCount)
    {
        if (voteCount.Length <= 0)
        {
            return (0);
        }
        if (voteTotal > 0)
        {
            return ((Int32.Parse(voteCount) * 100 / voteTotal));
        }
        return (0);
    }

    public int FormatVoteImage(int voteCount)
    {
        return (voteCount * 3);
    }
    protected void WebOnlineVoteBtn_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/WebOnlinVote.aspx");
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?