using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.BOS;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Model.DynamicForm;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Web.DynamicForm;
using System.ComponentModel;
using System.Data;
using Kingdee.BOS.App.Data;
namespace MyPlugin
{
public class MyPlugin : AbstractBillPlugIn
{
[HotUpdate]
/// <summary>
/// 界面数据发生变化之后,需要处理的功能
/// </summary>
/// <param name="e"></param>
public override void DataChanged(DataChangedEventArgs e)
{
switch (e.Field.Key.ToUpperInvariant())
{
case "FACCOUNTID":
string _str = DeptEmp(e.NewValue.ToString());
if (_str != null && _str!="")
{
string[] xstr = _str.Split('_');
if (xstr[0] != "")
{
try
{
//维度关联字段赋值
((DynamicWebFormView)this.View).SetItemValueByIDFromClient("$$FDETAILID__FFLEX5", xstr[0], e.Row);
}
catch
{ }
}
if (xstr[1] != "")
{
try
{
((DynamicWebFormView)this.View).SetItemValueByIDFromClient("$$FDETAILID__FFLEX7", xstr[1], e.Row);
}
catch
{ }
}
this.View.UpdateView("FDetailID", e.Row);
}
break;
default:
break;
}
}
/// <summary>
/// 读取金蝶数据库
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
private string DeptEmp(string id)
{
DynamicObjectCollection Dyobj = DBUtils.ExecuteDynamicObject(this.Context, "select top 1 F_DEPT as FDept,F_EMP as FEmp from BOS_DFREE_SDMENTRY where F_SUBJECT=" + id + " order by FEntryID desc");
foreach (DynamicObject obj in Dyobj)
{
//给基础资料物料,赋值
return obj["FDept"].ToString() + "_" + obj["FEmp"].ToString();
}
return null;
}
}
}
10-20
2795
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-10
10-22
1979
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)