import clr
clr.AddReference('System')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
from System import*
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.App.Data import *
def DataChanged(e):
#明细中增加销售客户字段(基本资料):F_MarketClient;物料编码:FMaterialId;明细中增加客户物料字段(基本资料):FMapId
if e.Key == "F_MarketClient" or e.Key =="FMaterialId" or e.Key == "FMapId":
hh=this.View.Model.GetEntryCurrentRowIndex("FEntity");#获取单据体当前焦点行号
if hh >= 0 :
khObj = this.Model.GetValue("F_MarketClient",hh);
if khObj is not None:
KHnumber = khObj["Number"];
if e.Key == "FMaterialId":
baseObj=this.Model.GetValue("FMaterialId",hh);
if baseObj is not None:
cc = baseObj["Number"]
sql1 = "select a.FNUMBER from V_SAL_CUSTMATMAPPING a left join T_BD_CUSTOMER c on a.FCUSTOMERID = c.FCUSTID inner join T_BD_MATERIAL d on a.FMaterialId = d.FMaterialId where d.FNUMBER = '"+str(cc)+"' and c.fnumber = '" + str(KHnumber)+"'"
KHnumbers = DBUtils.ExecuteScalar(this.Context,sql1,None);
this.View.Model.SetItemValueByNumber("FMapId",KHnumbers,hh);
elif e.Key == "FMapId":
fmapObj=this.Model.GetValue("FMapId",hh);
if fmapObj is not None:
mm = fmapObj["Number"]
sql2 = "select d.FNUMBER from V_SAL_CUSTMATMAPPING a left join T_BD_CUSTOMER c on a.FCUSTOMERID = c.FCUSTID inner join T_BD_MATERIAL d on a.FMaterialId = d.FMaterialId where a.fnumber = '"+str(mm)+"' and c.fnumber = '" + str(KHnumber) +"'"
FMaterials = DBUtils.ExecuteScalar(this.Context,sql2,None);
this.View.Model.SetItemValueByNumber("FMaterialId",FMaterials,hh);
推荐阅读