移动表单保存不到数据库里
金蝶云社区-云社区用户Re2X1820
云社区用户Re2X1820
1人赞赏了该文章 850次浏览 未经作者许可,禁止转载编辑于2015年11月09日 18:38:56

移动表单保存不到数据库里,下面是代码,最后一个弹出消息代码this.View.ShowMessage("save success123!"+text) 可正常执行。
import clr
clr.AddReference("System")
clr.AddReference("System.Core")
clr.AddReference("Kingdee.BOS")
clr.AddReference("Kingdee.BOS.Core")
clr.AddReference("Kingdee.BOS.Mobile")
clr.AddReference("Kingdee.BOS.DataEntity")
clr.AddReference("Kingdee.BOS.Contracts")
clr.AddReference("Kingdee.BOS.ServiceHelper")
from Kingdee.BOS import *
from Kingdee.BOS.Mobile import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
from Kingdee.BOS.Core.Metadata import *
from Kingdee.BOS.Core.Metadata.EntityElement import *
from Kingdee.BOS.Core.Metadata.FieldElement import *
from Kingdee.BOS.ServiceHelper import *
from Kingdee.BOS.Orm.Metadata.DataEntity import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.Contracts import *
from System import *
from System.Collections.Generic import *
from System.Linq import *

def ButtonClick(e):
#this.View.ShowMessage(e.Key);
metadata = MetaDataServiceHelper.Load(this.Context, "DN_LoanBillReq");
dynamicObject = metadata.BusinessInfo.GetDynamicObjectType();
saveObj = DynamicObject(dynamicObject);
#文本
text = this.Model.GetValue("F_DN_Text");

metadata.BusinessInfo.GetField("F_DN_Text").DynamicProperty.SetValue(saveObj, text);

lstData = List[DynamicObject]();
lstData.Add(saveObj);
#Context必须从this.View.Context获取,不要加get_Context,切记
#接口最好不要用,会报透明代理转换错误的,由C#去调用接口
#savesercie = ServiceFactory.GetSaveService(this.View.Context);
#savesercie.Save(this.View.Context, Enumerable.ToArray(lstData));
BusinessDataServiceHelper.Save(this.View.Context,metadata.BusinessInfo,Enumerable.ToArray(lstData));
this.View.ShowMessage("save success123!"+text);