实例介绍
【实例简介】
【实例截图】
【核心代码】 string varVoucherID = gv_PO.GetFocusedRowCellDisplayText("ID");
string bodyID = gv_PO.GetFocusedRowCellDisplayText("bodyID");
//第二步:构造环境上下文对象,传入login,并按需设置其它上下文参数
U8EnvContext envContext = new U8EnvContext();
envContext.U8Login = cm.u8Login;
//采购所有接口均支持内部独立事务和外部事务,默认内部事务
//如果是外部事务,则需要传递ADO.Connection对象,并将IsIndependenceTransaction属性设置为false
//envContext.BizDbConnection = new ADO.Connection();
//envContext.IsIndependenceTransaction = false;
//设置上下文参数
envContext.SetApiContext("VoucherType", 1); //上下文数据类型:int,含义:单据类型,采购订单 1
envContext.SetApiContext("bPositive", true); //上下文数据类型:bool,含义:红蓝标识:True,蓝
envContext.SetApiContext("sBillType", ""); //上下文数据类型:string,含义:为空串
envContext.SetApiContext("sBusType", "普通采购"); //上下文数据类型:string,含义:业务类型:普通采购,直运采购,受托代销
//第三步:设置API地址标识(Url)
//当前API:装载单据的地址标识为:U8API/PurchaseOrder/GetVoucherData
U8ApiAddress myApiAddress = new U8ApiAddress("U8API/PurchaseOrder/GetVoucherData");
//第四步:构造APIBroker
U8ApiBroker broker = new U8ApiBroker(myApiAddress, envContext);
//第五步:API参数赋值
//给普通参数strWhere赋值。此参数的数据类型为System.String,此参数按值传递,表示过滤条件串
broker.AssignNormalValue("strWhere", "");
//给普通参数varVoucherID赋值。此参数的数据类型为System.String,此参数按值传递,表示单据主表ID
broker.AssignNormalValue("varVoucherID", varVoucherID);
//给普通参数strLocateWhere赋值。此参数的数据类型为System.String,此参数按值传递,表示定位条件串
broker.AssignNormalValue("strLocateWhere", "");
//第六步:调用API
if (!broker.Invoke())
{
//错误处理
Exception apiEx = broker.GetException();
if (apiEx != null)
{
if (apiEx is MomSysException)
{
MomSysException sysEx = apiEx as MomSysException;
Console.WriteLine("系统异常:" sysEx.Message);
//todo:异常处理
}
else if (apiEx is MomBizException)
{
MomBizException bizEx = apiEx as MomBizException;
Console.WriteLine("API异常:" bizEx.Message);
//todo:异常处理
}
//异常原因
String exReason = broker.GetExceptionString();
if (exReason.Length != 0)
{
Console.WriteLine("异常原因:" exReason);
}
}
//结束本次调用,释放API资源
broker.Release();
return;
}
//第七步:获取返回结果
//获取返回值
//获取普通返回值。此参数的数据类型为System.String,此参数按引用传递,表示错误描述:空,正确;非空,错误
System.String result = broker.GetReturnValue() as System.String;
//获取out/inout参数值
//out参数DomHead为BO对象(表头),此BO对象的业务类型为采购订单。BO参数均按引用传递,具体请参考服务接口定义
//如果要取原始的XMLDOM对象结果,请使用GetResult("DomHead") as MSXML2.DOMDocument
BusinessObject DomHeadRet = broker.GetBoParam("DomHead");
Console.WriteLine("BO对象(表头)行数为:" DomHeadRet.RowCount); //获取BO对象(表头)的行数
//获取BO对象(表头)各字段的值。字段定义详见API服务接口定义
/****************************** 以下是必输字段 ****************************/
poid = Convert.ToInt32(DomHeadRet[0]["poid"]); //主关键字段,int类型
cbustype = Convert.ToString(DomHeadRet[0]["cbustype"]); //业务类型,int类型
dpodate = Convert.ToDateTime(DomHeadRet[0]["dpodate"]); //日期,DateTime类型
cpoid = Convert.ToString(DomHeadRet[0]["cpoid"]); //订单编号,string类型
cvenabbname = Convert.ToString(DomHeadRet[0]["cvenabbname"]); //供货单位,string类型
cexch_name = Convert.ToString(DomHeadRet[0]["cexch_name"]); //币种,string类型
nflat = Convert.ToDouble(DomHeadRet[0]["nflat"]); //汇率,double类型
cmaker = Convert.ToString(DomHeadRet[0]["cmaker"]); //制单人,string类型
cvencode = Convert.ToString(DomHeadRet[0]["cvencode"]); //供货单位编号,string类型
ufts = Convert.ToString(DomHeadRet[0]["ufts"]); //时间戳,string类型
idiscounttaxtype = Convert.ToInt32(DomHeadRet[0]["idiscounttaxtype"]); //扣税类别,int类型
contractcodet = Convert.ToString(DomHeadRet[0]["contractcodet"]); //合同号,string类型
iflowid = Convert.ToString(DomHeadRet[0]["iflowid"]); //流程ID,string类型
cflowname = Convert.ToString(DomHeadRet[0]["cflowname"]); //流程模式描述,string类型
dclosetime = Convert.ToString(DomHeadRet[0]["dclosetime"]); //关闭时间,string类型
dclosedate = Convert.ToString(DomHeadRet[0]["dclosedate"]); //关闭日期,string类型
ccontactcode = Convert.ToString(DomHeadRet[0]["ccontactcode"]); //供方联系人编码,string类型
cmobilephone = Convert.ToString(DomHeadRet[0]["cmobilephone"]); //供方联系人手机号,string类型
cappcode = Convert.ToString(DomHeadRet[0]["cappcode"]); //请购单号,string类型
csysbarcode = Convert.ToString(DomHeadRet[0]["csysbarcode"]); //单据条码,string类型
cchangverifier = Convert.ToString(DomHeadRet[0]["cchangverifier"]); //变更审批人,string类型
cchangaudittime = Convert.ToString(DomHeadRet[0]["cchangaudittime"]); //变更审批时间,string类型
cchangauditdate = Convert.ToString(DomHeadRet[0]["cchangauditdate"]); //变更审批日期,string类型
controlresult = Convert.ToString(DomHeadRet[0]["controlresult"]); //controlresult,string类型
ibg_overflag = Convert.ToString(DomHeadRet[0]["ibg_overflag"]); //预算审批状态,string类型
cbg_auditor = Convert.ToString(DomHeadRet[0]["cbg_auditor"]); //预算审批人,string类型
cbg_audittime = Convert.ToString(DomHeadRet[0]["cbg_audittime"]); //预算审批时间,string类型
#region
/***************************** 以下是非必输字段 ****************************/
/*
string ipresent = Convert.ToString(DomHeadRet[0]["ipresent"]); //现存量,string类型
DateTime cmaketime = Convert.ToDateTime(DomHeadRet[0]["cmaketime"]); //制单时间,DateTime类型
DateTime cmodifytime = Convert.ToDateTime(DomHeadRet[0]["cmodifytime"]); //修改时间,DateTime类型
DateTime caudittime = Convert.ToDateTime(DomHeadRet[0]["caudittime"]); //审核时间,DateTime类型
DateTime cauditdate = Convert.ToDateTime(DomHeadRet[0]["cauditdate"]); //审核日期,DateTime类型
DateTime cmodifydate = Convert.ToDateTime(DomHeadRet[0]["cmodifydate"]); //修改日期,DateTime类型
string creviser = Convert.ToString(DomHeadRet[0]["creviser"]); //修改人,string类型
string cptname = Convert.ToString(DomHeadRet[0]["cptname"]); //采购类型,string类型
string cvenname = Convert.ToString(DomHeadRet[0]["cvenname"]); //供应商全称,string类型
string iverifystateex = Convert.ToString(DomHeadRet[0]["iverifystateex"]); //审核状态,string类型
string ireturncount = Convert.ToString(DomHeadRet[0]["ireturncount"]); //打回次数,string类型
string iswfcontrolled = Convert.ToString(DomHeadRet[0]["iswfcontrolled"]); //是否启用工作流,string类型
string cdepname = Convert.ToString(DomHeadRet[0]["cdepname"]); //部门,string类型
string cpersonname = Convert.ToString(DomHeadRet[0]["cpersonname"]); //业务员,string类型
double itaxrate = Convert.ToDouble(DomHeadRet[0]["itaxrate"]); //税率,double类型
string cpayname = Convert.ToString(DomHeadRet[0]["cpayname"]); //付款条件,string类型
string cmemo = Convert.ToString(DomHeadRet[0]["cmemo"]); //备注,string类型
DateTime dplanarrdate = Convert.ToDateTime(DomHeadRet[0]["dplanarrdate"]); //计划到货日期,DateTime类型
string cverifier = Convert.ToString(DomHeadRet[0]["cverifier"]); //审核人,string类型
string cchanger = Convert.ToString(DomHeadRet[0]["cchanger"]); //变更人,string类型
string ccloser = Convert.ToString(DomHeadRet[0]["ccloser"]); //关闭人,string类型
int ivtid = Convert.ToInt32(DomHeadRet[0]["ivtid"]); //单据模版号,int类型
string cvenbank = Convert.ToString(DomHeadRet[0]["cvenbank"]); //供方银行名称,string类型
string cptcode = Convert.ToString(DomHeadRet[0]["cptcode"]); //采购类型编号,string类型
double myname = Convert.ToDouble(DomHeadRet[0]["myname"]); //地址,double类型
double myphone = Convert.ToDouble(DomHeadRet[0]["myphone"]); //电话,double类型
double myfax = Convert.ToDouble(DomHeadRet[0]["myfax"]); //传真,double类型
double myzip = Convert.ToDouble(DomHeadRet[0]["myzip"]); //邮编,double类型
string cvenaddress = Convert.ToString(DomHeadRet[0]["cvenaddress"]); //供方地址,string类型
string cvenphone = Convert.ToString(DomHeadRet[0]["cvenphone"]); //供方电话,string类型
string cvenfax = Convert.ToString(DomHeadRet[0]["cvenfax"]); //供方传真,string类型
string cvenpostcode = Convert.ToString(DomHeadRet[0]["cvenpostcode"]); //供方邮编,string类型
string cvenperson = Convert.ToString(DomHeadRet[0]["cvenperson"]); //供方联系人,string类型
string cvenaccount = Convert.ToString(DomHeadRet[0]["cvenaccount"]); //供方银行账号,string类型
string cvenregcode = Convert.ToString(DomHeadRet[0]["cvenregcode"]); //供方纳税登记号,string类型
string cstate = Convert.ToString(DomHeadRet[0]["cstate"]); //状态(数据库),string类型
string cperiod = Convert.ToString(DomHeadRet[0]["cperiod"]); //计划周期,string类型
string carrivalplace = Convert.ToString(DomHeadRet[0]["carrivalplace"]); //到货地址,string类型
double ibargain = Convert.ToDouble(DomHeadRet[0]["ibargain"]); //订金,double类型
string csccode = Convert.ToString(DomHeadRet[0]["csccode"]); //运输方式编号,string类型
double icost = Convert.ToDouble(DomHeadRet[0]["icost"]); //运费,double类型
string cscname = Convert.ToString(DomHeadRet[0]["cscname"]); //运输方式,string类型
string cpaycode = Convert.ToString(DomHeadRet[0]["cpaycode"]); //付款条件编号,string类型
string cpersoncode = Convert.ToString(DomHeadRet[0]["cpersoncode"]); //业务员编号,string类型
string cdepcode = Convert.ToString(DomHeadRet[0]["cdepcode"]); //部门编号,string类型
string cdefine1 = Convert.ToString(DomHeadRet[0]["cdefine1"]); //表头自定义项1,string类型
string cdefine2 = Convert.ToString(DomHeadRet[0]["cdefine2"]); //表头自定义项2,string类型
string cdefine3 = Convert.ToString(DomHeadRet[0]["cdefine3"]); //表头自定义项3,string类型
DateTime cdefine4 = Convert.ToDateTime(DomHeadRet[0]["cdefine4"]); //表头自定义项4,DateTime类型
int cdefine5 = Convert.ToInt32(DomHeadRet[0]["cdefine5"]); //表头自定义项5,int类型
DateTime cdefine6 = Convert.ToDateTime(DomHeadRet[0]["cdefine6"]); //表头自定义项6,DateTime类型
double cdefine7 = Convert.ToDouble(DomHeadRet[0]["cdefine7"]); //表头自定义项7,double类型
string cdefine8 = Convert.ToString(DomHeadRet[0]["cdefine8"]); //表头自定义项8,string类型
string cdefine9 = Convert.ToString(DomHeadRet[0]["cdefine9"]); //表头自定义项9,string类型
string cdefine10 = Convert.ToString(DomHeadRet[0]["cdefine10"]); //表头自定义项10,string类型
string cdefine11 = Convert.ToString(DomHeadRet[0]["cdefine11"]); //表头自定义项11,string类型
string cdefine12 = Convert.ToString(DomHeadRet[0]["cdefine12"]); //表头自定义项12,string类型
string cdefine13 = Convert.ToString(DomHeadRet[0]["cdefine13"]); //表头自定义项13,string类型
string cdefine14 = Convert.ToString(DomHeadRet[0]["cdefine14"]); //表头自定义项14,string类型
int cdefine15 = Convert.ToInt32(DomHeadRet[0]["cdefine15"]); //表头自定义项15,int类型
double cdefine16 = Convert.ToDouble(DomHeadRet[0]["cdefine16"]); //表头自定义项16,double类型
string cvendefine1 = Convert.ToString(DomHeadRet[0]["cvendefine1"]); //供应商自定义项1,string类型
string cvendefine2 = Convert.ToString(DomHeadRet[0]["cvendefine2"]); //供应商自定义项2,string类型
string cvendefine3 = Convert.ToString(DomHeadRet[0]["cvendefine3"]); //供应商自定义项3,string类型
string cvendefine4 = Convert.ToString(DomHeadRet[0]["cvendefine4"]); //供应商自定义项4,string类型
string cvendefine5 = Convert.ToString(DomHeadRet[0]["cvendefine5"]); //供应商自定义项5,string类型
string cvendefine6 = Convert.ToString(DomHeadRet[0]["cvendefine6"]); //供应商自定义项6,string类型
string cvendefine7 = Convert.ToString(DomHeadRet[0]["cvendefine7"]); //供应商自定义项7,string类型
string cvendefine8 = Convert.ToString(DomHeadRet[0]["cvendefine8"]); //供应商自定义项8,string类型
string cvendefine9 = Convert.ToString(DomHeadRet[0]["cvendefine9"]); //供应商自定义项9,string类型
string cvendefine10 = Convert.ToString(DomHeadRet[0]["cvendefine10"]); //供应商自定义项10,string类型
string cvenpuomprotocol = Convert.ToString(DomHeadRet[0]["cvenpuomprotocol"]); //收付款协议编码,string类型
string cvendefine11 = Convert.ToString(DomHeadRet[0]["cvendefine11"]); //供应商自定义项11,string类型
string cvenpuomprotocolname = Convert.ToString(DomHeadRet[0]["cvenpuomprotocolname"]); //收付款协议名称,string类型
string cvendefine12 = Convert.ToString(DomHeadRet[0]["cvendefine12"]); //供应商自定义项12,string类型
string cvendefine13 = Convert.ToString(DomHeadRet[0]["cvendefine13"]); //供应商自定义项13,string类型
string cvendefine14 = Convert.ToString(DomHeadRet[0]["cvendefine14"]); //供应商自定义项14,string类型
string cvendefine15 = Convert.ToString(DomHeadRet[0]["cvendefine15"]); //供应商自定义项15,string类型
string cvendefine16 = Convert.ToString(DomHeadRet[0]["cvendefine16"]); //供应商自定义项16,string类型
string clocker = Convert.ToString(DomHeadRet[0]["clocker"]); //锁定人,string类型
*/
#endregion
//out参数domBody为BO对象(表体),此BO对象的业务类型为采购订单。BO参数均按引用传递,具体请参考服务接口定义
//如果要取原始的XMLDOM对象结果,请使用GetResult("domBody") as MSXML2.DOMDocument
BusinessObject domBodyRet = broker.GetBoParam("domBody");
Console.WriteLine("BO对象(表体)行数为:" domBodyRet.RowCount); //获取BO对象(表体)的行数
//获取BO对象(表体)各字段的值。以下代码示例只取第一行。字段定义详见API服务接口定义
/****************************** 以下是必输字段 ****************************/
id = Convert.ToInt32(domBodyRet[0]["id"]); //主关键字段,int类型
cinvcode = Convert.ToString(domBodyRet[0]["cinvcode"]); //存货编码,string类型
iquantity = Convert.ToDouble(domBodyRet[0]["iquantity"]); //数量,double类型
darrivedate = Convert.ToDateTime(domBodyRet[0]["darrivedate"]); //计划到货日期,DateTime类型
ipertaxrate = Convert.ToDouble(domBodyRet[0]["ipertaxrate"]); //税率,double类型
poid1 = Convert.ToInt32(domBodyRet[0]["poid"]); //主表id,int类型
bgsp = Convert.ToInt32(domBodyRet[0]["bgsp"]); //是否检验,int类型
editprop = Convert.ToString(domBodyRet[0]["editprop"]); //编辑属性:A表新增,M表修改,D表删除,string类型
cbg_itemcode = Convert.ToString(domBodyRet[0]["cbg_itemcode"]); //预算项目编码,string类型
cbg_itemname = Convert.ToString(domBodyRet[0]["cbg_itemname"]); //预算项目,string类型
cbg_caliberkey1 = Convert.ToString(domBodyRet[0]["cbg_caliberkey1"]); //口径1类型编码,string类型
cbg_caliberkeyname1 = Convert.ToString(domBodyRet[0]["cbg_caliberkeyname1"]); //口径1类型名称,string类型
cbg_caliberkey2 = Convert.ToString(domBodyRet[0]["cbg_caliberkey2"]); //口径2类型编码,string类型
cbg_caliberkeyname2 = Convert.ToString(domBodyRet[0]["cbg_caliberkeyname2"]); //口径2类型名称,string类型
cbg_caliberkey3 = Convert.ToString(domBodyRet[0]["cbg_caliberkey3"]); //口径3类型编码,string类型
cbg_caliberkeyname3 = Convert.ToString(domBodyRet[0]["cbg_caliberkeyname3"]); //口径3类型名称,string类型
cbg_calibercode1 = Convert.ToString(domBodyRet[0]["cbg_calibercode1"]); //口径1编码,string类型
cbg_calibername1 = Convert.ToString(domBodyRet[0]["cbg_calibername1"]); //口径1名称,string类型
cbg_calibercode2 = Convert.ToString(domBodyRet[0]["cbg_calibercode2"]); //口径2编码,string类型
cbg_calibername2 = Convert.ToString(domBodyRet[0]["cbg_calibername2"]); //口径2名称,string类型
cbg_calibercode3 = Convert.ToString(domBodyRet[0]["cbg_calibercode3"]); //口径3编码,string类型
cbg_calibername3 = Convert.ToString(domBodyRet[0]["cbg_calibername3"]); //口径3名称,string类型
cbg_auditopinion = Convert.ToString(domBodyRet[0]["cbg_auditopinion"]); //审批意见,string类型
ibg_ctrl = Convert.ToString(domBodyRet[0]["ibg_ctrl"]); //是否预算控制,string类型
fexquantity = Convert.ToString(domBodyRet[0]["fexquantity"]); //累计出口数量,string类型
ivouchrowno = Convert.ToString(domBodyRet[0]["ivouchrowno"]); //行号,string类型
cbg_caliberkeyname4 = Convert.ToString(domBodyRet[0]["cbg_caliberkeyname4"]); //口径4类型名称,string类型
cbg_caliberkey5 = Convert.ToString(domBodyRet[0]["cbg_caliberkey5"]); //口径5类型编码,string类型
cbg_caliberkeyname5 = Convert.ToString(domBodyRet[0]["cbg_caliberkeyname5"]); //口径5类型名称,string类型
cbg_caliberkey6 = Convert.ToString(domBodyRet[0]["cbg_caliberkey6"]); //口径6类型编码,string类型
cbg_caliberkeyname6 = Convert.ToString(domBodyRet[0]["cbg_caliberkeyname6"]); //口径6类型名称,string类型
cbg_calibercode4 = Convert.ToString(domBodyRet[0]["cbg_calibercode4"]); //口径4编码,string类型
cbg_calibername4 = Convert.ToString(domBodyRet[0]["cbg_calibername4"]); //口径4名称,string类型
cbg_calibercode5 = Convert.ToString(domBodyRet[0]["cbg_calibercode5"]); //口径5编码,string类型
cbg_calibername5 = Convert.ToString(domBodyRet[0]["cbg_calibername5"]); //口径5名称,string类型
cbg_calibercode6 = Convert.ToString(domBodyRet[0]["cbg_calibercode6"]); //口径6编码,string类型
cbg_calibername6 = Convert.ToString(domBodyRet[0]["cbg_calibername6"]); //口径6名称,string类型
csrpolicy = Convert.ToString(domBodyRet[0]["csrpolicy"]); //供需政策,string类型
irequiretrackstyle = Convert.ToString(domBodyRet[0]["irequiretrackstyle"]); //存货需求跟踪方式,string类型
ipresentb = Convert.ToString(domBodyRet[0]["ipresentb"]); //现存量,string类型
cbg_caliberkey4 = Convert.ToString(domBodyRet[0]["cbg_caliberkey4"]); //口径4类型编码,string类型
cxjspdids = Convert.ToString(domBodyRet[0]["cxjspdids"]); //采购比价审批单子表ID,string类型
cbmemo = Convert.ToString(domBodyRet[0]["cbmemo"]); //备注,string类型
cbsysbarcode = Convert.ToString(domBodyRet[0]["cbsysbarcode"]); //单据行条码,string类型
planlotnumber = Convert.ToString(domBodyRet[0]["planlotnumber"]); //计划批号,string类型
cplanmethod = Convert.ToString(domBodyRet[0]["cplanmethod"]); //计划方法,string类型
double iquantity1 = Convert.ToDouble(domBodyRet[1]["iquantity"]);
#region
/***************************** 以下是非必输字段 ****************************/
/*
double iinvexchrate = Convert.ToDouble(domBodyRet[0]["iinvexchrate"]); //换算率,double类型
string cinvname = Convert.ToString(domBodyRet[0]["cinvname"]); //存货名称,string类型
string cinvstd = Convert.ToString(domBodyRet[0]["cinvstd"]); //规格型号,string类型
double iquotedprice = Convert.ToDouble(domBodyRet[0]["iquotedprice"]); //报价,double类型
double inum = Convert.ToDouble(domBodyRet[0]["inum"]); //件数,double类型
double iunitprice = Convert.ToDouble(domBodyRet[0]["iunitprice"]); //原币单价,double类型
double imoney = Convert.ToDouble(domBodyRet[0]["imoney"]); //原币金额,double类型
double itax = Convert.ToDouble(domBodyRet[0]["itax"]); //原币税额,double类型
double idiscount = Convert.ToDouble(domBodyRet[0]["idiscount"]); //折扣额,double类型
double inatunitprice = Convert.ToDouble(domBodyRet[0]["inatunitprice"]); //本币单价,double类型
double inatmoney = Convert.ToDouble(domBodyRet[0]["inatmoney"]); //本币金额,double类型
double inattax = Convert.ToDouble(domBodyRet[0]["inattax"]); //本币税额,double类型
double inatsum = Convert.ToDouble(domBodyRet[0]["inatsum"]); //本币价税合计,double类型
double inatdiscount = Convert.ToDouble(domBodyRet[0]["inatdiscount"]); //本币折扣额,double类型
double isum = Convert.ToDouble(domBodyRet[0]["isum"]); //原币价税合计,double类型
string cfree2 = Convert.ToString(domBodyRet[0]["cfree2"]); //自由项2,string类型
string cfree1 = Convert.ToString(domBodyRet[0]["cfree1"]); //自由项1,string类型
double bmark = Convert.ToDouble(domBodyRet[0]["bmark"]); //标志,double类型
string cdefine22 = Convert.ToString(domBodyRet[0]["cdefine22"]); //表体自定义项1,string类型
string cdefine23 = Convert.ToString(domBodyRet[0]["cdefine23"]); //表体自定义项2,string类型
string cdefine24 = Convert.ToString(domBodyRet[0]["cdefine24"]); //表体自定义项3,string类型
string cdefine25 = Convert.ToString(domBodyRet[0]["cdefine25"]); //表体自定义项4,string类型
double cdefine26 = Convert.ToDouble(domBodyRet[0]["cdefine26"]); //表体自定义项5,double类型
double cdefine27 = Convert.ToDouble(domBodyRet[0]["cdefine27"]); //表体自定义项6,double类型
string cinvdefine1 = Convert.ToString(domBodyRet[0]["cinvdefine1"]); //存货自定义项1,string类型
string cinvdefine4 = Convert.ToString(domBodyRet[0]["cinvdefine4"]); //存货自定义项4,string类型
string cinvdefine5 = Convert.ToString(domBodyRet[0]["cinvdefine5"]); //存货自定义项5,string类型
string cinvdefine6 = Convert.ToString(domBodyRet[0]["cinvdefine6"]); //存货自定义项6,string类型
string cinvdefine7 = Convert.ToString(domBodyRet[0]["cinvdefine7"]); //存货自定义项7,string类型
string cinvdefine8 = Convert.ToString(domBodyRet[0]["cinvdefine8"]); //存货自定义项8,string类型
string cinvdefine9 = Convert.ToString(domBodyRet[0]["cinvdefine9"]); //存货自定义项9,string类型
string cinvdefine10 = Convert.ToString(domBodyRet[0]["cinvdefine10"]); //存货自定义项10,string类型
string cinvdefine11 = Convert.ToString(domBodyRet[0]["cinvdefine11"]); //存货自定义项11,string类型
string cinvdefine12 = Convert.ToString(domBodyRet[0]["cinvdefine12"]); //存货自定义项12,string类型
string cinvdefine13 = Convert.ToString(domBodyRet[0]["cinvdefine13"]); //存货自定义项13,string类型
string cinvdefine14 = Convert.ToString(domBodyRet[0]["cinvdefine14"]); //存货自定义项14,string类型
string cinvdefine15 = Convert.ToString(domBodyRet[0]["cinvdefine15"]); //存货自定义项15,string类型
string cinvdefine16 = Convert.ToString(domBodyRet[0]["cinvdefine16"]); //存货自定义项16,string类型
string cinvdefine2 = Convert.ToString(domBodyRet[0]["cinvdefine2"]); //存货自定义项2,string类型
string cinvdefine3 = Convert.ToString(domBodyRet[0]["cinvdefine3"]); //存货自定义项3,string类型
string citemcode = Convert.ToString(domBodyRet[0]["citemcode"]); //项目编码,string类型
string citem_class = Convert.ToString(domBodyRet[0]["citem_class"]); //项目大类编码,string类型
string ppcids = Convert.ToString(domBodyRet[0]["ppcids"]); //采购计划子表ID,string类型
string citemname = Convert.ToString(domBodyRet[0]["citemname"]); //项目名称,string类型
string citem_name = Convert.ToString(domBodyRet[0]["citem_name"]); //项目大类名称,string类型
string cfree3 = Convert.ToString(domBodyRet[0]["cfree3"]); //自由项3,string类型
string cfree4 = Convert.ToString(domBodyRet[0]["cfree4"]); //自由项4,string类型
string cfree5 = Convert.ToString(domBodyRet[0]["cfree5"]); //自由项5,string类型
string cfree6 = Convert.ToString(domBodyRet[0]["cfree6"]); //自由项6,string类型
string cfree7 = Convert.ToString(domBodyRet[0]["cfree7"]); //自由项7,string类型
string cfree8 = Convert.ToString(domBodyRet[0]["cfree8"]); //自由项8,string类型
string cfree9 = Convert.ToString(domBodyRet[0]["cfree9"]); //自由项9,string类型
string cfree10 = Convert.ToString(domBodyRet[0]["cfree10"]); //自由项10,string类型
string imainid = Convert.ToString(domBodyRet[0]["imainid"]); //对应单据主表id,string类型
string btaxcost = Convert.ToString(domBodyRet[0]["btaxcost"]); //单价标准,string类型
string corufts = Convert.ToString(domBodyRet[0]["corufts"]); //对应单据时间戳,string类型
double itaxprice = Convert.ToDouble(domBodyRet[0]["itaxprice"]); //含税单价,double类型
string cunitid = Convert.ToString(domBodyRet[0]["cunitid"]); //单位编码,string类型
string cinva_unit = Convert.ToString(domBodyRet[0]["cinva_unit"]); //采购单位,string类型
string cinvm_unit = Convert.ToString(domBodyRet[0]["cinvm_unit"]); //主计量,string类型
string igrouptype = Convert.ToString(domBodyRet[0]["igrouptype"]); //分组类型,string类型
int iappids = Convert.ToInt32(domBodyRet[0]["iappids"]); //请购单子表id,int类型
int isosid = Convert.ToInt32(domBodyRet[0]["isosid"]); //订单子表id,int类型
string cdefine28 = Convert.ToString(domBodyRet[0]["cdefine28"]); //表体自定义项7,string类型
string cdefine29 = Convert.ToString(domBodyRet[0]["cdefine29"]); //表体自定义项8,string类型
string cdefine30 = Convert.ToString(domBodyRet[0]["cdefine30"]); //表体自定义项9,string类型
string cdefine31 = Convert.ToString(domBodyRet[0]["cdefine31"]); //表体自定义项10,string类型
string cdefine32 = Convert.ToString(domBodyRet[0]["cdefine32"]); //表体自定义项11,string类型
string cdefine33 = Convert.ToString(domBodyRet[0]["cdefine33"]); //表体自定义项12,string类型
int cdefine34 = Convert.ToInt32(domBodyRet[0]["cdefine34"]); //表体自定义项13,int类型
int cdefine35 = Convert.ToInt32(domBodyRet[0]["cdefine35"]); //表体自定义项14,int类型
DateTime cdefine36 = Convert.ToDateTime(domBodyRet[0]["cdefine36"]); //表体自定义项15,DateTime类型
DateTime cdefine37 = Convert.ToDateTime(domBodyRet[0]["cdefine37"]); //表体自定义项16,DateTime类型
string csource = Convert.ToString(domBodyRet[0]["csource"]); //单据来源,string类型
string cinvaddcode = Convert.ToString(domBodyRet[0]["cinvaddcode"]); //存货代码,string类型
string cbcloser = Convert.ToString(domBodyRet[0]["cbcloser"]); //行关闭人,string类型
string cveninvcode = Convert.ToString(domBodyRet[0]["cveninvcode"]); //供应商存货编码,string类型
string cveninvname = Convert.ToString(domBodyRet[0]["cveninvname"]); //供应商存货名称,string类型
int ippartid = Convert.ToInt32(domBodyRet[0]["ippartid"]); //母件Id,int类型
int ipquantity = Convert.ToInt32(domBodyRet[0]["ipquantity"]); //母件数量,int类型
int iptoseq = Convert.ToInt32(domBodyRet[0]["iptoseq"]); //选配序号,int类型
string contractrowno = Convert.ToString(domBodyRet[0]["contractrowno"]); //合同标的编码,string类型
string contractrowguid = Convert.ToString(domBodyRet[0]["contractrowguid"]); //合同标的GUID,string类型
string contractcode = Convert.ToString(domBodyRet[0]["contractcode"]); //合同号,string类型
int sotype = Convert.ToInt32(domBodyRet[0]["sotype"]); //需求跟踪方式,int类型
string csocode = Convert.ToString(domBodyRet[0]["csocode"]); //需求跟踪号,string类型
string irowno = Convert.ToString(domBodyRet[0]["irowno"]); //需求跟踪行号,string类型
string sodid = Convert.ToString(domBodyRet[0]["sodid"]); //需求跟踪子表ID,string类型
DateTime cbclosetime = Convert.ToDateTime(domBodyRet[0]["cbclosetime"]); //关闭时间,DateTime类型
DateTime cbclosedate = Convert.ToDateTime(domBodyRet[0]["cbclosedate"]); //关闭日期,DateTime类型
int upsotype = Convert.ToInt32(domBodyRet[0]["upsotype"]); //上游单据类型,int类型
string cupsocode = Convert.ToString(domBodyRet[0]["cupsocode"]); //上游单据号,string类型
double iinvmpcost = Convert.ToDouble(domBodyRet[0]["iinvmpcost"]); //最高进价,double类型
string cdemandmemo = Convert.ToString(domBodyRet[0]["cdemandmemo"]); //需求分类代号说明,string类型
int iorderdid = Convert.ToInt32(domBodyRet[0]["iorderdid"]); //销售订单子表id,int类型
int iordertype = Convert.ToInt32(domBodyRet[0]["iordertype"]); //销售订单类型,int类型
string csoordercode = Convert.ToString(domBodyRet[0]["csoordercode"]); //销售订单号,string类型
int iorderseq = Convert.ToInt32(domBodyRet[0]["iorderseq"]); //销售订单行号,int类型
string bgift = Convert.ToString(domBodyRet[0]["bgift"]); //赠品,string类型
*/
#endregion
//结束本次调用,释放API资源
broker.Release();
return;
}
private void button3_Click(object sender, EventArgs e)
{
string sqlstr = @"select a.poid 'ID', b.ID 'bodyID', a.cPOID '采购订单', b.cInvCode '物料编码', c.cInvName '物料名称', c.cInvStd '规格型号', c.cInvCCode '分类', b.iQuantity '采购数量', isnull(b.freceivedqty,0) '已入库数', b.fPoRetQuantity '退货数量', b.fPoArrQuantity '累计到货数', b.iArrQTY '净到货数'
from po_pomain a
left
join po_podetails b on a.POID = b.POID
left
join inventory c on b.cInvCode = c.cInvCode
where a.iverifystateex = 2 and a.cState != 2 ";
dt = cm.ExeSQLdt(sqlstr);
if (dt.Rows.Count > 0)
{
dt_PO.DataSource = dt;
gv_PO.RefreshData();
}
else
{
MessageBox.Show("查询采购单失败!");
}
【实例截图】

【核心代码】 string varVoucherID = gv_PO.GetFocusedRowCellDisplayText("ID");
string bodyID = gv_PO.GetFocusedRowCellDisplayText("bodyID");
//第二步:构造环境上下文对象,传入login,并按需设置其它上下文参数
U8EnvContext envContext = new U8EnvContext();
envContext.U8Login = cm.u8Login;
//采购所有接口均支持内部独立事务和外部事务,默认内部事务
//如果是外部事务,则需要传递ADO.Connection对象,并将IsIndependenceTransaction属性设置为false
//envContext.BizDbConnection = new ADO.Connection();
//envContext.IsIndependenceTransaction = false;
//设置上下文参数
envContext.SetApiContext("VoucherType", 1); //上下文数据类型:int,含义:单据类型,采购订单 1
envContext.SetApiContext("bPositive", true); //上下文数据类型:bool,含义:红蓝标识:True,蓝
envContext.SetApiContext("sBillType", ""); //上下文数据类型:string,含义:为空串
envContext.SetApiContext("sBusType", "普通采购"); //上下文数据类型:string,含义:业务类型:普通采购,直运采购,受托代销
//第三步:设置API地址标识(Url)
//当前API:装载单据的地址标识为:U8API/PurchaseOrder/GetVoucherData
U8ApiAddress myApiAddress = new U8ApiAddress("U8API/PurchaseOrder/GetVoucherData");
//第四步:构造APIBroker
U8ApiBroker broker = new U8ApiBroker(myApiAddress, envContext);
//第五步:API参数赋值
//给普通参数strWhere赋值。此参数的数据类型为System.String,此参数按值传递,表示过滤条件串
broker.AssignNormalValue("strWhere", "");
//给普通参数varVoucherID赋值。此参数的数据类型为System.String,此参数按值传递,表示单据主表ID
broker.AssignNormalValue("varVoucherID", varVoucherID);
//给普通参数strLocateWhere赋值。此参数的数据类型为System.String,此参数按值传递,表示定位条件串
broker.AssignNormalValue("strLocateWhere", "");
//第六步:调用API
if (!broker.Invoke())
{
//错误处理
Exception apiEx = broker.GetException();
if (apiEx != null)
{
if (apiEx is MomSysException)
{
MomSysException sysEx = apiEx as MomSysException;
Console.WriteLine("系统异常:" sysEx.Message);
//todo:异常处理
}
else if (apiEx is MomBizException)
{
MomBizException bizEx = apiEx as MomBizException;
Console.WriteLine("API异常:" bizEx.Message);
//todo:异常处理
}
//异常原因
String exReason = broker.GetExceptionString();
if (exReason.Length != 0)
{
Console.WriteLine("异常原因:" exReason);
}
}
//结束本次调用,释放API资源
broker.Release();
return;
}
//第七步:获取返回结果
//获取返回值
//获取普通返回值。此参数的数据类型为System.String,此参数按引用传递,表示错误描述:空,正确;非空,错误
System.String result = broker.GetReturnValue() as System.String;
//获取out/inout参数值
//out参数DomHead为BO对象(表头),此BO对象的业务类型为采购订单。BO参数均按引用传递,具体请参考服务接口定义
//如果要取原始的XMLDOM对象结果,请使用GetResult("DomHead") as MSXML2.DOMDocument
BusinessObject DomHeadRet = broker.GetBoParam("DomHead");
Console.WriteLine("BO对象(表头)行数为:" DomHeadRet.RowCount); //获取BO对象(表头)的行数
//获取BO对象(表头)各字段的值。字段定义详见API服务接口定义
/****************************** 以下是必输字段 ****************************/
poid = Convert.ToInt32(DomHeadRet[0]["poid"]); //主关键字段,int类型
cbustype = Convert.ToString(DomHeadRet[0]["cbustype"]); //业务类型,int类型
dpodate = Convert.ToDateTime(DomHeadRet[0]["dpodate"]); //日期,DateTime类型
cpoid = Convert.ToString(DomHeadRet[0]["cpoid"]); //订单编号,string类型
cvenabbname = Convert.ToString(DomHeadRet[0]["cvenabbname"]); //供货单位,string类型
cexch_name = Convert.ToString(DomHeadRet[0]["cexch_name"]); //币种,string类型
nflat = Convert.ToDouble(DomHeadRet[0]["nflat"]); //汇率,double类型
cmaker = Convert.ToString(DomHeadRet[0]["cmaker"]); //制单人,string类型
cvencode = Convert.ToString(DomHeadRet[0]["cvencode"]); //供货单位编号,string类型
ufts = Convert.ToString(DomHeadRet[0]["ufts"]); //时间戳,string类型
idiscounttaxtype = Convert.ToInt32(DomHeadRet[0]["idiscounttaxtype"]); //扣税类别,int类型
contractcodet = Convert.ToString(DomHeadRet[0]["contractcodet"]); //合同号,string类型
iflowid = Convert.ToString(DomHeadRet[0]["iflowid"]); //流程ID,string类型
cflowname = Convert.ToString(DomHeadRet[0]["cflowname"]); //流程模式描述,string类型
dclosetime = Convert.ToString(DomHeadRet[0]["dclosetime"]); //关闭时间,string类型
dclosedate = Convert.ToString(DomHeadRet[0]["dclosedate"]); //关闭日期,string类型
ccontactcode = Convert.ToString(DomHeadRet[0]["ccontactcode"]); //供方联系人编码,string类型
cmobilephone = Convert.ToString(DomHeadRet[0]["cmobilephone"]); //供方联系人手机号,string类型
cappcode = Convert.ToString(DomHeadRet[0]["cappcode"]); //请购单号,string类型
csysbarcode = Convert.ToString(DomHeadRet[0]["csysbarcode"]); //单据条码,string类型
cchangverifier = Convert.ToString(DomHeadRet[0]["cchangverifier"]); //变更审批人,string类型
cchangaudittime = Convert.ToString(DomHeadRet[0]["cchangaudittime"]); //变更审批时间,string类型
cchangauditdate = Convert.ToString(DomHeadRet[0]["cchangauditdate"]); //变更审批日期,string类型
controlresult = Convert.ToString(DomHeadRet[0]["controlresult"]); //controlresult,string类型
ibg_overflag = Convert.ToString(DomHeadRet[0]["ibg_overflag"]); //预算审批状态,string类型
cbg_auditor = Convert.ToString(DomHeadRet[0]["cbg_auditor"]); //预算审批人,string类型
cbg_audittime = Convert.ToString(DomHeadRet[0]["cbg_audittime"]); //预算审批时间,string类型
#region
/***************************** 以下是非必输字段 ****************************/
/*
string ipresent = Convert.ToString(DomHeadRet[0]["ipresent"]); //现存量,string类型
DateTime cmaketime = Convert.ToDateTime(DomHeadRet[0]["cmaketime"]); //制单时间,DateTime类型
DateTime cmodifytime = Convert.ToDateTime(DomHeadRet[0]["cmodifytime"]); //修改时间,DateTime类型
DateTime caudittime = Convert.ToDateTime(DomHeadRet[0]["caudittime"]); //审核时间,DateTime类型
DateTime cauditdate = Convert.ToDateTime(DomHeadRet[0]["cauditdate"]); //审核日期,DateTime类型
DateTime cmodifydate = Convert.ToDateTime(DomHeadRet[0]["cmodifydate"]); //修改日期,DateTime类型
string creviser = Convert.ToString(DomHeadRet[0]["creviser"]); //修改人,string类型
string cptname = Convert.ToString(DomHeadRet[0]["cptname"]); //采购类型,string类型
string cvenname = Convert.ToString(DomHeadRet[0]["cvenname"]); //供应商全称,string类型
string iverifystateex = Convert.ToString(DomHeadRet[0]["iverifystateex"]); //审核状态,string类型
string ireturncount = Convert.ToString(DomHeadRet[0]["ireturncount"]); //打回次数,string类型
string iswfcontrolled = Convert.ToString(DomHeadRet[0]["iswfcontrolled"]); //是否启用工作流,string类型
string cdepname = Convert.ToString(DomHeadRet[0]["cdepname"]); //部门,string类型
string cpersonname = Convert.ToString(DomHeadRet[0]["cpersonname"]); //业务员,string类型
double itaxrate = Convert.ToDouble(DomHeadRet[0]["itaxrate"]); //税率,double类型
string cpayname = Convert.ToString(DomHeadRet[0]["cpayname"]); //付款条件,string类型
string cmemo = Convert.ToString(DomHeadRet[0]["cmemo"]); //备注,string类型
DateTime dplanarrdate = Convert.ToDateTime(DomHeadRet[0]["dplanarrdate"]); //计划到货日期,DateTime类型
string cverifier = Convert.ToString(DomHeadRet[0]["cverifier"]); //审核人,string类型
string cchanger = Convert.ToString(DomHeadRet[0]["cchanger"]); //变更人,string类型
string ccloser = Convert.ToString(DomHeadRet[0]["ccloser"]); //关闭人,string类型
int ivtid = Convert.ToInt32(DomHeadRet[0]["ivtid"]); //单据模版号,int类型
string cvenbank = Convert.ToString(DomHeadRet[0]["cvenbank"]); //供方银行名称,string类型
string cptcode = Convert.ToString(DomHeadRet[0]["cptcode"]); //采购类型编号,string类型
double myname = Convert.ToDouble(DomHeadRet[0]["myname"]); //地址,double类型
double myphone = Convert.ToDouble(DomHeadRet[0]["myphone"]); //电话,double类型
double myfax = Convert.ToDouble(DomHeadRet[0]["myfax"]); //传真,double类型
double myzip = Convert.ToDouble(DomHeadRet[0]["myzip"]); //邮编,double类型
string cvenaddress = Convert.ToString(DomHeadRet[0]["cvenaddress"]); //供方地址,string类型
string cvenphone = Convert.ToString(DomHeadRet[0]["cvenphone"]); //供方电话,string类型
string cvenfax = Convert.ToString(DomHeadRet[0]["cvenfax"]); //供方传真,string类型
string cvenpostcode = Convert.ToString(DomHeadRet[0]["cvenpostcode"]); //供方邮编,string类型
string cvenperson = Convert.ToString(DomHeadRet[0]["cvenperson"]); //供方联系人,string类型
string cvenaccount = Convert.ToString(DomHeadRet[0]["cvenaccount"]); //供方银行账号,string类型
string cvenregcode = Convert.ToString(DomHeadRet[0]["cvenregcode"]); //供方纳税登记号,string类型
string cstate = Convert.ToString(DomHeadRet[0]["cstate"]); //状态(数据库),string类型
string cperiod = Convert.ToString(DomHeadRet[0]["cperiod"]); //计划周期,string类型
string carrivalplace = Convert.ToString(DomHeadRet[0]["carrivalplace"]); //到货地址,string类型
double ibargain = Convert.ToDouble(DomHeadRet[0]["ibargain"]); //订金,double类型
string csccode = Convert.ToString(DomHeadRet[0]["csccode"]); //运输方式编号,string类型
double icost = Convert.ToDouble(DomHeadRet[0]["icost"]); //运费,double类型
string cscname = Convert.ToString(DomHeadRet[0]["cscname"]); //运输方式,string类型
string cpaycode = Convert.ToString(DomHeadRet[0]["cpaycode"]); //付款条件编号,string类型
string cpersoncode = Convert.ToString(DomHeadRet[0]["cpersoncode"]); //业务员编号,string类型
string cdepcode = Convert.ToString(DomHeadRet[0]["cdepcode"]); //部门编号,string类型
string cdefine1 = Convert.ToString(DomHeadRet[0]["cdefine1"]); //表头自定义项1,string类型
string cdefine2 = Convert.ToString(DomHeadRet[0]["cdefine2"]); //表头自定义项2,string类型
string cdefine3 = Convert.ToString(DomHeadRet[0]["cdefine3"]); //表头自定义项3,string类型
DateTime cdefine4 = Convert.ToDateTime(DomHeadRet[0]["cdefine4"]); //表头自定义项4,DateTime类型
int cdefine5 = Convert.ToInt32(DomHeadRet[0]["cdefine5"]); //表头自定义项5,int类型
DateTime cdefine6 = Convert.ToDateTime(DomHeadRet[0]["cdefine6"]); //表头自定义项6,DateTime类型
double cdefine7 = Convert.ToDouble(DomHeadRet[0]["cdefine7"]); //表头自定义项7,double类型
string cdefine8 = Convert.ToString(DomHeadRet[0]["cdefine8"]); //表头自定义项8,string类型
string cdefine9 = Convert.ToString(DomHeadRet[0]["cdefine9"]); //表头自定义项9,string类型
string cdefine10 = Convert.ToString(DomHeadRet[0]["cdefine10"]); //表头自定义项10,string类型
string cdefine11 = Convert.ToString(DomHeadRet[0]["cdefine11"]); //表头自定义项11,string类型
string cdefine12 = Convert.ToString(DomHeadRet[0]["cdefine12"]); //表头自定义项12,string类型
string cdefine13 = Convert.ToString(DomHeadRet[0]["cdefine13"]); //表头自定义项13,string类型
string cdefine14 = Convert.ToString(DomHeadRet[0]["cdefine14"]); //表头自定义项14,string类型
int cdefine15 = Convert.ToInt32(DomHeadRet[0]["cdefine15"]); //表头自定义项15,int类型
double cdefine16 = Convert.ToDouble(DomHeadRet[0]["cdefine16"]); //表头自定义项16,double类型
string cvendefine1 = Convert.ToString(DomHeadRet[0]["cvendefine1"]); //供应商自定义项1,string类型
string cvendefine2 = Convert.ToString(DomHeadRet[0]["cvendefine2"]); //供应商自定义项2,string类型
string cvendefine3 = Convert.ToString(DomHeadRet[0]["cvendefine3"]); //供应商自定义项3,string类型
string cvendefine4 = Convert.ToString(DomHeadRet[0]["cvendefine4"]); //供应商自定义项4,string类型
string cvendefine5 = Convert.ToString(DomHeadRet[0]["cvendefine5"]); //供应商自定义项5,string类型
string cvendefine6 = Convert.ToString(DomHeadRet[0]["cvendefine6"]); //供应商自定义项6,string类型
string cvendefine7 = Convert.ToString(DomHeadRet[0]["cvendefine7"]); //供应商自定义项7,string类型
string cvendefine8 = Convert.ToString(DomHeadRet[0]["cvendefine8"]); //供应商自定义项8,string类型
string cvendefine9 = Convert.ToString(DomHeadRet[0]["cvendefine9"]); //供应商自定义项9,string类型
string cvendefine10 = Convert.ToString(DomHeadRet[0]["cvendefine10"]); //供应商自定义项10,string类型
string cvenpuomprotocol = Convert.ToString(DomHeadRet[0]["cvenpuomprotocol"]); //收付款协议编码,string类型
string cvendefine11 = Convert.ToString(DomHeadRet[0]["cvendefine11"]); //供应商自定义项11,string类型
string cvenpuomprotocolname = Convert.ToString(DomHeadRet[0]["cvenpuomprotocolname"]); //收付款协议名称,string类型
string cvendefine12 = Convert.ToString(DomHeadRet[0]["cvendefine12"]); //供应商自定义项12,string类型
string cvendefine13 = Convert.ToString(DomHeadRet[0]["cvendefine13"]); //供应商自定义项13,string类型
string cvendefine14 = Convert.ToString(DomHeadRet[0]["cvendefine14"]); //供应商自定义项14,string类型
string cvendefine15 = Convert.ToString(DomHeadRet[0]["cvendefine15"]); //供应商自定义项15,string类型
string cvendefine16 = Convert.ToString(DomHeadRet[0]["cvendefine16"]); //供应商自定义项16,string类型
string clocker = Convert.ToString(DomHeadRet[0]["clocker"]); //锁定人,string类型
*/
#endregion
//out参数domBody为BO对象(表体),此BO对象的业务类型为采购订单。BO参数均按引用传递,具体请参考服务接口定义
//如果要取原始的XMLDOM对象结果,请使用GetResult("domBody") as MSXML2.DOMDocument
BusinessObject domBodyRet = broker.GetBoParam("domBody");
Console.WriteLine("BO对象(表体)行数为:" domBodyRet.RowCount); //获取BO对象(表体)的行数
//获取BO对象(表体)各字段的值。以下代码示例只取第一行。字段定义详见API服务接口定义
/****************************** 以下是必输字段 ****************************/
id = Convert.ToInt32(domBodyRet[0]["id"]); //主关键字段,int类型
cinvcode = Convert.ToString(domBodyRet[0]["cinvcode"]); //存货编码,string类型
iquantity = Convert.ToDouble(domBodyRet[0]["iquantity"]); //数量,double类型
darrivedate = Convert.ToDateTime(domBodyRet[0]["darrivedate"]); //计划到货日期,DateTime类型
ipertaxrate = Convert.ToDouble(domBodyRet[0]["ipertaxrate"]); //税率,double类型
poid1 = Convert.ToInt32(domBodyRet[0]["poid"]); //主表id,int类型
bgsp = Convert.ToInt32(domBodyRet[0]["bgsp"]); //是否检验,int类型
editprop = Convert.ToString(domBodyRet[0]["editprop"]); //编辑属性:A表新增,M表修改,D表删除,string类型
cbg_itemcode = Convert.ToString(domBodyRet[0]["cbg_itemcode"]); //预算项目编码,string类型
cbg_itemname = Convert.ToString(domBodyRet[0]["cbg_itemname"]); //预算项目,string类型
cbg_caliberkey1 = Convert.ToString(domBodyRet[0]["cbg_caliberkey1"]); //口径1类型编码,string类型
cbg_caliberkeyname1 = Convert.ToString(domBodyRet[0]["cbg_caliberkeyname1"]); //口径1类型名称,string类型
cbg_caliberkey2 = Convert.ToString(domBodyRet[0]["cbg_caliberkey2"]); //口径2类型编码,string类型
cbg_caliberkeyname2 = Convert.ToString(domBodyRet[0]["cbg_caliberkeyname2"]); //口径2类型名称,string类型
cbg_caliberkey3 = Convert.ToString(domBodyRet[0]["cbg_caliberkey3"]); //口径3类型编码,string类型
cbg_caliberkeyname3 = Convert.ToString(domBodyRet[0]["cbg_caliberkeyname3"]); //口径3类型名称,string类型
cbg_calibercode1 = Convert.ToString(domBodyRet[0]["cbg_calibercode1"]); //口径1编码,string类型
cbg_calibername1 = Convert.ToString(domBodyRet[0]["cbg_calibername1"]); //口径1名称,string类型
cbg_calibercode2 = Convert.ToString(domBodyRet[0]["cbg_calibercode2"]); //口径2编码,string类型
cbg_calibername2 = Convert.ToString(domBodyRet[0]["cbg_calibername2"]); //口径2名称,string类型
cbg_calibercode3 = Convert.ToString(domBodyRet[0]["cbg_calibercode3"]); //口径3编码,string类型
cbg_calibername3 = Convert.ToString(domBodyRet[0]["cbg_calibername3"]); //口径3名称,string类型
cbg_auditopinion = Convert.ToString(domBodyRet[0]["cbg_auditopinion"]); //审批意见,string类型
ibg_ctrl = Convert.ToString(domBodyRet[0]["ibg_ctrl"]); //是否预算控制,string类型
fexquantity = Convert.ToString(domBodyRet[0]["fexquantity"]); //累计出口数量,string类型
ivouchrowno = Convert.ToString(domBodyRet[0]["ivouchrowno"]); //行号,string类型
cbg_caliberkeyname4 = Convert.ToString(domBodyRet[0]["cbg_caliberkeyname4"]); //口径4类型名称,string类型
cbg_caliberkey5 = Convert.ToString(domBodyRet[0]["cbg_caliberkey5"]); //口径5类型编码,string类型
cbg_caliberkeyname5 = Convert.ToString(domBodyRet[0]["cbg_caliberkeyname5"]); //口径5类型名称,string类型
cbg_caliberkey6 = Convert.ToString(domBodyRet[0]["cbg_caliberkey6"]); //口径6类型编码,string类型
cbg_caliberkeyname6 = Convert.ToString(domBodyRet[0]["cbg_caliberkeyname6"]); //口径6类型名称,string类型
cbg_calibercode4 = Convert.ToString(domBodyRet[0]["cbg_calibercode4"]); //口径4编码,string类型
cbg_calibername4 = Convert.ToString(domBodyRet[0]["cbg_calibername4"]); //口径4名称,string类型
cbg_calibercode5 = Convert.ToString(domBodyRet[0]["cbg_calibercode5"]); //口径5编码,string类型
cbg_calibername5 = Convert.ToString(domBodyRet[0]["cbg_calibername5"]); //口径5名称,string类型
cbg_calibercode6 = Convert.ToString(domBodyRet[0]["cbg_calibercode6"]); //口径6编码,string类型
cbg_calibername6 = Convert.ToString(domBodyRet[0]["cbg_calibername6"]); //口径6名称,string类型
csrpolicy = Convert.ToString(domBodyRet[0]["csrpolicy"]); //供需政策,string类型
irequiretrackstyle = Convert.ToString(domBodyRet[0]["irequiretrackstyle"]); //存货需求跟踪方式,string类型
ipresentb = Convert.ToString(domBodyRet[0]["ipresentb"]); //现存量,string类型
cbg_caliberkey4 = Convert.ToString(domBodyRet[0]["cbg_caliberkey4"]); //口径4类型编码,string类型
cxjspdids = Convert.ToString(domBodyRet[0]["cxjspdids"]); //采购比价审批单子表ID,string类型
cbmemo = Convert.ToString(domBodyRet[0]["cbmemo"]); //备注,string类型
cbsysbarcode = Convert.ToString(domBodyRet[0]["cbsysbarcode"]); //单据行条码,string类型
planlotnumber = Convert.ToString(domBodyRet[0]["planlotnumber"]); //计划批号,string类型
cplanmethod = Convert.ToString(domBodyRet[0]["cplanmethod"]); //计划方法,string类型
double iquantity1 = Convert.ToDouble(domBodyRet[1]["iquantity"]);
#region
/***************************** 以下是非必输字段 ****************************/
/*
double iinvexchrate = Convert.ToDouble(domBodyRet[0]["iinvexchrate"]); //换算率,double类型
string cinvname = Convert.ToString(domBodyRet[0]["cinvname"]); //存货名称,string类型
string cinvstd = Convert.ToString(domBodyRet[0]["cinvstd"]); //规格型号,string类型
double iquotedprice = Convert.ToDouble(domBodyRet[0]["iquotedprice"]); //报价,double类型
double inum = Convert.ToDouble(domBodyRet[0]["inum"]); //件数,double类型
double iunitprice = Convert.ToDouble(domBodyRet[0]["iunitprice"]); //原币单价,double类型
double imoney = Convert.ToDouble(domBodyRet[0]["imoney"]); //原币金额,double类型
double itax = Convert.ToDouble(domBodyRet[0]["itax"]); //原币税额,double类型
double idiscount = Convert.ToDouble(domBodyRet[0]["idiscount"]); //折扣额,double类型
double inatunitprice = Convert.ToDouble(domBodyRet[0]["inatunitprice"]); //本币单价,double类型
double inatmoney = Convert.ToDouble(domBodyRet[0]["inatmoney"]); //本币金额,double类型
double inattax = Convert.ToDouble(domBodyRet[0]["inattax"]); //本币税额,double类型
double inatsum = Convert.ToDouble(domBodyRet[0]["inatsum"]); //本币价税合计,double类型
double inatdiscount = Convert.ToDouble(domBodyRet[0]["inatdiscount"]); //本币折扣额,double类型
double isum = Convert.ToDouble(domBodyRet[0]["isum"]); //原币价税合计,double类型
string cfree2 = Convert.ToString(domBodyRet[0]["cfree2"]); //自由项2,string类型
string cfree1 = Convert.ToString(domBodyRet[0]["cfree1"]); //自由项1,string类型
double bmark = Convert.ToDouble(domBodyRet[0]["bmark"]); //标志,double类型
string cdefine22 = Convert.ToString(domBodyRet[0]["cdefine22"]); //表体自定义项1,string类型
string cdefine23 = Convert.ToString(domBodyRet[0]["cdefine23"]); //表体自定义项2,string类型
string cdefine24 = Convert.ToString(domBodyRet[0]["cdefine24"]); //表体自定义项3,string类型
string cdefine25 = Convert.ToString(domBodyRet[0]["cdefine25"]); //表体自定义项4,string类型
double cdefine26 = Convert.ToDouble(domBodyRet[0]["cdefine26"]); //表体自定义项5,double类型
double cdefine27 = Convert.ToDouble(domBodyRet[0]["cdefine27"]); //表体自定义项6,double类型
string cinvdefine1 = Convert.ToString(domBodyRet[0]["cinvdefine1"]); //存货自定义项1,string类型
string cinvdefine4 = Convert.ToString(domBodyRet[0]["cinvdefine4"]); //存货自定义项4,string类型
string cinvdefine5 = Convert.ToString(domBodyRet[0]["cinvdefine5"]); //存货自定义项5,string类型
string cinvdefine6 = Convert.ToString(domBodyRet[0]["cinvdefine6"]); //存货自定义项6,string类型
string cinvdefine7 = Convert.ToString(domBodyRet[0]["cinvdefine7"]); //存货自定义项7,string类型
string cinvdefine8 = Convert.ToString(domBodyRet[0]["cinvdefine8"]); //存货自定义项8,string类型
string cinvdefine9 = Convert.ToString(domBodyRet[0]["cinvdefine9"]); //存货自定义项9,string类型
string cinvdefine10 = Convert.ToString(domBodyRet[0]["cinvdefine10"]); //存货自定义项10,string类型
string cinvdefine11 = Convert.ToString(domBodyRet[0]["cinvdefine11"]); //存货自定义项11,string类型
string cinvdefine12 = Convert.ToString(domBodyRet[0]["cinvdefine12"]); //存货自定义项12,string类型
string cinvdefine13 = Convert.ToString(domBodyRet[0]["cinvdefine13"]); //存货自定义项13,string类型
string cinvdefine14 = Convert.ToString(domBodyRet[0]["cinvdefine14"]); //存货自定义项14,string类型
string cinvdefine15 = Convert.ToString(domBodyRet[0]["cinvdefine15"]); //存货自定义项15,string类型
string cinvdefine16 = Convert.ToString(domBodyRet[0]["cinvdefine16"]); //存货自定义项16,string类型
string cinvdefine2 = Convert.ToString(domBodyRet[0]["cinvdefine2"]); //存货自定义项2,string类型
string cinvdefine3 = Convert.ToString(domBodyRet[0]["cinvdefine3"]); //存货自定义项3,string类型
string citemcode = Convert.ToString(domBodyRet[0]["citemcode"]); //项目编码,string类型
string citem_class = Convert.ToString(domBodyRet[0]["citem_class"]); //项目大类编码,string类型
string ppcids = Convert.ToString(domBodyRet[0]["ppcids"]); //采购计划子表ID,string类型
string citemname = Convert.ToString(domBodyRet[0]["citemname"]); //项目名称,string类型
string citem_name = Convert.ToString(domBodyRet[0]["citem_name"]); //项目大类名称,string类型
string cfree3 = Convert.ToString(domBodyRet[0]["cfree3"]); //自由项3,string类型
string cfree4 = Convert.ToString(domBodyRet[0]["cfree4"]); //自由项4,string类型
string cfree5 = Convert.ToString(domBodyRet[0]["cfree5"]); //自由项5,string类型
string cfree6 = Convert.ToString(domBodyRet[0]["cfree6"]); //自由项6,string类型
string cfree7 = Convert.ToString(domBodyRet[0]["cfree7"]); //自由项7,string类型
string cfree8 = Convert.ToString(domBodyRet[0]["cfree8"]); //自由项8,string类型
string cfree9 = Convert.ToString(domBodyRet[0]["cfree9"]); //自由项9,string类型
string cfree10 = Convert.ToString(domBodyRet[0]["cfree10"]); //自由项10,string类型
string imainid = Convert.ToString(domBodyRet[0]["imainid"]); //对应单据主表id,string类型
string btaxcost = Convert.ToString(domBodyRet[0]["btaxcost"]); //单价标准,string类型
string corufts = Convert.ToString(domBodyRet[0]["corufts"]); //对应单据时间戳,string类型
double itaxprice = Convert.ToDouble(domBodyRet[0]["itaxprice"]); //含税单价,double类型
string cunitid = Convert.ToString(domBodyRet[0]["cunitid"]); //单位编码,string类型
string cinva_unit = Convert.ToString(domBodyRet[0]["cinva_unit"]); //采购单位,string类型
string cinvm_unit = Convert.ToString(domBodyRet[0]["cinvm_unit"]); //主计量,string类型
string igrouptype = Convert.ToString(domBodyRet[0]["igrouptype"]); //分组类型,string类型
int iappids = Convert.ToInt32(domBodyRet[0]["iappids"]); //请购单子表id,int类型
int isosid = Convert.ToInt32(domBodyRet[0]["isosid"]); //订单子表id,int类型
string cdefine28 = Convert.ToString(domBodyRet[0]["cdefine28"]); //表体自定义项7,string类型
string cdefine29 = Convert.ToString(domBodyRet[0]["cdefine29"]); //表体自定义项8,string类型
string cdefine30 = Convert.ToString(domBodyRet[0]["cdefine30"]); //表体自定义项9,string类型
string cdefine31 = Convert.ToString(domBodyRet[0]["cdefine31"]); //表体自定义项10,string类型
string cdefine32 = Convert.ToString(domBodyRet[0]["cdefine32"]); //表体自定义项11,string类型
string cdefine33 = Convert.ToString(domBodyRet[0]["cdefine33"]); //表体自定义项12,string类型
int cdefine34 = Convert.ToInt32(domBodyRet[0]["cdefine34"]); //表体自定义项13,int类型
int cdefine35 = Convert.ToInt32(domBodyRet[0]["cdefine35"]); //表体自定义项14,int类型
DateTime cdefine36 = Convert.ToDateTime(domBodyRet[0]["cdefine36"]); //表体自定义项15,DateTime类型
DateTime cdefine37 = Convert.ToDateTime(domBodyRet[0]["cdefine37"]); //表体自定义项16,DateTime类型
string csource = Convert.ToString(domBodyRet[0]["csource"]); //单据来源,string类型
string cinvaddcode = Convert.ToString(domBodyRet[0]["cinvaddcode"]); //存货代码,string类型
string cbcloser = Convert.ToString(domBodyRet[0]["cbcloser"]); //行关闭人,string类型
string cveninvcode = Convert.ToString(domBodyRet[0]["cveninvcode"]); //供应商存货编码,string类型
string cveninvname = Convert.ToString(domBodyRet[0]["cveninvname"]); //供应商存货名称,string类型
int ippartid = Convert.ToInt32(domBodyRet[0]["ippartid"]); //母件Id,int类型
int ipquantity = Convert.ToInt32(domBodyRet[0]["ipquantity"]); //母件数量,int类型
int iptoseq = Convert.ToInt32(domBodyRet[0]["iptoseq"]); //选配序号,int类型
string contractrowno = Convert.ToString(domBodyRet[0]["contractrowno"]); //合同标的编码,string类型
string contractrowguid = Convert.ToString(domBodyRet[0]["contractrowguid"]); //合同标的GUID,string类型
string contractcode = Convert.ToString(domBodyRet[0]["contractcode"]); //合同号,string类型
int sotype = Convert.ToInt32(domBodyRet[0]["sotype"]); //需求跟踪方式,int类型
string csocode = Convert.ToString(domBodyRet[0]["csocode"]); //需求跟踪号,string类型
string irowno = Convert.ToString(domBodyRet[0]["irowno"]); //需求跟踪行号,string类型
string sodid = Convert.ToString(domBodyRet[0]["sodid"]); //需求跟踪子表ID,string类型
DateTime cbclosetime = Convert.ToDateTime(domBodyRet[0]["cbclosetime"]); //关闭时间,DateTime类型
DateTime cbclosedate = Convert.ToDateTime(domBodyRet[0]["cbclosedate"]); //关闭日期,DateTime类型
int upsotype = Convert.ToInt32(domBodyRet[0]["upsotype"]); //上游单据类型,int类型
string cupsocode = Convert.ToString(domBodyRet[0]["cupsocode"]); //上游单据号,string类型
double iinvmpcost = Convert.ToDouble(domBodyRet[0]["iinvmpcost"]); //最高进价,double类型
string cdemandmemo = Convert.ToString(domBodyRet[0]["cdemandmemo"]); //需求分类代号说明,string类型
int iorderdid = Convert.ToInt32(domBodyRet[0]["iorderdid"]); //销售订单子表id,int类型
int iordertype = Convert.ToInt32(domBodyRet[0]["iordertype"]); //销售订单类型,int类型
string csoordercode = Convert.ToString(domBodyRet[0]["csoordercode"]); //销售订单号,string类型
int iorderseq = Convert.ToInt32(domBodyRet[0]["iorderseq"]); //销售订单行号,int类型
string bgift = Convert.ToString(domBodyRet[0]["bgift"]); //赠品,string类型
*/
#endregion
//结束本次调用,释放API资源
broker.Release();
return;
}
private void button3_Click(object sender, EventArgs e)
{
string sqlstr = @"select a.poid 'ID', b.ID 'bodyID', a.cPOID '采购订单', b.cInvCode '物料编码', c.cInvName '物料名称', c.cInvStd '规格型号', c.cInvCCode '分类', b.iQuantity '采购数量', isnull(b.freceivedqty,0) '已入库数', b.fPoRetQuantity '退货数量', b.fPoArrQuantity '累计到货数', b.iArrQTY '净到货数'
from po_pomain a
left
join po_podetails b on a.POID = b.POID
left
join inventory c on b.cInvCode = c.cInvCode
where a.iverifystateex = 2 and a.cState != 2 ";
dt = cm.ExeSQLdt(sqlstr);
if (dt.Rows.Count > 0)
{
dt_PO.DataSource = dt;
gv_PO.RefreshData();
}
else
{
MessageBox.Show("查询采购单失败!");
}
好例子网口号:伸出你的我的手 — 分享!
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论