我怕删了又有用 存一下垃圾吧
clr.AddReference("Newtonsoft.Json")
from Newtonsoft.Json import JsonConvert
from clr import AddReference
AddReference("Kingdee.Bos.App")
from Kingdee.BOS.App.Data import DBUtils
def DataChanged(e):
global row
row=e.Row
if e.Key == 'F_WKYC_Text1' or e.Key == 'F_WKYC_TEXT1':
# this.View.ShowMessage('test')
end_price()
else:
pass
def end_price():
obj = this.Model.DataObject['SaleOrderEntry']# [row]['F_RICH_Base5']['Number']# ['F_RICH_Base5'] #对象
s = JsonConvert.SerializeObject(obj) #序列化方法
# this.View.ShowMessage(s)
material_ID= obj[row]['MaterialId_Id']
if material_ID ==0:
raise Exception('请先选择物料后尝试,程序终止!')
else:
sql = '''/*dialect*/SELECT
T1.FID,T2.FMATERIALID as 物料ID,T3.FTaxPrice as 含税单价,max(t1.FApproveDate) as 审核日期
FROM T_SAL_ORDER T1
INNER JOIN T_SAL_ORDERENTRY T2 ON T1.FID=T2.FID
INNER JOIN T_SAL_ORDERENTRY_F T3 ON T3.FENTRYID=T2.FENTRYID
where t1.FDocumentStatus ='C' and T2.FMATERIALID='{0}'
GROUP BY T1.FID,T2.FMATERIALID,T3.FTaxPrice
'''.format(material_ID)
data = DBUtils.ExecuteEnumerable(this.Context, sql) # 返回数据库结果
rows = DBUtils.ExecuteDataSet(this.Context, sql).Tables[0].Rows.Count # 返回数据库行数
if rows==1:
for i in data:
# this.View.ShowMessage(str(i['含税单价']))
this.Model.SetValue('FTAXPRICE',i['含税单价'],row)
break
elif rows==0:
this.Model.SetValue('FTAXPRICE',0,row)
else:
raise Exception('单价查询有误,请联系管理员!')