水晶报表显示不出数据来 c#水晶报表水晶报表数据不显示 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 分析投票结果柱形图//加载数据 protected void Page_Load(object sender, EventArgs e) { string cmdtxt1 =System.Configuration.ConfigurationManager.AppSettings["conn"].ToString(); SqlConnection Con = new SqlConnection(cmdtxt1); Con.Open(); SqlCommand Com = new SqlCommand("select * from tb_CarVote 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)); }//codego.net/tags/1/1///显示图表 // <param name="strContent">相关主题下的内容</param> // <param name="decNumAll">所有的票数</param> 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();//得到选项名称 decimal decItemNum = Convert.ToDecimal(strContentIN.Split(',')[0]);//得到选项的投票数 decimal decPercent = GetPercent(decItemNum, decNumAll) * 100;//得到百分比 string strPercent = decPercent.ToString();//将百分比转为字符型 if (strPercent.Length > 5)//如果百分比结果长度超过5位 { strPercent = strPercent.Substring(0, 5);//将百分比的余数截短为“00.00” } strBody += "<tr><td width=100 style=font-size:9pt;text-align:center>" + strItemName + "</td><td width=50 style=font-size:9pt;color=red;text-align:center>" + decItemNum.ToString() + "票</td><td style=font-size:9pt><img src=Images/bar1.gif height=10 width=" + strPercent + "%>" + strPercent + "%</td></tr>\n"; } strBody += "</table></body>"; return strBody; } <在线等>垃圾回收问题-2 Sql2005数据库怎么转换Sql2000 c# 如何把一个流程图存为bmp格式的图像? 请教一个C#操作命令行的问题 C#字符串数组中排序的问题,求教 Studio 2010 的MSDN 那里有下载 请教c#下扫雷的编程思路! 多线程操作文本文件的问题 如何通过DHTMLEDIT控件来操做编辑页面? ref,in.out的区别,::是否还保留? File.Move()异常 多线程问题?请各位高手帮忙!
//加载数据
protected void Page_Load(object sender, EventArgs e)
{
string cmdtxt1 =System.Configuration.ConfigurationManager.AppSettings["conn"].ToString();
SqlConnection Con = new SqlConnection(cmdtxt1);
Con.Open();
SqlCommand Com = new SqlCommand("select * from tb_CarVote 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));
}//codego.net/tags/1/1/
//显示图表
// <param name="strContent">相关主题下的内容</param>
// <param name="decNumAll">所有的票数</param>
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();//得到选项名称
decimal decItemNum = Convert.ToDecimal(strContentIN.Split(',')[0]);//得到选项的投票数
decimal decPercent = GetPercent(decItemNum, decNumAll) * 100;//得到百分比
string strPercent = decPercent.ToString();//将百分比转为字符型
if (strPercent.Length > 5)//如果百分比结果长度超过5位
{
strPercent = strPercent.Substring(0, 5);//将百分比的余数截短为“00.00”
}
strBody += "<tr><td width=100 style=font-size:9pt;text-align:center>" + strItemName + "</td><td width=50 style=font-size:9pt;color=red;text-align:center>" + decItemNum.ToString() + "票</td><td style=font-size:9pt><img src=Images/bar1.gif height=10 width=" + strPercent + "%>" + strPercent + "%</td></tr>\n";
}
strBody += "</table></body>";
return strBody;
}