1. 登录BOS IDE,扩展“应收票据收发存明细表过滤条件”显示隐藏列 增加目标字段,扩展“应收票据收发存明细表”增加目标字段
2. 二开代码,新增服务器插件实现类,继承ReceivableBillTransactReport(如图2.1所示)
图2.1
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Contracts.Report;
using Kingdee.K3.FIN.App.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace Kingdee.K3.FIN.CN.App.Report
{
/// <summary>
///
/// </summary>
[Description("应收票据收发存明细表1111111")]
public class ReceiveableBillTransactRemarkReport : Kingdee.K3.FIN.CN.App.Report.ReceivableBillTransactReport
{
/// <summary>
///
/// </summary>
/// <param name="filter"></param>
/// <param name="tableName"></param>
public override void BuilderReportSqlAndTempTable(BOS.Core.Report.IRptParams filter, string tableName)
{
base.BuilderReportSqlAndTempTable(filter, tableName);
//创建字段
var addColumnSql = string.Format(@" IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = '{0}' AND KSQL_COL_NAME IN ('FREMARK'))
29. ALTER TABLE {0} ADD (FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL ) ", tableName);
DBUtils.Execute(this.Context, addColumnSql);
//创建临时表
//将票据关联的字段写入临时表中
var remarkTmpTable = CreateTable();
var sql = string.Format(@" INSERT INTO {0} (FID,FREMARK) SELECT A.FID,B.FEXPLANATION FROM {1} A INNER JOIN T_CN_BILLRECEIVABLE_D B
ON A.FID = B.FID ", remarkTmpTable, tableName);
DBUtils.Execute(this.Context, sql);
//通过merge将临时表中的内容写入tableName
var mergeSql = string.Format(@" MERGE INTO {0} A
USING {1} B
ON A.FID=B.FID
WHEN MATCHED THEN
UPDATE SET A.FREMARK=B.FREMARK ", tableName, remarkTmpTable);
DBUtils.Execute(this.Context, mergeSql);
CommonFunction.DropTempTable(this.Context, remarkTmpTable);
}
private string CreateTable()
{
var tmpTableName = CommonFunction.GetTempTableName(this.Context);
var sb = new StringBuilder();
sb.AppendFormat(@"CREATE TABLE {0}(
FID INT,
FREMARK NVARCHAR(255)
)", tmpTableName);
DBUtils.Execute(this.Context, sb.ToString());
return tmpTableName;
}
}
}
3. BOSIDE为应收票据收发存明细表注册上述服务器插件,并反注册原插件(如图3.1所示)
图3.1
推荐阅读