日期:2014-05-17 浏览次数:20459 次
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.Data.SqlClient;
public partial class Result : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string cmdtxt1 = "server=(local);database=db_13;Uid=sa;Pwd=";
SqlConnection Con = new SqlConnection(cmdtxt1);
Con.Open();
SqlCommand Com = new SqlCommand("select * from tb_06 where ID=" + Request["ID"] + "", Con);
SqlDataReader dr = Com.ExecuteReader();
dr.Read();
string strContent = null;
if (dr.HasRows)
{
strContent = dr["Content"].ToString();
}
dr.Close();
decimal decNumAll = GetNumAll(strContent);//得到所有票数,C#在除法运算中需用decimal类型,否则将会把小数点后的数去掉
Response.Write(GetResult(strContent, decNumAll));
}
/// <summary>
/// 显示图象
/// </summary>
/// <param name="strContent">相关主题下的内容</param>
/// <param name="decNumAll">所有的票数</param>
/// <returns></returns>
public string GetResult(string strContent, decimal decNumAll)
{
string[] arrContent = strContent.Split('
------解决方案--------------------
');
string strBody = "<body style=text-align:center><table width=60% border=1 cellpadding=0 cellspacing=0 text-align:center>\n";
foreach (string strContentIN in arrContent)
{
string strItemName = strContentIN.Split(',')[1].ToString();//得到选项名称