多分录下推插件模板,金蝶云星空企业版
亮点:只需配置好参数,代码无需改动
using Kingdee.BOS.Core.Bill.PlugIn; using Kingdee.BOS.Core.Metadata; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Util; using System; using System.ComponentModel; using System.Data; namespace CQXR.DDL.K3.BOS.BusinessPlugIn.BillPlugIn { [HotUpdate] [Description("xx模块--下推xxx,携带xxx,yyy")] public class XxxxYyyy : AbstractBillPlugIn { //上下游单据 参数 public string ydbh = "F_QGXM_YDBH";//源单编号 //分录表名 public string[] tn = { "F_QGXM_Entity_8DBG", "F_QGXM_YZCS", "F_QGXM_8DBGCXZG" }; //分录标识 public string[] id = { "F_QGXM_Entity_8DBG_yrr", "F_QGXM_YZCS_tqn", "F_QGXM_8DBGCXZG_795" }; // 变更分录 字段 标识 public string[,] field = { {"F_QGXM_Base_re5_h1g","F_QGXM_DHHM_zc5","F_QGXM_GW_imu","F_QGXM_Text_ca9_1xj"}, {"F_QGXM_Text_795_c1c", "F_QGXM_Base_qku_vb1","F_QGXM_Date_fg2_emq","F_QGXM_Text_w5c_xwf"}, {"F_QGXM_Text_795_vb1_qku","F_QGXM_Base_qku_c1c_9uj","F_QGXM_WCRQ_s58","F_QGXM_Text_yrr_bgx" } }; // ORM实体名 字段 如果字段属性=基础资料 后面要加 _Id public string[,] orm = { { "F_QGXM_BASE_RE5","F_QGXM_DHHM","F_QGXM_GW","F_QGXM_TEXT_CA9" }, { "F_QGXM_TEXT_795","F_QGXM_BASE_QKU","F_QGXM_DATE_FG2","F_QGXM_TEXT_W5C"}, {"F_QGXM_TEXT_795","F_QGXM_BASE_QKU","F_QGXM_WCRQ","F_QGXM_TEXT_YRR" } }; /// <summary> /// 获取SQL语句的字段拼接字串 /// </summary> /// <param name="preword"></param> /// <param name="m"></param> /// <param name="orms"></param> /// <returns></returns> public string getFields(string preword, string[,] orms, int m) { string fields = ""; for (int i = 0; i < orms.GetLength(1); i++) { fields += preword + orms[m,i]; if (i < orms.GetLength(1) - 1) { fields += ","; } } return fields; } /// <summary> /// 下推代码 /// </summary> /// <param name="e"></param> public override void AfterBindData(EventArgs e) { base.AfterBindData(e); if (this.View.OpenParameter.Status.Equals(OperationStatus.ADDNEW)) { string billno = Convert.ToString(this.View.Model.GetValue(ydbh)); if (billno != "") { for(int m = 0; m < tn.Length; m++) { //查询分录数据 var sql = $@"/*dialect*/ select {getFields("a.",orm, m)} from {tn[m]} a inner join t_8dreport b on a.fid=b.fid where b.fbillno='{billno}'"; DataTable ds = DBServiceHelper.ExecuteDataSet(this.Context, sql).Tables[0]; //string aid = id;//单据体标识 if (ds != null && ds.Rows.Count > 0) { this.View.Model.DeleteEntryData(id[m]); //循环读取每一行数据 for (int i = 0; i < ds.Rows.Count; i++) { this.View.Model.CreateNewEntryRow(id[m]); for(int n = 0; n < orm.GetLength(1); n++) { //分录赋值 this.View.Model.SetValue(field[m,n], ds.Rows[i][orm[m,n]].ToString(), i); } } } //刷新单据体 this.View.UpdateView(id[m]); } } } } } }
标签:插件,分录,下推,QGXM,using,View,public,string From: https://www.cnblogs.com/wishit/p/18419532