$PBExportHeader$uo_inware_buy.sru forward global type uo_inware_buy from uo_inware end type end forward global type uo_inware_buy from uo_inware end type global uo_inware_buy uo_inware_buy type variables end variables forward prototypes public function integer secauditing (boolean arg_ifcommit, ref string arg_msg) public function integer c_secauditing (boolean arg_ifcommit, ref string arg_msg) public function integer uof_create_buytask (ref string arg_msg, boolean arg_ifcommit) public function integer auditing_end (ref string arg_msg) public function integer c_auditing_chk (ref string arg_msg) public function integer c_auditing_end (ref string arg_msg) public function integer uof_destroy_buytask (ref string arg_msg, boolean arg_ifcommit) public function integer uof_save_dytitle_inwarebuy (long arg_hang, string arg_name, string arg_dwtitlename, string arg_execltitlename, string arg_filtername, ref string arg_msg) public function integer acceptmx (s_inwaremx s_mx, ref string arg_msg) public function integer save (boolean arg_ifcommit, ref string arg_msg) public function integer priceaudit (long arg_scid, long arg_inwareid, boolean arg_ifcommit, ref string arg_msg) public function integer c_priceaudit (long arg_scid, long arg_inwareid, boolean arg_ifcommit, ref string arg_msg) end prototypes public function integer secauditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i String ls_about,ls_dscrp Long ll_moneyid uo_mustpay uo_pay uo_pay = Create uo_mustpay Decimal ld_payamt = 0,ld_mstpayamt = 0, ld_otheramt = 0,ld_taxamt,ld_payamt_tax IF inwareid = 0 THEN rslt = 0 arg_msg = "没有审核对象" GOTO ext END IF IF flag = 0 THEN rslt = 0 arg_msg = "单据还没有经过仓库审核" GOTO ext END IF IF secflag = 1 THEN rslt = 0 arg_msg = "单据已经过财务审核" GOTO ext END IF Int li_btype Long ll_accountsid SELECT btype,accountsid INTO :li_btype,:ll_accountsid FROM cw_banktype Where banktypeid = :relint_1 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'more than') > 0 THEN arg_msg = '查询结算方式类型失败,查询数据返回值多于一个' ELSE arg_msg = '查询结算方式类型失败,'+ commit_transaction.SQLErrText END IF GOTO ext END IF SELECT count(*) INTO :cnt FROM u_user Where username = :publ_operator Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,操作员" GOTO ext END IF IF cnt = 0 THEN rslt = 0 arg_msg = "操作员姓名未登记或已取消" GOTO ext END IF UPDATE u_inware SET secauditingrep = :publ_operator, secauditingdate = getdate(), secflag = 1 WHERE u_inware.inwareid = :inwareid And flag = 1 And secflag = 0 And scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致财务审核单据操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext ELSEIF commit_transaction.SQLNRows = 0 THEN rslt = 0 arg_msg = "单据正在财务审核,请稍后查询。" GOTO ext END IF IF sum_uamt <> 0 And dxflag = 0 THEN Long ll_dft_itemid_pay,ll_dft_itemid_yh, ll_dft_itemid_sj IF thflag = 1 THEN IF sys_option_buy_dscrp_sec = 0 THEN ls_about = inwarecode + "退货款" ELSE ls_about = inwarecode + "退货款,备注:" + Trim(dscrp) END IF IF f_get_itemid(5,ll_dft_itemid_pay, arg_msg) = 0 THEN // 采购外协退货项目 rslt = 0 GOTO ext END IF ELSE IF sys_option_buy_dscrp_sec = 0 THEN ls_about = inwarecode + "应付款" ELSE ls_about = inwarecode + "应付款,备注:" + Trim(dscrp) END IF IF f_get_itemid(2,ll_dft_itemid_pay, arg_msg) = 0 THEN //采购外协付款项目 rslt = 0 GOTO ext END IF END IF //财务支持多币种 IF sys_option_msp_multimoney = 0 THEN SELECT moneyid Into :ll_moneyid From cw_currency Where native = 1; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询本位币失败!'+commit_transaction.SQLErrText GOTO ext END IF sum_bsamt = Round(sum_bsamt , sys_buyamt_round) ld_mstpayamt = sum_bsamt - sum_bsamt_tax ld_otheramt = Round(otheramt * mrate, 2) ld_taxamt = sum_bsamt_tax ELSE ll_moneyid = relint_3 sum_uamt = Round(sum_uamt , sys_buyamt_round) ld_mstpayamt = sum_uamt - sum_uamt_tax ld_otheramt = otheramt ld_taxamt = sum_uamt_tax END IF IF li_btype = 1 THEN ld_payamt = ld_mstpayamt - ld_otheramt + ld_taxamt //ld_payamt_tax = ld_taxamt ELSE ld_payamt = 0 //ld_payamt_tax = 0 END IF // DateTime plandate // SetNull(plandate) IF uo_pay.add_payrec (scid,sptid,indate,inrep,ld_mstpayamt,ld_mstpayamt,ld_payamt,ls_about,& inwarecode,relint_1,1,publ_operator,inwareid,0,arg_msg,False,viewdate,ll_accountsid,ll_dft_itemid_pay,ll_moneyid,part) = 0 THEN rslt = 0 GOTO ext END IF IF ld_taxamt <> 0 THEN ls_about = inwarecode + "税金" //撤审有用, 应收明细增加有用 IF f_get_itemid(7,ll_dft_itemid_sj, arg_msg) = 0 THEN //采购税金项目 rslt = 0 GOTO ext END IF IF uo_pay.add_payrecmx(scid,uo_pay.ref_payid,inwarecode,indate,relint_1,ld_taxamt,ld_payamt_tax,& publ_operator,ls_about,inrep,3,0,ll_dft_itemid_sj,sptid,arg_msg,False, ll_moneyid,part) = 0 THEN rslt = 0 GOTO ext END IF END IF IF otheramt <> 0 THEN ls_about = inwarecode + sys_option_change_otheramt IF f_get_itemid(8,ll_dft_itemid_yh, arg_msg) = 0 THEN //采购税金项目 rslt = 0 GOTO ext END IF IF uo_pay.add_payrecmx(scid,uo_pay.ref_payid,inwarecode,indate,relint_1,0 - ld_otheramt,0,& publ_operator,ls_about,inrep,3,0,ll_dft_itemid_yh,sptid,arg_msg,False, ll_moneyid,part) = 0 THEN rslt = 0 GOTO ext END IF END IF UPDATE u_inware SET relint_2 = :uo_pay.ref_payid WHERE u_inware.inwareid = :inwareid AND scid = :scid AND flag = 1 And secflag = 1 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '更新相关应付帐ID失败' rslt = 0 GOTO ext END IF END IF secflag = 1 ext: IF rslt = 0 THEN ROLLBACK Using commit_transaction; ELSEIF rslt = 1 And arg_ifcommit THEN COMMIT Using commit_transaction; END IF Destroy uo_pay IF thflag = 0 THEN arg_msg = '采购进仓单,'+ arg_msg ELSE arg_msg = '采购退货单,'+ arg_msg END IF RETURN rslt end function public function integer c_secauditing (boolean arg_ifcommit, ref string arg_msg); Long rslt = 1,cnt = 0,i DateTime null_dt uo_mustpay uo_pay uo_pay = Create uo_mustpay String ls_mtrlname String ls_tmpcode SetNull(null_dt) IF inwareid = 0 THEN rslt = 0 arg_msg = "没有撤审对象" GOTO ext END IF IF it_newbegin Or it_updatebegin THEN rslt = 0 arg_msg = "编辑状态下不可以执行撤审" GOTO ext END IF IF cwauditingflag = 1 THEN rslt = 0 arG_MSG = "该单据已经总账审核,不能进行财务撤审" GOTO ext END IF IF secflag = 0 THEN rslt = 0 arg_msg = "该单据财务未审,不能进行财务撤审" GOTO ext END IF SELECT count(*) INTO :cnt FROM u_user Where username = :publ_operator Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,操作员" GOTO ext END IF IF cnt = 0 THEN rslt = 0 arg_msg = "操作员姓名未登记或已取消" GOTO ext END IF UPDATE u_inware SET secauditingrep = '', secauditingdate = :null_dt, secflag = 0,relint_2 = 0 WHERE u_inware.inwareid = :inwareid And secflag = 1 And scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致财务审核单据操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext ELSEIF commit_transaction.SQLNRows = 0 THEN rslt = 0 arg_msg = "单据正在财务审核,请稍后查询。" GOTO ext END IF IF sum_uamt <> 0 And dxflag = 0 THEN Long ll_payid, ll_listno String ls_about Boolean lb_del ll_payid = relint_2 //==================================================================== // 修改: 检查是否已开供应商付款结算单 //-------------------------------------------------------------------- // 作者: lwl 日期: 2015年06月04日 SELECT COUNT(0) INTO :cnt FROM u_Bmstamtmx INNER JOIN u_Bmstamt ON u_Bmstamtmx.Baid = u_Bmstamt.Baid WHERE (u_Bmstamt.billtype = 1) And (u_Bmstamtmx.takeid = :ll_payid); IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询是否已开供应商付款结算单失败,' + sqlca.SQLErrText GOTO ext END IF IF cnt > 0 THEN SELECT TOP 1 u_Bmstamt.BaCode INTO :ls_tmpcode FROM u_Bmstamtmx INNER JOIN u_Bmstamt ON u_Bmstamtmx.Baid = u_Bmstamt.Baid WHERE (u_Bmstamt.billtype = 1) And (u_Bmstamtmx.takeid = :ll_payid); IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询已开供应商付款结算单失败,' + sqlca.SQLErrText GOTO ext END IF rslt = 0 arg_msg = '已开供应商付款结算单['+ls_tmpcode+'],不能撤审' GOTO ext END IF //==================================================================== IF otheramt <> 0 THEN //删优惠 ls_about = inwarecode + sys_option_change_otheramt SELECT listno INTO :ll_listno FROM u_bmstpaymx WHERE payid = :ll_payid AND dscrp = :ls_about And buildtype = 3; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询应付帐"+sys_option_change_otheramt+"金额明细失败,"+sqlca.SQLErrText GOTO ext END IF IF uo_pay.del_payrecmx(3, ll_payid , ll_listno,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF END IF IF sum_uamt_tax <> 0 THEN //删税金 ls_about = inwarecode + "税金" //删已收 SELECT listno INTO :ll_listno FROM u_bmstpaymx WHERE payid = :ll_payid AND dscrp = :ls_about And buildtype = 3; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询应付帐税金明细失败,"+sqlca.SQLErrText GOTO ext END IF IF uo_pay.del_payrecmx(3, ll_payid , ll_listno,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF END IF IF uo_pay.del_payrec(scid,1,relint_2,sptid,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF END IF secflag = 0 ext: IF rslt = 0 THEN ROLLBACK Using commit_transaction; ELSEIF rslt = 1 And arg_ifcommit THEN COMMIT Using commit_transaction; END IF Destroy uo_pay IF thflag = 0 THEN arg_msg = '采购进仓单,'+ arg_msg ELSE arg_msg = '采购退货单,'+ arg_msg END IF RETURN rslt end function public function integer uof_create_buytask (ref string arg_msg, boolean arg_ifcommit);Long rslt = 1, i uo_buytask uo_task uo_task = Create uo_buytask uo_task.commit_transaction = commit_transaction IF thflag = 1 And relint_4 = 1 THEN IF uo_task.newbegin(scid,arg_msg) = 0 THEN // rslt = 0 GOTO ext END IF uo_task.Requiredate = indate //要求完成日期 uo_task.Assign_emp = inrep //订单负责人 uo_task.Kind = 0 uo_task.sptid = sptid uo_task.dscrp = dscrp uo_task.relcode = inwarecode uo_task.banktypeid = relint_1 uo_task.billtype = 0 uo_task.moneyid = relint_3 uo_task.mrate = mrate FOR i = 1 To it_mxbt IF uo_task.acceptmx(0,& 0,& '',& inwaremx[i].mtrlid,& 0 - inwaremx[i].uqty,& 0 - inwaremx[i].addqty,& inwaremx[i].uprice,& inwaremx[i].rebate,& 0,& inwaremx[i].mxdscrp,& inwaremx[i].mtrlcode,& arg_msg,& i,& indate,& storageid,& inwaremx[i].status,& inwaremx[i].woodcode,& inwaremx[i].pcode,& inwaremx[i].unit,& inwaremx[i].rate,& 0,& 0,& '',& '',& 0,0,& inwaremx[i].plancode,& inwaremx[i].mxdscrp2,& inwaremx[i].mxdscrp3,& inwaremx[i].mxdscrp4) = 0 THEN //新加plancode rslt = 0 GOTO ext END IF NEXT IF uo_task.savesubmit(publ_operator,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF Long ll_taskid Long ll_scid String ls_taskcode ll_taskid = uo_task.taskid ls_taskcode = uo_task.TaskCode ll_scid = uo_task.scid IF uo_task.firstpermit(ll_scid,ll_taskid,publ_operator,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF UPDATE u_inware SET relint_5 = :ll_taskid, part = :ls_taskcode WHERE u_inware.inwareid = :inwareid And scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致生成采购订单操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext ELSEIF commit_transaction.SQLNRows = 0 THEN rslt = 0 arg_msg = "单据正在生成采购订单,请稍后查询。" GOTO ext END IF END IF ext: Destroy uo_task IF rslt = 0 THEN ROLLBACK Using commit_transaction; ELSEIF arg_ifcommit THEN COMMIT Using commit_transaction; END IF RETURN rslt end function public function integer auditing_end (ref string arg_msg);//uo_inware_buy 重写 Long rslt = 1 Long i uo_buytask uo_task uo_task = Create uo_buytask uo_task.commit_transaction = commit_transaction uo_spt_price uo_sptprice uo_sptprice = Create uo_spt_price //Long ll_mxsptid = 0 //Decimal ld_cost FOR i = 1 To it_mxbt //更新采购订单 IF billtype = 1 And inwaremx[i].relid > 0 THEN IF uo_task.addmxcmpl(scid,inwaremx[i].relid,inwaremx[i].relprintid,inwaremx[i].buyqty,inwaremx[i].addqty,arg_msg,False) <> 1 THEN rslt = 0 GOTO ext END IF IF uo_task.trycmplbuytask(scid,inwaremx[i].relid,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF END IF //增加采购历史 IF uo_sptprice.uf_update_sptprice(thflag,sptid,inwaremx[i].mtrlid,inwaremx[i].unit,& inwaremx[i].status,inwaremx[i].woodcode,inwaremx[i].pcode,inwareid,relint_3,& inwaremx[i].uprice,inwaremx[i].rebate,inwaremx[i].rate,inwaremx[i].price,& indate,inwarecode,0,inwaremx[i].mxdscrp,inwaremx[i].printid,0,False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF NEXT //自动生成采购订单审核 IF uof_create_buytask(arg_msg, False) = 0 THEN rslt = 0 GOTO ext END IF ext: Destroy uo_buytask Destroy uo_sptprice RETURN rslt end function public function integer c_auditing_chk (ref string arg_msg);//uo_inware_buy 重写 Long rslt = 1 IF secflag = 1 THEN rslt = 0 arg_msg = "单据已经财务审核" GOTO ext END IF IF sys_option_hide_ware = 0 THEN IF billtype = 8 And relid > 0 THEN rslt = 0 arg_msg = "该进仓单是系统生成(如成本调整单),不能撤审!" GOTO ext END IF IF billtype <> 9 THEN IF uof_check_warepdb_audit(storageid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF ELSE IF Not sysautobuild THEN IF dscrp = '盘点表审核自动生成盘盈单' THEN arg_msg = '系统自动生成的单据不能手动撤审' rslt = 0 GOTO ext END IF END IF END IF END IF ext: RETURN rslt end function public function integer c_auditing_end (ref string arg_msg);Long rslt = 1 Long i uo_buytask uo_task uo_task = Create uo_buytask uo_task.commit_transaction = commit_transaction uo_spt_price uo_sptprice uo_sptprice = Create uo_spt_price Long ll_mxsptid = 0 Long ll_mtrlwareid FOR i = 1 To it_mxbt //更新合同完成数量 IF billtype = 1 And inwaremx[i].relid > 0 THEN IF uo_task.addmxcmpl(scid,inwaremx[i].relid,inwaremx[i].relprintid,0 - inwaremx[i].buyqty,0 - inwaremx[i].addqty,arg_msg,False) <> 1 THEN rslt = 0 GOTO ext END IF IF uo_task.trycmplbuytask(scid,inwaremx[i].relid,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF END IF //清除采购历史 IF uo_sptprice.uf_del_sptprice(thflag,sptid,inwaremx[i].mtrlid,inwaremx[i].unit,inwaremx[i].status,inwaremx[i].woodcode,inwaremx[i].pcode,& inwareid,inwaremx[i].printid,relint_3,False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF NEXT //自动删除采购订单审核 IF uof_destroy_buytask(arg_msg, False) = 0 THEN rslt = 0 GOTO ext END IF //IF thflag = 1 And relint_4 = 1 THEN // Long ll_status // SELECT status // INTO :ll_status // FROM u_buytask // Where taskid = :relint_5 And scid = :scid Using commit_transaction; // IF commit_transaction.SQLCode = -1 THEN // rslt = 0 // arg_msg = "查询采购订单操作失败"+"~n"+commit_transaction.SQLErrText // GOTO ext // ELSEIF commit_transaction.SQLCode = 0 THEN // IF ll_status = 1 Or ll_status = 0 THEN // IF ll_status = 1 THEN // IF uo_task.cancelpermit(scid,relint_5,arg_msg,False) = 0 THEN // rslt = 0 // GOTO ext // END IF // END IF // // IF uo_task.Cancel(scid,relint_5,arg_msg,False) = 0 THEN // rslt = 0 // GOTO ext // END IF // // ELSE // arg_msg = '无法删除该退货单生成的采购订单(' + part + '),请手动删除' // rslt = -1 // END IF // // END IF // // UPDATE u_inware // SET relint_5 = 0, // part = '' // WHERE u_inware.inwareid = :inwareid // And scid = :scid Using commit_transaction; // // IF commit_transaction.SQLCode <> 0 THEN // rslt = 0 // arg_msg = "删除采购订单操作失败"+"~n"+commit_transaction.SQLErrText // GOTO ext // ELSEIF commit_transaction.SQLNRows = 0 THEN // rslt = 0 // arg_msg = "单据正在删除采购订单,请稍后查询。" // GOTO ext // END IF //END IF ext: Destroy uo_task Destroy uo_sptprice RETURN rslt end function public function integer uof_destroy_buytask (ref string arg_msg, boolean arg_ifcommit);Long rslt = 1, i uo_buytask uo_task uo_task = Create uo_buytask uo_task.commit_transaction = commit_transaction IF thflag = 1 And relint_4 = 1 THEN Long ll_status SELECT status INTO :ll_status FROM u_buytask Where taskid = :relint_5 And scid = :scid Using commit_transaction; IF commit_transaction.SQLCode = -1 THEN rslt = 0 arg_msg = "查询采购订单操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext ELSEIF commit_transaction.SQLCode = 0 THEN IF ll_status = 1 Or ll_status = 0 THEN IF ll_status = 1 THEN IF uo_task.cancelpermit(scid,relint_5,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF END IF IF uo_task.Cancel(scid,relint_5,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF ELSE arg_msg = '无法删除该退货单生成的采购订单(' + part + '),请手动删除' rslt = -1 END IF END IF UPDATE u_inware SET relint_5 = 0, part = '' WHERE u_inware.inwareid = :inwareid And scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除采购订单操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext ELSEIF commit_transaction.SQLNRows = 0 THEN rslt = 0 arg_msg = "单据正在删除采购订单,请稍后查询。" GOTO ext END IF END IF ext: Destroy uo_task IF rslt = 0 THEN ROLLBACK Using commit_transaction; ELSEIF arg_ifcommit THEN COMMIT Using commit_transaction; END IF RETURN rslt end function public function integer uof_save_dytitle_inwarebuy (long arg_hang, string arg_name, string arg_dwtitlename, string arg_execltitlename, string arg_filtername, ref string arg_msg);Long rslt = 1, i if isnull(arg_filtername) then arg_filtername='' UPDATE u_dytitle_inwarebuy SET hang = :arg_hang, dwtitlename = :arg_dwtitlename, execltitlename = :arg_execltitlename, filtername=:arg_filtername WHERE name = :arg_name Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "更新明细标题与execl标题对应关系表操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext ELSEIF commit_transaction.SQLNRows = 0 THEN INSERT INTO u_dytitle_inwarebuy(hang,name,dwtitlename,execltitlename,filtername) VALUES (:arg_hang,:arg_name,:arg_dwtitlename,:arg_execltitlename,:arg_filtername) Using commit_transaction; END IF ext: IF rslt = 0 THEN ROLLBACK Using commit_transaction; ELSE COMMIT Using commit_transaction; END IF RETURN rslt end function public function integer acceptmx (s_inwaremx s_mx, ref string arg_msg);Long rslt = 1,cnt = 0,ls_i Decimal ld_planprice,ld_cost,ld_dftsptprice Decimal ld_noauditqty,ld_bootqty String ls_relcode,ls_unit,ls_saletaskcode Int li_iflimitprice Dec ld_round = 100 uo_spt_price uo_sptprice uo_sptprice = Create uo_spt_price If it_newbegin = False And it_updatebegin = False Then rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" Goto ext End If //清除空值 If IsNull(s_mx.printid) Then s_mx.printid = 0 If IsNull(s_mx.mtrlid) Then s_mx.mtrlid = 0 If IsNull(s_mx.mtrlcode) Then s_mx.mtrlcode = '' If IsNull(s_mx.plancode) Then s_mx.plancode = '' If IsNull(s_mx.status) Then s_mx.status = '' If IsNull(s_mx.uqty) Then s_mx.uqty = 0 If IsNull(s_mx.addqty) Then s_mx.addqty = 0 If IsNull(s_mx.packqty) Then s_mx.packqty = 0 If IsNull(s_mx.uprice) Then s_mx.uprice = 0 If IsNull(s_mx.rebate) Then s_mx.rebate = 0 If IsNull(s_mx.mxdscrp) Then s_mx.mxdscrp = '' If IsNull(s_mx.mxdscrp2) Then s_mx.mxdscrp2 = '' If IsNull(s_mx.mxdscrp3) Then s_mx.mxdscrp3 = '' If IsNull(s_mx.mxdscrp4) Then s_mx.mxdscrp4 = '' If IsNull(s_mx.jgprice) Then s_mx.jgprice = 0 If IsNull(s_mx.ifrel) Then s_mx.ifrel = 0 If IsNull(s_mx.relid) Then s_mx.relid = 0 If IsNull(s_mx.relprintid) Then s_mx.relprintid = 0 If IsNull(s_mx.mxdscrp) Then s_mx.woodcode = '' If IsNull(s_mx.pcode) Then s_mx.pcode = '' If IsNull(s_mx.sptid) Then s_mx.sptid = 0 If IsNull(s_mx.mtrlcuscode) Then s_mx.mtrlcuscode = '' If IsNull(s_mx.unit) Then s_mx.unit = '' If IsNull(s_mx.rate) Then s_mx.rate = 1 If s_mx.rate = 0 Then s_mx.rate = 1 If IsNull(s_mx.formula) Then s_mx.formula = '' If IsNull(s_mx.waredscrp) Then s_mx.waredscrp = '' If mrate = 0 Then mrate = 1 If IsNull(s_mx.tax) Then s_mx.tax = 0 If IsNull(s_mx.uamt_tax) Then s_mx.uamt_tax = 0 If IsNull(s_mx.buyqty) Then s_mx.buyqty = 0 If IsNull(s_mx.uprice_notax) Then s_mx.uprice_notax = 0 If s_mx.uprice_notax = 0 Then s_mx.uprice_notax = s_mx.uprice / (1 + s_mx.tax) End If s_mx.uqty = Round(s_mx.uqty,5) s_mx.addqty = Round(s_mx.addqty,5) If sys_option_outware_if_buyqty = 1 And billtype = 1 Then //采购 , 采购数与进仓数分离 Else //不分离 s_mx.buyqty = s_mx.uqty End If If s_mx.mtrlid = 0 Or (s_mx.buyqty = 0 And s_mx.uqty = 0 And s_mx.addqty = 0) Then rslt = 1 Goto ext End If If acceptmx_chk(s_mx, arg_msg) = 0 Then rslt = 0 Goto ext End If //检查物料id Select unit,planprice,iflimitprice Into :ls_unit,:ld_planprice,:li_iflimitprice From u_mtrldef Where u_mtrldef.mtrlid = :s_mx.mtrlid Using commit_transaction ; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "第" + String(s_mx.printid) + "行,查询物料资料信息失败,编码:"+s_mx.mtrlcode Goto ext End If //确实有=1的情况 //IF ls_unit <> s_mx.unit And s_mx.rate = 1 THEN // arg_msg = "第" + String(s_mx.printid) + "行,库存单位与采购单位不同,但转换率为1,请检查!" // rslt = 0 // GOTO ext //END IF If ls_unit = s_mx.unit And s_mx.rate <> 1 Then arg_msg = "第" + String(s_mx.printid) + "行,库存单位与采购单位相同,但转换率不为1,请检查!" rslt = 0 Goto ext End If //查询采购限价并检查进仓价 If billtype = 1 Or billtype = 4 Then If li_iflimitprice = 1 Then If uo_sptprice.uf_check_price_save(thflag,sptid,s_mx.mtrlid,s_mx.mtrlcode,s_mx.unit,s_mx.status,s_mx.woodcode,s_mx.pcode,s_mx.uprice * s_mx.rebate,arg_msg) = 0 Then arg_msg = "第" + String(s_mx.printid) + "行," + arg_msg rslt = 0 Goto ext End If End If End If Int li_if_cus_mtrlware, li_if_plancode, li_inwaretype If sys_option_hide_ware = 0 Then Select balctype , if_plancode, inwaretype Into :li_if_cus_mtrlware, :li_if_plancode, :li_inwaretype From u_storage Where storageid = :storageid; If sqlca.SQLCode <> 0 Then arg_msg = "第" + String(s_mx.printid) + "行,查询仓库是否使用客户库存失败" rslt = 0 Goto ext End If End If //关于客户库存处理,sptid Long ll_cusid Int li_bhflag If dxflag = 0 Then If li_if_cus_mtrlware = 1 Then If billtype = 3 Then //特殊情况 20140104 //生产进仓单,按订单进仓的产品,如果订单的客户为 备货客户, 进仓时不按客户库存; If s_mx.ifrel > 0 Then If s_mx.relid = 0 Then arg_msg = "第" + String(s_mx.printid) + '行,请先择相应的销售订单' rslt = 0 Goto ext End If Select top 1 cusid Into :ll_cusid From u_saletaskmx,u_saletask Where u_saletaskmx.scid = u_saletask.scid And u_saletaskmx.taskid = u_saletask.taskid And u_saletaskmx.scid = :scid And u_saletaskmx.taskid = :s_mx.relid And u_saletaskmx.printid = :s_mx.relprintid And u_saletaskmx.mtrlid = :s_mx.mtrlid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = "第" + String(s_mx.printid) + '行,查询销售订单客户资料失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If // s_mx.mtrlid 以后有可能是 下级的生产物料!!!! If IsNull(ll_cusid) Then ll_cusid = 0 If ll_cusid > 0 Then Select bhflag Into :li_bhflag From u_cust Where cusid = :ll_cusid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = "第" + String(s_mx.printid) + '行,查询销售订单客户资料失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If Else li_bhflag = 0 End If If IsNull(li_bhflag) Then li_bhflag = 0 If li_bhflag = 1 Then s_mx.sptid = 0 Else s_mx.sptid = s_mx.sptid End If End If Else s_mx.sptid = s_mx.sptid End If Else s_mx.sptid = 0 End If Else If li_if_cus_mtrlware <> 1 Then arg_msg = "仓库没有使用客户库存,不能建立代销单据" rslt = 0 Goto ext End If s_mx.sptid = sptid End If Choose Case billtype Case 1 //采购 If s_mx.ifrel > 0 Then If s_mx.relid = 0 Then arg_msg = "第" + String(s_mx.printid) + "行,请先择相应的订单!" rslt = 0 Goto ext End If Select taskcode ,uqty - consignedqty, CASE when u_buytask.billtype = 1 THEN u_buytaskmx.relcode ELSE '' End Into :ls_relcode,:ld_bootqty,:ls_saletaskcode From u_buytaskmx,u_buytask Where u_buytaskmx.taskid = u_buytask.taskid And u_buytaskmx.scid = u_buytask.scid And u_buytaskmx.scid = :scid And u_buytaskmx.taskid = :s_mx.relid And u_buytaskmx.printid = :s_mx.relprintid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = "第" + String(s_mx.printid) + "行,查询采购订单是否有订购:"+s_mx.mtrlcode+'失败!'+commit_transaction.SQLErrText rslt = 0 Goto ext End If //查相关销售订单已开单数 ld_noauditqty = 0 Select sum(uqty) Into :ld_noauditqty From u_inwaremx Where scid = :scid And relid = :s_mx.relid And relprintid = :s_mx.relprintid And inwareid <> :inwareid; If sqlca.SQLCode <> 0 Then arg_msg = "第" + String(s_mx.printid) + "行,查询"+s_mx.mtrlcode+'相关订单单据已开单数失败!' rslt = 0 Goto ext End If If IsNull(ld_noauditqty) Then ld_noauditqty = 0 Else s_mx.relid = 0 s_mx.relprintid = 0 End If Case 3 //生产 If s_mx.ifrel > 0 Then If s_mx.relid = 0 Then arg_msg = "第" + String(s_mx.printid) + '行,请先择相应的销售订单' rslt = 0 Goto ext End If Select top 1 taskcode Into :ls_relcode From u_saletaskmx,u_saletask Where u_saletaskmx.scid = u_saletask.scid And u_saletaskmx.taskid = u_saletask.taskid And u_saletaskmx.scid = :scid And u_saletaskmx.taskid = :s_mx.relid And u_saletaskmx.printid = :s_mx.relprintid And u_saletaskmx.mtrlid = :s_mx.mtrlid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = "第" + String(s_mx.printid) + '行,查询销售订单是否有排产:'+s_mx.mtrlcode+'失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If Else s_mx.relid = 0 s_mx.relprintid = 0 End If Case 4 //外协 If s_mx.ifrel > 0 Then If s_mx.relid = 0 Then arg_msg = "第" + String(s_mx.printid) + '行,请先择相应的外协订单' rslt = 0 Goto ext End If Select u_order_wfjg.taskcode, CASE when u_order_wfjg.billtype = 1 THEN u_order_wfjgmx.relcode ELSE '' End Into :ls_relcode,:ls_saletaskcode From u_order_wfjgmx,u_order_wfjg Where u_order_wfjgmx.scid = u_order_wfjg.scid And u_order_wfjgmx.wfjgid = u_order_wfjg.wfjgid And u_order_wfjgmx.wfjgid = :s_mx.relid And u_order_wfjgmx.printid = :s_mx.relprintid And u_order_wfjgmx.mtrlid = :s_mx.mtrlid And u_order_wfjgmx.status = :s_mx.status And u_order_wfjgmx.woodcode = :s_mx.woodcode And u_order_wfjgmx.pcode = :s_mx.pcode Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = "第" + String(s_mx.printid) + '行,查询外协订单是否有加工:'+s_mx.mtrlcode+'失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If End If End Choose //处理plancode storage_plancode_flag = 0 If li_if_plancode = 0 Then //不使用 s_mx.plancode = '' Else If thflag <> 1 Then //退货不处理 If li_inwaretype = 1 Then //无(不变) //inwaremx[it_mxbt].plancode = s_mx.plancode ElseIf li_inwaretype = 2 Then //价格 s_mx.plancode = String(Round(s_mx.uprice * s_mx.rebate,5)) ElseIf li_inwaretype = 3 Then //订单 If ls_relcode <> '' And billtype = 3 Then s_mx.plancode = ls_relcode ElseIf ls_saletaskcode <> '' And (billtype = 1 Or billtype = 4 ) Then s_mx.plancode = ls_saletaskcode Else s_mx.plancode = s_mx.plancode //(不变) End If ElseIf li_inwaretype = 5 Then //进仓单号 storage_plancode_flag = 1 //仓库中是否设置了使用 “进仓单号” 作为批号 ElseIf li_inwaretype = 6 Then //数值 s_mx.plancode = String(s_mx.uqty,'#,##0.####') ElseIf li_inwaretype = 7 Then //日期时间顺序 If s_mx.plancode = '' Then s_mx.plancode = String(Today(), 'yymmddhhmm') + '-' + String(s_mx.printid) End If End If End If //退货不处理 End If //处理 sptmtrlname String ls_sptmtrlname If billtype = 1 Then If uo_sptprice.uf_getmtrlname(sptid,s_mx.mtrlid,ls_sptmtrlname,arg_msg) = 0 Then rslt = 0 Goto ext End If Else ls_sptmtrlname = "" End If //处理价格=============================== //取默认报价 If billtype = 1 Then f_get_defsptprice(sptid,s_mx.mtrlid,s_mx.unit,s_mx.status,s_mx.pcode,s_mx.woodcode,ld_dftsptprice) Else ld_dftsptprice = 0 End If //不是自动的单价 If sysautobuild = False Then If s_mx.uprice * s_mx.rebate < 0 Then //检查进仓价 rslt = 0 arg_msg = "第" + String(s_mx.printid) + '行,' + String(s_mx.mtrlcode)+" 单价错误" Goto ext End If End If If s_mx.tax < 0 Then rslt = 0 arg_msg = "税率不能为负数" Goto ext End If //检查成本价调整单 Long ll_mtrlwareid If sys_option_hide_ware = 0 Then Select mtrlwareid Into :ll_mtrlwareid From u_mtrlware Where ( mtrlid = :s_mx.mtrlid ) And ( plancode = :s_mx.plancode ) And ( storageid = :storageid ) And ( scid = :scid ) And ( status = :s_mx.status ) And ( sptid = :s_mx.sptid) And ( dxflag = :dxflag) And ( woodcode = :s_mx.woodcode) And ( pcode = :s_mx.pcode) Using commit_transaction; If commit_transaction.SQLCode = -1 Then arg_msg = "第" + String(s_mx.printid) + "行,查询库存信息失败!" rslt = 0 Goto ext End If If IsNull(ll_mtrlwareid) Then ll_mtrlwareid = 0 If ll_mtrlwareid > 0 Then If Not (billtype = 8 And sptname = '成本价调整单审核自动生成') Then cnt = 0 Select count(*) Into :cnt From u_updatecost,u_updatecostmx Where u_updatecost.wareid = u_updatecostmx.wareid And u_updatecost.flag = 0 And u_updatecostmx.mtrlwareid = :ll_mtrlwareid And u_updatecost.scid = :scid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "第" + String(s_mx.printid) + "行,查询成本价调整单操作失败" Goto ext End If If cnt > 0 Then rslt = 0 arg_msg = "第" + String(s_mx.printid) + "行," + s_mx.mtrlcode + "已开成本价调整单,请先审核" Goto ext End If End If //出仓的, 查询成本价 Else End If End If //s_mx.price = Round(s_mx.enprice * mrate * s_mx.rebate,10) //进仓实价, 本位币,库存单位 s_mx.qty = Round(s_mx.uqty * s_mx.rate, sys_option_unit_dec) //库存单位,进仓数量 //写入内容 it_mxbt++ inwaremx[it_mxbt].mtrlwareid = ll_mtrlwareid inwaremx[it_mxbt].printid = s_mx.printid inwaremx[it_mxbt].mtrlid = s_mx.mtrlid inwaremx[it_mxbt].mtrlcode = s_mx.mtrlcode inwaremx[it_mxbt].unit = s_mx.unit inwaremx[it_mxbt].rate = s_mx.rate inwaremx[it_mxbt].noauditqty = ld_noauditqty inwaremx[it_mxbt].bootqty = ld_bootqty inwaremx[it_mxbt].addqty = s_mx.addqty inwaremx[it_mxbt].uqty = s_mx.uqty inwaremx[it_mxbt].qty = s_mx.qty inwaremx[it_mxbt].buyqty = s_mx.buyqty inwaremx[it_mxbt].packqty = s_mx.packqty inwaremx[it_mxbt].uprice = s_mx.uprice //进仓价, 原币, 进仓单位 If s_mx.buyqty <> 0 Then inwaremx[it_mxbt].fprice = Round((s_mx.uprice * s_mx.buyqty) /(Round(s_mx.buyqty * s_mx.rate,sys_option_unit_dec)) * mrate ,10) //进仓价, 本位币, 库存单位 Else inwaremx[it_mxbt].fprice = Round(s_mx.uprice * s_mx.rate * mrate,10) End If inwaremx[it_mxbt].fprice_notax = inwaremx[it_mxbt].fprice / (1 + s_mx.tax) //不含税价 inwaremx[it_mxbt].price = Round(inwaremx[it_mxbt].fprice * s_mx.rebate,10) //进仓实价, 本位币,库存单位 inwaremx[it_mxbt].rebate = s_mx.rebate inwaremx[it_mxbt].tax = s_mx.tax If billtype = 1 Then ld_round = 10.0 ^ (2 - sys_option_inware_buy_amt_round) If sys_option_inware_buy_amt_round = 5 Then ld_round = 1000 End If inwaremx[it_mxbt].uamt = Round(s_mx.buyqty * s_mx.uprice * s_mx.rebate * ld_round, 0) / ld_round //原币,实价含税金额 If s_mx.uamt_tax = 0 Then inwaremx[it_mxbt].uamt_tax = Round((s_mx.buyqty * s_mx.uprice * s_mx.rebate) * s_mx.tax / (1 + s_mx.tax) * ld_round, 0) / ld_round //原币, 税金 Else inwaremx[it_mxbt].uamt_tax = s_mx.uamt_tax End If inwaremx[it_mxbt].bsamt = Round(s_mx.buyqty * s_mx.uprice * s_mx.rebate * mrate * ld_round, 0) / ld_round //本位币, 实价含税金额 inwaremx[it_mxbt].bsamt_tax = Round((s_mx.buyqty * s_mx.uprice * s_mx.rebate * mrate) * s_mx.tax / (1 + s_mx.tax) * ld_round, 0) / ld_round //本位币, 税金 inwaremx[it_mxbt].planprice = ld_planprice inwaremx[it_mxbt].jgprice = s_mx.jgprice inwaremx[it_mxbt].mxdscrp = s_mx.mxdscrp inwaremx[it_mxbt].mxdscrp2 = s_mx.mxdscrp2 inwaremx[it_mxbt].mxdscrp3 = s_mx.mxdscrp3 inwaremx[it_mxbt].mxdscrp4 = s_mx.mxdscrp4 inwaremx[it_mxbt].dxflag = dxflag inwaremx[it_mxbt].relid = s_mx.relid inwaremx[it_mxbt].relprintid = s_mx.relprintid inwaremx[it_mxbt].ifrel = s_mx.ifrel inwaremx[it_mxbt].status = s_mx.status inwaremx[it_mxbt].woodcode = s_mx.woodcode inwaremx[it_mxbt].pcode = s_mx.pcode inwaremx[it_mxbt].relcode = ls_relcode inwaremx[it_mxbt].mtrlcuscode = s_mx.mtrlcuscode inwaremx[it_mxbt].dftsptprice = ld_dftsptprice inwaremx[it_mxbt].formula = s_mx.formula inwaremx[it_mxbt].waredscrp = s_mx.waredscrp inwaremx[it_mxbt].inworkdate = s_mx.inworkdate inwaremx[it_mxbt].plancode = s_mx.plancode inwaremx[it_mxbt].sptid = s_mx.sptid inwaremx[it_mxbt].sptmtrlname = ls_sptmtrlname //供应商别名 inwaremx[it_mxbt].uprice_notax = s_mx.uprice_notax //不含税单价 //IF sys_option_buyth_wareamt = 0 THEN // Decimal ld_cost_notax If (billtype = 1 And thflag = 1 And sys_option_buyth_wareamt = 0 ) & Or (s_mx.uqty < 0 And billtype <> 3 And billtype <> 1) Then //采购退货单 或者 非采购/生产进仓 Select cost,cost_notax Into :ld_cost,:ld_cost_notax From u_mtrlware Where scid = :scid And mtrlid = :s_mx.mtrlid And storageid = :storageid And status = :s_mx.status And plancode = :s_mx.plancode And woodcode = :s_mx.woodcode And pcode = :s_mx.pcode And dxflag = :dxflag And sptid = :s_mx.sptid; If sqlca.SQLCode <> 0 Or IsNull(ld_cost) Then ld_cost = 0 If sqlca.SQLCode <> 0 Or IsNull(ld_cost_notax) Then ld_cost_notax = 0 inwaremx[it_mxbt].cost = ld_cost inwaremx[it_mxbt].cost_notax = ld_cost_notax Else inwaremx[it_mxbt].cost = inwaremx[it_mxbt].fprice * s_mx.rebate inwaremx[it_mxbt].cost_notax = inwaremx[it_mxbt].fprice_notax * s_mx.rebate End If inwaremx[it_mxbt].costamt = Round(inwaremx[it_mxbt].cost * inwaremx[it_mxbt].qty, 2) //成本金额,库存单位 ext: Destroy uo_sptprice If rslt = 0 Then p_clearmx() arg_msg = billname + ',' + arg_msg End If Return(rslt) end function public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i DateTime server_dt Long ls_newid String ls_sccode IF IsNull(relid) THEN relid = 0 IF IsNull(storageid) THEN storageid = 0 IF IsNull(inrep) THEN inrep = '' IF IsNull(dscrp) THEN dscrp = '' IF IsNull(part) THEN part = '' IF IsNull(sptid) THEN sptid = 0 IF IsNull(sptname) THEN sptname = '' IF IsNull(dxflag) THEN dxflag = 0 IF IsNull(thflag) THEN thflag = 0 IF IsNull(relint_1) THEN relint_1 = 0 IF IsNull(relint_2) THEN relint_2 = 0 IF IsNull(relint_3) THEN relint_3 = 0 IF IsNull(relint_4) THEN relint_4 = 0 IF IsNull(relint_5) THEN relint_5 = 0 IF IsNull(relstr_1) THEN relstr_1 = '' IF IsNull(relstr_2) THEN relstr_2 = '' IF IsNull(relstr_3) THEN relstr_3 = '' IF IsNull(mrate) THEN mrate = 0 IF mrate = 0 THEN mrate = 1 IF it_newbegin = False And it_updatebegin = False THEN rslt = 0 arg_msg = "非编辑状态不可以提交" GOTO ext END IF SELECT Top 1 getdate() Into :server_dt From u_user Using commit_transaction ; //取得系统时间,借用操作员表 IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,日期 " GOTO ext END IF IF save_chk(arg_msg) = 0 THEN rslt = 0 GOTO ext END IF ////////////////////////////////////////////// //开始区分:新建/更新 处理 IF inwareid = 0 THEN //新建 ls_newid = f_sys_scidentity(scid,"u_inware","inwareid",arg_msg,if_getid_ture,commit_transaction) IF ls_newid <= 0 THEN rslt = 0 GOTO ext END IF //取分部代号 IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF //取得新单据编号 CHOOSE CASE billtype CASE 1,2 IF thflag = 0 THEN inwarecode = getid(scid,ls_sccode + 'CG',Date(server_dt),if_getid_ture,commit_transaction) ELSE inwarecode = getid(scid,ls_sccode + 'CT',Date(server_dt),if_getid_ture,commit_transaction) END IF CASE 3 inwarecode = getid(scid,ls_sccode + 'CP',Date(server_dt),if_getid_ture,commit_transaction) CASE 4 IF thflag = 0 THEN inwarecode = getid(scid,ls_sccode + 'WN',Date(server_dt),if_getid_ture,commit_transaction) ELSE inwarecode = getid(scid,ls_sccode + 'WH',Date(server_dt),if_getid_ture,commit_transaction) END IF CASE 8 inwarecode = getid(scid,ls_sccode + 'JC',Date(server_dt),if_getid_ture,commit_transaction) CASE 9 inwarecode = getid(scid,ls_sccode + 'PY',Date(server_dt),if_getid_ture,commit_transaction) CASE 12 inwarecode = getid(scid,ls_sccode + 'IC',Date(server_dt),if_getid_ture,commit_transaction) CASE 15 inwarecode = getid(scid,ls_sccode + 'DC',Date(server_dt),if_getid_ture,commit_transaction) CASE 20 IF thflag = 0 THEN inwarecode = getid(scid,ls_sccode + 'RI',Date(server_dt),if_getid_ture,commit_transaction) ELSE inwarecode = getid(scid,ls_sccode + 'RT',Date(server_dt),if_getid_ture,commit_transaction) END IF CASE 22 inwarecode = getid(scid,ls_sccode + 'TI',Date(server_dt),if_getid_ture,commit_transaction) END CHOOSE IF inwarecode = "err" THEN inwarecode = '' rslt = 0 arg_msg = "无法获取进仓单编号"+"~n" GOTO ext END IF INSERT INTO u_inware ( scid, inwareid, inwarecode, billtype, relid, storageid, indate, inrep, part, dscrp, sptid, sptname, thflag, dxflag, otheramt, opdate, opemp, relint_1, relint_2, relint_3, relstr_1, relstr_2, relstr_3, mrate, relint_4, relint_5, viewdate) VALUES ( :scid, :ls_newid, :inwarecode, :billtype, :relid, :storageid, :indate, :inrep, :part, :dscrp, :sptid, :sptname, :thflag, :dxflag, :otheramt, :server_dt, :publ_operator, :relint_1, :relint_2, :relint_3, :relstr_1, :relstr_2, :relstr_3, :mrate, :relint_4, :relint_5, :viewdate) Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_inware') > 0 THEN arg_msg = '插入单据资料失败,关键字ID重复' ELSEIF Pos(Lower(commit_transaction.SQLErrText),'IX_u_inware') > 0 THEN arg_msg = '插入单据资料失败,单据编号重复' ELSE arg_msg = '插入单据资料失败,'+commit_transaction.SQLErrText END IF //arg_msg = "插入操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //读取新inwareid inwareid = ls_newid ELSE //////////////////////////////////////////////// //更新 UPDATE u_inware SET billtype = :billtype, relid = :relid, storageid = :storageid, indate = :indate, inrep = :inrep, part = :part, dscrp = :dscrp, sptid = :sptid, sptname = :sptname, thflag = :thflag, dxflag = :dxflag, otheramt = :otheramt, moddate = :server_dt, modemp = :publ_operator, relint_1 = :relint_1, relint_2 = :relint_2, relint_3 = :relint_3, relstr_1 = :relstr_1, relstr_2 = :relstr_2, relstr_3 = :relstr_3, mrate = :mrate, relint_4 = :relint_4, relint_5 = :relint_5, viewdate = :viewdate WHERE u_inware.inwareid = :inwareid AND u_inware.scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_inware') > 0 THEN arg_msg = '更新单据资料失败,关键字ID重复' ELSEIF Pos(Lower(commit_transaction.SQLErrText),'IX_u_inware') > 0 THEN arg_msg = '更新单据资料失败,单据编号重复' ELSE arg_msg = '更新单据资料失败,'+commit_transaction.SQLErrText END IF arg_msg = "更新单据操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF IF billtype > 1 Or billtype = 1 And flag = 0 THEN //删除原有明细 DELETE FROM u_inwaremx WHERE u_inwaremx.inwareid = :inwareid And u_inwaremx.scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除旧有单据明细操作失败"+"~n" GOTO ext END IF ELSE END IF END IF IF billtype > 1 Or billtype = 1 And flag = 0 THEN FOR i = 1 To it_mxbt IF storage_plancode_flag = 1 THEN //仓库中是否设置了使用 “进仓单号” 作为批号 inwaremx[i].plancode = inwarecode END IF INSERT INTO u_inwaremx (scid, inwareid, printid, mtrlid, plancode, status, qty, addqty, packqty, fprice, rebate, price, planprice, mxdscrp, jgprice, relid, relprintid, ifrel, woodcode, relcode, pcode, sptid_cusid, cost, sptmtrlname, unit, rate, uprice, uqty, bootqty, noauditqty, mtrlcuscode, dftsptprice, formula, waredscrp, inworkdate, tax, buyqty, uamt, uamt_tax, bsamt, bsamt_tax, costamt, uprice_notax, mxdscrp2, mxdscrp3, mxdscrp4, cost_notax) VALUES ( :scid, :inwareid, :inwaremx[i].printid, :inwaremx[i].mtrlid, :inwaremx[i].plancode, :inwaremx[i].status, :inwaremx[i].qty, :inwaremx[i].addqty, :inwaremx[i].packqty, :inwaremx[i].fprice, :inwaremx[i].rebate, :inwaremx[i].price, :inwaremx[i].planprice, :inwaremx[i].mxdscrp, :inwaremx[i].jgprice, :inwaremx[i].relid, :inwaremx[i].relprintid, :inwaremx[i].ifrel, :inwaremx[i].woodcode, :inwaremx[i].relcode, :inwaremx[i].pcode, :inwaremx[i].sptid, :inwaremx[i].cost, :inwaremx[i].sptmtrlname, :inwaremx[i].unit, :inwaremx[i].rate, :inwaremx[i].uprice, :inwaremx[i].uqty, :inwaremx[i].bootqty, :inwaremx[i].noauditqty, :inwaremx[i].mtrlcuscode, :inwaremx[i].dftsptprice, :inwaremx[i].formula, :inwaremx[i].waredscrp, :inwaremx[i].inworkdate, :inwaremx[i].tax, :inwaremx[i].buyqty, :inwaremx[i].uamt, :inwaremx[i].uamt_tax, :inwaremx[i].bsamt, :inwaremx[i].bsamt_tax, :inwaremx[i].costamt, :inwaremx[i].uprice_notax, :inwaremx[i].mxdscrp2, :inwaremx[i].mxdscrp3, :inwaremx[i].mxdscrp4, :inwaremx[i].cost_notax) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN IF it_newbegin THEN inwareid = 0 rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_inwaremx') > 0 THEN arg_msg = '插入单据明细内容失败,关键字ID重复' ELSEIF Pos(Lower(commit_transaction.SQLErrText),'IX_u_inwaremx') > 0 THEN arg_msg = '插入单据明细内容失败,三个属性字段重复' ELSE arg_msg = '插入单据明细内容失败,'+commit_transaction.SQLErrText END IF GOTO ext END IF NEXT ELSE FOR i = 1 To it_mxbt UPDATE u_inWAREmx SET uprice = :inWAREmx[i].uprice, mxdscrp = :inwaremx[I].mxdscrp, fprice = :inwaremx[I].fprice, rebate = :inwaremx[I].rebate, price = :inwaremx[I].price, tax = :inwaremx[i].tax, uamt = :inwaremx[i].uamt, uamt_tax = :inwaremx[i].uamt_tax, bsamt = :inwaremx[i].bsamt, bsamt_tax = :inwaremx[i].bsamt_tax, uprice_notax =:inwaremx[i].uprice_notax WHERE ( scid = :scid AND inWAREid = :inwareid AND printid = :inwaremx[i].printid); IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "更新明细价格、备注操作失败"+"~n" GOTO ext END IF NEXT END IF IF save_end(arg_msg) = 0 THEN rslt = 0 GOTO ext END IF it_newbegin = False it_updatebegin = False ext: IF rslt = 0 THEN ROLLBACK Using commit_transaction; p_clearmx() arg_msg = billname + ',' + arg_msg ELSEIF rslt = 1 And arg_ifcommit THEN COMMIT Using commit_transaction; END IF RETURN rslt end function public function integer priceaudit (long arg_scid, long arg_inwareid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i IF arg_scid < 0 THEN rslt = 0 arg_msg = "错误的分部ID" GOTO ext END IF IF arg_inwareid <= 0 THEN rslt = 0 arg_msg = "没有确认对象" GOTO ext END IF if getinfo(arg_scid,arg_inwareid,arg_msg) = 0 then rslt = 0 goto ext end if IF priceflag = 1 THEN rslt = 0 arg_msg = "单据已经确认" GOTO ext END IF UPDATE u_inware SET priceemp = :publ_operator, pricedate = getdate(), priceflag = 1 WHERE u_inware.inwareid = :arg_inwareid AND priceflag = 0 AND scid = :arg_scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致确认单据操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext ELSEIF commit_transaction.SQLNRows = 0 THEN rslt = 0 arg_msg = "单据正在确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText GOTO ext END IF priceflag = 1 ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT USING commit_transaction; END IF RETURN rslt end function public function integer c_priceaudit (long arg_scid, long arg_inwareid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i DateTime null_dt SetNull(null_dt) IF arg_scid < 0 THEN rslt = 0 arg_msg = "错误的分部ID" GOTO ext END IF IF arg_inwareid <= 0 THEN rslt = 0 arg_msg = "没有确认对象" GOTO ext END IF if getinfo(arg_scid,arg_inwareid,arg_msg) = 0 then rslt = 0 goto ext end if IF priceflag = 0 THEN rslt = 0 arg_msg = "单据未确认" GOTO ext END IF UPDATE u_inware SET priceemp = '', pricedate = :null_dt, priceflag = 0 WHERE u_inware.inwareid = :arg_inwareid AND priceflag = 1 AND scid = :arg_scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致确认单据操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext ELSEIF commit_transaction.SQLNRows = 0 THEN rslt = 0 arg_msg = "单据正在确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText GOTO ext END IF priceflag = 0 ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT USING commit_transaction; END IF RETURN rslt end function on uo_inware_buy.create call super::create end on on uo_inware_buy.destroy call super::destroy end on