Asp.net源码专业站
首页->聊天计数->简单网站计数器统(单用户)源码>>StatByMonth.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:简单网站计数器统(单用户)源码
当前文件:文件类型 SimpleWebStat/StatByMonth.aspx.cs[1K,2009-6-12 11:54:10]打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using System.Data.SqlClient; 12 13public partial class StatByMonth : System.Web.UI.Page 14{ 15 protected int total = 0; 16 protected void Page_Load(object sender, EventArgs e) 17 { 18 if(!Page.IsPostBack) 19 { ///绑定控件的数据 20 string dtString = YearList.SelectedItem.Text + "-1-1"; 21 BindVisitData(DateTime.Parse(dtString)); 22 } 23 } 24 private void BindVisitData(DateTime dDate) 25 { ///按照年份从数据库获取访问日志 26 IVisitor visit = new Visitor(); 27 SqlDataReader dr = visit.GetVisitorsByYear(dDate); 28 ///创建数组 29 ArrayList statList = new ArrayList(); 30 DateTime dt = dDate; 31 ///添加12个月 32 for(int i = 0; i < 12; i++) 33 { 34 VisitStat stat = new VisitStat(); 35 stat.Name = (i + 1).ToString() + ""; 36 stat.Number = 0; 37 stat.Percent = 0; 38 statList.Add(stat); 39 } 40 ///读取数据 41 //int total = 0; 42 while(dr.Read()) 43 { ///统计每月的访问量 44 dt = DateTime.Parse(dr["VisitDate"].ToString()); 45 ((VisitStat)statList[dt.Month - 1]).Number++; 46 total++; 47 } 48 dr.Close(); 49 if(total > 0) 50 { 51 dt = dDate; 52 for(int i = 0; i < 12; i++) 53 { ///计算每月访问量的百分比 54 ((VisitStat)statList[i]).Percent = (int)((double)((VisitStat)statList[i]).Number * 100) / total; 55 } 56 } 57 ///绑定数据 58 StatView.DataSource = statList; 59 StatView.DataBind(); 60 } 61 62 protected void YearList_SelectedIndexChanged(object sender,EventArgs e) 63 { ///重新绑定控件的数据 64 string dtString = YearList.SelectedItem.Text + "-1-1"; 65 BindVisitData(DateTime.Parse(dtString)); 66 } 67} 68
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:简单网站计数器统(单用户)源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146