if (result.Equals("1"))
{
string sFBillNo = "";
sFBillNo = Convert.ToString(billno.Text).ToString();
JObject jsonRoot = new JObject();
// Creator: 创建用户
jsonRoot.Add("Creator", sUID);
// NeedUpDateFields: 哪些字段需要更新?
//jsonRoot.Add("NeedUpDateFields", new JArray(""));
// Model: 单据详细数据参数
JObject model = new JObject();
jsonRoot.Add("Model", model);
// 开始设置单据字段值
//model.Add("FID", "0");
//单位标准工时单位
JObject basedata = new JObject();
model.Add("FDate", "2018-08-08");//单据日期
basedata.Add("FNumber", "100");
model.Add("FPrdOrgId", basedata);//生产组织
//单据类型:FBillType (必填项) SCHBD01_SYS--入库汇报,SCHBD02_SYS--返工汇报
basedata = new JObject();
basedata.Add("FNumber", "SCHBD01_SYS");
model.Add("FBillType", basedata);
//单据状态:FDocumentStatus (必填项)
model.Add("FDocumentStatus", "A");//创建中
// 开始构建单据体参数:集合参数JArray
JArray entryRows = new JArray();
// 把单据体行集合,添加到model中,以单据体Key为标识
string entityKey = "FEntity"; //gao FSerialSubEntity
model.Add(entityKey, entryRows);
JArray FSerialSubEntity = new JArray();
string str_sub = "FSerialSubEntity";
//entryRows.
// 通过循环创建单据体行:示例代码仅创建一行
for (int i = 0; i <= 0; i++)
{
// 添加新行,把新行加入到单据体行集合
JObject entryRow = new JObject();
entryRows.Add(entryRow);
//子表中的子表
entryRow.Add(str_sub, FSerialSubEntity);
// 给新行,设置关键字段值
// 单据体主键:必须填写,系统据此判断是新增还是修改行
entryRow.Add("FEntryID", "0");
//entryRow.Add("FFinishQty", 1);//完成数量:FFinishQty
entryRow.Add("FTimeUnitId", "3600");//时间单位
// 基本单位:FBaseUnitId 基础资料,填写编码
//basedata = new JObject();
//basedata.Add("FNumber", "Pcs");
//entryRow.Add("FBaseUnitId", basedata);
// 单位:FUnitID 基础资料,填写编码
basedata = new JObject();
basedata.Add("FNumber", "Pcs");
entryRow.Add("FUnitID", basedata);
//生产车间:FWorkshipId (必填项)
basedata = new JObject();
basedata.Add("FNumber", "20430");
entryRow.Add("FWorkshipId", basedata);
//生产汇报类型:FReportType (必填项)
basedata = new JObject();
basedata.Add("FNumber", "HBLX01_SYS");
entryRow.Add("FReportType", basedata);
//入库组织:FStockInOrgId (必填项)
basedata = new JObject();
basedata.Add("FNumber", "100");
entryRow.Add("FStockInOrgId", basedata);
//仓库:FStockId (必填项)
basedata = new JObject();
basedata.Add("FNumber", "CK006");
entryRow.Add("FStockId", basedata);
entryRow.Add("FStandHourUnitId", "3600");//单位标准工时单位
//物料:FQCMaterialId 基础资料
JObject SubRow = new JObject();
FSerialSubEntity.Add(SubRow);
basedata = new JObject();
basedata.Add("FNumber", "7930101386");
SubRow.Add("FQCMaterialId", basedata);
// 数量:FQCQty:数量字段
SubRow.Add("FQCQty", "1");
}
// 调用Web API接口服务,保存采购订单
result = client.Execute
"Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save",
new object[] { "PRD_MORPT", jsonRoot.ToString() });
}
JSON:
{
"Creator": "高军锋",
"Model": {
"FDate": "2018-08-08",
"FPrdOrgId": {
"FNumber": "100"
},
"FBillType": {
"FNumber": "SCHBD01_SYS"
},
"FDocumentStatus": "A",
"FEntity": [
{
"FSerialSubEntity": [
{
"FQCMaterialId": {
"FNumber": "7930101386"
},
"FQCQty": "1"
}
],
"FEntryID": "0",
"FTimeUnitId": "3600",
"FUnitID": {
"FNumber": "Pcs"
},
"FWorkshipId": {
"FNumber": "20430"
},
"FReportType": {
"FNumber": "HBLX01_SYS"
},
"FStockInOrgId": {
"FNumber": "100"
},
"FStockId": {
"FNumber": "CK006"
},
"FStandHourUnitId": "3600"
}
]
}
}