温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:我的小书坊源码(三层实现)
当前文件:
MyBookShop/BookStatistics.aspx.cs,打开代码结构图
MyBookShop/BookStatistics.aspx.cs,打开代码结构图1using System; 2
using System.Collections; 3
using System.ComponentModel; 4
using System.Data; 5
using System.Drawing; 6
using System.Web; 7
using System.Web.SessionState; 8
using System.Web.UI; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.HtmlControls; 11
12
using MyBookShop.BusinessLogicLayer; 13
14
namespace MyBookShop.Web 15
{ 16
/// <summary> 17
/// BookStatistics 的摘要说明。 18
/// </summary> 19
public partial class BookStatistics : System.Web.UI.Page 20
{ 21
22
protected void Page_Load(object sender, System.EventArgs e) 23
{ 24
if(!IsPostBack) 25
DrawChartByCategory(); 26
} 27
28
/// <summary> 29
/// 按照图书类别统计 30
/// </summary> 31
private void DrawChartByCategory() 32
{ 33
DataTable dt=Book.GetSaleCountByCategory(); 34
string title="图书销售量统计"; //标题 35
string subTitle="基于图书种类"; //副标题 36
string targetFile = Server.MapPath(".\\Images\\") + "Category.gif"; //图象文件 37
Chart.DrawPie(title,subTitle,300,300,dt,targetFile,"CategoryName","SaleCount"); 38
39
Image.ImageUrl=targetFile; 40
} 41
/// <summary> 42
/// 按照出版社统计 43
/// </summary> 44
//该源码下载自www.51aspx.com(51-aspx.com) 45
private void DrawChartByPublisher() 46
{ 47
DataTable dt=Book.GetSaleCountByPublisher(); 48
string title="图书销售量统计"; //标题 49
string subTitle="基于出版社"; //副标题 50
string targetFile = Server.MapPath(".") + "\\Images\\Publiser.gif"; //图象文件 51
52
Chart.DrawPie(title,subTitle,300,300,dt,targetFile,"Publisher","SaleCount"); 53
54
Image.ImageUrl=targetFile; 55
} 56
/// <summary> 57
/// 按照价格类别统计 58
/// </summary> 59
private void DrawChartByPrice() 60
{ 61
DataTable dt=Book.GetSaleCountByPrice(); 62
string title="图书销售量统计"; //标题 63
string subTitle="基于图书价格"; //副标题 64
65
string targetFile = HttpContext.Current.Server.MapPath(".\\Images\\") + "Price.gif"; //图象文件 66
Chart.DrawPie(title,subTitle,300,300,dt,targetFile,"PriceGrade","SaleCount"); 67
68
Image.ImageUrl=targetFile; 69
} 70
/// <summary> 71
/// 下拉框选择事件 72
/// </summary> 73
/// <param name="sender"></param> 74
/// <param name="e"></param> 75
protected void DropDownListType_SelectedIndexChanged(object sender, System.EventArgs e) 76
{ 77
switch(DropDownListType.SelectedValue) 78
{ 79
case "图书类别": 80
DrawChartByCategory(); 81
break; 82
case "出版社": 83
DrawChartByPublisher(); 84
break; 85
case "价格": 86
DrawChartByPrice(); 87
break; 88
89
} 90
} 91
} 92
} 93





}