32.4、动态表单插件,打开动态表单,值传递,给单据体赋值,代码原创
27人赞赏了该文章
2.1万次浏览
编辑于2021年06月24日 18:36:55
业务场景:打开销售订单, 点击按钮,弹出动态表单(下游的销售出库单),类似单据体,业务查询,历史价格功能;
续
1、打开VS,添加一个类库
2、修改类名称为DyFormOutBill
具体可以参考31.2,1-5步
3、添加public
public class DyFormOutBill:AbstractDynamicFormPlugIn { }
4、执行sql
//where FSOORDERNO='{0}' string sql = string.Format(@"/*dialect*/select t1.FID,t2.FBILLNO,t3.FNUMBER,t4.FNAME,t1.FREALQTY,FSOORDERNO from T_SAL_OUTSTOCKENTRY t1 inner join T_SAL_OUTSTOCK t2 on t1.FID=t2.FID inner join T_SAL_OUTSTOCKENTRY_R t5 on t1.FENTRYID=t5.FENTRYID left join T_BD_MATERIAL t3 on t1.FMATERIALID=t3.FMATERIALID left join T_BD_MATERIAL_L t4 on t1.FMATERIALID=t4.FMATERIALID and t4.FLOCALEID=2052 where FSOORDERNO='{0}'" , FBillNo);
5、
//给单据体赋值.构造动态表单 //定义一个单据体,获取动态表单F_YDIE_Entity Entity entity = this.View.BillBusinessInfo.GetEntity("F_YDIE_Entity");
//给单据体赋值.构造动态表单 for(int i=0; i<dt.Rows.Count;i++) { //每一行的值定义成 DynamicObject类型 DynamicObject row = new DynamicObject(entity.DynamicObjectType); entity.SeqDynamicProperty.SetValue(row, i + 1); //第i行 row["FOutBillNo"] = dt.Rows[i]["FBILLNO"].ToString(); row["FMaterailNo"] = dt.Rows[i]["FNUMBER"].ToString(); row["FMaterailName"] = dt.Rows[i]["FNAME"].ToString(); row["FQTY"] = dt.Rows[i]["FREALQTY"].ToString(); rows.Add(row); }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ComponentModel; //动态表单 using Kingdee.BOS.Core.DynamicForm.PlugIn; //执行sql using Kingdee.BOS.App.Data; //单据体 using Kingdee.BOS.Core.Metadata.EntityElement; using System.Data; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.Core.Bill; using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Core.Metadata; namespace Kingdee.Bos.Project.DyForm { [Description("动态表单并赋值")] [Kingdee.BOS.Util.HotUpdate] public class DyFormOutBill:AbstractDynamicFormPlugIn { //接收传回来的数据 string FBillNo; DataTable dt; public override void OnLoad(EventArgs e) {//OnLoad加载事件 base.OnLoad(e); //接收传回来的数据 FBillNo = this.View.OpenParameter.GetCustomParameter("FBillNo").ToString(); //执行sql //where FSOORDERNO='{0}' string sql = string.Format(@"/*dialect*/select t1.FID,t2.FBILLNO,t3.FNUMBER,t4.FNAME,t1.FREALQTY,FSOORDERNO from T_SAL_OUTSTOCKENTRY t1 inner join T_SAL_OUTSTOCK t2 on t1.FID=t2.FID inner join T_SAL_OUTSTOCKENTRY_R t5 on t1.FENTRYID=t5.FENTRYID left join T_BD_MATERIAL t3 on t1.FMATERIALID=t3.FMATERIALID left join T_BD_MATERIAL_L t4 on t1.FMATERIALID=t4.FMATERIALID and t4.FLOCALEID=2052 where FSOORDERNO='{0}'" , FBillNo); dt = DBUtils.ExecuteDataSet(this.Context, sql).Tables[0]; //大于0,说明取到数了 if(dt.Rows.Count >0) { //给单据体赋值.构造动态表单 //定义一个单据体,获取动态表单F_YDIE_Entity Entity entity = this.View.BillBusinessInfo.GetEntity("F_YDIE_Entity"); //转换成行 DynamicObjectCollection rows = this.Model.GetEntityDataObject(entity); // 把加载的数据包,加入到单据体行集合中 // 示例代码,创建一个空的数据包,仅用来演示如何向单据体集合添加新行 //给单据体赋值.构造动态表单 for(int i=0; i<dt.Rows.Count;i++) { //每一行的值定义成 DynamicObject类型 DynamicObject row = new DynamicObject(entity.DynamicObjectType); entity.SeqDynamicProperty.SetValue(row, i + 1); //第i行 row["FOutBillNo"] = dt.Rows[i]["FBILLNO"].ToString(); row["FMaterailNo"] = dt.Rows[i]["FNUMBER"].ToString(); row["FMaterailName"] = dt.Rows[i]["FNAME"].ToString(); row["FQTY"] = dt.Rows[i]["FREALQTY"].ToString(); rows.Add(row); } } } } }
6、最终效果,打开销售订单,点按钮,查看销售出库单
视频下载链接:
链接:https://pan.baidu.com/s/15XbedFRIaA20XY-Q10Y1rA
提取码:KISS
总目录链接
https://vip.kingdee.com/article/64993872014591232
Kingdee.Bos.Project.DyForm.zip(18.93KB)
赞 27
27人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!