一、客户对账单二开添加字段,继承原来客户对账单表单插件Statement基类
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Util;
using Kingdee.K3.FIN.Business.PlugIn.ARAP;
using Kingdee.K3.FIN.ServiceHelper;
using System;
using System.ComponentModel;
using System.Data;
using System.Linq;
namespace Demo.BusinessPlugIn
{
public class khdzdBillPlugin:Statement
{
string customerName = ""; //过滤条件往来单位
string newtempTable = ""; //新的临时表
bool NewSearch = false; //是否是新查询的数
public override void BarItemClick(BarItemClickEventArgs e)
{
if (e.BarItemKey == "tbFilter")
{
this.customerName = "";
NewSearch = true;
}
if (e.BarItemKey == "tbRefresh")
{
NewSearch = true;
}
base.BarItemClick(e);
}
public override void DataChanged(DataChangedEventArgs e)
{
if (e.Field.Key == "FCombo")
{
NewSearch = false;
}
base.DataChanged(e);
}
protected override void Refresh()
{
if (this.filterPara == null)
{
return;
}
string oldSelectedValue = Convert.ToString(this.View.Model.GetValue("FCombo"));
if (Convert.ToBoolean(this.filterPara.CustomFilter["FByContact"]))
{
customerName = this.GetCustomerData(oldSelectedValue);
}
dropTempTable();
base.Refresh();
}
public override void BeforeClosed(BeforeClosedEventArgs e)
{
dropTempTable();
base.BeforeClosed(e);
}
/// 将标准的对账单生成的临时表数据复制到带有扩展字段的临时表里面去
public void CopyDataToNewTempTable()
{
var custmoFilter = this.filterPara.CustomFilter;
DynamicObjectCollection jszh = custmoFilter["F_UGWH_Assistant_83g"] as DynamicObjectCollection;
string where = "";
if (!jszh.IsNullOrEmptyOrWhiteSpace())
{
foreach (var item in jszh)
{
string FDATAVALUE = TypeUtil.GetDynamicObjectNdata(item["F_UGWH_Assistant_83g"], "FDataValue");
where += "'" + FDATAVALUE + "',";
}
if (!where.IsNullOrEmptyOrWhiteSpace())
{
where = "where FPRESETTEXT1 in (" + where.Substring(0, where.Length - 1) + ") ";
}
}
this.newtempTable = GetTempTable();
string sql = string.Format(@"/*dialect*/
select * into {1} from (
select
'FPRESETTEXT1'=iif(t2.FPRESETTEXT1 is null ,'',t2.FPRESETTEXT1)+iif(t3.FPRESETTEXT1 is null ,'',t3.FPRESETTEXT1)+iif(t4.FPRESETTEXT1 is null ,'',t4.FPRESETTEXT1),
t1.*
from {0} t1
left join t_AR_receivable t2 on t1.FID=t2.FID and t1.FFORMID='AR_receivable'
left join T_AR_RECEIVEBILL t3 on t1.FID=t3.FID and t1.FFORMID='AR_RECEIVEBILL'
left join T_AR_REFUNDBILL t4 on t1.FID=t4.FID and t1.FFORMID='AR_REFUNDBILL'
) tab {2}",
this.tempTable, this.newtempTable,where);
DBUtils.Execute(this.Context, sql);
}
/// 获取新的带有扩展字段的数据
public DataTable GetNewData()
{
CopyDataToNewTempTable();
DataTable dataByContactUnit = StatementServiceHelper.GetDataByContactUnit(base.Context, this.newtempTable, customerName);
return dataByContactUnit;
}
/// 获取新的带扩展字段的汇总数据
public DataTable GetNewSumDate()
{
DataTable sumDataByContactUnit = StatementServiceHelper.GetSumDataByContactUnit(base.Context, this.newtempTable, this.agingKeys.Keys.ToList(), customerName);
return sumDataByContactUnit;
}
public override void SetListData(DataTable data)
{
if (NewSearch)
{
DataTable dt = GetNewData();
string oldTempTable = this.tempTable;
this.tempTable = this.newtempTable;
this.newtempTable = oldTempTable;
base.SetListData(dt);
}
else
{
base.SetListData(data);
}
}
public override void SetListSumData(DataTable data)
{
if (NewSearch)
{
DataTable dt = GetNewSumDate();
base.SetListSumData(dt);
}
else
{
base.SetListSumData(data);
}
}
/// 删除临时表
private void dropTempTable()
{
if (!string.IsNullOrWhiteSpace(this.newtempTable))
{
IDBService dbservice = Kingdee.BOS.App.ServiceHelper.GetService<IDBService>();
dbservice.DeleteTemporaryTableName(this.Context, new string[] { this.newtempTable });
this.newtempTable = "";
}
}
/// 获取临时表名称
private string GetTempTable()
{
IDBService dbservice = Kingdee.BOS.App.ServiceHelper.GetService<IDBService>();
string[] temptables = dbservice.CreateTemporaryTableName(this.Context, 1);
return temptables[0];
}
}
}
二、客户对账单注册插件,停用继承的插件,注意客户对账单添加的字段标识和sql里面添加的一直,还要过滤条件表单记得添加显示隐藏列(标识也是和对账单里面新加的一至)
![](https://i-blog.csdnimg.cn/direct/b88def5e3fb94e80a97514dada9c5b19.png)