账表实现汇总表穿透到明细表

本文介绍了报表系统中实现精度控制的方法及SQL构建过程。通过设置ReportProperty.DecimalControlFieldList来控制汇总表与明细表的数值精度,并展示了如何根据过滤条件动态构建SQL查询语句。

汇总表的关键代码 :
public override void Initialize()
{
base.Initialize();
this.ReportProperty.ReportType = ReportType.REPORTTYPE_NORMAL;
this.ReportProperty.IsGroupSummary = true;
this.ReportProperty.DetailReportId = "PBNI_StoreAgeDetail";
#region 精度控制
this.ReportProperty.DecimalControlFieldList = ReportCommon.GetDecimalControlList("FAMOUNTDIGITS", decimalControl);
#endregion
}

明细表的关键代码:
public override void Initialize()
{
base.Initialize();
#region 精度控制
this.ReportProperty.DecimalControlFieldList = ReportCommon.GetDecimalControlList("FAMOUNTDIGITS", decimalControl);
#endregion
}
public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
{
base.BuilderReportSqlAndTempTable(filter, tableName);
tempTableName = tableName;
tempTables.Add(tableName);
using (new SessionScope())
{
StringBuilder sSQL = new StringBuilder();
StringBuilder sql = new StringBuilder();
StringBuilder where = new StringBuilder();
sql.Append(@"/dialect/ ");
bool srcFilter = false;
Dictionary<string, object> dctCurrRow = new Dictionary<string, object>();
if (!filter.IsRefresh && filter.CustomParams.Count() > 1 && filter.CustomParams.ContainsKey("ParentReportFilter"))
{
dctCurrRow = (Dictionary<string, object>)filter.CustomParams["ParentReportCurrentRow"];
srcFilter = true;
}
if (srcFilter)
{
if (dctCurrRow.ContainsKey("FBEGINDATE") && dctCurrRow["FBEGINDATE"] != null && !string.IsNullOrEmpty(dctCurrRow["FBEGINDATE"].ToString()))
{
where.AppendFormat(" and cardMsg.FOPENDATE>='{0}' ", dctCurrRow["FBEGINDATE"].ToString());
}
if (dctCurrRow.ContainsKey("FENDDATE") && dctCurrRow["FENDDATE"] != null && !string.IsNullOrEmpty(dctCurrRow["FENDDATE"].ToString()))
{
where.AppendFormat(" and cardMsg.FOPENDATE<'{0}' ", dctCurrRow["FENDDATE"].ToString());
}
if (dctCurrRow.ContainsKey("FCARDCLASS") && dctCurrRow["FCARDCLASS"] != null && !string.IsNullOrEmpty(dctCurrRow["FCARDCLASS"].ToString()))
{
where.AppendFormat(" and kll.FNAME='{0}' ", dctCurrRow["FCARDCLASS"].ToString());
}
if (dctCurrRow.ContainsKey("FCARDTYPE") && dctCurrRow["FCARDTYPE"] != null && !string.IsNullOrEmpty(dctCurrRow["FCARDTYPE"].ToString()))
{
where.AppendFormat(" and cypt.FDATAVALUE='{0}' ", dctCurrRow["FCARDTYPE"].ToString());
}
}
var baseObjs = DBUtils.ExecuteDynamicObject(this.Context, string.Format(sql.ToString(), where));
sSQL.AppendLine("select * ,2 FAMOUNTDIGITS,{0} into {1} from #temp ");
sSQL.AppendLine("drop table #temp ");
KSQL_SEQ = string.Format(KSQL_SEQ, " FCARDNUMBER asc ");
string SQL = string.Format(sSQL.ToString(), this.KSQL_SEQ, tableName);
DBUtils.Execute(this.Context, SQL.ToString());
}
}

转载于:https://blog.51cto.com/yataigp/2108720

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值