分页报表首先需要实现的方法就是GetList,这个方法用来获得分页的条件。
其他的就和其他报表类似了。[code]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.BOS.Core.Report.PlugIn;
using Kingdee.BOS.Core.Report;
using System.Data;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Contracts.Report;
using Kingdee.BOS.Core.CommonFilter;
using Kingdee.BOS.Util;
namespace Kingdee.BOS.Demo.Report
{
public class DemoMoveReport : SysReportBaseService
{
public override void Initialize()
{
// 标记报表类型
this.ReportProperty.ReportType = Core.Report.ReportType.REPORTTYPE_MOVE;
this.ReportProperty.IsGroupSummary = true;
}
///
/// 构建分页报表每个报表的临时表
/// 首先从分页依据中拿到本次分页的条件,就是当前页报表的条件:this.CacheDataList[filter.CurrentPosition]
/// 然后把条件拼装到SQL中,例如b.FLocaleId= dr["FLocaleId"] 语言id=当前报表的语言id
///
///
///
public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
{
DataRow dr = this.CacheDataList[filter.CurrentPosition];
string sSQL = @"select a.fdeptid as FID, fname,ffullname as fdesc,FLocaleId,'BD_DEPARTMENT' as fformid, {0} into {1} from T_BD_DEPARTMENT a
inner join T_BD_DEPARTMENT_l b on a.fdeptid=b.fdeptid where b.FLocaleId=" + dr["FLocaleId"].ToString();
KSQL_SEQ = string.Format(KSQL_SEQ, "b.FLocaleId");
sSQL = string.Format(sSQL, this.KSQL_SEQ, tableName);
DBUtils.Execute(this.Context, sSQL);
}
public override List
{
List
Core.Report.SummaryField fs = new Core.Report.SummaryField("FLocaleId", Core.Enums.BOSEnums.Enu_SummaryType.SUM);
fls.Add(fs);
return fls;
}
///
/// 分页报表必须实现的方法,此方法用于为报表提供分页依据。
/// 比如以下示例:分别按语言来对部门分类,也就是说每种语言一个报表,中文的是一个报表、英文的一个报表,繁体的一个
///
///
///
public override DataTable GetList(IRptParams filter)
{
DataTable dt;
string sSQL = "select FLocaleId from T_BD_DEPARTMENT_L group by FLocaleId";
dt = DBUtils.ExecuteDataSet(this.Context, sSQL).Tables[0];
return dt;
}
public override ReportTitles GetReportTitles(IRptParams filter)
{
ReportTitles titles = new ReportTitles();
if (CacheDataList == null)
{
DataTable dt = GetList(filter);
if (dt != null && dt.Rows.Count > 0)
{
//titles.AddTitle("FCondition", dt.Rows[0]["flocaleid"].ToString());
return titles;
}
return null;
}
DataRow dr = this.CacheDataList[filter.CurrentPosition];
//titles.AddTitle("FCondition", dr["flocaleid"].ToString());
return titles;
}
public override ReportHeader GetReportHeaders(IRptParams filter)
{
// TODO:
ReportHeader header = new ReportHeader();
header.AddChild("FID", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("编码","002460030014674",Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID));
header.AddChild("fname", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("全名","002460030014677",Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID));
header.AddChild("fdesc", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("别名","002460030014680",Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID));
header.AddChild("FLocaleId", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("类别","002460030014683",Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID),SqlStorageType.SqlInt);
return header;
}
}
}
[/code]
推荐阅读