自己做的简单账表报错:CommandText 属性尚未初始化
金蝶云社区-1969523032
1969523032
0人赞赏了该文章 1,575次浏览 未经作者许可,禁止转载编辑于2016年02月23日 21:07:25

自己做的简单账表,报错为:CommandText 属性尚未初始化,大神帮忙看看是为啥
源代码如下:
public override void Initialize()
{
this.ReportProperty.IsGroupSummary = true;
this.ReportProperty.BillKeyFieldName = "FID";
//base.Initialize();
}

public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
{
string sSQL = string.Empty;
List lstSql = new List();
StringBuilder sqlbuilder = new StringBuilder();
sqlbuilder.AppendLine("select ROW_NUMBER() OVER (ORDER BY t1.名称 ASC) AS 序号, t1.FNUMBER as 商品编码, t1.名称, t1.规格型号, t1.基本计量单位, t1.周转期, CEILING(t1.箱装数) 箱装数,t1.在途量,t1.已占用量,t1.日均销量,t1.现有库存量,case when t1.订货量 <= 0 then null else CEILING(t1.订货量/t1.箱装数) * CEILING(t1.箱装数) end '订货量(散)', case when t1.订货量 <= 0 then null else CEILING(t1.订货量/t1.箱装数) end '订货量(箱)' into {0} from ");
sqlbuilder.AppendLine("(select a1.FNUMBER,a7.FNAME as 名称,a7.FSPECIFICATION as 规格型号,a8.FNAME 基本计量单位,a2.未出数量 as 已占用量,a3.日均销量,a4.未入库*(case when a1.F_BOS_WLZXS = 0 OR a1.F_BOS_WLZXS IS null then 1 else a1.F_BOS_WLZXS end) as 在途量,a5.库存量主单位 as 现有库存量,a6.FSAFESTOCK 安全库存,(case when a1.F_BOS_WLZXS IS null or a1.F_BOS_WLZXS = '0' then 1 else a1.F_BOS_WLZXS end) as '箱装数',a1.F_JJ_ZZTS as 周转期,((case when (a3.日均销量 * a1.F_JJ_ZZTS) IS null then '0' else a3.日均销量 * a1.F_JJ_ZZTS end) - case when (a4.未入库*(case when a1.F_BOS_WLZXS =0 OR a1.F_BOS_WLZXS IS null then 1 else a1.F_BOS_WLZXS end)) IS null then '0' else (a4.未入库*(case when a1.F_BOS_WLZXS =0 OR a1.F_BOS_WLZXS IS null then 1 else a1.F_BOS_WLZXS end)) end - case when a5.库存量主单位 IS null then '0' else a5.库存量主单位 end + case when a2.未出数量 IS null then '0' else a2.未出数量 end + case when a6.FSAFESTOCK IS null then '0' else a6.FSAFESTOCK end) as '订货量' from T_BD_MATERIAL a1 ");
sqlbuilder.AppendLine("left join (select a1.FMATERIALID,sum(a2.FBASEREMAINOUTQTY) as 未出数量 from T_SAL_ORDERENTRY a1 left join T_SAL_ORDERENTRY_R a2 on a1.FENTRYID=a2.FENTRYID group by a1.FMaterialId) a2 on a1.FMATERIALID=a2.FMATERIALID left join (select a1.FMaterialID,sum(a1.FBASEUNITQTY)/30 as '日均销量' from T_SAL_OUTSTOCK t1 left join T_SAL_OUTSTOCKENTRY a1 on t1.FID=a1.FID where t1.FDATE (getdate()-30) and t1.FDOCUMENTSTATUS='C' group by a1.FMaterialID ) a3 on a1.FMATERIALID=a3.FMATERIALID ");
sqlbuilder.AppendLine("left join ( select a1.FMATERIALID,sum(a2.FREMAINSTOCKINQTY) as 未入库 from t_PUR_POOrder t1 left join t_PUR_POOrderEntry a1 on t1.FID=a1.FID left join t_PUR_POOrderEntry_R a2 on a1.FENTRYID=a2.FENTRYID group by a1.FMATERIALID ) a4 on a1.FMATERIALID=a4.FMATERIALID left join ( select FMATERIALID ,sum(FBASEQTY) 库存量主单位 from T_STK_INVENTORY where fstockid='100241' group by FMATERIALID ) a5 on a1.FMATERIALID=a5.FMATERIALID left join t_BD_MaterialStock a6 on a1.FMATERIALID=a6.FMATERIALID left join T_BD_MATERIAL_L a7 on a1.FMATERIALID=a7.FMATERIALID left join (select a1.FMATERIALID,a1.FBASEUNITID,a3.FNAME from t_BD_MaterialBase a1 left join T_BD_UNIT a2 on a1.FBASEUNITID=a2.FMASTERID left join T_BD_UNIT_L a3 on a2.FUNITID=a3.FUNITID ) a8 on a1.FMATERIALID=a8.FMATERIALID where a1.F_JJ_SSYWLX='5691a6b908c03d' and a1.FDOCUMENTSTATUS='C' and a1.FFORBIDSTATUS='A' ) t1 ");
DBUtils.Execute(this.Context, sSQL);
}
public override ReportTitles GetReportTitles(IRptParams filter)
{
ReportTitles titles = new ReportTitles();
titles.AddTitle("FNUMBER", "商品编码");
//titles.AddTitle("FLabel", "66666");
return titles;
}
///


/// 构建动态列
///

///
///
public override ReportHeader GetReportHeaders(IRptParams filter)
{
ReportHeader header = new ReportHeader();
header.AddChild("FNUMBER", new LocaleValue("商品编码", this.Context.UserLocale.LCID));
//header.AddChild("FNAME", new LocaleValue("名称", this.Context.UserLocale.LCID));
//header.AddChild("FCREATEDATE", new LocaleValue("创建日期", this.Context.UserLocale.LCID));
//header.AddChild("FDESCRIPTION", new LocaleValue("描述", this.Context.UserLocale.LCID));
//header.AddChild("FMATERIALID", new LocaleValue("ID", this.Context.UserLocale.LCID));
return header;
}

调试时发现报错的代码为:
“DBUtils.Execute(this.Context, sSQL);”
这一行