代码拉取完成,页面将自动刷新
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Permission;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using Kingdee.BOS.Web.Report.SQLReport;
using System.ComponentModel;
using System.Data;
using System.Reflection;
namespace FZ.Plugins
{
/// <summary> /// 【表单插件】直接SQL账表双击数据行打开新窗体
/// </summary>
[Description("【表单插件】直接SQL账表双击数据行打开新窗体"), HotUpdate]
public class multiBillOpen_Sql_Rpt : AbstractDynamicFormPlugIn
{
public override void EntityRowDoubleClick(EntityRowClickEventArgs e)
{
base.EntityRowDoubleClick(e);
var ColKey = e.ColKey ;
var view = this.View as SQLReportView;
if (view == null)
{
return;
}
// 获取当前行指定单元格的数据
// 版本PT-146850 [7.5.1.202008]前用此方法
var currentRowValue = GetCurrentRowValue(view, "单据编号");
// 版本PT-146850 [7.5.1.202008]后用此方法
//var currentRowValue = view.GetCurrentRowValue("单据编号");
if (currentRowValue == null) { return; }
var billNo = currentRowValue.ToString();
// 使用单据视图打开
//ShowBillForm(billNo);
// 使用列表视图打开
ShowListForm(billNo);
}
/// <summary>
/// 使用单据视图打开
/// </summary>
/// <param name="billNo">单据编号</param>
private void ShowBillForm(string billNo)
{
var sql = string.Format("SELECT FID FROM T_PUR_POORDER WHERE FBILLNO='{0}'", billNo);
var pkId = DBServiceHelper.ExecuteScalar<long>(this.Context, sql, 0);
if (pkId <= 0) { return; }
var param = new BillShowParameter();
param.FormId = "PUR_PurchaseOrder"; // 业务对象标识
param.PKey = pkId.ToString(); // 单据内码
param.Status = OperationStatus.VIEW; // 查看模式打开
//param.Status = OperationStatus.EDIT; // 编辑模式打开
this.View.ShowForm(param);
}
/// <summary>
/// 使用列表视图打开
/// </summary>
/// <param name="billNo">单据编号</param>
private void ShowListForm(string billNo)
{
var param = new ListShowParameter();
param.FormId = "PUR_PurchaseOrder"; // 业务对象标识
param.PermissionItemId = PermissionConst.View; // 验证当前用户查看权限
param.OpenStyle.ShowType = ShowType.MainNewTabPage; // 主控台开新页签
param.ListFilterParameter.Filter = string.Format("FBillNo='{0}'", billNo); // 查看指定单据
this.View.ShowForm(param);
}
/// <summary>
/// 获取当前选中行指定列的数据
/// </summary>
/// <param name="view"></param>
/// <param name="columnName"></param>
/// <returns></returns>
private object GetCurrentRowValue(IDynamicFormView view, string columnName)
{
var currentPageData = GetValue(view, "currentPageData") as DataTable;
if (currentPageData == null) { return null; }
if (!currentPageData.Columns.Contains(columnName))
{ return null; }
if (view.OpenParameter.GetCustomParameter("FLIST_selectedRows") == null)
{ return null; }
var curRow = view.OpenParameter.GetCustomParameter("FLIST_selectedRows").ToString();
// 反射获取当前账表数据包
var rows = currentPageData.Select(string.Format("{0}={1}", "FIDENTITYID", curRow));
if (rows.Length > 0)
{ return rows[0][columnName]; }
return null;
}
/// <summary>
/// 反射获取当前视图的某个值
/// </summary>
/// <param name="obj"></param>
/// <param name="propertyName"></param>
/// <returns></returns>
private object GetValue(object obj, string propertyName)
{
var field = typeof(SQLReportView).GetField(propertyName, BindingFlags.NonPublic | BindingFlags.Instance);
if (field != null)
{
return field.GetValue(obj);
}
return null;
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。