⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 view.aspx.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
字号:
//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Data;
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;
using System.ComponentModel;
using System.Drawing;
using System.Web.SessionState;
using NetCMS.Content;
using NetCMS.Content.Common;
using NetCMS.Model;

public partial class vote_vview : NetCMS.Web.UI.BasePage
{
    Survey sur = new Survey();
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.CacheControl = "no-cache"; //清除缓存
        if (!IsPostBack)//判断页面是否重载
        {
            //判断用户是否登录
            copyright.InnerHtml = CopyRight;            //获取版权信息
        }
        showResult.InnerHtml = ShowResultt();
    }

    string ShowResultt()
    {
        //输出最终结果
        if (Request.QueryString["TID"] == null || Request.QueryString["TID"] == string.Empty)
        {
            PageError("缺少必要的参数", "");
        }
        int tid = int.Parse(Request.QueryString["TID"]);


        string titlename = "";//主题名  
        string strlist = "";
        if (tid <= 0)
        {
            //PageError("参数错误", "");
            return "";
        }
        else
        {
            //取得主题名
            VoteTopicInfo dtt = sur.GetTopic(tid);
            #region titlename
            if (dtt.TID != 0)
            {
                titlename = dtt.Title;
            }
            else
            {
                PageError("抱歉,参数错误", "");
            }
            #endregion
            int total = 0;
            DataTable dt = sur.GetVoteStat(tid, out total);

            strlist = "<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" class=\"table\">\n";
            strlist += "<tr class=\"TR_BG_list\"><td width=100% class=\"list_link\" colspan=\"3\">主题:" + titlename + "</td></tr>\n";
            strlist += "</table>\n";

            #region 循环
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int nowNum = 0;//当前票数(真实票数)
                int baseNum = 0;//基本票数(添加的时候的票数)
                string color = "";//显示颜色
                int iid = (int)dt.Rows[i]["IID"];//选项ID
                //查询相应ID的投票数(为投票的真实票数,除去了后台添加时赋给的投票数)
                if (dt.Rows[i]["VoteCount"] != DBNull.Value)
                    baseNum = (int)dt.Rows[i]["VoteCount"];//取得基本票数的值
                int nsum = Convert.ToInt32(dt.Rows[i]["Result"]);
                nowNum = baseNum + nsum;//取得总的投票数
                if (dt.Rows[i]["DisColor"] != DBNull.Value)
                    color = dt.Rows[i]["DisColor"].ToString();//取得选项的颜色(仅限于文字颜色)
                string ItemName = dt.Rows[i]["ItemName"].ToString();//得到选项名称
                double decPercent = GetPercent(nowNum, total);//得到百分比

                string strPercent = decPercent.ToString("0.###");
                strlist += "<table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\">\n";
                strlist += "<tr class=\"TR_BG_list\"><td width=\"20%\" class=\"list_link\">";
                if (dt.Rows[i]["ItemMode"] != DBNull.Value && Convert.ToByte(dt.Rows[i]["ItemMode"]) == 0X02 && dt.Rows[i]["PicSrc"] != DBNull.Value && dt.Rows[i]["PicSrc"].ToString().Trim() != string.Empty)
                {
                    string imgpath = dt.Rows[i]["PicSrc"].ToString().Replace("{@dirfile}", NetCMS.Config.UIConfig.dirFile);
                    strlist += "<a href=\"" + imgpath + "\" target=\"_blank\"><img  height=\"18\" src=\"" + imgpath + "\" title=\"点击查看图片\" border=\"0\" alt=\"暂无图片\"/></a>";
                }
                strlist += "<font color=\"#" + color + "\"><a title=\"所属主题:" + titlename + "\">" + ItemName + "</font></a>";
                strlist += "</td>";
                strlist += "<td width=\"10%\" class=\"list_link\" align=\"center\"><a title=\"主题:" + titlename + "--选项:" + ItemName + "\">";
                strlist += "<font color=\"#" + color + "\">" + nowNum + "票</font></a></td><td class=\"list_link\" width=\"70%\">";
                strlist += "<div style=\"height:18px;border-right: gainsboro 1px solid; border-top: gainsboro 1px solid; border-left: gainsboro 1px solid; border-bottom: gainsboro 1px solid;background-color:#" + color + ";width:" + strPercent + "%;\"><b>" + strPercent + "%</b></div></td></tr>\n";
                strlist += "</table>";
            }
            #endregion
            //Response.Write(strlist);
            return strlist;
        }
    }

    //百分比
    //nowNum:当前选项本身的票数;CountNum:所有的票数
    double GetPercent(int nowNum, int CountNum)
    {
        if (CountNum == 0)//如果总票数是零
        {
            return 0;
        }
        //计算百分数
        return (double)((nowNum * 100.00) / CountNum);
    }

}

⌨️ 快捷键说明

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