需求開發一個小報表,顯示最近五個月的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的代碼:
新聞熱點
疑難解答
圖片精選