U8API——向U8数据库表导入数据

时间:2024-12-16 15:36:44

一、打开API资源管理器

U8API——向U8数据库表导入数据

U8API——向U8数据库表导入数据

U8API——向U8数据库表导入数据

替换两个引用

U8API——向U8数据库表导入数据

打开应用实例,选择相应的功能

U8API——向U8数据库表导入数据

U8API——向U8数据库表导入数据

复制相应的封装类到自己的目录下

在数据库新建临时表,与目标表相同

数据导入:

思路:先将要导入的数据导入到与U8目标表相同的临时表,再用API从临时表导入到U8目标表

//导入临时表-产成品入库、销售发货
public void ImportU8RdDis()
{
lb_info.Items.Add(DateTime.Now + " 生成开始.....");
lb_state.Text = "当前状态:正在生成数据,请勿操作..."; //从过磅记录表里查询所有未导入U8数据库的记录
List<ShippingInquiries> siListRdrecord = new List<ShippingInquiries>();
siListRdrecord = u8api.SelectAllNOu8Rdrecord10();
List<ShippingInquiries> siListSales = new List<ShippingInquiries>();
siListSales = u8api.SelectAllNOu8Sales(); //将榜单数据中未进行推送的数据,送到临时表,并执行导入U8
u8api.DeleteTemporaryTable();//插入临时表前清空之前的记录
//产成品入库
foreach (ShippingInquiries si in siListRdrecord)
{
int i = u8api.InsertU8Rdrecord10(si);//导入临时表
if (i > )
{
lb_info.Items.Add(DateTime.Now + " 正在生成过磅单的U8 <产成品> 单据,磅单编号为:" + si.NO);
bool ok_Rdrecord = U8Rdrecord10(i);//从临时表导入U8
if (ok_Rdrecord)
{
lb_info.Items.Add(DateTime.Now + " 磅单编号为:" + si.NO + "单据,生单成功");
u8api.UpdateToU8State(si.NO);
}
else
{
lb_info.Items.Add(DateTime.Now + " 磅单编号为:" + si.NO + "单据,生单失败!");
}
}
}
//发货单
foreach (ShippingInquiries si in siListSales)
{
int i = u8api.InsertU8Sales(si);//导入临时表
if (i > )
{
lb_info.Items.Add(DateTime.Now + " 正在生成过磅单的U8 <发货单> 单据,磅单编号为:" + si.NO);
bool ok_Sales = U8Sales(i);//从临时表导入U8
if(ok_Sales)
{
lb_info.Items.Add(DateTime.Now + " 磅单编号为:" + si.NO + "单据,生单成功");
u8api.UpdateToU8State(si.NO);
}
else
{
lb_info.Items.Add(DateTime.Now + " 磅单编号为:" + si.NO + "单据,生单失败!");
}
}
}
lb_info.Items.Add(DateTime.Now + " 生成结束");
lb_state.Text = "当前状态:生成数据完成,等待下一次生成开始";
}

先导入临时表,再导入U8

导入临时表代码

//将数据导入临时表-发货单表
public int InsertU8Sales(ShippingInquiries si)
{
int i = ;
conn.Open();
try
{
cmd.CommandText = "insert into TWKF_Sales_T(ivouchstate,csysbarcode,bsaleoutcreatebill,cbustype,ivtid,cdlcode,cvouchtype,cvouchname,cstcode,cstname,ddate,cdepcode,cdepname,ccuscode,ccusabbname,cexch_name,iexchrate,itaxrate,cdefine1,cDefine2,breturnflag,cverifier,cmaker,icuscreline,bfirst,sbvid,dverifydate,isale,ccusname,clastcusname,clastcustname,cauthid,brequestsign,iflowid,billafterlosssettle,bcusinvlimited,bbillbluesalelist,bbillredsalelist,bcredit,bcreditdate,bmustbook,ccreditcuscode,ccreditcusname,ioutgolden,iverifystate,iswfcontrolled,dcreatesystime,dverifysystime,bcashsale,bsigncreate,bneedbill,iprintcount,cinvoicecompany,cinvoicecompanyabbname,baccswitchflag,ccccode,bcal,zdsum,linenum,bnottogoldtax) values(@ivouchstate,@csysbarcode,@bsaleoutcreatebill,@cbustype,@ivtid,@cdlcode,@cvouchtype,@cvouchname,@cstcode,@cstname,@ddate,@cdepcode,@cdepname,@ccuscode,@ccusabbname,@cexch_name,@iexchrate,@itaxrate,@cdefine1,@cDefine2,@breturnflag,@cverifier,@cmaker,@icuscreline,@bfirst,@sbvid,@dverifydate,@isale,@ccusname,@clastcusname,@clastcustname,@cauthid,@brequestsign,@iflowid,@billafterlosssettle,@bcusinvlimited,@bbillbluesalelist,@bbillredsalelist,@bcredit,@bcreditdate,@bmustbook,@ccreditcuscode,@ccreditcusname,@ioutgolden,@iverifystate,@iswfcontrolled,@dcreatesystime,@dverifysystime,@bcashsale,@bsigncreate,@bneedbill,@iprintcount,@cinvoicecompany,@cinvoicecompanyabbname,@baccswitchflag,@ccccode,@bcal,@zdsum,@linenum,@bnottogoldtax);select @@IDENTITY;";
cmd.Parameters.Clear();
cmd.Parameters.Add("@ivouchstate", "Approved");//单据状态
cmd.Parameters.Add("@csysbarcode", "||SA01|0000000001");//单据条码
cmd.Parameters.Add("@bsaleoutcreatebill","");//销售出库开票标识
cmd.Parameters.Add("@cbustype", "普通销售");//业务类型
cmd.Parameters.Add("@ivtid", "");//单据模版号
cmd.Parameters.Add("@cdlcode", "");//发货退货单号
cmd.Parameters.Add("@cvouchtype", "");//单据类型编码
cmd.Parameters.Add("@cvouchname", "发货单");//单据类型名称
cmd.Parameters.Add("@cstcode", "");//销售类型编码
cmd.Parameters.Add("@cstname", "西坡石厂销售");//销售类型名称
cmd.Parameters.Add("@ddate", si.GrossWeightTime);//单据日期
cmd.Parameters.Add("@cdepcode", si.cInvCode.Substring(, ));//部门编码
cmd.Parameters.Add("@cdepname", "总经办");//部门名称//通过哪个表由部门编码查询部门名称▲▲▲▲▲▲▲▲
cmd.Parameters.Add("@ccuscode", si.cCusCode);//客户编码
cmd.Parameters.Add("@ccusabbname", si.ReceivingUnit);//客户简称
cmd.Parameters.Add("@cexch_name", "人民币");//币种名称
cmd.Parameters.Add("@iexchrate", "");//汇率
cmd.Parameters.Add("@itaxrate", "");//表头税率
cmd.Parameters.Add("@cDefine1", si.ReceivingUnit);//收货单位
cmd.Parameters.Add("@cDefine2", si.NO);//榜单单号
cmd.Parameters.Add("@breturnflag", "");//退货标志
cmd.Parameters.Add("@cverifier", "demo");//审核人
cmd.Parameters.Add("@cmaker", "demo");//制单人
cmd.Parameters.Add("@icuscreline", "");//信用额度
cmd.Parameters.Add("@bfirst", "");//销售期初标志
cmd.Parameters.Add("@sbvid", "");//销售发票主表标识
cmd.Parameters.Add("@dverifydate", si.GrossWeightTime);//审核日期
cmd.Parameters.Add("@isale", "");//是否先发货
cmd.Parameters.Add("@ccusname", si.ReceivingUnit);//客户名称
cmd.Parameters.Add("@clastcusname", si.ReceivingUnit);
cmd.Parameters.Add("@clastcustname", si.ReceivingUnit);
cmd.Parameters.Add("@cauthid", si.cCusCode);//权限ID
cmd.Parameters.Add("@brequestsign", "");//请求标识
cmd.Parameters.Add("@iflowid", "");//流程id
cmd.Parameters.Add("@billafterlosssettle", "");//必须签回处理完成才能开票(签回)
cmd.Parameters.Add("@bcusinvlimited", "");//允许限销控制
cmd.Parameters.Add("@bbillbluesalelist", "");//销售发货单/退货单(蓝票)
cmd.Parameters.Add("@bbillredsalelist", "");//销售发货单/退货单(红票)
cmd.Parameters.Add("@bcredit", "否");//是否控制信用额度
cmd.Parameters.Add("@bcreditdate", "");//是否控制信用期限
cmd.Parameters.Add("@bmustbook", "");//必有定金
cmd.Parameters.Add("@ccreditcuscode", si.cCusCode);//信用单位编号
cmd.Parameters.Add("@ccreditcusname", si.ReceivingUnit);//信用单位名称
cmd.Parameters.Add("@ioutgolden", "");//金税导出次数
cmd.Parameters.Add("@iverifystate", "");//系统保留
cmd.Parameters.Add("@iswfcontrolled", "");//启用工作流
cmd.Parameters.Add("@dcreatesystime", si.GrossWeightTime);//制单时间
cmd.Parameters.Add("@dverifysystime", si.GrossWeightTime);//审核时间
cmd.Parameters.Add("@bcashsale", "");//现款结算
cmd.Parameters.Add("@bsigncreate", "");//签回损失生成
cmd.Parameters.Add("@bneedbill", "");//是否需要开票
cmd.Parameters.Add("@iprintcount", "");//打印次数
cmd.Parameters.Add("@cinvoicecompany", si.cCusCode);//开票单位
cmd.Parameters.Add("@cinvoicecompanyabbname", si.ReceivingUnit);//开票单位简称
cmd.Parameters.Add("@baccswitchflag", "");//存货选项切换
cmd.Parameters.Add("@ccccode", si.cInvCode.Substring(, ));
cmd.Parameters.Add("@bcal", "");//折算方式
cmd.Parameters.Add("@zdsum", "0.00");//zdsum
cmd.Parameters.Add("@linenum", "");//linenum
cmd.Parameters.Add("@bnottogoldtax", "");//不导出到金税 i = Convert.ToInt32(cmd.ExecuteScalar()); if (i > )
{
cmd.CommandText = "insert into TWKF_Sales_W(cwhcode,cinvcode,bservice,cinvname,cinvstd,cinvm_unit,igrouptype,cgroupcode,cbsysbarcode,iquantity,iquotedprice,itaxunitprice,iunitprice,imoney,itax,idiscount,dlid,inatunitprice,inatmoney,inattax,inatsum,inatdiscount,isum,binvbatch,cwhvaluestyle,bfree1,bfree2,bfree3,bfree4,bfree5,bfree6,bfree7,bfree8,bfree9,bfree10,bsalepricefree1,bsalepricefree2,bsalepricefree3,bsalepricefree4,bsalepricefree5,bsalepricefree6,bsalepricefree7,bsalepricefree8,bsalepricefree9,bsalepricefree10,bbatchcreate,bbatchproperty1,bbatchproperty2,bbatchproperty3,bbatchproperty4,bbatchproperty5,bbatchproperty6,bbatchproperty7,bbatchproperty8,bbatchproperty9,bbatchproperty10,ivolume,kl,kl2,binvtype,itb,binvquality,cmassunit,itaxrate,cDefine22,idlsid,isettleprice,dkl1,dkl2,fsalecost,fsaleprice,cinvccode,bgsp,btrack,bSpecialties,bisstqc,foutquantity,bsettleall,csettleall,ccomunitcode,batomodel,bptomodel,bqaneedcheck,bgift,bsaleprice,bqaurgency,bqachecking,btracksalebill,bqachecked,iqaquantity,iqanum,fretsum,irowno,binvmodel,csrpolicy,fsumsignquantity,fsumsignnum,funsignquantity,fcusminprice,iexpiratdatecalcu,fretqtywkp,fretqtyykp,bcosting,bneedsign,bsignover,autoid2,bproxywh,tbquantity,dblpreexchmomey,dblpremomey,bcontrolserial,bserial,bneedloss,frlossqty,isettletype,bbatch,bcode,bmpforderclosed,fappretwkpqty,cinvcname,biacreatebill,fstockquan,fstockquano,fcanusequan,fcanusequano,fretailrealamount,fretailsettleamount,cDefine23,cDefine24) values(@cwhcode,@cinvcode,@bservice,@cinvname,@cinvstd,@cinvm_unit,@igrouptype,@cgroupcode,@cbsysbarcode,@iquantity,@iquotedprice,@itaxunitprice,@iunitprice,@imoney,@itax,@idiscount,@dlid,@inatunitprice,@inatmoney,@inattax,@inatsum,@inatdiscount,@isum,@binvbatch,@cwhvaluestyle,@bfree1,@bfree2,@bfree3,@bfree4,@bfree5,@bfree6,@bfree7,@bfree8,@bfree9,@bfree10,@bsalepricefree1,@bsalepricefree2,@bsalepricefree3,@bsalepricefree4,@bsalepricefree5,@bsalepricefree6,@bsalepricefree7,@bsalepricefree8,@bsalepricefree9,@bsalepricefree10,@bbatchcreate,@bbatchproperty1,@bbatchproperty2,@bbatchproperty3,@bbatchproperty4,@bbatchproperty5,@bbatchproperty6,@bbatchproperty7,@bbatchproperty8,@bbatchproperty9,@bbatchproperty10,@ivolume,@kl,@kl2,@binvtype,@itb,@binvquality,@cmassunit,@itaxrate,@cDefine22,@idlsid,@isettleprice,@dkl1,@dkl2,@fsalecost,@fsaleprice,@cinvccode,@bgsp,@btrack,@bSpecialties,@bisstqc,@foutquantity,@bsettleall,@csettleall,@ccomunitcode,@batomodel,@bptomodel,@bqaneedcheck,@bgift,@bsaleprice,@bqaurgency,@bqachecking,@btracksalebill,@bqachecked,@iqaquantity,@iqanum,@fretsum,@irowno,@binvmodel,@csrpolicy,@fsumsignquantity,@fsumsignnum,@funsignquantity,@fcusminprice,@iexpiratdatecalcu,@fretqtywkp,@fretqtyykp,@bcosting,@bneedsign,@bsignover,@autoid2,@bproxywh,@tbquantity,@dblpreexchmomey,@dblpremomey,@bcontrolserial,@bserial,@bneedloss,@frlossqty,@isettletype,@bbatch,@bcode,@bmpforderclosed,@fappretwkpqty,@cinvcname,@biacreatebill,@fstockquan,@fstockquano,@fcanusequan,@fcanusequano,@fretailrealamount,@fretailsettleamount,@cDefine23,@cDefine24)";
cmd.Parameters.Clear();
//cmd.Parameters.Add("@cwhname",);//仓库名称
cmd.Parameters.Add("@cwhcode","");//仓库编码
cmd.Parameters.Add("@cinvcode",si.cInvCode);//存货编码
cmd.Parameters.Add("@bservice","");//是否应税劳务
cmd.Parameters.Add("@cinvname",si.cInvName);//存货名称
cmd.Parameters.Add("@cinvstd",si.Specifications);//规格型号
cmd.Parameters.Add("@cinvm_unit","吨");//主计量单位
cmd.Parameters.Add("@igrouptype","");//计量单位组类别
cmd.Parameters.Add("@cgroupcode","");//计量单位组编码
cmd.Parameters.Add("@cbsysbarcode","||SA01|0000000001|1");//单据行条码
cmd.Parameters.Add("@iquantity",si.NetWeight);//数量
cmd.Parameters.Add("@iquotedprice",si.UnitPrice);//报价
cmd.Parameters.Add("@itaxunitprice",si.UnitPrice);//原币含税单价
cmd.Parameters.Add("@iunitprice",si.UnitPrice);//原币无税单价
cmd.Parameters.Add("@imoney",si.NetWeight*si.UnitPrice);//原币无税金额
cmd.Parameters.Add("@itax","0.00");//原币税额
cmd.Parameters.Add("@idiscount","0.00");//原币折扣额
cmd.Parameters.Add("@dlid",i);//发货退货单主表标识
cmd.Parameters.Add("@inatunitprice","1.0000000000");//本币无税单价
cmd.Parameters.Add("@inatmoney",si.NetWeight*si.UnitPrice);//本币无税金额
cmd.Parameters.Add("@inattax","0.00");//本币税额
cmd.Parameters.Add("@inatsum",si.NetWeight*si.UnitPrice);//本币价税合计
cmd.Parameters.Add("@inatdiscount","0.00");//本币折扣额
cmd.Parameters.Add("@isum",si.NetWeight*si.UnitPrice);//原币价税合计
cmd.Parameters.Add("@binvbatch","");//是否批次管理
cmd.Parameters.Add("@cwhvaluestyle","全月平均法");//计价方式
cmd.Parameters.Add("@bfree1","");//存货是否有*项
cmd.Parameters.Add("@bfree2","");//存货是否有*项
cmd.Parameters.Add("@bfree3","");//存货是否有*项
cmd.Parameters.Add("@bfree4","");//存货是否有*项
cmd.Parameters.Add("@bfree5","");//存货是否有*项
cmd.Parameters.Add("@bfree6","");//存货是否有*项
cmd.Parameters.Add("@bfree7","");//存货是否有*项
cmd.Parameters.Add("@bfree8","");//存货是否有*项
cmd.Parameters.Add("@bfree9","");//存货是否有*项
cmd.Parameters.Add("@bfree10","");//存货是否有*项
cmd.Parameters.Add("@bsalepricefree1","");//销售定价*项
cmd.Parameters.Add("@bsalepricefree2","");//销售定价*项
cmd.Parameters.Add("@bsalepricefree3","");//销售定价*项
cmd.Parameters.Add("@bsalepricefree4","");//销售定价*项
cmd.Parameters.Add("@bsalepricefree5","");//销售定价*项
cmd.Parameters.Add("@bsalepricefree6","");//销售定价*项
cmd.Parameters.Add("@bsalepricefree7","");//销售定价*项
cmd.Parameters.Add("@bsalepricefree8","");//销售定价*项
cmd.Parameters.Add("@bsalepricefree9","");//销售定价*项
cmd.Parameters.Add("@bsalepricefree10","");//销售定价*项
cmd.Parameters.Add("@bbatchcreate","");//是否建立批次档案
cmd.Parameters.Add("@bbatchproperty1","");//是否启用批次属性
cmd.Parameters.Add("@bbatchproperty2","");//是否启用批次属性
cmd.Parameters.Add("@bbatchproperty3","");//是否启用批次属性
cmd.Parameters.Add("@bbatchproperty4","");//是否启用批次属性
cmd.Parameters.Add("@bbatchproperty5","");//是否启用批次属性
cmd.Parameters.Add("@bbatchproperty6","");//是否启用批次属性
cmd.Parameters.Add("@bbatchproperty7","");//是否启用批次属性
cmd.Parameters.Add("@bbatchproperty8","");//是否启用批次属性
cmd.Parameters.Add("@bbatchproperty9","");//是否启用批次属性
cmd.Parameters.Add("@bbatchproperty10","");//是否启用批次属性
cmd.Parameters.Add("@ivolume","");//单位体积
cmd.Parameters.Add("@kl","100.0000000000");//扣率
cmd.Parameters.Add("@kl2","100.0000000000");//二次扣率
cmd.Parameters.Add("@binvtype","");//是否折扣
cmd.Parameters.Add("@itb","正常");//退补标志
cmd.Parameters.Add("@binvquality","");//是否保质期管理
cmd.Parameters.Add("@cmassunit","");//保质期单位
cmd.Parameters.Add("@itaxrate","0.0000000000");//税率
cmd.Parameters.Add("@cDefine22", si.CarCode);//车号
cmd.Parameters.Add("@idlsid","");//发货退货单子表标识2 ??????????????????????????
cmd.Parameters.Add("@isettleprice",si.UnitPrice);//结算单价
cmd.Parameters.Add("@dkl1","0.0000000000");//倒扣1
cmd.Parameters.Add("@dkl2","0.0000000000");//倒扣2
cmd.Parameters.Add("@fsalecost",si.UnitPrice);//零售单价
cmd.Parameters.Add("@fsaleprice",si.NetWeight*si.UnitPrice);//零售金额
cmd.Parameters.Add("@cinvccode",si.cInvCode.Substring(,));//存货大类编码
cmd.Parameters.Add("@bgsp","否");//是否质检
cmd.Parameters.Add("@btrack","");//是否出库跟踪入库
cmd.Parameters.Add("@bSpecialties","");//是否特殊药品
cmd.Parameters.Add("@bisstqc","");//库存期初标记
cmd.Parameters.Add("@foutquantity",si.SumNetWeight);//累计出库数量
cmd.Parameters.Add("@bsettleall","");//结算标志
cmd.Parameters.Add("@csettleall","未关闭");//关闭标志
cmd.Parameters.Add("@ccomunitcode","");//主计量单位编码(若要从表里查询,可以从qt_query_batchsn_ls中查询)
cmd.Parameters.Add("@batomodel","否");//是否ATO模型
cmd.Parameters.Add("@bptomodel","否");//是否PTO模型
cmd.Parameters.Add("@bqaneedcheck","否");//是否质检
cmd.Parameters.Add("@bgift","");//是否赠品
cmd.Parameters.Add("@bsaleprice","");//报价含税标识
cmd.Parameters.Add("@bqaurgency","否");//是否急料
cmd.Parameters.Add("@bqachecking","否");//是否在检
cmd.Parameters.Add("@btracksalebill","");//PE跟单
cmd.Parameters.Add("@bqachecked","否");//是否报检
cmd.Parameters.Add("@iqaquantity","0.0000000000");//检验合格数量
cmd.Parameters.Add("@iqanum","0.0000000000");//检验合格件数
cmd.Parameters.Add("@fretsum","0.000000000");//退货金额
cmd.Parameters.Add("@irowno","");//行号????????????????????????????????????????????????????????????
cmd.Parameters.Add("@binvmodel","否");//模型
cmd.Parameters.Add("@csrpolicy","PE");//供需政策
cmd.Parameters.Add("@fsumsignquantity","0.000000000");//签回数量
cmd.Parameters.Add("@fsumsignnum","0.000000000");//签回件数
cmd.Parameters.Add("@funsignquantity",si.NetWeight);//未签回数量
cmd.Parameters.Add("@fcusminprice","0.000000000");//客户最低售价 ????????????????????????????????????
cmd.Parameters.Add("@iexpiratdatecalcu","");//有效期推算方式
cmd.Parameters.Add("@fretqtywkp","0.000000000");//未开票退货数量
cmd.Parameters.Add("@fretqtyykp","0.000000000");//已开票退货数量
cmd.Parameters.Add("@bcosting","");//是否记账
cmd.Parameters.Add("@bneedsign","");//需要签回
cmd.Parameters.Add("@bsignover","");//发货签回完成
cmd.Parameters.Add("@autoid2",i);//发货单子表ID
cmd.Parameters.Add("@bproxywh","");//代管仓
cmd.Parameters.Add("@tbquantity","0.000000000");//退补数量
cmd.Parameters.Add("@dblpreexchmomey","0.000000");//预收款原币金额
cmd.Parameters.Add("@dblpremomey","0.000000");//预收款本币金额
cmd.Parameters.Add("@bcontrolserial", "");//控制序列号
cmd.Parameters.Add("@bserial", "");//是否有序列号管理
cmd.Parameters.Add("@bneedloss", "");//需要损失处理
cmd.Parameters.Add("@frlossqty", "0.000000");//合理损耗数量
cmd.Parameters.Add("@isettletype", "");//责任承担处理
cmd.Parameters.Add("@bbatch", "");//是否已指定批号
cmd.Parameters.Add("@bcode", "");//是否已指定入库单号
cmd.Parameters.Add("@bmpforderclosed", "");//订单关闭标识
cmd.Parameters.Add("@fappretwkpqty", "0.000000000");//未开票退货申请数量
cmd.Parameters.Add("@cinvcname", si.cInvName);//存货名称
cmd.Parameters.Add("@biacreatebill", "");//存货核算参照销售出库开票标识
cmd.Parameters.Add("@fstockquan", "0.000000000");//现存数量
cmd.Parameters.Add("@fstockquano", "0.000000000");//现存件数
cmd.Parameters.Add("@fcanusequan", "0.000000000");//可用数量
cmd.Parameters.Add("@fcanusequano", "0.000000000");//可用件数
cmd.Parameters.Add("@fretailrealamount", "0.000000000");//
cmd.Parameters.Add("@fretailsettleamount", "0.000000000");//
cmd.Parameters.Add("@cDefine23", si.TareTime.ToString());//进场时间
cmd.Parameters.Add("@cDefine24", si.CardNumber);//卡号 cmd.ExecuteNonQuery(); }
}
catch
{
conn.Close();
} finally
{
conn.Close();
} return i;
}

导入临时表代码,注意字段是否为空

U8API导入U8代码

/// <summary>
/// 发货单
/// </summary>
public bool U8Sales(int ID)
{
bool ok = false;
string Ex = "";
DispatchList.DispatchListAdd(U8Login, ID, out Ex);
if (Ex.Length == )
{
//lb_info.Items.Add("生成单据失败,原因如下:" + Ex);
}
else
{
ok = true;
}
return ok;
}

执行U8API

public static void DispatchListAdd(U8Login.clsLogin u8Login, int dlid, out string Ex)
{
string Ex0 = "";
//第二步:构造环境上下文对象,传入login,并按需设置其它上下文参数
U8EnvContext envContext = new U8EnvContext();
envContext.U8Login = u8Login; //销售所有接口均支持内部独立事务和外部事务,默认内部事务
//如果是外部事务,则需要传递ADO.Connection对象,并将IsIndependenceTransaction属性设置为false
//envContext.BizDbConnection = new ADO.Connection();
//envContext.IsIndependenceTransaction = false; //设置上下文参数
envContext.SetApiContext("VoucherType", ""); //上下文数据类型:int,含义:单据类型:9 //第三步:设置API地址标识(Url)
//当前API:新增或修改的地址标识为:U8API/Consignment/Save
U8ApiAddress myApiAddress = new U8ApiAddress("U8API/Consignment/Save"); //第四步:构造APIBroker
U8ApiBroker broker = new U8ApiBroker(myApiAddress, envContext); //第五步:API参数赋值 //给BO表头参数domHead赋值,此BO参数的业务类型为发货单,属表头参数。BO参数均按引用传递
//提示:给BO表头参数domHead赋值有两种方法 //方法一是直接传入MSXML2.DOMDocumentClass对象
//broker.AssignNormalValue("domHead", new MSXML2.DOMDocumentClass())
ADODB.Connection conn = new ADODB.ConnectionClass();
ADODB.Recordset rs = new ADODB.RecordsetClass(); MSXML2.DOMDocument domhead = new MSXML2.DOMDocumentClass(); string strConn = "Provider=SQLOLEDB;Initial Catalog=UFDATA_002_2014;Data Source=127.0.0.1;";
//string strConn = "Provider=SQLOLEDB;Initial Catalog=UFDATA_999_2017;Data Source=127.0.0.1;"; conn.Open(strConn, "sa", u8Login.SysPassword, );
string sql = "select top 1 * from TWKF_Sales_T where dlid='" + dlid + "'";
rs.Open(sql, conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic, -); rs.Save(domhead, ADODB.PersistFormatEnum.adPersistXML);
U8APIHelper.FormatDom(ref domhead, "A");
broker.AssignNormalValue("DomHead", domhead);
domhead.selectSingleNode("//rs:data/z:row").attributes.getNamedItem("dlid").nodeValue = ""; MSXML2.DOMDocument domBody = new MSXML2.DOMDocumentClass();
//domBody.RowCount = 1; ADODB.Connection conn1 = new ADODB.ConnectionClass();
ADODB.Recordset rs1 = new ADODB.RecordsetClass();
string strConn1 = "Provider=SQLOLEDB;Initial Catalog=UFDATA_002_2014;Data Source=127.0.0.1;";
//string strConn1 = "Provider=SQLOLEDB;Initial Catalog=UFDATA_999_2017;Data Source=127.0.0.1;"; conn1.Open(strConn1, "sa", u8Login.SysPassword, );
sql = "select top 1 * from TWKF_Sales_W where dlid='" + dlid + "'";
rs1.Open(sql, conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic, -); rs1.Save(domBody, ADODB.PersistFormatEnum.adPersistXML);
U8APIHelper.FormatDom(ref domBody, "A");
broker.AssignNormalValue("domBody", domBody);
domBody.selectSingleNode("//rs:data/z:row").attributes.getNamedItem("dlid").nodeValue = "";
domBody.selectSingleNode("//rs:data/z:row").attributes.getNamedItem("autoid").nodeValue = ""; //给普通参数VoucherState赋值。此参数的数据类型为int,此参数按值传递,表示状态:0增加;1修改
broker.AssignNormalValue("VoucherState", ); //该参数vNewID为INOUT型普通参数。此参数的数据类型为string,此参数按值传递。在API调用返回时,可以通过GetResult("vNewID")获取其值
broker.AssignNormalValue("vNewID", ""); //给普通参数DomConfig赋值。此参数的数据类型为MSXML2.IXMLDOMDocument2,此参数按引用传递,表示ATO,PTO选配
MSXML2.IXMLDOMDocument2 domMsg = new MSXML2.DOMDocumentClass();
broker.AssignNormalValue("DomConfig", domMsg); //第六步:调用API
if (!broker.Invoke())
{
//错误处理
Exception apiEx = broker.GetException();
if (apiEx != null)
{
if (apiEx is MomSysException)
{
MomSysException sysEx = apiEx as MomSysException;
Ex0 += "系统异常:" + sysEx.Message;
//todo:异常处理
}
else if (apiEx is MomBizException)
{
MomBizException bizEx = apiEx as MomBizException;
Ex0 += "API异常:" + bizEx.Message;
//todo:异常处理
}
//异常原因
String exReason = broker.GetExceptionString();
if (exReason.Length != )
{
Ex0 += "异常原因:" + exReason;
}
}
//结束本次调用,释放API资源
broker.Release();
Ex = Ex0;
return;
} //第七步:获取返回结果 //获取返回值
//获取普通返回值。此返回值数据类型为System.String,此参数按值传递,表示成功返回空串
System.String result = broker.GetReturnValue() as System.String; //获取out/inout参数值 //获取普通INOUT参数vNewID。此返回值数据类型为string,在使用该参数之前,请判断是否为空
string vNewIDRet = broker.GetResult("vNewID") as string;
Ex0 += vNewIDRet; //结束本次调用,释放API资源
broker.Release();
Ex = Ex0;
return;
}

U8API

修改连接字符串和查询语句(注意大小写)

U8API——向U8数据库表导入数据