| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1268 人关注过本帖
标题:请求高手帮忙![求助]
取消只看楼主 加入收藏
17594840
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2004-12-2
收藏
 问题点数:0 回复次数:0 
请求高手帮忙![求助]

请教高手我做了网页上用按钮一点从数据库里取出数据画出饼图!但是图出来后按钮就消失了!我还想往里面添加一些超连接按钮!请高手帮忙指点不胜感激!!源程序的.cs文件如下.

using System ; using System . Collections ; using System . ComponentModel ; using System . Data ; using System . Drawing ; using System . Web ; //using System . Web .Drawing . Drawing2D; using System . Web . UI ; using System . Web . UI . WebControls ; using System . Web . UI . HtmlControls ; using System . Drawing . Imaging ; //下面程序中使用的ImageFormat类所在的命名空间 using System .Data.SqlClient ;

namespace huitu { /// <summary> /// WebForm2 的摘要说明。 /// </summary> public class WebForm2 : System.Web.UI.Page { protected System.Web.UI.WebControls.Label Label1; protected System.Web.UI.WebControls.Button Button1; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 }

#region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.Button1.Click += new System.EventHandler(this.Button1_Click); this.Load += new System.EventHandler(this.Page_Load);

} #endregion

private void Button1_Click(object sender, System.EventArgs e) { string connectString="server=localhost;database=jczx;uid=sa;pwd="; SqlConnection conn=new SqlConnection(connectString); SqlCommand command1=conn.CreateCommand(); SqlCommand command2=conn.CreateCommand(); SqlCommand command3=conn.CreateCommand(); SqlCommand command4=conn.CreateCommand(); command1.CommandText="select count(*) from tea2004 where zc='教授'"; command2.CommandText="select count(*) from tea2004 where zc='副教授'"; command3.CommandText="select count(*) from tea2004 where zc='讲师'"; command4.CommandText="select count(*) from tea2004 where zc='助教'"; conn.Open(); int jiaoshou=(int)command1.ExecuteScalar(); //Response.Write(jiaoshou.ToString()); //conn.Close(); //conn.Open(); int fujiaoshou=(int)command2.ExecuteScalar(); //Response.Write(fujiaoshou.ToString()); //conn.Close(); //conn.Open(); int jiangshi=(int)command3.ExecuteScalar(); //Response.Write(jiangshi.ToString()); //conn.Close(); //conn.Open(); int zhujiao=(int)command4.ExecuteScalar(); //Response.Write(zhujiao.ToString()); conn.Close(); float all=jiaoshou+fujiaoshou+jiangshi+zhujiao; //Response.Write(all.ToString()); float js=360*jiaoshou/all; //Response.Write(js.ToString()); //Response.Write(js.ToString()); float fjs=360*fujiaoshou/all; float jshi=360*jiangshi/all; float zj=360*zhujiao/all; Bitmap image=new Bitmap(520,450); Graphics g=Graphics.FromImage(image); g.Clear(Color.Snow); //画出大方框 g.DrawRectangle(Pens.Black,0,0,518,448); //画饼图 g.DrawPie(Pens.Red,45,45,350,350,0,js); g.FillPie(new SolidBrush(Color.Red),45,45,350,350,0,js); g.DrawPie(Pens.Blue,45,45,350,350,js,fjs); g.FillPie(new SolidBrush(Color.Blue),45,45,350,350,js,fjs); g.DrawPie(Pens.Yellow,45,45,350,350,js+fjs,jshi); g.FillPie(new SolidBrush(Color.Yellow),45,45,350,350,js+fjs,jshi); g.DrawPie(Pens.Green,45,45,350,350,js+fjs+jshi,zj); g.FillPie(new SolidBrush(Color.Green),45,45,350,350,js+fjs+jshi,zj); //话小方格并且用颜色填充 g.FillRectangle(new SolidBrush(Color.Red),410,30,40,20); g.DrawRectangle(Pens.Red,410,30,20,20); g.FillRectangle(new SolidBrush(Color.Blue),410,60,40,20); g.DrawRectangle(Pens.Blue,410,60,40,20); g.FillRectangle(new SolidBrush(Color.Yellow),410,90,40,20); g.DrawRectangle(Pens.Yellow,410,90,40,20); g.FillRectangle(new SolidBrush(Color.Green),410,120,40,20); g.DrawRectangle(Pens.Green,410,120,40,20); //在方格后面写字 g.DrawString("教授",new Font("黑体",13),Brushes.Black,new Point(455,30)); g.DrawString("副教授",new Font("黑体",13),Brushes.Black,new Point(455,60)); g.DrawString("讲师",new Font("黑体",13),Brushes.Black,new Point(455,90)); g.DrawString("助教",new Font("黑体",13),Brushes.Black,new Point(455,120)); image.Save(Response.OutputStream,ImageFormat.Jpeg); } } }

搜索更多相关主题的帖子: 请求 
2004-12-06 17:34
快速回复:请求高手帮忙![求助]
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023230 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved