账表开发-直接sql账表中打开直接sql账表原创
20人赞赏了该文章
5,155次浏览
编辑于2022年01月19日 09:58:37
示例说明:
在直接sql账表aa中双击行弹出直接sql账表cccc
把双击行的创建时间传入到直接sql账表cccc中
直接sql账表cccc,取到传入的条件,对数据进行过滤,显示创建时间大于条件的数据
在直接sql账表aa,表单插件代码:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using System.Reflection; using System.Data; using Kingdee.BOS.Util; using Kingdee.BOS.Core.Report.PlugIn; using Kingdee.BOS.Core.Report.PlugIn.Args; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Model.Report; using Kingdee.BOS.Web.Report.SQLReport; using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Core.Report; namespace Kingdee.BOS.TestPlugIn.BillFormPlugin { [HotUpdate] [Description("在直接sql账表aa表单插件")] public class BillASqlReportPlugIn : AbstractSysReportPlugIn { /// <summary> /// 帐表行双击事件 /// </summary> /// <param name="e"></param> public override void EntityRowDoubleClick(EntityRowClickEventArgs e) { base.EntityRowDoubleClick(e); var columnName = "创建时间"; //列名创建时间 var reportModel = this.Model as SQLReportModel; var reportView = this.View as SQLReportView; var columnValue = reportView.GetCurrentRowValue(columnName); //得到当前行对应的列值 if (!columnValue.IsNullOrEmptyOrWhiteSpace()) { //直接sql帐表显示参数 SQLReportShowParameter sqlParameter = new SQLReportShowParameter(); sqlParameter.FormId = "k0da374d0ff3243ea91325edc1013e223"; //这个没有用,直接sql帐表不会自动加上,只要在列表过滤中有用 // sqlParameter.ReportFilterParameter.Filter = columnValue; sqlParameter.CustomParams.Add("SqlFilter", columnValue); sqlParameter.OpenStyle.ShowType = ShowType.Modal; this.View.ShowForm(sqlParameter); } } /// <summary> /// 得到某行列的值,或者通过此方法得到当前行对应的列值 /// </summary> private string GetColumnValue(SQLReportView view, string columnName, int rowIndex) { var result = string.Empty; var currentPageDataField= typeof(SQLReportView).GetField("currentPageData", BindingFlags.NonPublic | BindingFlags.Instance); if (currentPageDataField!= null) { var pageData = currentPageDataField.GetValue(view) as DataTable; if (pageData != null && pageData.Columns.Contains(columnName)) { result = ObjectUtils.Object2String(pageData.Rows[rowIndex-1][columnName]); } } return result; } } }
在直接sql账表cccc,表单插件代码:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using Kingdee.BOS.Util; using Kingdee.BOS.Core.Report.PlugIn; using Kingdee.BOS.Core.Report.PlugIn.Args; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Model.Report; using Kingdee.BOS.Web.Report.SQLReport; namespace Kingdee.BOS.TestPlugIn.BillFormPlugin { [HotUpdate] [Description("在直接sql账表cccc表单插件")] public class BillCReportPlugIn : AbstractSysReportPlugIn { /// <summary> /// 初始化事件之后 /// </summary> /// <param name="e"></param> public override void OnInitialize(InitializeEventArgs e) { base.OnInitialize(e); var reportModel = this.Model as SQLReportModel; //直接sql帐表对应的Model var strFilter = ObjectUtils.Object2String(reportModel.OpenParameter.GetCustomParameter("SqlFilter")); //得到父表传入的过滤 //这里创建日期为关键字也是过滤行,把它的值替换为传入的值,如果取不到说明不存在,直接退出 var dateFilterRow = reportModel.FilterParameter.SQLFilterRows.FirstOrDefault(x => x.FilterField.KeyWord.EqualsIgnoreCase("#FDate1#")); if (dateFilterRow != null) { dateFilterRow.Value = strFilter; } } } }
运行效果:
赞 20
20人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读