http://www.codeproject.com/aspnet/AntiAuto.asp
解决方案 »
- TextBox框控件如何数据传递到下一页?
- 问一个菜鸟问题,怎么不显示网站的默认页面的名称!
- 如何动态添加 Menu的一子项于 一个项中
- 请指点: 在windows下能否通过.net程序来获取linux下的用户列表,甚至通过自己写的windows程序界面增加修改linux的用户
- 求助:如何比较两个日期的大小??????
- 如何将从TEXTBOX中输入的文字(有回车)原样输出呢?
- 请问Property 过程有什么用啊 ????
- 请问这个站多少钱?
- 怎样改变webform的caption阿
- 请问怎样在DataList中实现象DataGrid那样的分页功能?
- 如何设定一个层的大小跟着屏幕变化而变化,我想无论如何变化均需减去一个固定值。
- 关于WEB用户控件
如果是要画一幅图片才会用到Drawing呀!
System.Drawing.Font fontLegend=new System.Drawing.Font("Verdana",11,FontStyle.Bold);
System.Drawing.Font fontTitle=new System.Drawing.Font("Verdana",9);
System.Drawing.Font fontHead=new System.Drawing.Font("Verdana",9,FontStyle.Bold);
int width=489;//白色背景宽
int height =264;//白色背景高
const int blankspace=16;
int titleHeight=fontLegend.Height+blankspace;
string ImgPath=Server.MapPath(".")+"\\AccountImage\\"+"test.gif";
Bitmap objbitmap=new Bitmap(width,height);
Graphics objgraphics=Graphics.FromImage(objbitmap);
objgraphics.FillRectangle(new SolidBrush(Color.White),0,0,width,height);
string title="Papers Table From "+StartDate+" To "+EndDate;
SolidBrush blackbrush=new SolidBrush(Color.Black);
StringFormat stringFormat=new StringFormat();
stringFormat.Alignment=StringAlignment.Center;
stringFormat.LineAlignment=StringAlignment.Center;
//Draw Grid
int xHeight=titleHeight+fontTitle.Height+10;
int xxHeight=fontTitle.Height+10;
Pen objPen=new Pen(Color.Black,1);
objgraphics.DrawString(title,fontLegend,blackbrush,new Rectangle(0,0,width,titleHeight),stringFormat);
objgraphics.DrawRectangle(objPen,5,titleHeight,width-10,height-titleHeight-6);
int i=0;
for(i=1;i<=8;i++)
{
objgraphics.DrawLine(objPen,5,xHeight,width-5,xHeight);
xHeight+=xxHeight;
}
int xwidth=width/3;
objgraphics.DrawLine(objPen,5+xwidth,titleHeight,5+xwidth,height-6);
objgraphics.DrawLine(objPen,5+xwidth*2,titleHeight,5+xwidth*2,height-6);
//Get Data From DataBase
string strConnection = "server="+ConfigurationSettings.AppSettings["ServerName"];
strConnection += ";uid="+ConfigurationSettings.AppSettings["UserName"];
strConnection += ";password="+ConfigurationSettings.AppSettings["Password"];
strConnection += ";initial catalog="+ConfigurationSettings.AppSettings["Database"];
SqlConnection MyConnection = new SqlConnection(strConnection);
string strCommand="select PaperState,count(distinct PID) as co from [tb_paper] where cast(UploadDate as datetime) between '"+StartDate+"' and '"+EndDate+"' Group by PaperState";
SqlCommand Comm=new SqlCommand(strCommand,MyConnection);
MyConnection.Open();
SqlDataReader dr=Comm.ExecuteReader();
string[] leftString=new string[7];
long[] Num=new long[7];
string[] Percent=new string[7];
i=0;
long Total=0;
while(dr.Read())
{
leftString[i]=GetState(dr["PaperState"].ToString());
Num[i]=long.Parse(dr["co"].ToString());
Total+=Num[i];
i++;
}
for(i=0;i<7;i++)
{
double tempPer=(double)Num[i]/(double)Total;
Percent[i]=tempPer.ToString("##.##%");
}
//Begin to Draw String
//Draw Table Head
string temp="Number";
objgraphics.DrawString(temp,fontHead,blackbrush,new Rectangle(5+xwidth,titleHeight,xwidth,xxHeight),stringFormat);
temp="Percent";
objgraphics.DrawString(temp,fontHead,blackbrush,new Rectangle(5+xwidth*2,titleHeight,xwidth,xxHeight),stringFormat);
//Draw Table Left
for(i=0;i<7;i++)
objgraphics.DrawString(leftString[i],fontTitle,blackbrush,new Rectangle(5,xxHeight*(i+1)+titleHeight,xwidth,xxHeight),stringFormat);
//Draw Number
for(i=0;i<7;i++)
objgraphics.DrawString(Num[i].ToString(),fontTitle,blackbrush,new Rectangle(5+xwidth,xxHeight*(i+1)+titleHeight,xwidth,xxHeight),stringFormat);
//Draw Percent
for(i=0;i<7;i++)
objgraphics.DrawString(Percent[i],fontTitle,blackbrush,new Rectangle(5+xwidth*2,xxHeight*(i+1)+titleHeight,xwidth,xxHeight),stringFormat);
//Draw Foot
temp="Total";
objgraphics.DrawString(temp,fontHead,blackbrush,new Rectangle(5,xxHeight*8+titleHeight,xwidth,xxHeight),stringFormat);
objgraphics.DrawString(Total.ToString(),fontHead,blackbrush,new Rectangle(5+xwidth,xxHeight*8+titleHeight,xwidth,xxHeight),stringFormat);
objgraphics.DrawString("100%",fontHead,blackbrush,new Rectangle(5+xwidth*2,xxHeight*8+titleHeight,xwidth,xxHeight),stringFormat);
//Save
objbitmap.Save(ImgPath,System.Drawing.Imaging.ImageFormat.Gif);
objgraphics.Dispose();
objbitmap.Dispose();
string ImgPath2="AccountImage/test.gif";
string ImgTag="<img src='"+ImgPath2+"'>";
ChartHolder.Controls.Add(new LiteralControl(ImgTag));
//