需求开发一个小报表,显示最近五个月的summary的数量统计,报表会随月份的变化而变化,如下图。第一列[Department]固定,第二至第六列,也就是说Nov 2012 这列会在下月的时候消失,其后的列会向前移,最后一列Mar 2013 会变为Apr 2013。
下图中,最底一行是显示每一列的总数(除第一列外)。




上面全是html的设计,下面将是程序开发。
复制代码 代码如下:
//实例化对象,以及宣告一个DataTable对象objDt。 
PrintLog objPrintLog = new PrintLog(); 
DataTable objDt; 
//宣告5个变量,将用来存储那5个月份每个部分的数量 
decimal c1, c2, c3, c4, c5;
复制代码 代码如下:
 
protected void Page_Load(object sender, EventArgs e) 
{ 
if (!IsPostBack) 
{ 
Data_Binding(); 
} 
} 
private void Data_Binding() 
{ 
((IUserControlContainer)this.Master).ShowControl = true; 
CultureInfo oCultureInfo = new CultureInfo("en"); //设置好区域文化 
DateTime currentDateTime = DateTime.Now; //获取当前日期时间 
objPrintLog.Year = currentDateTime.Year; //获取年份赋值 
objPrintLog.Month = currentDateTime.Month;//获取月份赋值 
objPrintLog.Months = 5; //最近连续5个月份 
objDt = objPrintLog.GetSummaryReportByYearMonth(); 
this.RepeaterLFMS.DataSource = objDt; 
this.RepeaterLFMS.DataBind(); 
} 


 最后是Foot的代码:

新闻热点
疑难解答
图片精选