$PBExportHeader$uo_outware_ll.sru forward global type uo_outware_ll from nonvisualobject end type end forward global type uo_outware_ll from nonvisualobject end type global uo_outware_ll uo_outware_ll type variables Long uo_outwareid String uo_outwarecode Decimal uo_sumamt_native Decimal uo_sumamt_en int uo_option_confirmaudit_sale_ll int uo_option_m_msttake int uo_option_otheramt_msttake string uo_option_change_otheramt int uo_option_mtrlware_limit int uo_option_noauditingqty_mode end variables forward prototypes public function integer add_dscrp (long arg_outwareid, string arg_newdescppart, ref string arg_msg) public function integer del (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit) public function integer updatebegin (long arg_outwareid, ref string arg_msg) public function integer audit (long arg_outwareid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit) public function integer audit_2 (long arg_outwareid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit) public function integer caudit (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit) public function integer caudit_2 (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit) public function integer save (s_outware_ll arg_out_ll, string arg_opemp, ref string arg_msg, boolean arg_ifcommit) public function integer audit_p (long arg_outwareid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit) public function integer caudit_p (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit) private function integer p_getinfo (long arg_outwareid, ref s_outware_ll arg_ref_s_outware, ref string arg_msg) private function integer getinfo (long arg_outwareid, ref s_outware_ll arg_ref_s_outware_ll, ref string arg_msg) public function integer uof_noauditingqty_add (s_outwaremx_ll arg_s_mx[], ref string arg_msg) public function integer uof_noauditingqty_del (long arg_outwareid, ref string arg_msg) end prototypes public function integer add_dscrp (long arg_outwareid, string arg_newdescppart, ref string arg_msg);Int rslt = 1 s_outware_ll arg_s_out_ll IF arg_newdescppart = '' THEN rslt = 0 arg_msg = "要添加内容为空,操作取消" GOTO ext END IF IF p_getinfo(arg_outwareid,arg_s_out_ll,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF arg_s_out_ll.flag = 0 THEN rslt = 0 arg_msg = "待审核状态下不可用" GOTO ext END IF UPDATE u_outware_ll SET dscrp = dscrp + ' ' + :arg_newdescppart Where u_outware_ll.outwareid = :arg_outwareid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致添加备注操作失败"+"~n"+sqlca.SQLErrText GOTO ext END IF ext: IF rslt = 1 THEN COMMIT; ELSE ROLLBACK; END IF RETURN rslt end function public function integer del (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 s_outware_ll arg_s_out_ll If arg_outwareid <= 0 Then rslt = 0 arg_msg = '错误单据唯一码' Goto ext End If If p_getinfo(arg_outwareid,arg_s_out_ll,arg_msg) = 0 Then rslt = 0 Goto ext End If If arg_s_out_ll.flag <> 0 Then rslt = 0 arg_msg = '单据不是在待审状态,不可以删除' Goto ext End If //更新库存已开单数(减) If uof_noauditingqty_del(arg_outwareid,arg_msg) = 0 Then rslt = 0 Goto ext End If Delete From u_outwaremx_ll Where outwareid = :arg_outwareid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "删除单据明细操作失败"+"~n"+sqlca.SQLErrText Goto ext End If Delete From u_outware_ll Where outwareid = :arg_outwareid And flag = 0; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "删除单据操作失败"+"~n"+sqlca.SQLErrText Goto ext End If ext: If rslt = 0 Then Rollback; ElseIf rslt = 1 And arg_ifcommit Then Commit; End If Return rslt end function public function integer updatebegin (long arg_outwareid, ref string arg_msg);Int rslt = 1 s_outware_ll arg_s_out_ll IF uo_option_confirmaudit_sale_ll = -1000 THEN rslt = 0 arg_msg = '选项:[134]来料加工发货单先确认后审核,读取初始默认值失败,操作取消!' GOTO ext END IF IF arg_outwareid <= 0 THEN rslt = 0 arg_msg = '错误单据唯一码' GOTO ext END IF IF p_getinfo(arg_outwareid,arg_s_out_ll,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF String ls_storagename SELECT storagename INTO :ls_storagename FROM u_storage Where storageid = :arg_s_out_ll.storageid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,仓库" GOTO ext END IF //检查是否有该仓库的建立权限 IF sys_user_storagestr_new <> '0' THEN IF Pos(sys_user_storagestr_new,','+String(arg_s_out_ll.storageid)+',') <= 0 THEN rslt = 0 arg_msg = '没有仓库: '+ls_storagename+' 的建立权限,不允许修改该仓库的单据' GOTO ext END IF END IF // IF uo_option_confirmaudit_sale_ll = 1 THEN IF arg_s_out_ll.priceflag = 1 AND arg_s_out_ll.flag = 1 AND arg_s_out_ll.secflag = 1 THEN rslt = 0 arg_msg = '单据已经过仓库及财务审核,不可以修改' GOTO ext END IF ELSE IF arg_s_out_ll.flag = 1 AND arg_s_out_ll.secflag = 1 THEN rslt = 0 arg_msg = '单据已经过仓库及财务审核,不可以修改' GOTO ext ELSEIF arg_s_out_ll.priceflag = 1 AND arg_s_out_ll.flag = 0 AND arg_s_out_ll.secflag = 0 THEN rslt = 0 arg_msg = '单据已经确认,仓审前不可以修改,不可以修改' GOTO ext END IF END IF ext: RETURN rslt end function public function integer audit (long arg_outwareid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt Long i,ll_ref_relid s_outware_ll arg_s_out_ll rslt = 1 IF uo_option_confirmaudit_sale_ll = -1000 THEN rslt = 0 arg_msg = '选项:[134]来料加工发货单先确认后审核,读取初始默认值失败,操作取消!' GOTO ext END IF uo_outware uo_out uo_out = CREATE uo_outware uo_out.commit_transaction = sqlca uo_out.if_getid_ture = FALSE uo_saletask_ll uo_t_ll uo_t_ll = CREATE uo_saletask_ll uo_t_ll.commit_transaction = sqlca IF arg_outwareid <= 0 THEN rslt = 0 arg_msg = '错误单据唯一码' GOTO ext END IF IF getinfo(arg_outwareid,arg_s_out_ll,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF String ls_storagename Long ll_scid_storage SELECT storagename,scid INTO :ls_storagename,:ll_scid_storage FROM u_storage Where storageid = :arg_s_out_ll.storageid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,仓库" GOTO ext END IF //检查是否有该仓库的建立权限 IF sys_user_storagestr_audit <> '0' THEN IF Pos(sys_user_storagestr_audit,','+String(arg_s_out_ll.storageid)+',') <= 0 THEN rslt = 0 arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许审核该仓库的单据' GOTO ext END IF END IF // IF arg_s_out_ll.flag = 1 THEN rslt = 0 arg_msg = '单据已经审核,不可以再审' GOTO ext END IF IF uo_option_confirmaudit_sale_ll = 1 THEN IF arg_s_out_ll.priceflag = 0 THEN rslt = 0 arg_msg = "单据需要确认后才能审核,请检查" GOTO ext END IF END IF //更新审核标记 UPDATE u_outware_ll SET auditingrep = :arg_opemp, auditingdate = getdate(), flag = 1 WHERE outwareid = :arg_outwareid AND flag = 0; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致单据审核操作失败"+"~n"+sqlca.SQLErrText GOTO ext ELSEIF sqlca.SQLNRows = 0 THEN rslt = 0 arg_msg = "单据正在审核,请稍后重试。"+"~n"+sqlca.SQLErrText GOTO ext END IF //更新订单完成数 FOR i = 1 TO UpperBound(arg_s_out_ll.arg_s_mx) - 1 IF arg_s_out_ll.arg_s_mx[i].relid = 0 THEN CONTINUE IF uo_t_ll.addmxcmpl(arg_s_out_ll.arg_s_mx[i].relid,& arg_s_out_ll.arg_s_mx[i].relprintid,arg_s_out_ll.arg_s_mx[i].uqty,arg_msg,FALSE) = 0 THEN arg_msg = '行:'+String(i)+','+arg_msg rslt = 0 GOTO ext END IF IF uo_t_ll.trycmplsaletask(arg_s_out_ll.arg_s_mx[i].relid,arg_msg,FALSE) = 0 THEN arg_msg = '行:'+String(i)+','+arg_msg rslt = 0 GOTO ext END IF NEXT //生成并审核出仓单 IF uo_out.newbegin(ll_scid_storage,5,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF uo_out.relid = arg_s_out_ll.outwareid uo_out.outdate = arg_s_out_ll.outdate uo_out.outrep = arg_s_out_ll.outrep uo_out.part = arg_s_out_ll.outwarecode uo_out.dscrp = arg_s_out_ll.dscrp uo_out.cusname = '来料加工发货单出仓单' uo_out.storageid = arg_s_out_ll.storageid uo_out.cusid = arg_s_out_ll.cusid FOR i = 1 TO UpperBound(arg_s_out_ll.arg_s_mx) - 1 IF uo_out.acceptmx(arg_s_out_ll.arg_s_mx[i].mtrlwareid,& arg_s_out_ll.arg_s_mx[i].qty,arg_s_out_ll.arg_s_mx[i].fprice,1,& arg_s_out_ll.arg_s_mx[i].mxdscrp,arg_s_out_ll.arg_s_mx[i].printid,& arg_msg,0,0,0,& arg_s_out_ll.arg_s_mx[i].packqty,arg_s_out_ll.arg_s_mx[i].outtypestr,0,& 0,arg_s_out_ll.arg_s_mx[i].u_mtrldef_unit,& arg_s_out_ll.arg_s_mx[i].qty,1,'','',0,0,'',0,0,0,0,'','') = 0 THEN rslt = 0 GOTO ext END IF NEXT IF uo_out.Save(FALSE,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF ll_ref_relid = uo_out.outwareid //4.原事务审核出仓单 IF uo_out.getinfo(ll_scid_storage,ll_ref_relid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF uo_out.auditing(FALSE,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF UPDATE u_outware_ll SET relid = :ll_ref_relid Where outwareid = :arg_outwareid; IF sqlca.SQLCode <> 0 THEN arg_msg = '更新相关出仓单id失败,'+sqlca.SQLErrText rslt = 0 GOTO ext END IF //更新库存已开单数(减) If uof_noauditingqty_del(arg_outwareid,arg_msg) = 0 Then rslt = 0 Goto ext End If ext: IF rslt = 0 THEN ROLLBACK; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT; END IF DESTROY uo_out DESTROY uo_t_ll RETURN rslt end function public function integer audit_2 (long arg_outwareid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 long i s_outware_ll arg_s_out_ll //uo_option_m_msttake //uo_option_otheramt_msttake //uo_option_change_otheramt IF uo_option_m_msttake = -1000 THEN rslt = 0 arg_msg = '选项:[045]系统使用多币种应收帐,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_otheramt_msttake = -1000 THEN rslt = 0 arg_msg = '选项:[052]优惠金额多币种,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_change_otheramt = '-1000' THEN rslt = 0 arg_msg = '选项:[050]销售发货单优惠金额文本,读取初始默认值失败,操作取消!' GOTO ext END IF uo_musttake uo_t uo_t = create uo_musttake uo_cusprice uo_update_cusprice uo_update_cusprice = Create uo_cusprice IF arg_outwareid <= 0 THEN rslt = 0 arg_msg = '错误单据唯一码' GOTO ext END IF IF getinfo(arg_outwareid,arg_s_out_ll,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF arg_s_out_ll.flag <> 1 THEN rslt = 0 arg_msg = '单据不是在仓审状态,不可以财务审' GOTO ext END IF //更新审核标记 UPDATE u_outware_ll SET secauditingrep = :arg_opemp, secauditingdate = getdate(), secflag = 1 WHERE outwareid = :arg_outwareid AND flag = 1; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致单据财务审操作失败"+"~n"+sqlca.SQLErrText GOTO ext ELSEIF sqlca.SQLNRows = 0 THEN rslt = 0 arg_msg = "单据正在审核,请稍后重试。"+"~n"+sqlca.SQLErrText GOTO ext END IF FOR i = 1 To upperbound(arg_s_out_ll.arg_s_mx) - 1 IF uo_update_cusprice.uof_update_custprice(0,0,arg_s_out_ll.cusid,& arg_s_out_ll.arg_s_mx[i].mtrlid,arg_s_out_ll.arg_s_mx[i].mtrlcode,arg_s_out_ll.arg_s_mx[i].status,& arg_s_out_ll.arg_s_mx[i].woodcode,arg_s_out_ll.arg_s_mx[i].pcode,& arg_s_out_ll.outwareid,arg_s_out_ll.outwarecode,arg_s_out_ll.outdate,arg_s_out_ll.arg_s_mx[i].enprice,& arg_s_out_ll.arg_s_mx[i].rebate,arg_s_out_ll.arg_s_mx[i].costamt,0,'',& arg_s_out_ll.arg_s_mx[i].printid,0,arg_s_out_ll.relint_2,0,0,False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF NEXT //生成应收帐 String ls_mtrlname String ls_about Decimal ld_takeamt = 0,ld_msttakeamt = 0 Long ll_moneyid,ll_moneyid_yh,ll_moneyid_native decimal ld_mrate,ld_mrate_yh Int li_btype Long ll_accountsid SELECT btype,accountsid INTO :li_btype,:ll_accountsid FROM cw_banktype Where banktypeid = :arg_s_out_ll.relint_1; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询结算方式类型失败,'+ sqlca.SQLErrText GOTO ext END IF IF uo_sumamt_en <> 0 THEN Long ll_dft_itemid_take,ll_dft_itemid_yh IF arg_s_out_ll.thflag = 1 THEN ls_about = arg_s_out_ll.outwarecode + "退货款,相关号:"+arg_s_out_ll.part SELECT itemid INTO :ll_dft_itemid_take FROM u_itemdef Where dfttype = 4; IF sqlca.SQLCode <> 0 THEN arg_msg = '查询默认销售退货项目资料失败,'+sqlca.sqlerrtext rslt = 0 GOTO ext END IF ELSE ls_about = arg_s_out_ll.outwarecode + "应收款,相关号:"+arg_s_out_ll.part SELECT itemid INTO :ll_dft_itemid_take FROM u_itemdef Where dfttype = 1 using sqlca; IF sqlca.SQLCode <> 0 THEN arg_msg = '查询默认应收项目资料失败,'+sqlca.sqlerrtext rslt = 0 GOTO ext END IF END IF SELECT moneyid INTO :ll_moneyid_native FROM cw_currency Where native = 1; IF sqlca.SQLCode <> 0 THEN arg_msg = '查询本位币资料失败' rslt = 0 GOTO ext END IF IF uo_option_m_msttake = 0 THEN ld_msttakeamt = uo_sumamt_native ll_moneyid = ll_moneyid_native ld_mrate = 1 ELSE ld_msttakeamt = uo_sumamt_en ll_moneyid = arg_s_out_ll.relint_2 ld_mrate = arg_s_out_ll.mrate END IF Decimal ld_mrate_amt IF arg_s_out_ll.otheramt <> 0 THEN IF uo_option_otheramt_msttake = 1 THEN ld_mrate_amt = arg_s_out_ll.otheramt * arg_s_out_ll.mrate ll_moneyid_yh = arg_s_out_ll.relint_2 ld_mrate_yh = arg_s_out_ll.mrate ELSE ld_mrate_amt = arg_s_out_ll.otheramt ll_moneyid_yh = ll_moneyid_native ld_mrate_yh = 1 END IF END IF IF li_btype = 1 THEN ld_takeamt = ld_msttakeamt - ld_mrate_amt ELSE ld_takeamt = 0 END IF String ls_taskdscrp Decimal ld_taskamt String ls_taskcode[] Decimal ld_saletaskamt[] Long ll_i,j,k ll_i = 0 FOR i = 1 TO upperbound(arg_s_out_ll.arg_s_mx) - 1 IF arg_s_out_ll.arg_s_mx[i].ifrel = 1 THEN IF uo_option_m_msttake = 0 THEN ld_taskamt = arg_s_out_ll.arg_s_mx[i].uqty * arg_s_out_ll.arg_s_mx[i].rebate * arg_s_out_ll.arg_s_mx[i].price //计算单据总金额 ELSE ld_taskamt = arg_s_out_ll.arg_s_mx[i].uqty * arg_s_out_ll.arg_s_mx[i].rebate * arg_s_out_ll.arg_s_mx[i].enprice //计算单据总金额 END IF FOR j = 1 TO ll_i IF ls_taskcode[j] = arg_s_out_ll.arg_s_mx[i].relcode THEN ld_saletaskamt[j] = ld_saletaskamt[j] + ld_taskamt GOTO exit_for END IF NEXT ll_i++ ls_taskcode[ll_i] = arg_s_out_ll.arg_s_mx[i].relcode ld_saletaskamt[ll_i] = ld_taskamt END IF exit_for: NEXT FOR k = 1 TO ll_i ls_taskdscrp = ls_taskdscrp + '订单'+ls_taskcode[k]+'金额:'+String(ld_saletaskamt[k],'#,##0.00')+',' NEXT s_bmsttake s_take s_take.scid = arg_s_out_ll.scid s_take.cusid = arg_s_out_ll.cusid s_take.takedate = arg_s_out_ll.outdate s_take.inrep = arg_s_out_ll.outrep s_take.oriamt = ld_msttakeamt s_take.msttakeamt = ld_msttakeamt s_take.takeamt = ld_takeamt s_take.takeamt_cn = ld_takeamt s_take.dscrp = ls_about s_take.billcode = arg_s_out_ll.outwarecode s_take.relcode = arg_s_out_ll.part s_take.banktypeid = arg_s_out_ll.relint_1 s_take.opemp = publ_operator s_take.buildtype = 1 s_take.outwareid = arg_s_out_ll.outwareid s_take.accountsid = ll_accountsid s_take.itemid = ll_dft_itemid_take s_take.moneyid = ll_moneyid s_take.moneyid_cn = ll_moneyid s_take.viewdate = arg_s_out_ll.viewdate s_take.taskdscrp = ls_taskdscrp s_take.mrate = ld_mrate IF uo_t.add_takerec(s_take,arg_msg,FALSE) = 0 THEN rslt = 0 GOTO ext END IF IF arg_s_out_ll.otheramt <> 0 THEN ls_about = arg_s_out_ll.outwarecode + uo_option_change_otheramt +",相关号:"+arg_s_out_ll.part SELECT itemid INTO :ll_dft_itemid_yh FROM u_itemdef Where dfttype = 3; IF sqlca.SQLCode <> 0 THEN arg_msg = '查询默认优惠项目资料失败' rslt = 0 GOTO ext END IF s_bmsttakemx s_takemx s_takemx.scid = arg_s_out_ll.scid s_takemx.takeid = uo_t.ref_takeid s_takemx.cusid = arg_s_out_ll.cusid s_takemx.takedate = arg_s_out_ll.outdate s_takemx.inrep = arg_s_out_ll.outrep s_takemx.msttakeamt = 0 - ld_mrate_amt s_takemx.takeamt = 0 s_takemx.dscrp = ls_about s_takemx.billcode = arg_s_out_ll.outwarecode s_takemx.banktypeid = arg_s_out_ll.relint_1 s_takemx.opemp = publ_operator s_takemx.buildtype = 3 s_takemx.outwareid = arg_s_out_ll.outwareid s_takemx.salebillid = 0 s_takemx.itemid = ll_dft_itemid_yh s_takemx.moneyid = ll_moneyid_yh s_takemx.mrate = ld_mrate_yh IF uo_t.add_takerecmx(s_takemx,arg_msg,FALSE) = 0 THEN rslt = 0 GOTO ext END IF END IF UPDATE u_outware_ll SET relint_3 = :uo_t.ref_takeid WHERE u_outware_ll.outwareid = :arg_outwareid AND flag = 1 AND secflag = 1; IF sqlca.SQLCode <> 0 THEN arg_msg = '更新相关应收帐id失败' rslt = 0 GOTO ext END IF END IF ext: IF rslt = 0 THEN ROLLBACK; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT; END IF Destroy uo_update_cusprice RETURN rslt end function public function integer caudit (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Long i s_outware_ll arg_s_out_ll DateTime null_dt SetNull(null_dt) uo_outware uo_out uo_out = Create uo_outware uo_out.commit_transaction = sqlca uo_out.if_getid_ture = False uo_saletask_ll uo_t_ll uo_t_ll = Create uo_saletask_ll uo_t_ll.commit_transaction = sqlca If arg_outwareid <= 0 Then rslt = 0 arg_msg = '错误单据唯一码' Goto ext End If If getinfo(arg_outwareid,arg_s_out_ll,arg_msg) = 0 Then rslt = 0 Goto ext End If String ls_storagename Long ll_scid_storage Select storagename,scid Into :ls_storagename,:ll_scid_storage From u_storage Where storageid = :arg_s_out_ll.storageid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "查询操作失败,仓库" Goto ext End If //检查是否有该仓库的建立权限 If sys_user_storagestr_audit <> '0' Then If Pos(sys_user_storagestr_audit,','+String(arg_s_out_ll.storageid)+',') <= 0 Then rslt = 0 arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许撤审该仓库的单据' Goto ext End If End If // If arg_s_out_ll.ctmint > 0 Then arg_msg = '单据已截数,不能操作' rslt = 0 Goto ext End If If arg_s_out_ll.secflag = 1 Then rslt = 0 arg_msg = '单据已财务审,不可以撤审' Goto ext End If If arg_s_out_ll.flag = 0 Then rslt = 0 arg_msg = '单据未仓审,不可以撤审' Goto ext End If //更新审核标记 Update u_outware_ll Set auditingrep = '', auditingdate = :null_dt, flag = 0 Where outwareid = :arg_outwareid And flag = 1 And secflag = 0; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致单据撤审操作失败"+"~n"+sqlca.SQLErrText Goto ext ElseIf sqlca.SQLNRows = 0 Then rslt = 0 arg_msg = "单据正在撤审,请稍后重试。"+"~n"+sqlca.SQLErrText Goto ext End If //更新订单完成数 For i = 1 To UpperBound(arg_s_out_ll.arg_s_mx) - 1 If arg_s_out_ll.arg_s_mx[i].relid = 0 Then Continue If uo_t_ll.addmxcmpl(arg_s_out_ll.arg_s_mx[i].relid,& arg_s_out_ll.arg_s_mx[i].relprintid,0 - arg_s_out_ll.arg_s_mx[i].uqty,arg_msg,False) = 0 Then rslt = 0 Goto ext End If If uo_t_ll.trycmplsaletask(arg_s_out_ll.arg_s_mx[i].relid,arg_msg,False) = 0 Then rslt = 0 Goto ext End If Next //撤审并删除出仓单 If uo_out.getinfo(ll_scid_storage,arg_s_out_ll.relid,arg_msg) = 0 Then rslt = 0 Goto ext End If If uo_out.c_auditing(False,arg_msg) = 0 Then rslt = 0 Goto ext End If If uo_out.del(ll_scid_storage,arg_s_out_ll.relid,0,arg_msg,False) = 0 Then rslt = 0 Goto ext End If //更新库存已开单数 If uof_noauditingqty_add(arg_s_out_ll.arg_s_mx,arg_msg) = 0 Then rslt = 0 Goto ext End If ext: If rslt = 0 Then Rollback; ElseIf rslt = 1 And arg_ifcommit Then Commit; End If Destroy uo_out Destroy uo_t_ll Return rslt end function public function integer caudit_2 (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Long i s_outware_ll arg_s_out_ll uo_musttake uo_t uo_t = Create uo_musttake uo_cusprice uo_update_cusprice uo_update_cusprice = Create uo_cusprice DateTime null_dt SetNull(null_dt) If arg_outwareid <= 0 Then rslt = 0 arg_msg = '错误单据唯一码' Goto ext End If If p_getinfo(arg_outwareid,arg_s_out_ll,arg_msg) = 0 Then rslt = 0 Goto ext End If If arg_s_out_ll.ctmint > 0 Then arg_msg = '单据已截数,不能操作' rslt = 0 Goto ext End If If arg_s_out_ll.secflag = 0 Then rslt = 0 arg_msg = '单据不是在财审状态,不可以撤审' Goto ext End If //更新审核标记 Update u_outware_ll Set secauditingrep = '', secauditingdate = :null_dt, secflag = 0 Where outwareid = :arg_outwareid And secflag = 1; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致单据撤审操作失败"+"~n"+sqlca.SQLErrText Goto ext ElseIf sqlca.SQLNRows = 0 Then rslt = 0 arg_msg = "单据正在撤审,请稍后重试。"+"~n"+sqlca.SQLErrText Goto ext End If For i = 1 To UpperBound(arg_s_out_ll.arg_s_mx) If uo_update_cusprice.uof_del_cusprice_auto(arg_s_out_ll.cusid,arg_s_out_ll.outwareid,& arg_s_out_ll.arg_s_mx[i].printid,arg_s_out_ll.arg_s_mx[i].mtrlid,arg_s_out_ll.arg_s_mx[i].status,& arg_s_out_ll.arg_s_mx[i].woodcode,arg_s_out_ll.arg_s_mx[i].pcode,& 0,arg_s_out_ll.relint_2,0,0,False,arg_msg) = 0 Then rslt = 0 Goto ext End If Next //删除应收帐 If arg_s_out_ll.relint_3 > 0 Then If uo_t.del_takerec(arg_s_out_ll.scid,1,arg_s_out_ll.relint_3,arg_s_out_ll.cusid,arg_msg,False) = 0 Then rslt = 0 Goto ext End If End If ext: If rslt = 0 Then Rollback; ElseIf rslt = 1 And arg_ifcommit Then Commit; End If Destroy uo_t Return rslt end function public function integer save (s_outware_ll arg_out_ll, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1 Long cnt = 0 DateTime server_dt Long ll_outwareid,it_mxbt,i,ls_i String ls_sccode,ls_outwarecode Int li_flag,li_priceflag If uo_option_mtrlware_limit = -1000 Then rslt = 0 arg_msg = '选项:[037]客户库存选择限制,读取初始默认值失败,操作取消!' Goto ext End If If IsNull(arg_out_ll.scid) Then arg_out_ll.scid = 0 If IsNull(arg_out_ll.outwareid) Then arg_out_ll.outwareid = 0 If IsNull(arg_out_ll.outrep) Then arg_out_ll.outrep = '' If IsNull(arg_out_ll.part) Then arg_out_ll.part = '' If IsNull(arg_out_ll.dscrp) Then arg_out_ll.dscrp = '' If IsNull(arg_out_ll.relid) Then arg_out_ll.relid = 0 If IsNull(arg_out_ll.relid) Then arg_out_ll.relid = 0 If IsNull(arg_out_ll.storageid) Then arg_out_ll.storageid = 0 If IsNull(arg_out_ll.cusid) Then arg_out_ll.cusid = 0 If IsNull(arg_out_ll.otheramt) Then arg_out_ll.otheramt = 0 If IsNull(arg_out_ll.relstr_1) Then arg_out_ll.relstr_1 = '' If IsNull(arg_out_ll.relstr_2) Then arg_out_ll.relstr_2 = '' If IsNull(arg_out_ll.relstr_3) Then arg_out_ll.relstr_3 = '' If IsNull(arg_out_ll.relint_1) Then arg_out_ll.relint_1 = 0 If IsNull(arg_out_ll.relint_2) Then arg_out_ll.relint_2 = 0 If IsNull(arg_out_ll.relint_3) Then arg_out_ll.relint_3 = 0 If IsNull(arg_out_ll.rel_address) Then arg_out_ll.rel_address = '' If IsNull(arg_out_ll.rel_tele) Then arg_out_ll.rel_tele = '' If IsNull(arg_out_ll.rel_fax) Then arg_out_ll.rel_fax = '' If IsNull(arg_out_ll.rel_rep) Then arg_out_ll.rel_rep = '' If IsNull(arg_out_ll.mrate) Then arg_out_ll.mrate = 0 If IsNull(arg_out_ll.damt) Then arg_out_ll.damt = 0 If IsNull(arg_out_ll.upname) Then arg_out_ll.upname = '' If IsNull(arg_out_ll.thflag) Then arg_out_ll.thflag = 0 it_mxbt = UpperBound(arg_out_ll.arg_s_mx) If it_mxbt <= 0 Then rslt = 0 arg_msg = "没有正确明细内容" Goto ext End If String ls_storagename Long ll_scid_storage Int li_if_cus_mtrlware Int ls_noallocflag Select storagename,scid,balctype,noallocflag Into :ls_storagename,:ll_scid_storage,:li_if_cus_mtrlware,:ls_noallocflag From u_storage Where storageid = :arg_out_ll.storageid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "查询仓库资料失败" Goto ext End If //检查是否有该仓库的建立权限 If sys_user_storagestr_new <> '0' Then If Pos(sys_user_storagestr_new,','+String(arg_out_ll.storageid)+',') <= 0 Then rslt = 0 arg_msg = '没有仓库: '+ls_storagename+' 的建立权限,不允许建立该仓库的单据' Goto ext End If End If // If arg_out_ll.outwareid = 0 Then If f_check_inoutdate(arg_out_ll.storageid,arg_out_ll.outdate,True,arg_msg) = 0 Then rslt = 0 Goto ext End If Else Select flag,priceflag Into :li_flag,:li_priceflag From u_outware_ll Where outwareid = :arg_out_ll.outwareid; If sqlca.SQLCode <> 0 Then arg_msg = '查询单据状态失败,'+sqlca.SQLErrText rslt = 0 Goto ext End If If li_flag = 0 Then If f_check_inoutdate(arg_out_ll.storageid,arg_out_ll.outdate,True,arg_msg) = 0 Then rslt = 0 Goto ext End If End If End If If arg_out_ll.cusid = 0 Then arg_msg = '请选择客户资料' rslt = 0 Goto ext End If cnt = 0 Select count(*) Into :cnt From u_cust Where cusid = :arg_out_ll.cusid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "查询操作失败,客户资料" Goto ext End If If arg_out_ll.relint_1 = 0 Then arg_msg = '请选择结算方式' rslt = 0 Goto ext End If cnt = 0 Select count(*) Into :cnt From cw_currency Where moneyid = :arg_out_ll.relint_2; If sqlca.SQLCode <> 0 Then arg_msg = '查询币种失败' rslt = 0 Goto ext End If If cnt = 0 Then arg_msg = '币种资料不存在' rslt = 0 Goto ext End If If arg_out_ll.mrate = 0 Then arg_msg = '币种汇率错误' rslt = 0 Goto ext End If If arg_out_ll.outrep = '' Then arg_msg = '请输入业务员' rslt = 0 Goto ext End If Select Top 1 getdate() Into :server_dt From u_user; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "查询操作失败,日期 " Goto ext End If Decimal i_notauditqty,i_allouseqty Decimal ol_mtrl_qty,ld_mx_qty,ld_ref_qty,ld_ref_pack_min_nofpqty,ld_ref_noauditingqty_ifpackpro Int li_ifpackpro String ls_msg,ls_unit String ls_relcode Decimal lde_noconqty,lde_mx_qty,lde_notauditqty For i = 1 To it_mxbt If arg_out_ll.arg_s_mx[i].ifrel = 1 And arg_out_ll.arg_s_mx[i].relid = 0 Then arg_msg = '行:'+String(arg_out_ll.arg_s_mx[i].printid)+',物料:'+arg_out_ll.arg_s_mx[i].mtrlcode+',没有选订单,请检查' rslt = 0 Goto ext End If If arg_out_ll.arg_s_mx[i].rebate <= 0 Then arg_msg = '行:'+String(arg_out_ll.arg_s_mx[i].printid)+',物料:'+arg_out_ll.arg_s_mx[i].mtrlcode+',折扣错误,请检查' rslt = 0 Goto ext End If If arg_out_ll.arg_s_mx[i].enprice * arg_out_ll.arg_s_mx[i].rebate < 0 Then //检查单价 rslt = 0 arg_msg = '行:'+String(arg_out_ll.arg_s_mx[i].printid)+',物料:'+arg_out_ll.arg_s_mx[i].mtrlcode+',单价错误,请检查' Goto ext End If arg_out_ll.arg_s_mx[i].mtrlwarescid = ll_scid_storage i_notauditqty = 0 i_allouseqty = 0 ol_mtrl_qty = 0 ld_mx_qty = 0 ld_ref_qty = 0 //检查物料库存ID Select u_mtrlware.mtrlid, u_mtrlware.storageid, u_mtrlware.plancode, u_mtrlware.status, u_mtrlware.cost, u_mtrldef.mtrlcode, u_mtrlware.sptid, u_mtrlware.dxflag, u_mtrlware.woodcode, u_mtrlware.pcode, u_mtrlware.noauditingqty, u_mtrlware.noallocqty, u_mtrlware.mtrlcuscode, u_mtrlware.location Into :arg_out_ll.arg_s_mx[i].mtrlid, :arg_out_ll.arg_s_mx[i].storageid, :arg_out_ll.arg_s_mx[i].plancode, :arg_out_ll.arg_s_mx[i].status, :arg_out_ll.arg_s_mx[i].cost, :arg_out_ll.arg_s_mx[i].mtrlcode, :arg_out_ll.arg_s_mx[i].sptid, :arg_out_ll.arg_s_mx[i].dxflag, :arg_out_ll.arg_s_mx[i].woodcode, :arg_out_ll.arg_s_mx[i].pcode, :i_notauditqty, :i_allouseqty, :arg_out_ll.arg_s_mx[i].mtrlcuscode, :arg_out_ll.arg_s_mx[i].location From u_mtrlware,u_mtrldef Where ( u_mtrlware.mtrlwareid = :arg_out_ll.arg_s_mx[i].mtrlwareid ) And ( u_mtrlware.mtrlid = u_mtrldef.mtrlid ) And ( u_mtrlware.scid = :arg_out_ll.arg_s_mx[i].mtrlwarescid ); If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "行"+String(arg_out_ll.arg_s_mx[i].printid)+"物料,查询操作失败,库存编号(出仓单)错误,分部:"+String(arg_out_ll.arg_s_mx[i].mtrlwarescid)+'库存:'+String(arg_out_ll.arg_s_mx[i].mtrlwareid)+',~n'+sqlca.SQLErrText Goto ext End If If IsNull(i_allouseqty) Then i_allouseqty = 0 If IsNull(i_notauditqty) Then i_notauditqty = 0 If li_if_cus_mtrlware = 1 And uo_option_mtrlware_limit = 0 Then If arg_out_ll.cusid <> arg_out_ll.arg_s_mx[i].sptid Then rslt = 0 arg_msg = "行"+String(arg_out_ll.arg_s_mx[i].printid)+"物料,查询操作失败,明细纪录对应的库存不是该客户的库存!" Goto ext End If End If //*****检查大于未开数不可以开单 If li_flag = 0 Then If ls_noallocflag = 1 Then If arg_out_ll.outwareid > 0 Then Select sum(u_outwaremx.qty) Into :ol_mtrl_qty From u_outwaremx Where u_outwaremx.outwareid = :arg_out_ll.outwareid And u_outwaremx.mtrlwareid = :arg_out_ll.arg_s_mx[i].mtrlwareid; If sqlca.SQLCode = -1 Then rslt = 0 arg_msg = "行"+String(arg_out_ll.arg_s_mx[i].printid)+"物料,查询原开单数量失败" Goto ext End If End If For ls_i = 1 To it_mxbt If arg_out_ll.arg_s_mx[i].mtrlwareid = arg_out_ll.arg_s_mx[ls_i].mtrlwareid Then ld_mx_qty = ld_mx_qty + arg_out_ll.arg_s_mx[ls_i].qty End If Next ld_mx_qty = ld_mx_qty + arg_out_ll.arg_s_mx[i].qty If IsNull(ol_mtrl_qty) Then ol_mtrl_qty = 0 If IsNull(ld_mx_qty) Then ld_mx_qty = 0 Select ifpackpro Into :li_ifpackpro From u_mtrldef Where mtrlid = :arg_out_ll.arg_s_mx[i].mtrlid ; If sqlca.SQLCode <> 0 Then arg_msg = "行"+String(arg_out_ll.arg_s_mx[i].printid)+"物料,查询物料是否包件产品失败,"+sqlca.SQLErrText rslt = 0 Goto ext End If //查询可装数 ld_ref_qty = 0 If li_ifpackpro = 1 Then If f_cmp_di_qty(arg_out_ll.arg_s_mx[i].mtrlid,arg_out_ll.storageid,& arg_out_ll.arg_s_mx[i].status,arg_out_ll.arg_s_mx[i].woodcode,& arg_out_ll.arg_s_mx[i].pcode,arg_out_ll.arg_s_mx[i].plancode,& arg_out_ll.arg_s_mx[i].mtrlcuscode,ld_ref_qty,ld_ref_pack_min_nofpqty,ld_ref_noauditingqty_ifpackpro,ls_msg,arg_msg) = 0 Then ld_ref_qty = 0 End If End If If ld_mx_qty > ( i_allouseqty - i_notauditqty + ol_mtrl_qty + ld_ref_qty ) Then rslt = 0 arg_msg = "行"+String(arg_out_ll.arg_s_mx[i].printid)+"物料,库存未开单数不够,不能开单.未开单数{"+String(i_allouseqty - i_notauditqty + ol_mtrl_qty,'#####,0.00#######')+"}" + "可组装数{"+String(ld_ref_qty,'#####,0.00#######')+"}" Goto ext End If End If End If //检查订单数 If arg_out_ll.arg_s_mx[i].relid > 0 And li_flag = 0 Then Select u_saletask_ll.taskcode, u_saletaskmx_ll.usaleqty - u_saletaskmx_ll.consignedqty Into :ls_relcode,:lde_noconqty From u_saletaskmx_ll,u_saletask_ll Where u_saletaskmx_ll.taskid = :arg_out_ll.arg_s_mx[i].relid And u_saletaskmx_ll.printid = :arg_out_ll.arg_s_mx[i].relprintid And u_saletaskmx_ll.taskid = u_saletask_ll.taskid; If sqlca.SQLCode <> 0 Then arg_msg = "行"+String(arg_out_ll.arg_s_mx[i].printid)+'物料,查询销售订单是否有订购产品失败' rslt = 0 Goto ext End If lde_mx_qty = 0 For ls_i = 1 To UpperBound(arg_out_ll.arg_s_mx) - 1 If arg_out_ll.arg_s_mx[i].relid = arg_out_ll.arg_s_mx[ls_i].relid And & arg_out_ll.arg_s_mx[i].relprintid = arg_out_ll.arg_s_mx[ls_i].relprintid Then lde_mx_qty = lde_mx_qty + arg_out_ll.arg_s_mx[ls_i].uqty End If Next //查询相关订单已开发货单未审核数量 Select isnull(sum(u_outwaremx_ll.uqty),0) Into :lde_notauditqty From u_outwaremx_ll,u_outware_ll Where u_outwaremx_ll.relid = :arg_out_ll.arg_s_mx[i].relid And u_outwaremx_ll.relprintid = :arg_out_ll.arg_s_mx[i].relprintid And u_outware_ll.flag = 0 And u_outwaremx_ll.outwareid = u_outware_ll.outwareid And u_outware_ll.outwareid <> :arg_out_ll.outwareid; If sqlca.SQLCode <> 0 Then arg_msg = "行"+String(arg_out_ll.arg_s_mx[i].printid)+'物料,查询销售订单:'+ls_relcode+',已开发货单未审核数量失败' rslt = 0 Goto ext End If If lde_notauditqty + lde_mx_qty > lde_noconqty Then arg_msg = "行"+String(arg_out_ll.arg_s_mx[i].printid)+'物料所属订单:'+ls_relcode+' 未发货数:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########') rslt = 0 Goto ext End If arg_out_ll.arg_s_mx[i].relcode = ls_relcode End If If arg_out_ll.arg_s_mx[i].rate = 0 Then arg_out_ll.arg_s_mx[i].rate = 1 arg_out_ll.arg_s_mx[i].rate = arg_out_ll.arg_s_mx[i].qty / arg_out_ll.arg_s_mx[i].uqty Select unit Into :ls_unit From u_mtrldef Where mtrlid = :arg_out_ll.arg_s_mx[i].mtrlid ; If sqlca.SQLCode <> 0 Then arg_msg = "行"+String(arg_out_ll.arg_s_mx[i].printid)+"物料,查询物料库存单位失败,"+sqlca.SQLErrText rslt = 0 Goto ext End If If Trim(ls_unit) <> Trim(arg_out_ll.arg_s_mx[i].unit) And arg_out_ll.arg_s_mx[i].rate = 1 Then arg_msg = '单据,行:'+String(arg_out_ll.arg_s_mx[i].printid)+',物料库存单位:'+Trim(ls_unit)+'与计价单位:'+Trim(arg_out_ll.arg_s_mx[i].unit)+'不同,但转换率为1,请检查' rslt = 0 Goto ext End If If Trim(ls_unit) = Trim(arg_out_ll.arg_s_mx[i].unit) And arg_out_ll.arg_s_mx[i].rate <> 1 Then arg_msg = '进仓单,行:'+String(arg_out_ll.arg_s_mx[i].printid)+',物料库存单位:'+Trim(ls_unit)+'与采购单位:'+Trim(arg_out_ll.arg_s_mx[i].unit)+'相同,但转换率不为1,请检查' rslt = 0 Goto ext End If arg_out_ll.arg_s_mx[i].price = arg_out_ll.arg_s_mx[i].enprice * arg_out_ll.mrate arg_out_ll.arg_s_mx[i].fprice = arg_out_ll.arg_s_mx[i].price / arg_out_ll.arg_s_mx[i].rate //取定价 f_get_defsaleprice(arg_out_ll.cusid,arg_out_ll.arg_s_mx[i].mtrlid,& arg_out_ll.arg_s_mx[i].status,arg_out_ll.arg_s_mx[i].pcode,& arg_out_ll.arg_s_mx[i].woodcode,arg_out_ll.relint_2,arg_out_ll.arg_s_mx[i].dftsaleprice) Next If arg_out_ll.outwareid = 0 Then ll_outwareid = f_sys_scidentity(0,"u_outware_ll","outwareid",arg_msg,True,id_sqlca) If ll_outwareid <= 0 Then rslt = 0 Goto ext End If If f_get_sccode(arg_out_ll.scid,sqlca,ls_sccode,arg_msg) = 0 Then rslt = 0 Goto ext End If If arg_out_ll.thflag = 0 Then ls_outwarecode = getid(arg_out_ll.scid,ls_sccode + 'LX',Date(server_dt),False,sqlca) Else ls_outwarecode = getid(arg_out_ll.scid,ls_sccode + 'LH',Date(server_dt),False,sqlca) End If If ls_outwarecode = "err" Or ls_outwarecode = '' Then rslt = 0 arg_msg = "无法获取单据编号"+"~n"+sqlca.SQLErrText Goto ext End If Insert Into u_outware_ll ( scid, outwareid, outwarecode, relid, storageid, outdate, outrep, part, dscrp, cusid, thflag, opdate, opemp, relstr_1, relstr_2, relstr_3, relint_1, relint_2, relint_3, otheramt, damt, rel_address, rel_tele, rel_fax, rel_rep, mrate, upname, viewdate) Values ( :arg_out_ll.scid, :ll_outwareid, :ls_outwarecode, :arg_out_ll.relid, :arg_out_ll.storageid, :arg_out_ll.outdate, :arg_out_ll.outrep, :arg_out_ll.part, :arg_out_ll.dscrp, :arg_out_ll.cusid, :arg_out_ll.thflag, :server_dt, :arg_opemp, :arg_out_ll.relstr_1, :arg_out_ll.relstr_2, :arg_out_ll.relstr_3, :arg_out_ll.relint_1, :arg_out_ll.relint_2, :arg_out_ll.relint_3, :arg_out_ll.otheramt, :arg_out_ll.damt, :arg_out_ll.rel_address, :arg_out_ll.rel_tele, :arg_out_ll.rel_fax, :arg_out_ll.rel_rep, :arg_out_ll.mrate, :arg_out_ll.upname, :arg_out_ll.viewdate); If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致新增单据操作失败"+"~n"+sqlca.SQLErrText Goto ext End If For i = 1 To it_mxbt Insert Into u_outwaremx_ll (outwareid, mtrlwarescid, mtrlwareid, printid, mtrlid, plancode, status, qty, fprice, rebate, mxdscrp, sptid, dxflag, costamt, ifrel, relid, packqty, woodcode, relcode, pcode, enprice, outtypestr, dftsaleprice, cost, planqty, relprintid, unit, rate, uqty, storageid, scidprice, price, mtrlcuscode, location) Values ( :ll_outwareid, :arg_out_ll.arg_s_mx[i].mtrlwarescid, :arg_out_ll.arg_s_mx[i].mtrlwareid, :arg_out_ll.arg_s_mx[i].printid, :arg_out_ll.arg_s_mx[i].mtrlid, :arg_out_ll.arg_s_mx[i].plancode, :arg_out_ll.arg_s_mx[i].status, :arg_out_ll.arg_s_mx[i].qty, :arg_out_ll.arg_s_mx[i].fprice, :arg_out_ll.arg_s_mx[i].rebate, :arg_out_ll.arg_s_mx[i].mxdscrp, :arg_out_ll.arg_s_mx[i].sptid, :arg_out_ll.arg_s_mx[i].dxflag, :arg_out_ll.arg_s_mx[i].costamt, :arg_out_ll.arg_s_mx[i].ifrel, :arg_out_ll.arg_s_mx[i].relid, :arg_out_ll.arg_s_mx[i].packqty, :arg_out_ll.arg_s_mx[i].woodcode, :arg_out_ll.arg_s_mx[i].relcode, :arg_out_ll.arg_s_mx[i].pcode, :arg_out_ll.arg_s_mx[i].enprice, :arg_out_ll.arg_s_mx[i].outtypestr, :arg_out_ll.arg_s_mx[i].dftsaleprice, :arg_out_ll.arg_s_mx[i].cost, :arg_out_ll.arg_s_mx[i].planqty, :arg_out_ll.arg_s_mx[i].relprintid, :arg_out_ll.arg_s_mx[i].unit, :arg_out_ll.arg_s_mx[i].rate, :arg_out_ll.arg_s_mx[i].uqty, :arg_out_ll.arg_s_mx[i].storageid, :arg_out_ll.arg_s_mx[i].scidprice, :arg_out_ll.arg_s_mx[i].price, :arg_out_ll.arg_s_mx[i].mtrlcuscode, :arg_out_ll.arg_s_mx[i].Location); If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致新增单据明细操作失败"+"~n"+sqlca.SQLErrText Goto ext End If Next //更新库存已开单数 If uof_noauditingqty_add(arg_out_ll.arg_s_mx,arg_msg) = 0 Then rslt = 0 Goto ext End If uo_outwareid = ll_outwareid uo_outwarecode = ls_outwarecode Else If li_flag = 0 And li_priceflag = 0 Then Update u_outware_ll Set storageid = :arg_out_ll.storageid, outdate = :arg_out_ll.outdate, outrep = :arg_out_ll.outrep, part = :arg_out_ll.part, dscrp = :arg_out_ll.dscrp, cusid = :arg_out_ll.cusid, moddate = :server_dt, modemp = :arg_opemp, relstr_1 = :arg_out_ll.relstr_1, relstr_2 = :arg_out_ll.relstr_2, relstr_3 = :arg_out_ll.relstr_3, relint_1 = :arg_out_ll.relint_1, relint_2 = :arg_out_ll.relint_2, otheramt = :arg_out_ll.otheramt, damt = :arg_out_ll.damt, rel_address = :arg_out_ll.rel_address, rel_tele = :arg_out_ll.rel_tele, rel_fax = :arg_out_ll.rel_fax, rel_rep = :arg_out_ll.rel_rep, mrate = :arg_out_ll.mrate, upname = :arg_out_ll.upname, viewdate = :arg_out_ll.viewdate Where outwareid = :arg_out_ll.outwareid And flag = 0; If sqlca.SQLCode <> 0 Or sqlca.SQLNRows <= 0 Then rslt = 0 arg_msg = "因网络或其它原因导致更新单据操作失败(1)"+"~n"+sqlca.SQLErrText Goto ext End If //更新库存已开单数(减) If uof_noauditingqty_del(arg_out_ll.outwareid,arg_msg) = 0 Then rslt = 0 Goto ext End If //删除原有明细 Delete From u_outwaremx_ll Where outwareid = :arg_out_ll.outwareid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "删除旧有明细操作失败"+"~n"+sqlca.SQLErrText Goto ext End If For i = 1 To it_mxbt Insert Into u_outwaremx_ll (outwareid, mtrlwarescid, mtrlwareid, printid, mtrlid, plancode, status, qty, fprice, rebate, mxdscrp, sptid, dxflag, costamt, ifrel, relid, packqty, woodcode, relcode, pcode, enprice, outtypestr, dftsaleprice, cost, planqty, relprintid, unit, rate, uqty, storageid, scidprice, price, mtrlcuscode, location) Values ( :arg_out_ll.outwareid, :arg_out_ll.arg_s_mx[i].mtrlwarescid, :arg_out_ll.arg_s_mx[i].mtrlwareid, :arg_out_ll.arg_s_mx[i].printid, :arg_out_ll.arg_s_mx[i].mtrlid, :arg_out_ll.arg_s_mx[i].plancode, :arg_out_ll.arg_s_mx[i].status, :arg_out_ll.arg_s_mx[i].qty, :arg_out_ll.arg_s_mx[i].fprice, :arg_out_ll.arg_s_mx[i].rebate, :arg_out_ll.arg_s_mx[i].mxdscrp, :arg_out_ll.arg_s_mx[i].sptid, :arg_out_ll.arg_s_mx[i].dxflag, :arg_out_ll.arg_s_mx[i].costamt, :arg_out_ll.arg_s_mx[i].ifrel, :arg_out_ll.arg_s_mx[i].relid, :arg_out_ll.arg_s_mx[i].packqty, :arg_out_ll.arg_s_mx[i].woodcode, :arg_out_ll.arg_s_mx[i].relcode, :arg_out_ll.arg_s_mx[i].pcode, :arg_out_ll.arg_s_mx[i].enprice, :arg_out_ll.arg_s_mx[i].outtypestr, :arg_out_ll.arg_s_mx[i].dftsaleprice, :arg_out_ll.arg_s_mx[i].cost, :arg_out_ll.arg_s_mx[i].planqty, :arg_out_ll.arg_s_mx[i].relprintid, :arg_out_ll.arg_s_mx[i].unit, :arg_out_ll.arg_s_mx[i].rate, :arg_out_ll.arg_s_mx[i].uqty, :arg_out_ll.arg_s_mx[i].storageid, :arg_out_ll.arg_s_mx[i].scidprice, :arg_out_ll.arg_s_mx[i].price, :arg_out_ll.arg_s_mx[i].mtrlcuscode, :arg_out_ll.arg_s_mx[i].Location); If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致新增单据明细操作失败"+"~n"+sqlca.SQLErrText Goto ext End If Next //更新库存已开单数 If uof_noauditingqty_add(arg_out_ll.arg_s_mx,arg_msg) = 0 Then rslt = 0 Goto ext End If ElseIf li_flag = 0 And li_priceflag = 1 Then Update u_outware_ll Set storageid = :arg_out_ll.storageid, outdate = :arg_out_ll.outdate, outrep = :arg_out_ll.outrep, part = :arg_out_ll.part, dscrp = :arg_out_ll.dscrp, cusid = :arg_out_ll.cusid, moddate = :server_dt, modemp = :arg_opemp, relstr_1 = :arg_out_ll.relstr_1, relstr_2 = :arg_out_ll.relstr_2, relstr_3 = :arg_out_ll.relstr_3, relint_1 = :arg_out_ll.relint_1, relint_2 = :arg_out_ll.relint_2, otheramt = :arg_out_ll.otheramt, damt = :arg_out_ll.damt, rel_address = :arg_out_ll.rel_address, rel_tele = :arg_out_ll.rel_tele, rel_fax = :arg_out_ll.rel_fax, rel_rep = :arg_out_ll.rel_rep, mrate = :arg_out_ll.mrate, upname = :arg_out_ll.upname, viewdate = :arg_out_ll.viewdate Where outwareid = :arg_out_ll.outwareid And flag = 0 And secflag = 0 And priceflag = 1; If sqlca.SQLCode <> 0 Or sqlca.SQLNRows <= 0 Then rslt = 0 arg_msg = "因网络或其它原因导致更新单据操作失败(2)"+"~n"+sqlca.SQLErrText Goto ext End If //更新库存已开单数(减) If uof_noauditingqty_del(arg_out_ll.outwareid,arg_msg) = 0 Then rslt = 0 Goto ext End If For i = 1 To it_mxbt Update u_outWAREmx_ll Set qty = :arg_out_ll.arg_s_mx[i].qty, mxdscrp = :arg_out_ll.arg_s_mx[i].mxdscrp, price = :arg_out_ll.arg_s_mx[i].price, fprice = :arg_out_ll.arg_s_mx[i].fprice, rebate = :arg_out_ll.arg_s_mx[i].rebate, enprice = :arg_out_ll.arg_s_mx[i].enprice, packqty = :arg_out_ll.arg_s_mx[i].packqty, outtypestr = :arg_out_ll.arg_s_mx[i].outtypestr Where (outWAREid = :arg_out_ll.outwareid And printid = :arg_out_ll.arg_s_mx[i].printid); If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致更新明细实发数操作失败"+"~n"+sqlca.SQLErrText Goto ext End If Next //更新库存已开单数 If uof_noauditingqty_add(arg_out_ll.arg_s_mx,arg_msg) = 0 Then rslt = 0 Goto ext End If Else Update u_outware_ll Set storageid = :arg_out_ll.storageid, outdate = :arg_out_ll.outdate, outrep = :arg_out_ll.outrep, part = :arg_out_ll.part, dscrp = :arg_out_ll.dscrp, cusid = :arg_out_ll.cusid, moddate = :server_dt, modemp = :arg_opemp, relstr_1 = :arg_out_ll.relstr_1, relstr_2 = :arg_out_ll.relstr_2, relstr_3 = :arg_out_ll.relstr_3, relint_1 = :arg_out_ll.relint_1, relint_2 = :arg_out_ll.relint_2, otheramt = :arg_out_ll.otheramt, damt = :arg_out_ll.damt, rel_address = :arg_out_ll.rel_address, rel_tele = :arg_out_ll.rel_tele, rel_fax = :arg_out_ll.rel_fax, rel_rep = :arg_out_ll.rel_rep, mrate = :arg_out_ll.mrate, upname = :arg_out_ll.upname, viewdate = :arg_out_ll.viewdate Where outwareid = :arg_out_ll.outwareid And flag = 1 And secflag = 0; If sqlca.SQLCode <> 0 Or sqlca.SQLNRows <= 0 Then rslt = 0 arg_msg = "因网络或其它原因导致更新单据操作失败(3)"+"~n"+sqlca.SQLErrText Goto ext End If For i = 1 To it_mxbt Update u_outWAREmx_ll Set mxdscrp = :arg_out_ll.arg_s_mx[i].mxdscrp, fprice = :arg_out_ll.arg_s_mx[i].fprice, rebate = :arg_out_ll.arg_s_mx[i].rebate, enprice = :arg_out_ll.arg_s_mx[i].enprice, price = :arg_out_ll.arg_s_mx[i].price Where (outWAREid = :arg_out_ll.outwareid And printid = :arg_out_ll.arg_s_mx[i].printid); If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致更新明细价格操作失败"+"~n"+sqlca.SQLErrText Goto ext End If Next End If uo_outwareid = arg_out_ll.outwareid End If ext: If rslt = 0 Then Rollback; ElseIf arg_ifcommit And rslt = 1 Then Commit; End If Return rslt end function public function integer audit_p (long arg_outwareid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 s_outware_ll arg_s_out_ll uo_cusprice uo_p uo_p = create uo_cusprice IF arg_outwareid <= 0 THEN rslt = 0 arg_msg = '错误单据唯一码' GOTO ext END IF IF getinfo(arg_outwareid,arg_s_out_ll,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF arg_s_out_ll.priceflag <> 0 THEN rslt = 0 arg_msg = '单据单据已经确认,不可以再确认' GOTO ext END IF //FOR i = 1 TO it_mxbt // IF arg_s_out_ll.arg_s_mx[i].outtypestr <> '' THEN CONTINUE // // IF sys_option_checkprice_native = 1 THEN // IF uo_p.uof_check_price (cusid,arg_s_out_ll.arg_s_mx[i].mtrlid,& // arg_s_out_ll.arg_s_mx[i].mtrlcode,arg_s_out_ll.arg_s_mx[i].status,& // arg_s_out_ll.arg_s_mx[i].pcode,arg_s_out_ll.arg_s_mx[i].woodcode,& // arg_s_out_ll.relint_2,arg_s_out_ll.arg_s_mx[i].price,arg_msg) = 0 THEN // rslt = 0 // GOTO ext // END IF // ELSE // IF uo_price.uof_check_price (cusid,outwaremx[i].mtrlid,& // outwaremx[i].mtrlcode,outwaremx[i].status,outwaremx[i].pcode,& // outwaremx[i].woodcode,relint_2,outwaremx[i].enprice * outwaremx[i].enprice,arg_msg) = 0 THEN // rslt = 0 // GOTO ext // END IF // END IF //NEXT //更新审核标记 UPDATE u_outware_ll SET priceemp = :arg_opemp, pricedate = getdate(), priceflag = 1 WHERE outwareid = :arg_outwareid AND priceflag = 0; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致单据确认操作失败"+"~n"+sqlca.SQLErrText GOTO ext ELSEIF sqlca.SQLNRows = 0 THEN rslt = 0 arg_msg = "单据正在确认,请稍后重试。"+"~n"+sqlca.SQLErrText GOTO ext END IF ext: IF rslt = 0 THEN ROLLBACK; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT; END IF RETURN rslt end function public function integer caudit_p (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 s_outware_ll arg_s_out_ll IF uo_option_confirmaudit_sale_ll = -1000 THEN rslt = 0 arg_msg = '选项:[134]来料加工发货单先确认后审核,读取初始默认值失败,操作取消!' GOTO ext END IF DateTime null_dt SetNull(null_dt) IF arg_outwareid <= 0 THEN rslt = 0 arg_msg = '错误单据唯一码' GOTO ext END IF IF p_getinfo(arg_outwareid,arg_s_out_ll,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF arg_s_out_ll.priceflag = 0 THEN rslt = 0 arg_msg = '单据还未确认,不能反确认' GOTO ext END IF IF uo_option_confirmaudit_sale_ll = 1 THEN IF arg_s_out_ll.flag = 1 THEN rslt = 0 arg_msg = "销售单已仓审,不能反确认" GOTO ext END IF END IF //更新审核标记 UPDATE u_outware_ll SET priceemp = '', pricedate = :null_dt, priceflag = 0 WHERE outwareid = :arg_outwareid AND priceflag = 1; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致单据撤审操作失败"+"~n"+sqlca.SQLErrText GOTO ext ELSEIF sqlca.SQLNRows = 0 THEN rslt = 0 arg_msg = "单据正在撤审,请稍后重试。"+"~n"+sqlca.SQLErrText GOTO ext END IF ext: IF rslt = 0 THEN ROLLBACK; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT; END IF RETURN rslt end function private function integer p_getinfo (long arg_outwareid, ref s_outware_ll arg_ref_s_outware, ref string arg_msg);Int rslt = 1 SELECT relid, flag, priceflag, secflag, cusid, scid, relint_1, relint_2, relint_3, ctmint, outwarecode, outdate, part, dscrp, outrep, storageid, outwareid, thflag, otheramt, viewdate, mrate INTO :arg_ref_s_outware.relid, :arg_ref_s_outware.flag, :arg_ref_s_outware.priceflag, :arg_ref_s_outware.secflag, :arg_ref_s_outware.cusid, :arg_ref_s_outware.scid, :arg_ref_s_outware.relint_1, :arg_ref_s_outware.relint_2, :arg_ref_s_outware.relint_3, :arg_ref_s_outware.ctmint, :arg_ref_s_outware.outwarecode, :arg_ref_s_outware.outdate, :arg_ref_s_outware.part, :arg_ref_s_outware.dscrp, :arg_ref_s_outware.outrep, :arg_ref_s_outware.storageid, :arg_ref_s_outware.outwareid, :arg_ref_s_outware.thflag, :arg_ref_s_outware.otheramt, :arg_ref_s_outware.viewdate, :arg_ref_s_outware.mrate FROM u_outware_ll Where outwareid = :arg_outwareid; IF sqlca.SQLCode <> 0 THEN ARG_MSG = '查询单据审核标记失败,'+sqlca.SQLErrText rslt = 0 GOTO ext END IF ext: RETURN rslt end function private function integer getinfo (long arg_outwareid, ref s_outware_ll arg_ref_s_outware_ll, ref string arg_msg);Int rslt = 1 Long i = 1,no_mxcheck = 0 uo_sumamt_native = 0 uo_sumamt_en = 0 IF arg_outwareid <= 0 THEN rslt = 0 arg_msg = '错误单据唯一码' GOTO ext END IF IF p_getinfo(arg_outwareid,arg_ref_s_outware_ll,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF //用游标读取明细 DECLARE cur_rqbuymx CURSOR FOR SELECT u_outwaremx_ll.mtrlwareid, u_outwaremx_ll.mtrlwarescid, u_outwaremx_ll.mtrlid, u_outwaremx_ll.storageid, u_outwaremx_ll.plancode, u_outwaremx_ll.status, u_outwaremx_ll.woodcode, u_outwaremx_ll.pcode, u_outwaremx_ll.Qty, u_mtrldef.mtrlcode, u_outwaremx_ll.fprice, u_outwaremx_ll.rebate, u_outwaremx_ll.costamt, u_outwaremx_ll.mxdscrp, u_outwaremx_ll.sptid, u_outwaremx_ll.dxflag, u_outwaremx_ll.printid, u_outwaremx_ll.ifrel, u_outwaremx_ll.relid, u_outwaremx_ll.relprintid, u_outwaremx_ll.packqty, u_outwaremx_ll.relcode, u_outwaremx_ll.enprice, u_outwaremx_ll.outtypestr, u_outwaremx_ll.dftsaleprice, u_outwaremx_ll.cost, u_outwaremx_ll.planqty, u_outwaremx_ll.uqty, u_outwaremx_ll.rate, u_outwaremx_ll.unit, u_outwaremx_ll.scidprice, u_outwaremx_ll.price, u_mtrldef.unit, u_outwaremx_ll.mtrlcuscode, u_outwaremx_ll.location FROM u_outwaremx_ll,u_mtrldef WHERE u_outwaremx_ll.outwareid = :arg_outwareid AND u_outwaremx_ll.mtrlid = u_mtrldef.mtrlid Order By u_outwaremx_ll.printid; OPEN cur_rqbuymx; FETCH cur_rqbuymx INTO :arg_ref_s_outware_ll.arg_s_mx[i].mtrlwareid, :arg_ref_s_outware_ll.arg_s_mx[i].mtrlwarescid, :arg_ref_s_outware_ll.arg_s_mx[i].mtrlid, :arg_ref_s_outware_ll.arg_s_mx[i].storageid, :arg_ref_s_outware_ll.arg_s_mx[i].plancode, :arg_ref_s_outware_ll.arg_s_mx[i].status, :arg_ref_s_outware_ll.arg_s_mx[i].woodcode, :arg_ref_s_outware_ll.arg_s_mx[i].pcode, :arg_ref_s_outware_ll.arg_s_mx[i].Qty, :arg_ref_s_outware_ll.arg_s_mx[i].mtrlcode, :arg_ref_s_outware_ll.arg_s_mx[i].fprice, :arg_ref_s_outware_ll.arg_s_mx[i].rebate, :arg_ref_s_outware_ll.arg_s_mx[i].costamt, :arg_ref_s_outware_ll.arg_s_mx[i].mxdscrp, :arg_ref_s_outware_ll.arg_s_mx[i].sptid, :arg_ref_s_outware_ll.arg_s_mx[i].dxflag, :arg_ref_s_outware_ll.arg_s_mx[i].printid, :arg_ref_s_outware_ll.arg_s_mx[i].ifrel, :arg_ref_s_outware_ll.arg_s_mx[i].relid, :arg_ref_s_outware_ll.arg_s_mx[i].relprintid, :arg_ref_s_outware_ll.arg_s_mx[i].packqty, :arg_ref_s_outware_ll.arg_s_mx[i].relcode, :arg_ref_s_outware_ll.arg_s_mx[i].enprice, :arg_ref_s_outware_ll.arg_s_mx[i].outtypestr, :arg_ref_s_outware_ll.arg_s_mx[i].dftsaleprice, :arg_ref_s_outware_ll.arg_s_mx[i].cost, :arg_ref_s_outware_ll.arg_s_mx[i].planqty, :arg_ref_s_outware_ll.arg_s_mx[i].uqty, :arg_ref_s_outware_ll.arg_s_mx[i].rate, :arg_ref_s_outware_ll.arg_s_mx[i].unit, :arg_ref_s_outware_ll.arg_s_mx[i].scidprice, :arg_ref_s_outware_ll.arg_s_mx[i].price, :arg_ref_s_outware_ll.arg_s_mx[i].u_mtrldef_unit, :arg_ref_s_outware_ll.arg_s_mx[i].mtrlcuscode, :arg_ref_s_outware_ll.arg_s_mx[i].location; DO WHILE sqlca.SQLCode = 0 //计算单据总金额 uo_sumamt_native = uo_sumamt_native + arg_ref_s_outware_ll.arg_s_mx[i].uqty * arg_ref_s_outware_ll.arg_s_mx[i].rebate * arg_ref_s_outware_ll.arg_s_mx[i].price uo_sumamt_en = uo_sumamt_en + arg_ref_s_outware_ll.arg_s_mx[i].uqty * arg_ref_s_outware_ll.arg_s_mx[i].rebate * arg_ref_s_outware_ll.arg_s_mx[i].enprice i++ FETCH cur_rqbuymx INTO :arg_ref_s_outware_ll.arg_s_mx[i].mtrlwareid, :arg_ref_s_outware_ll.arg_s_mx[i].mtrlwarescid, :arg_ref_s_outware_ll.arg_s_mx[i].mtrlid, :arg_ref_s_outware_ll.arg_s_mx[i].storageid, :arg_ref_s_outware_ll.arg_s_mx[i].plancode, :arg_ref_s_outware_ll.arg_s_mx[i].status, :arg_ref_s_outware_ll.arg_s_mx[i].woodcode, :arg_ref_s_outware_ll.arg_s_mx[i].pcode, :arg_ref_s_outware_ll.arg_s_mx[i].Qty, :arg_ref_s_outware_ll.arg_s_mx[i].mtrlcode, :arg_ref_s_outware_ll.arg_s_mx[i].fprice, :arg_ref_s_outware_ll.arg_s_mx[i].rebate, :arg_ref_s_outware_ll.arg_s_mx[i].costamt, :arg_ref_s_outware_ll.arg_s_mx[i].mxdscrp, :arg_ref_s_outware_ll.arg_s_mx[i].sptid, :arg_ref_s_outware_ll.arg_s_mx[i].dxflag, :arg_ref_s_outware_ll.arg_s_mx[i].printid, :arg_ref_s_outware_ll.arg_s_mx[i].ifrel, :arg_ref_s_outware_ll.arg_s_mx[i].relid, :arg_ref_s_outware_ll.arg_s_mx[i].relprintid, :arg_ref_s_outware_ll.arg_s_mx[i].packqty, :arg_ref_s_outware_ll.arg_s_mx[i].relcode, :arg_ref_s_outware_ll.arg_s_mx[i].enprice, :arg_ref_s_outware_ll.arg_s_mx[i].outtypestr, :arg_ref_s_outware_ll.arg_s_mx[i].dftsaleprice, :arg_ref_s_outware_ll.arg_s_mx[i].cost, :arg_ref_s_outware_ll.arg_s_mx[i].planqty, :arg_ref_s_outware_ll.arg_s_mx[i].uqty, :arg_ref_s_outware_ll.arg_s_mx[i].rate, :arg_ref_s_outware_ll.arg_s_mx[i].unit, :arg_ref_s_outware_ll.arg_s_mx[i].scidprice, :arg_ref_s_outware_ll.arg_s_mx[i].price, :arg_ref_s_outware_ll.arg_s_mx[i].u_mtrldef_unit, :arg_ref_s_outware_ll.arg_s_mx[i].mtrlcuscode, :arg_ref_s_outware_ll.arg_s_mx[i].location; LOOP CLOSE cur_rqbuymx; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck FROM u_outwaremx_ll WHERE outwareid = :arg_outwareid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,单据汇总数量" GOTO ext END IF IF i <> (no_mxcheck + 1) THEN rslt = 0 arg_msg = "查询操作失败,单据汇总内容" GOTO ext END IF ext: RETURN rslt end function public function integer uof_noauditingqty_add (s_outwaremx_ll arg_s_mx[], ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1 Int rslt = 1 Long i For i = 1 To UpperBound(arg_s_mx) Update u_mtrlware Set noauditingqty = noauditingqty + :arg_s_mx[i].qty, noauditinguqty = noauditingqty + :arg_s_mx[i].qty Where scid = :arg_s_mx[i].mtrlwarescid And mtrlwareid = :arg_s_mx[i].mtrlwareid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = '更新明细库存已开单数失败 '+sqlca.SQLErrText Goto ext End If Next ext: Return rslt end function public function integer uof_noauditingqty_del (long arg_outwareid, ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1 Int rslt = 1 Long i,ll_i i = 1 s_outwaremx_ll arg_s_mx[] Declare cur_mx Cursor For Select u_outwaremx_ll.mtrlwarescid, u_outwaremx_ll.mtrlwareid, u_outwaremx_ll.qty, u_outwaremx_ll.uqty, u_mtrldef.mtrlcode From u_outwaremx_ll,u_mtrldef Where u_outwaremx_ll.outwareid = :arg_outwareid And u_outwaremx_ll.mtrlid = u_mtrldef.mtrlid Order By u_owereturnmx.printid; Open cur_mx; Fetch cur_mx Into :arg_s_mx[i].mtrlwarescid,:arg_s_mx[i].mtrlwareid,:arg_s_mx[i].qty,:arg_s_mx[i].uqty,:arg_s_mx[i].mtrlcode; Do While sqlca.SQLCode = 0 i++ Fetch cur_mx Into :arg_s_mx[i].mtrlwarescid,:arg_s_mx[i].mtrlwareid,:arg_s_mx[i].qty,:arg_s_mx[i].uqty,:arg_s_mx[i].mtrlcode; Loop Close cur_mx; For ll_i = 1 To i - 1 Update u_mtrlware Set noauditingqty = noauditingqty - :arg_s_mx[ll_i].qty, noauditinguqty = noauditingqty - :arg_s_mx[ll_i].uqty Where scid = :arg_s_mx[ll_i].mtrlwarescid And mtrlwareid = :arg_s_mx[ll_i].mtrlwareid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = '物料'+string(arg_s_mx[ll_i].mtrlcode)+' 更新明细库存已开单数失败 '+sqlca.SQLErrText Goto ext End If Next ext: Return rslt end function on uo_outware_ll.create call super::create TriggerEvent( this, "constructor" ) end on on uo_outware_ll.destroy TriggerEvent( this, "destructor" ) call super::destroy end on event constructor;String str_optionvalue,arg_msg f_get_sys_option_value('134',str_optionvalue,arg_msg) uo_option_confirmaudit_sale_ll = Long(str_optionvalue) f_get_sys_option_value('045',str_optionvalue,arg_msg) uo_option_m_msttake = Long(str_optionvalue) f_get_sys_option_value('052',str_optionvalue,arg_msg) uo_option_otheramt_msttake = Long(str_optionvalue) f_get_sys_option_value('050',str_optionvalue,arg_msg) uo_option_change_otheramt = trim(str_optionvalue) f_get_sys_option_value('037',str_optionvalue,arg_msg) uo_option_mtrlware_limit = Long(str_optionvalue) f_get_sys_option_value('390',str_optionvalue,arg_msg) uo_option_noauditingqty_mode = Long(str_optionvalue) end event