单据列表和编辑界面套打携带凭证号(以应收单为例)二开方案仅供参考
使用visual studio新建工程,并添加相关引用
新建类TestPrinter.cs,继承基类“AbstractBillPlugIn”,并重载OnPrepareNotePrintData方法。
using Kingdee.BOS.App.Data; using Kingdee.BOS.Core.Bill.PlugIn; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.Orm.Metadata.DataEntity; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace TestPrintPlugIn { public class TestPrinter : AbstractBillPlugIn { public override void OnPrepareNotePrintData(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.PreparePrintDataEventArgs e) { if (e.DataSourceId.Equals("FBillHead", StringComparison.OrdinalIgnoreCase)) { DynamicObject billObj = this.Model.DataObject; // 读取单据内码 long billId = Convert.ToInt64(billObj[0]); // 查询vh表获取单据对应凭证号 string sql = string.Format("SELECT VH.FID,VH.FVOUCHERGROUPNO FROM T_AR_RECEIVABLE_VH VH WHERE FID={0}", billId); DataSet dataset = DBUtils.ExecuteDataSet(this.Context, sql); Dictionary<string, string> myDictionary = new Dictionary<string, string>(); foreach (DataTable dtt in dataset.Tables) { for (int i = 0; i < dtt.Rows.Count; i++) { try { myDictionary.Add(dtt.Rows[i]["FID"].ToString(), dtt.Rows[i]["FVOUCHERGROUPNO"].ToString()); } catch (Exception ex) { //log } } } //注册临时字段 DynamicObjectType dot = e.DataObjects[0].DynamicObjectType; dot.RegisterSimpleProperty("FVOUCHERGROUPNO", typeof(object), attributes: new SimplePropertyAttribute() { Alias = "FVOUCHERGROUPNO" }); DynamicObject obj = new DynamicObject(dot); foreach (var p in e.DataObjects[0].DynamicObjectType.Properties) { obj[p] = e.DataObjects[0][p]; } //动态字段赋值 obj["FVOUCHERGROUPNO"] = myDictionary[billId.ToString()]; e.DataObjects[0] = obj; } base.OnPrepareNotePrintData(e); } } }
新建类TestPrinterList.cs,继承基类“ AbstractListPlugIn”,并重载OnPrepareNotePrintData方法。
using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace TestPrintPlugIn { public class TestPrinterList : AbstractListPlugIn { public override void OnPrepareNotePrintData(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.PreparePrintDataEventArgs e) { base.OnPrepareNotePrintData(e); if (e.DataSourceId.Equals("FBillHead", StringComparison.OrdinalIgnoreCase)) { if (e.DataObjects != null) { List<long> lstId = new List<long>(); foreach (var data in e.DataObjects) { lstId.Add(Convert.ToInt32(data["FID"])); } //查询vh表获取单据对应凭证号 string sql = string.Format("SELECT VH.FID,VH.FVOUCHERGROUPNO FROM T_AR_RECEIVABLE_VH VH WHERE FID IN ({0})", string.Join(",",lstId)); DataSet dataset = DBUtils.ExecuteDataSet(this.Context, sql); Dictionary<string, string> myDictionary = new Dictionary<string, string>(); foreach (DataTable dtt in dataset.Tables) { for (int i = 0; i < dtt.Rows.Count; i++) { try { myDictionary.Add(dtt.Rows[i]["FID"].ToString(), dtt.Rows[i]["FVOUCHERGROUPNO"].ToString()); } catch (Exception ex) { //log } } } //注册临时字段 DynamicObjectType dot = e.DataObjects[0].DynamicObjectType; dot.RegisterSimpleProperty("FVOUCHERGROUPNO", typeof(object), attributes: new SimplePropertyAttribute() { Alias = "FVOUCHERGROUPNO" }); for (int i = 0; i < e.DataObjects.Length; i++) { DynamicObject obj = new DynamicObject(dot); foreach (var p in dot.Properties) { obj[p] = e.DataObjects[i][p]; } //动态字段赋值 obj["FVOUCHERGROUPNO"] = myDictionary[Convert.ToString(e.DataObjects[i]["FID"])]; e.DataObjects[i] = obj; } } } } } }
插件开发完毕后,编译工程生成成*.dll文件。
将步骤四里面编译生成的dll文件放到服务器Cloud站点的website/bin目录下面,并重启IIS。
在BOS IDE里面扩展应收单,给应收单注册套打插件。
套打设计器里面绑定动态字段“FVOUCHERGROUPNO”
登录 Cloud,打开应收单,打印预览
单据列表和编辑界面套打携带凭证号(以应收单为例)二开方案仅供参考
使用visual studio新建工程,并添加相关引用新建类TestPrinter.cs,继承基类“AbstractBillPlugIn”,并重载OnPrepareNotePrintData方法。u...
点击下载文档
本文2024-09-23 01:39:05发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-147281.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章