U8API——向U8数据库表导入数据
Posted 野性狼心
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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","以上是关于U8API——向U8数据库表导入数据的主要内容,如果未能解决你的问题,请参考以下文章万物皆可集成系列:低代码释放用友U8+深度价值— 数据融合应用