简单账表通过按钮快捷查询原创
11人赞赏了该文章
3,258次浏览
编辑于2021年08月22日 13:01:20
实现功能:根据单据头字段创建日期和物料编码的值直接查询账表数据,其中单据的创建日期小于字段创建日期的值,单据物料等于字段物料编码的值。
1. 创建直简单账表,命名为“单据A明细报表”,使用分隔容器分隔,单据头增加日期,基础资料字段和按钮字段,分别命名为创建日期,物料编码,和查询。并且创建日期和物料编码需要勾选上即时触发值更新,如下图:
2. 增加过滤方案“单据A简单报表过滤框“,在快捷过滤中增加日期和基础资料字段,分别命名为创建日期和物料编码,如下图:
3. 编写账表取数插件并注册,代码如下:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ComponentModel; using System.Data; using Kingdee.BOS.Contracts.Report; using Kingdee.BOS.Core.Report; using Kingdee.BOS.App.Data; using Kingdee.BOS.Util; using Kingdee.BOS.Orm.DataEntity; namespace Kingdee.BOS.TestPlugIn.BillFormPlugin { [HotUpdate] [Description("单据A分页帐表")] public class BillAReportPlugIn : SysReportBaseService { /// <summary> /// 得到汇总字段信息 /// </summary> /// <param name="filter"></param> /// <returns></returns> public override List<SummaryField> GetSummaryColumnInfo(IRptParams filter) { base.GetSummaryColumnInfo(filter); List<SummaryField> lstfield = new List<SummaryField>(); SummaryField sField = new SummaryField("F_KKK_Amount", Core.Enums.BOSEnums.Enu_SummaryType.SUM); lstfield.Add(sField); return lstfield; } /// <summary> /// 通过存储过程把数据灌入临时表中 /// </summary> /// <param name="filter"></param> /// <param name="tableName"></param> public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName) { DynamicObject dyFilter = filter.FilterParameter.CustomFilter;//快捷页签过滤条件 StringBuilder strOrgIds = new StringBuilder(); //组织内码集合 var createData = ObjectUtils.Object2String(dyFilter["FCreateDate1"]); var mNumberObj = dyFilter["FMNumber"] as DynamicObject; var mNumber = ObjectUtils.Object2String(mNumberObj["Number"]); var sql = string.Format(@"select tb.*,ROW_NUMBER() OVER( ORDER BY tb.FCREATEDATE) FIDENTITYID into {0} FROM( select t0.FBILLNO,t0.FCREATEDATE,t0.FBILLSTATUS,t3.FName,t2.FNUMBER,t1.F_KKK_BASEQTY,t1.F_KKK_PRICE,t1.F_KKK_AMOUNT from KKK_t_Cust100041 t0 join KKK_t_Cust_Entry100204 t1 on t1.FID = t0.FID left join T_BD_MATERIAL t2 on t2.FMATERIALID = t1.F_KKK_Material left join T_BD_MATERIAL_L t3 on t3.FMATERIALID = t1.F_KKK_Material and t3.FLocaleId=2052 where t0.FCreateDate <='{1}' and t2.FNumber ='{2}') tb", tableName, createData, mNumber); DBUtils.Execute(this.Context, sql); } /// <summary> /// 得到页面列表显示列头,动态增加列 /// </summary> /// <param name="filter"></param> /// <returns></returns> public override ReportHeader GetReportHeaders(IRptParams filter) { base.GetReportHeaders(filter); ReportHeader rHeader = new ReportHeader(); rHeader.AddChild("FBillNo", new LocaleValue("单据编号")); rHeader.AddChild("FCREATEDATE", new LocaleValue("创建日期")); rHeader.AddChild("FName", new LocaleValue("物料名称")); rHeader.AddChild("FNUMBER", new LocaleValue("物料编码")); rHeader.AddChild("F_KKK_BASEQTY", new LocaleValue("数量")); rHeader.AddChild("F_KKK_PRICE", new LocaleValue("单价")); rHeader.AddChild("F_KKK_AMOUNT", new LocaleValue("金额")); return rHeader; } //这个跟下面表单插件中的赋值效果是一样的 public override ReportTitles GetReportTitles(IRptParams filter) { var rTile = new ReportTitles(); var customFilterObj = filter.FilterParameter.CustomFilter; var CreateTime = ObjectUtils.Object2String(customFilterObj["FCreateDate1"]); var mObj =customFilterObj["FMNumber"] as DynamicObject; var mId = ObjectUtils.Object2String(mObj["Number"]); rTile.AddTitle("FCreateDate1", CreateTime); rTile.AddTitle("FMNumber", mId); return rTile; } } }
4. 编写表单插件BillASimpleReportFormPlugIn并注册,代码如下:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using Kingdee.BOS.Core; using Kingdee.BOS.Util; using Kingdee.BOS.Core.Report.PlugIn; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Model.Report; using Kingdee.BOS.Web.Report.SQLReport; using Kingdee.BOS.Core.Metadata.FormElement; using Kingdee.BOS.Orm.DataEntity; namespace Kingdee.BOS.TestPlugIn.BillFormPlugin { [HotUpdate] [Description("单据简单明细帐表表单插件")] public class BillASimpleReportFormPlugIn : AbstractSysReportPlugIn { /// <summary> /// 按钮点击事件 /// </summary> /// <param name="e"></param> public override void ButtonClick(ButtonClickEventArgs e) { if (e.Key.EqualsIgnoreCase("FBtnSearch"))//查询 { base.ButtonClick(e); var reportModel = this.Model as SysReportModel; //简单帐表对应的Model var mNumberObj = reportModel.DataObject["FMNumber"] as DynamicObject; //给过滤方案创建日期赋值 reportModel.FilterParameter.CustomFilter["FCreateDate1"] = reportModel.DataObject["FCreateDate1"]; //给过滤方案物料编码赋值 reportModel.FilterParameter.CustomFilter["FMNumber"] = mNumberObj; reportModel.FilterParameter.CustomFilter["FMNumber_Id"] = mNumberObj[0]; this.View.Refresh(); } } /// <summary> /// 数据绑定后事件 /// </summary> /// <param name="e"></param> public override void AfterBindData(EventArgs e) { var reportModel = this.Model as SysReportModel; var customFilterObj = reportModel.FilterParameter.CustomFilter; var CreateTime = ObjectUtils.Object2String(customFilterObj["FCreateDate1"]); this.Model.SetValue("FCreateDate1", CreateTime); var mId = ObjectUtils.Object2String(customFilterObj["FMNumber_Id"]); this.Model.SetValue("FMNumber", mId); this.View.UpdateView("FCreateDate1"); this.View.UpdateView("FMNumber"); var titles = reportModel.ReportTitles; if (titles != null) { foreach (var title in titles) { var ctl = reportView.TryGetControl(title.TitleKey); if (ctl != null) { ctl.Enabled = true; } } } } } }
5. 运行效果,如下图:
赞 11
11人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读