报错:请先录入采购组织内容
金蝶云社区-用户002
用户002
0人赞赏了该文章 2,638次浏览 未经作者许可,禁止转载编辑于2015年12月08日 17:00:16

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Kingdee.BOS.ServiceInterface.ClientSDK;
using WindowsFormsApplication2.ServiceReference1;

namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
STK_InStock();
}

public void STK_InStock()
{
try
{
ServiceConfig.URL = @"http://localhost/K3CloudServiceInterface/";
var user = new KDUser()
{
AccountId = "565f92557a4d1f",
UserName = "demo",
Password = "888888"
};
using (var client = new KDServiceClient(user, ServiceConfig.URL))//执行到此处报错
{
STK_InStock_Save stk_save = new STK_InStock_Save();
stk_save.Model = new STK_InStock();
//单据类型
stk_save.Model.FBillTypeID = new STK_InStock_BOS_BillType() { FNumber = "RKD01_SYS" };
//单据编号
stk_save.Model.FBillNo = "CGRK00012";
//创建人
stk_save.Creator = "demo";
//入库日期
stk_save.Model.FDate = Convert.ToDateTime("2015/12/8"); ;
//单据状态
stk_save.Model.FDocumentStatus = "C";
//采购部门
stk_save.Model.FPurchaseDeptId = new STK_InStock_BD_Department { FNUMBER = "BM000007" };
//采购组织
stk_save.Model.FPurchaseOrgId = new STK_InStock_ORG_Organizations { FNUMBER = "101.2" };
//收料部门
stk_save.Model.FStockDeptId = new STK_InStock_BD_Department { FNUMBER = "BM000001" };
//收料组织
stk_save.Model.FStockOrgId = new STK_InStock_ORG_Organizations() { FNUMBER = "101.2" };
//需求组织
stk_save.Model.FDemandOrgId = new STK_InStock_ORG_Organizations { FOrgID = 100003 };
//供货方
stk_save.Model.FSupplyId = new STK_InStock_BD_Supplier { FSupplierId = 100147 };
//供应商
stk_save.Model.FSupplierId = new STK_InStock_BD_Supplier { FSupplierId = 100147 };
//结算方
stk_save.Model.FSettleId = new STK_InStock_BD_Supplier { FSupplierId = 100147 };
//收款方
stk_save.Model.FChargeId = new STK_InStock_BD_Supplier { FSupplierId = 100147 };
stk_save.Model.STK_InStock__FInStockFin = new STK_InStock__FInStockFin()
{
//结算组织
FSettleOrgId = new STK_InStock_ORG_Organizations() { FNUMBER = "101.2" },
//结算币别
FSettleCurrId = new STK_InStock_BD_Currency() { FNumber = "PRE007" },
//本位币
FLocalCurrId = new STK_InStock_BD_Currency() { FCURRENCYID = 1 },
//汇率类型
FExchangeTypeId = new STK_InStock_BD_RateType() { FRATETYPEID = 1 },
//汇率
FExchangeRate = 1.000000M
};
//采购入库单明细
stk_save.Model.STK_InStock__FInStockEntry = new STK_InStock__FInStockEntry[] {
new STK_InStock__FInStockEntry(){
//物料编码
FMaterialId = new STK_InStock_BD_MATERIAL(){
FNumber="1.01.001.0070"
},
//货主类型
FOWNERTYPEID="BD_OwnerOrg",
//货主
FOWNERID= new STK_InStock_BOS_ItemClass{
FNumber="Y103"
},
FUnitID = new STK_InStock_BD_UNIT(){
FNumber="Pcs"
},
//仓库
FStockId= new STK_InStock_BD_STOCK(){
FNumber="CK002"
},
//基本单位数量
FBaseUnitQty= 10,
//数量
FAuxUnitQty = 10,
FRealQty=10,
//单价
FPrice = 10,
//价税合计
FAmount = 100,
FIsReceiveUpdateStock=true }
};
var result = client.Send(stk_save);
MessageBox.Show(result.Result.ResponseStatus.Message.ToString());
//if (result.Result.ResponseStatus != null)
//{
// StringBuilder sb = new StringBuilder();
// foreach (var item in result.Result.ResponseStatus.Errors)
// {
// sb.AppendLine(item.Message);
// }
// MessageBox.Show(sb.ToString());
//}
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}