首页 > 代码库 > U8API——向U8数据库表导入数据
U8API——向U8数据库表导入数据
一、打开API资源管理器
替换两个引用
打开应用实例,选择相应的功能
复制相应的封装类到自己的目录下
在数据库新建临时表,与目标表相同
数据导入:
思路:先将要导入的数据导入到与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 > 0) { 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 > 0) { 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 = "当前状态:生成数据完成,等待下一次生成开始"; }
导入临时表代码
//将数据导入临时表-发货单表 public int InsertU8Sales(ShippingInquiries si) { int i = 0; 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","0");//销售出库开票标识 cmd.Parameters.Add("@cbustype", "普通销售");//业务类型 cmd.Parameters.Add("@ivtid", "71");//单据模版号 cmd.Parameters.Add("@cdlcode", "0000000001");//发货退货单号 cmd.Parameters.Add("@cvouchtype", "05");//单据类型编码 cmd.Parameters.Add("@cvouchname", "发货单");//单据类型名称 cmd.Parameters.Add("@cstcode", "1");//销售类型编码 cmd.Parameters.Add("@cstname", "西坡石厂销售");//销售类型名称 cmd.Parameters.Add("@ddate", si.GrossWeightTime);//单据日期 cmd.Parameters.Add("@cdepcode", si.cInvCode.Substring(0, 2));//部门编码 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", "1");//汇率 cmd.Parameters.Add("@itaxrate", "0");//表头税率 cmd.Parameters.Add("@cDefine1", si.ReceivingUnit);//收货单位 cmd.Parameters.Add("@cDefine2", si.NO);//榜单单号 cmd.Parameters.Add("@breturnflag", "0");//退货标志 cmd.Parameters.Add("@cverifier", "demo");//审核人 cmd.Parameters.Add("@cmaker", "demo");//制单人 cmd.Parameters.Add("@icuscreline", "0");//信用额度 cmd.Parameters.Add("@bfirst", "0");//销售期初标志 cmd.Parameters.Add("@sbvid", "0");//销售发票主表标识 cmd.Parameters.Add("@dverifydate", si.GrossWeightTime);//审核日期 cmd.Parameters.Add("@isale", "0");//是否先发货 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", "1");//请求标识 cmd.Parameters.Add("@iflowid", "0");//流程id cmd.Parameters.Add("@billafterlosssettle", "0");//必须签回处理完成才能开票(签回) cmd.Parameters.Add("@bcusinvlimited", "0");//允许限销控制 cmd.Parameters.Add("@bbillbluesalelist", "0");//销售发货单/退货单(蓝票) cmd.Parameters.Add("@bbillredsalelist", "0");//销售发货单/退货单(红票) cmd.Parameters.Add("@bcredit", "否");//是否控制信用额度 cmd.Parameters.Add("@bcreditdate", "0");//是否控制信用期限 cmd.Parameters.Add("@bmustbook", "0");//必有定金 cmd.Parameters.Add("@ccreditcuscode", si.cCusCode);//信用单位编号 cmd.Parameters.Add("@ccreditcusname", si.ReceivingUnit);//信用单位名称 cmd.Parameters.Add("@ioutgolden", "0");//金税导出次数 cmd.Parameters.Add("@iverifystate", "0");//系统保留 cmd.Parameters.Add("@iswfcontrolled", "0");//启用工作流 cmd.Parameters.Add("@dcreatesystime", si.GrossWeightTime);//制单时间 cmd.Parameters.Add("@dverifysystime", si.GrossWeightTime);//审核时间 cmd.Parameters.Add("@bcashsale", "0");//现款结算 cmd.Parameters.Add("@bsigncreate", "0");//签回损失生成 cmd.Parameters.Add("@bneedbill", "1");//是否需要开票 cmd.Parameters.Add("@iprintcount", "0");//打印次数 cmd.Parameters.Add("@cinvoicecompany", si.cCusCode);//开票单位 cmd.Parameters.Add("@cinvoicecompanyabbname", si.ReceivingUnit);//开票单位简称 cmd.Parameters.Add("@baccswitchflag", "0");//存货选项切换 cmd.Parameters.Add("@ccccode", si.cInvCode.Substring(0, 2)); cmd.Parameters.Add("@bcal", "0");//折算方式 cmd.Parameters.Add("@zdsum", "0.00");//zdsum cmd.Parameters.Add("@linenum", "0");//linenum cmd.Parameters.Add("@bnottogoldtax", "0");//不导出到金税 i = Convert.ToInt32(cmd.ExecuteScalar()); if (i > 0) { 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","0");//仓库编码 cmd.Parameters.Add("@cinvcode",si.cInvCode);//存货编码 cmd.Parameters.Add("@bservice","0");//是否应税劳务 cmd.Parameters.Add("@cinvname",si.cInvName);//存货名称 cmd.Parameters.Add("@cinvstd",si.Specifications);//规格型号 cmd.Parameters.Add("@cinvm_unit","吨");//主计量单位 cmd.Parameters.Add("@igrouptype","0");//计量单位组类别 cmd.Parameters.Add("@cgroupcode","01");//计量单位组编码 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","0");//是否批次管理 cmd.Parameters.Add("@cwhvaluestyle","全月平均法");//计价方式 cmd.Parameters.Add("@bfree1","0");//存货是否有自由项 cmd.Parameters.Add("@bfree2","0");//存货是否有自由项 cmd.Parameters.Add("@bfree3","0");//存货是否有自由项 cmd.Parameters.Add("@bfree4","0");//存货是否有自由项 cmd.Parameters.Add("@bfree5","0");//存货是否有自由项 cmd.Parameters.Add("@bfree6","0");//存货是否有自由项 cmd.Parameters.Add("@bfree7","0");//存货是否有自由项 cmd.Parameters.Add("@bfree8","0");//存货是否有自由项 cmd.Parameters.Add("@bfree9","0");//存货是否有自由项 cmd.Parameters.Add("@bfree10","0");//存货是否有自由项 cmd.Parameters.Add("@bsalepricefree1","0");//销售定价自由项 cmd.Parameters.Add("@bsalepricefree2","0");//销售定价自由项 cmd.Parameters.Add("@bsalepricefree3","0");//销售定价自由项 cmd.Parameters.Add("@bsalepricefree4","0");//销售定价自由项 cmd.Parameters.Add("@bsalepricefree5","0");//销售定价自由项 cmd.Parameters.Add("@bsalepricefree6","0");//销售定价自由项 cmd.Parameters.Add("@bsalepricefree7","0");//销售定价自由项 cmd.Parameters.Add("@bsalepricefree8","0");//销售定价自由项 cmd.Parameters.Add("@bsalepricefree9","0");//销售定价自由项 cmd.Parameters.Add("@bsalepricefree10","0");//销售定价自由项 cmd.Parameters.Add("@bbatchcreate","0");//是否建立批次档案 cmd.Parameters.Add("@bbatchproperty1","0");//是否启用批次属性 cmd.Parameters.Add("@bbatchproperty2","0");//是否启用批次属性 cmd.Parameters.Add("@bbatchproperty3","0");//是否启用批次属性 cmd.Parameters.Add("@bbatchproperty4","0");//是否启用批次属性 cmd.Parameters.Add("@bbatchproperty5","0");//是否启用批次属性 cmd.Parameters.Add("@bbatchproperty6","0");//是否启用批次属性 cmd.Parameters.Add("@bbatchproperty7","0");//是否启用批次属性 cmd.Parameters.Add("@bbatchproperty8","0");//是否启用批次属性 cmd.Parameters.Add("@bbatchproperty9","0");//是否启用批次属性 cmd.Parameters.Add("@bbatchproperty10","0");//是否启用批次属性 cmd.Parameters.Add("@ivolume","0");//单位体积 cmd.Parameters.Add("@kl","100.0000000000");//扣率 cmd.Parameters.Add("@kl2","100.0000000000");//二次扣率 cmd.Parameters.Add("@binvtype","0");//是否折扣 cmd.Parameters.Add("@itb","正常");//退补标志 cmd.Parameters.Add("@binvquality","0");//是否保质期管理 cmd.Parameters.Add("@cmassunit","");//保质期单位 cmd.Parameters.Add("@itaxrate","0.0000000000");//税率 cmd.Parameters.Add("@cDefine22", si.CarCode);//车号 cmd.Parameters.Add("@idlsid","1000000002");//发货退货单子表标识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(0,2));//存货大类编码 cmd.Parameters.Add("@bgsp","否");//是否质检 cmd.Parameters.Add("@btrack","0");//是否出库跟踪入库 cmd.Parameters.Add("@bSpecialties","0");//是否特殊药品 cmd.Parameters.Add("@bisstqc","0");//库存期初标记 cmd.Parameters.Add("@foutquantity",si.SumNetWeight);//累计出库数量 cmd.Parameters.Add("@bsettleall","0");//结算标志 cmd.Parameters.Add("@csettleall","未关闭");//关闭标志 cmd.Parameters.Add("@ccomunitcode","01016");//主计量单位编码(若要从表里查询,可以从qt_query_batchsn_ls中查询) cmd.Parameters.Add("@batomodel","否");//是否ATO模型 cmd.Parameters.Add("@bptomodel","否");//是否PTO模型 cmd.Parameters.Add("@bqaneedcheck","否");//是否质检 cmd.Parameters.Add("@bgift","0");//是否赠品 cmd.Parameters.Add("@bsaleprice","1");//报价含税标识 cmd.Parameters.Add("@bqaurgency","否");//是否急料 cmd.Parameters.Add("@bqachecking","否");//是否在检 cmd.Parameters.Add("@btracksalebill","0");//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","1");//行号???????????????????????????????????????????????????????????? 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","0");//有效期推算方式 cmd.Parameters.Add("@fretqtywkp","0.000000000");//未开票退货数量 cmd.Parameters.Add("@fretqtyykp","0.000000000");//已开票退货数量 cmd.Parameters.Add("@bcosting","1");//是否记账 cmd.Parameters.Add("@bneedsign","1");//需要签回 cmd.Parameters.Add("@bsignover","0");//发货签回完成 cmd.Parameters.Add("@autoid2",i);//发货单子表ID cmd.Parameters.Add("@bproxywh","0");//代管仓 cmd.Parameters.Add("@tbquantity","0.000000000");//退补数量 cmd.Parameters.Add("@dblpreexchmomey","0.000000");//预收款原币金额 cmd.Parameters.Add("@dblpremomey","0.000000");//预收款本币金额 cmd.Parameters.Add("@bcontrolserial", "1");//控制序列号 cmd.Parameters.Add("@bserial", "0");//是否有序列号管理 cmd.Parameters.Add("@bneedloss", "0");//需要损失处理 cmd.Parameters.Add("@frlossqty", "0.000000");//合理损耗数量 cmd.Parameters.Add("@isettletype", "0");//责任承担处理 cmd.Parameters.Add("@bbatch", "0");//是否已指定批号 cmd.Parameters.Add("@bcode", "0");//是否已指定入库单号 cmd.Parameters.Add("@bmpforderclosed", "0");//订单关闭标识 cmd.Parameters.Add("@fappretwkpqty", "0.000000000");//未开票退货申请数量 cmd.Parameters.Add("@cinvcname", si.cInvName);//存货名称 cmd.Parameters.Add("@biacreatebill", "0");//存货核算参照销售出库开票标识 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 == 0) { //lb_info.Items.Add("生成单据失败,原因如下:" + Ex); } else { ok = true; } return ok; }
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", "9"); //上下文数据类型: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, 0); string sql = "select top 1 * from TWKF_Sales_T where dlid=‘" + dlid + "‘"; rs.Open(sql, conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic, -1); 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 = http://www.mamicode.com/""; 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, 0); sql = "select top 1 * from TWKF_Sales_W where dlid=‘" + dlid + "‘"; rs1.Open(sql, conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic, -1); 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 = http://www.mamicode.com/""; domBody.selectSingleNode("//rs:data/z:row").attributes.getNamedItem("autoid").nodeValue = http://www.mamicode.com/""; //给普通参数VoucherState赋值。此参数的数据类型为int,此参数按值传递,表示状态:0增加;1修改 broker.AssignNormalValue("VoucherState", 0); //该参数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 != 0) { 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——向U8数据库表导入数据
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。