插件下推时代码添加领料人失效
金蝶云社区-究极鹏鹏
究极鹏鹏
1人赞赏了该文章 899次浏览 未经作者许可,禁止转载编辑于2017年12月20日 10:10:29

public string setnewbill2(string sourceFormId, string targetFormId, int rowid, string ydid, string ydentryid, float qty2, Boolean rk, string targettype, string wlid, int empid)//
{
string entryid = null;
entryid = "PPBomEntry";
string entryname = "Entity";
string headname = "BillHead";
var rules = ConvertServiceHelper.GetConvertRules(this.View.Context, sourceFormId, targetFormId);
var rule = rules.FirstOrDefault(t => t.IsDefault);

string primaryKeyValue = ydid;
string returnvalue = null;
ListSelectedRow row = new ListSelectedRow(primaryKeyValue, ydentryid, rowid, sourceFormId);
row.EntryEntityKey = entryid;
ListSelectedRow[] selectedRows = new ListSelectedRow[] { row };
ConvertOperationResult operationResult = null;
Dictionary custParams = new Dictionary();
try
{
PushArgs pushArgs = new PushArgs(rule, selectedRows)
{
TargetBillTypeId = targettype, // 请设定目标单据单据类型。如无单据类型,可以空字符
// TargetOrgId = 0, // 请设定目标单据主业务组织。如无主业务组织,可以为0
CustomParams = custParams, // 可以传递额外附加的参数给单据转换插件,如无此需求,可以忽略
};
//执行下推操作,并获取下推结果
operationResult = ConvertServiceHelper.Push(this.View.Context, pushArgs, OperateOption.Create());
}
catch (KDException ex)
{
this.View.ShowErrMessage(ex.Message);
return ex.ToString();
}
DynamicObject[] objs = (from p in operationResult.TargetDataEntities
select p.DataEntity).ToArray();
FormMetadata formMetadata = MetaDataServiceHelper.Load(this.Context, "BD_Empinfo") as FormMetadata;
DynamicObject dynamicObject = BusinessDataServiceHelper.LoadSingle(
this.Context,
empid,
formMetadata.BusinessInfo.GetDynamicObjectType());
objs[0]["PickerId"] = dynamicObject; ///标记
objs[0]["PickerId_Id"] = empid;///标记

DynamicObjectCollection objEntry = (DynamicObjectCollection)objs[0][entryname];

objEntry[0]["ActualQty"] = qty2;
objEntry[0]["F_PAEZ_Qty"] = maozhong;
objEntry[0]["F_PAEZ_Integer"] = t1;
objEntry[0]["F_PAEZ_Decimal"] = t1zl;
objEntry[0]["F_PAEZ_Integer1"] = t2;
objEntry[0]["F_PAEZ_Decimal1"] = t2zl;

var targetBillMeta = MetaDataServiceHelper.Load(this.View.Context, targetFormId) as FormMetadata;
OperateOption saveOption = OperateOption.Create();
saveOption.SetIgnoreWarning(true); // 提交数据库保存,并获取保存结果
var saveResult = BusinessDataServiceHelper.Save(this.View.Context, targetBillMeta.BusinessInfo, objs, saveOption, "Save");
var submitResult = BusinessDataServiceHelper.Submit(this.View.Context, targetBillMeta.BusinessInfo, new object[] { objs[0]["ID"] }, "Submit");
var aduitResult = BusinessDataServiceHelper.Audit(this.View.Context, targetBillMeta.BusinessInfo, new object[] { objs[0]["ID"] }, null);
string save = ((IOperationResult)saveResult).IsSuccess.ToString();
string submit = ((IOperationResult)submitResult).IsSuccess.ToString();
string aduit = ((IOperationResult)aduitResult).IsSuccess.ToString();
if (save.ToUpperInvariant().Equals("TRUE") && submit.ToUpperInvariant().Equals("TRUE") && aduit.ToUpperInvariant().Equals("TRUE"))
{
IEnumerable ienumdy = ((IOperationResult)saveResult).SuccessDataEnity;
BillShowParameter para = new BillShowParameter();
para.OpenStyle.ShowType = ShowType.MainNewTabPage;//模态显示
para.FormId = targetFormId;//单据内码
para.Status = OperationStatus.VIEW;
foreach (DynamicObject item in ienumdy)
{
DynamicObject billobj = item;
para.PKey = billobj["Id"].ToString();
}
this.View.ShowForm(para);
}
return "保存:" + save + ",提交:" + submit + ",审核:" + aduit;
}

上面的代码中标记的地方对单据头的领料人(员工)进行了赋值,但是执行完成后单据中领料人为空

求指正!谢谢!

您的鼓励与嘉奖将成为创作者们前进的动力,如果觉得本文还不错,可以给予作者创作打赏哦!

请选择打赏金币数 *

10金币20金币30金币40金币50金币60金币
可用金币: 0