$PBExportHeader$uo_outware.sru forward global type uo_outware from nonvisualobject end type end forward global type uo_outware from nonvisualobject end type global uo_outware uo_outware type variables Public ProtectedWrite Long scid = 0 //分部id Public ProtectedWrite Long outwareid //进仓单表自动增量id Public ProtectedWrite String outwarecode //单据的唯一编号 Public ProtectedWrite Int billtype = 0 //业务类型 Public ProtectedWrite DateTime opdate //建立时间,自动 Public ProtectedWrite String opemp //建立操作员 Public ProtectedWrite DateTime moddate //修改时间,自动 Public ProtectedWrite String modemp //修改操作员 Public ProtectedWrite Int balcflag = 0 //仓库日结标志 Public ProtectedWrite Int flag = 0 //仓库审核标志 Public ProtectedWrite DateTime auditingdate //审核时间 Public ProtectedWrite String auditingrep //审核操作员 Public ProtectedWrite Int secflag = 0 //财务审核标志 Public ProtectedWrite DateTime secauditingdate //二审核时间 Public ProtectedWrite String secauditingrep //二审核操作员 Public ProtectedWrite Decimal sum_amt = 0 //单据总金额 Public ProtectedWrite Decimal sum_amt_en = 0 //单据总金额(其它单价) Public ProtectedWrite long balcdateint = 0 Public ProtectedWrite Decimal sum_taxamt = 0 //单据税额 Public ProtectedWrite Decimal sum_taxamt_en = 0 //单据税额(其它单价) Public ProtectedWrite Int priceflag = 0 //确认标志 Public ProtectedWrite DateTime pricedate //确认时间 Public ProtectedWrite String priceemp //确认操作员 Public ProtectedWrite Long ctmint Long relid = 0 //关联id Long storageid = 0 //进仓仓库 DateTime outdate //进仓发生时间 String outrep = '' //经手人 String part = '' //相关号码 String dscrp = '' //备注 Long cusid = 0 //客户id String cusname = '' //客户名称(不记帐模式使用) Int thflag = 0 //退货标记 Int ifauto = 0 String relstr_1 String relstr_2 String relstr_3 Long relint_1 Long relint_2 Long relint_3 long relint_4 Decimal otheramt Decimal damt Decimal mrate String rel_address String rel_tele String rel_fax String rel_rep String upname DateTime viewdate Long storagescid = 0 //仓库分部ID Long deptid = 0 long typeid = 0 String carcode String transcode Decimal totalamt Decimal getamt Int lsflag Int pda_flag DateTime pda_date long exchangeid string station_address Boolean if_getid_ture = True Transaction commit_transaction //数据commit事务 s_outwaremx outwaremx[], ins_ref_outwaremx[],ins_empty_outwaremx[] //明细结构数组 long ins_ref_mxbt = 0 s_outwaremx_mx outwaremx_mx[] s_outwaremx_barcode s_mx_barcode[] s_outware_itemmx outware_itemmx[] Long it_mxbt = 0 //明细结构数组末指针 Long it_mxbt_mx = 0 Long it_mxbt_barcode = 0 Long it_mxbt_item = 0 Boolean it_newbegin = False //新建标志 Boolean it_updatebegin = False //修改标志 Boolean if_pd_py_check_barcode = False Int uo_option_autowaste,uo_option_inout_type Int uo_option_barcode_outwareother_paudit Int uo_option_confirmaudit_sale,uo_option_sale_use_planqty Int uo_option_confirmaudit_scll,uo_option_cost_dec String uo_option_change_status,uo_option_change_woodcode,uo_option_change_pcode Int uo_option_mtrlware_autocmp,uo_option_mtrlware_limit Int uo_option_scll_limit,uo_option_if_pricetype Int uo_option_checkprice_native Int uo_option_if_saleout Int uo_option_disuse_outware_sale Int uo_option_sale_ifuse_negativeprice Int uo_option_pda_sale_lock Int uo_option_price_rmb int uo_option_outware_sale_checkprice int uo_option_scll_use_planqty int uo_option_barcodelocation_use_inwaremx_location int uo_option_djqty_check int uo_option_outware_saleout int uo_option_scllplan_outware_auto int uo_option_noauditingqty_mode int uo_option_outware_pack_save_cmp int uo_option_pk_notauditqty_check int uo_option_canpack_ifzanyong end variables forward prototypes public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg) public function integer save (boolean arg_ifcommit, ref string arg_msg) public function integer auditing (boolean arg_ifcommit, ref string arg_msg) public function integer updatebegin (long arg_scid, long arg_outwareid, integer arg_billtype, ref string arg_msg) public function integer getinfo (long arg_scid, long arg_outwareid, ref string arg_msg) public function integer add_dscrp (long arg_scid, long arg_outwareid, string arg_newdescppart, ref string arg_msg) public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg) public function integer p_clearmx () public function integer p_getinfo (long arg_scid, long arg_outwareid, ref string arg_msg) public function integer p_reset () public function integer p_update_cost (long arg_mtrlwareid, string arg_mtrlcode, decimal arg_qty, long arg_printid, ref decimal arg_ref_costamt, ref string arg_msg, boolean arg_ifcommit) public function integer del (long arg_scid, long arg_outwareid, integer arg_ifcheck_auto, ref string arg_msg, boolean arg_ifcommit) public function integer p_update_mtrlware_ws (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_uqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, string arg_mtrlcuscode, string arg_location, ref string arg_msg) public function integer uof_p_barcode (integer arg_audittype, ref string arg_msg) public function integer uof_outbarcode_add (integer arg_billtype, long arg_scid, long arg_outwareid, string arg_barcode, decimal arg_qty, ref string arg_msg, boolean arg_ifcommit) public function integer priceaudit (boolean arg_ifcommit, ref string arg_msg) public function integer c_priceaudit (boolean arg_ifcommit, ref string arg_msg) public function integer uof_set_qty_equal_bqty (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit) public function integer uof_check_qty_to_bqty (ref string arg_msg) public function integer uof_secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit) public function integer uof_c_secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit) public function integer acceptmx_item (long arg_printid, long arg_itemid, decimal arg_amt, string arg_mxdscrp, ref string arg_msg) public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_olmtrlid, long arg_packqty, string arg_outtype, decimal arg_planqty, long arg_relprintid, string arg_unit, decimal arg_uqty, decimal arg_rate, string arg_pricetype, string arg_formula, long arg_saleoutid, long arg_saleoutprintid, string arg_mxdscrp2, decimal arg_net_weight, decimal arg_gross_weight, decimal arg_cubage, decimal arg_taxrate, string arg_priceformula, string arg_qtyformula) public function integer uof_check_warepdb_audit (long arg_storageid, ref string arg_msg) public function integer uof_disuse (long arg_scid, long arg_outwareid, integer arg_disusetype, ref string arg_msg, boolean arg_ifcommit) public function integer uof_updatesaleoutcodestr (long arg_scid, long arg_outwareid, ref string arg_msg) public function integer acceptmx (s_outwaremx s_mx, ref string arg_msg) protected function integer p_update_mtrlware (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_uqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, string arg_mtrlcuscode, string arg_location, integer arg_ifvqty, ref string arg_msg) public function integer acceptmx_mx (long arg_printid, long arg_mtrlwareid, decimal arg_planqty, decimal arg_qty, string arg_mxdscrp, long arg_mxprintid, integer arg_ifnotinout, ref string arg_msg) public function integer uof_noauditingqty_add (long arg_scid, long arg_billtype, integer arg_relint_1, ref string arg_msg) public function integer uof_noauditingqty_del (long arg_scid, long arg_outwareid, ref string arg_msg) end prototypes public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg);Int rslt = 1 IF arg_scid < 0 THEN arg_msg = '请选择分部' rslt = 0 GOTO ext END IF IF Not (arg_billtype = 1 OR & arg_billtype = 2 OR & arg_billtype = 3 OR & arg_billtype = 4 OR & arg_billtype = 5 OR & arg_billtype = 6 OR & arg_billtype = 7 OR & arg_billtype = 8 OR & arg_billtype = 9 OR & arg_billtype = 10 OR & arg_billtype = 12 OR & arg_billtype = 15 OR & arg_billtype = 16 OR & arg_billtype = 17 or & arg_billtype = 18 or & arg_billtype = 19 or & arg_billtype = 20 or & arg_billtype = 21 or & arg_billtype = 22 or & arg_billtype = 23 or & arg_billtype = 24 or & arg_billtype = 25) THEN rslt = 0 arg_msg = '此单据类型必须为:' arg_msg = arg_msg+'1-销售出仓单[记帐模式],' arg_msg = arg_msg+'2-销售出仓单[不记帐模式],' arg_msg = arg_msg+'3-领料出仓单,' arg_msg = arg_msg+'4-外协出仓单,' arg_msg = arg_msg+'5-来料加工发货,' arg_msg = arg_msg+'6-售后服务出仓单,' arg_msg = arg_msg+'7-外协销售出仓单,' arg_msg = arg_msg+'8-其它出仓单,' arg_msg = arg_msg+'9-盘亏出仓单,' arg_msg = arg_msg+'10-工具出仓单,' arg_msg = arg_msg+'12-调拨出仓单' arg_msg = arg_msg+'15-拆装出仓单' arg_msg = arg_msg+'16-生产进仓车间自动出仓单(未分配)' arg_msg = arg_msg+'17-还货出仓单' arg_msg = arg_msg+'18-自动组装出仓单' arg_msg = arg_msg+'19-生产进仓车间自动出仓单(已分配)' arg_msg = arg_msg+'20-车间库存转换自动出仓单' arg_msg = arg_msg+'21-送货单包件明细自动出仓单' arg_msg = arg_msg+'22-欠货终止单自动出仓单' arg_msg = arg_msg+'23-收货单收货明细自动出仓单' arg_msg = arg_msg+'24-员工物品领用单' arg_msg = arg_msg+'25-发料损耗自动出仓单' GOTO ext END IF p_reset() billtype = arg_billtype scid = arg_scid it_newbegin = TRUE it_updatebegin = FALSE ext: IF rslt = 0 THEN p_reset() RETURN rslt end function public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1 Long cnt = 0,i,j DateTime server_dt Long ls_newid Int li_outtype String ls_storagename String ls_sccode Decimal ld_trueoverqty Int li_ifmrp Long ll_mtrlid_arr[] Decimal ld_qty_arr[] String ls_mtrlcode_arr[] Long ll_mxcnt = 0 Decimal ld_djqty,ld_noallocqty Int li_priceflag Long ll_cnt_billtype21 s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst ins_ref_outwaremx = ins_empty_outwaremx ins_ref_mxbt = 0 IF uo_option_disuse_outware_sale = -1000 THEN rslt = 0 arg_msg = '选项:[292]启用销售发货单废弃单,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_price_rmb = -1000 THEN arg_msg = '选项:[238]销售单价按人民币单价折算,读取初始默认值失败,操作取消!' rslt = 0 GOTO ext END IF IF uo_option_djqty_check = -1000 THEN rslt = 0 arg_msg = '选项:[378]进出仓检查冻结数不能大于库存数,读取初始默认值失败,操作取消!' GOTO ext END IF IF IsNull(relid) THEN relid = 0 IF IsNull(storageid) THEN storageid = 0 IF IsNull(outrep) THEN outrep = '' IF IsNull(dscrp) THEN dscrp = '' IF IsNull(part) THEN part = '' IF IsNull(cusid) THEN cusid = 0 IF IsNull(cusname) THEN cusname = '' IF IsNull(thflag) THEN thflag = 0 IF IsNull(otheramt) THEN otheramt = 0 IF IsNull(damt) THEN damt = 0 IF IsNull(relstr_1) THEN relstr_1 = '' IF IsNull(relstr_2) THEN relstr_2 = '' IF IsNull(relstr_3) THEN relstr_3 = '' 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(mrate) THEN mrate = 0 IF IsNull(ifauto) THEN ifauto = 0 IF IsNull(rel_address) THEN rel_address = '' IF IsNull(rel_tele) THEN rel_tele = '' IF IsNull(rel_fax) THEN rel_fax = '' IF IsNull(rel_rep) THEN rel_rep = '' IF IsNull(upname) THEN upname = '' IF IsNull(deptid) THEN deptid = 0 IF IsNull(totalamt) THEN totalamt = 0 IF IsNull(getamt) THEN getamt = 0 IF IsNull(lsflag) THEN lsflag = 0 IF IsNull(carcode) THEN carcode = '' IF IsNull(transcode) THEN transcode = '' IF IsNull(typeid) THEN typeid = 0 IF IsNull(exchangeid) THEN exchangeid = 0 IF IsNull(station_address) THEN station_address = '' 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 it_mxbt = 0 THEN //如果输入物料资料错则已经清空 rslt = 0 arg_msg = "没有正确出仓内容" GOTO ext END IF //yyx20150529发货单使用先确认后仓审模式在修改保存操作增加检查单据状态 IF uo_option_confirmaudit_sale = 1 THEN IF billtype = 1 And outwareid > 0 And priceflag = 0 THEN SELECT priceflag INTO :li_priceflag FROM u_outware WHERE u_outware.outwareid = :outwareid And u_outware.scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询单据确认状态操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF IF li_priceflag = 1 THEN arg_msg = '单据已经确认,不能保存,操作取消' rslt = 0 GOTO ext ELSE SELECT count(*) INTO :ll_cnt_billtype21 FROM u_outware WHERE u_outware.relid = :outwareid AND u_outware.scid = :scid And billtype = 21 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询单据是否已确认操作生成销售出仓单失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF IF ll_cnt_billtype21 > 0 THEN arg_msg = '单据已确认操作生成销售出仓单,不能保存,操作取消' rslt = 0 GOTO ext END IF END IF END IF END IF // Int li_mustloca,li_nocheck_bjmx SELECT storagename,outtype,mustloca,nocheck_bjmx,ifmrp INTO :ls_storagename,:li_outtype,:li_mustloca,:li_nocheck_bjmx,:li_ifmrp FROM u_storage Where storageid = :storageid Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,仓库出仓类型,"+commit_transaction.SQLErrText GOTO ext END IF IF li_nocheck_bjmx = 0 THEN IF li_outtype <> 0 And billtype = 1 And flag = 0 THEN IF it_mxbt_mx = 0 THEN rslt = 0 arg_msg = "没有正确包件明细" GOTO ext END IF END IF END IF //检查是否有该仓库的建立权限 IF sys_user_storagestr_new <> '0' THEN IF Pos(sys_user_storagestr_new,','+String(storageid)+',') <= 0 THEN rslt = 0 arg_msg = '没有仓库: '+ls_storagename+' 的建立权限,不允许建立该仓库的单据' GOTO ext END IF END IF // IF Year(Date(outdate)) < 2000 Or IsNull(outdate) THEN rslt = 0 arg_msg = "缺少出仓发生时间或不合理" GOTO ext END IF IF flag = 0 THEN Boolean lb_chk_balc = True IF sys_option_warebalc_checksale = 0 And billtype = 21 THEN //临时的,详见系统选项152 lb_chk_balc = False END IF IF f_check_inoutdate(storageid,outdate,lb_chk_balc,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF IF billtype = 1 Or billtype = 5 THEN SELECT name INTO :cusname FROM u_cust Where cusid = :cusid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,客户资料" GOTO ext END IF IF billtype = 1 THEN IF relint_1 = 0 THEN arg_msg = '请选择结算方式' rslt = 0 GOTO ext END IF cnt = 0 SELECT count(*) INTO :cnt FROM cw_currency Where moneyid = :relint_2; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询币种失败' rslt = 0 GOTO ext END IF IF cnt = 0 THEN arg_msg = '币种资料不存在' rslt = 0 GOTO ext END IF IF mrate = 0 THEN arg_msg = '币种汇率错误' rslt = 0 GOTO ext END IF IF f_moneyid_rate_check(relint_2,mrate,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF ELSEIF billtype = 4 Or billtype = 7 THEN SELECT name INTO :cusname FROM u_spt Where sptid = :cusid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,加工商资料" GOTO ext END IF ELSEIF billtype = 3 THEN IF relid = 0 THEN arg_msg = '请选择领料工组' rslt = 0 GOTO ext END IF IF relint_1 = 1 Or relint_1 = 2 THEN IF cusname = '' THEN arg_msg = '请输入原因' rslt = 0 GOTO ext END IF END IF ELSEIF billtype = 8 THEN IF Trim(cusname) = '' Or IsNull(cusname) THEN rslt = 0 arg_msg = "请输入出仓原因!" GOTO ext END IF END IF If (thflag = 1 Or (billtype = 3 And relint_1 = 2 )) And li_mustloca = 1 THEN // String ls_msg_loca Long ll_cnt_loca ll_cnt_loca = 0 FOR i = 1 To it_mxbt IF Trim(outwaremx[i].Location) = '' THEN ll_cnt_loca++ IF ll_cnt_loca <= 10 THEN IF Trim(ls_msg_loca) = '' THEN ls_msg_loca = ls_msg_loca + String(i) ELSE ls_msg_loca = ls_msg_loca + ','+String(i) END IF END IF END IF NEXT IF ll_cnt_loca > 0 THEN rslt = 0 IF ll_cnt_loca <= 10 THEN arg_msg = '仓库属性已设为仓位必填'+'~r~n'+'明细中第'+ls_msg_loca+'行没有填仓位,请检查' ELSE arg_msg = '仓库属性已设为仓位必填'+'~r~n'+'其中第'+ls_msg_loca+'等'+String(ll_cnt_loca)+'行明细没有填仓位,请详细检查' END IF GOTO ext END IF END IF IF billtype = 1 And thflag = 0 And outwareid > 0 And uo_option_disuse_outware_sale = 1 THEN IF uof_disuse(scid,outwareid,0,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF END IF //检查冻结数 IF uo_option_djqty_check = 1 And li_ifmrp = 1 And Not ( billtype = 3 And relint_1 = 4) THEN FOR i = 1 To it_mxbt FOR j = 1 To ll_mxcnt IF outwaremx[i].mtrlid = ll_mtrlid_arr[j] THEN ld_qty_arr[j] = ld_qty_arr[j] + outwaremx[i].qty GOTO _next_mx END IF NEXT ll_mxcnt++ ll_mtrlid_arr[ll_mxcnt] = outwaremx[i].mtrlid ld_qty_arr[ll_mxcnt] = outwaremx[i].qty ls_mtrlcode_arr[ll_mxcnt] = outwaremx[i].mtrlcode _next_mx: NEXT FOR i = 1 To ll_mxcnt SELECT SUM(u_OrderRqMtrl_scll.wareqty - u_OrderRqMtrl_scll.DstrQty + isnull(uv_outware_scll_back.qty,0) ) INTO :ld_djqty FROM u_OrderRqMtrl_scll INNER JOIN u_Order_ml ON u_OrderRqMtrl_scll.OrderID = u_Order_ml.OrderID LEFT OUTER JOIN uv_outware_scll_back ON u_OrderRqMtrl_scll.scid = uv_outware_scll_back.scid AND u_OrderRqMtrl_scll.OrderID = uv_outware_scll_back.relid AND u_OrderRqMtrl_scll.MtrlID = uv_outware_scll_back.mtrlid AND u_OrderRqMtrl_scll.status = uv_outware_scll_back.status AND u_OrderRqMtrl_scll.woodcode = uv_outware_scll_back.woodcode AND u_OrderRqMtrl_scll.pcode = uv_outware_scll_back.pcode WHERE (u_OrderRqMtrl_scll.wareqty <> 0) AND (u_Order_ml.Status NOT IN (3,5,6)) AND u_OrderRqMtrl_scll.wareqty - u_OrderRqMtrl_scll.DstrQty + isnull(uv_outware_scll_back.qty,0) > 0 AND u_OrderRqMtrl_scll.MtrlID = :ll_mtrlid_arr[i] And u_OrderRqMtrl_scll.scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN ld_djqty = 0 END IF IF IsNull(ld_djqty) THEN ld_djqty = 0 SELECT SUM(u_mtrlware.noallocqty) INTO :ld_noallocqty FROM u_mtrlware INNER JOIN u_storage ON u_mtrlware.storageid = u_storage.storageid WHERE (u_storage.inuse = 1) AND u_storage.ifmrp = 1 AND u_mtrlware.mtrlid = :ll_mtrlid_arr[i] And u_mtrlware.scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN ld_noallocqty = 0 END IF IF IsNull(ld_noallocqty) THEN ld_noallocqty = 0 IF ld_djqty > ld_noallocqty - ld_qty_arr[i] THEN rslt = 0 arg_msg = '物料['+ls_mtrlcode_arr[i]+']冻结数不能大于库存数,冻结数:'+String(ld_djqty,'#,##0.##########')+',库存数:'+String(ld_noallocqty,'#,##0.##########')+',本次出仓数:'+String(ld_qty_arr[i],'#,##0.##########') GOTO ext END IF NEXT END IF ////////////////////////////////////////////// //开始区分:新建/更新 处理 IF outwareid = 0 THEN //新建 ls_newid = f_sys_scidentity(scid,"u_outware","outwareid",arg_msg,True,id_sqlca) 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 outwarecode = getid(scid,ls_sccode + 'XS',Date(server_dt),if_getid_ture,commit_transaction) ELSE IF relid = 0 THEN outwarecode = getid(scid,ls_sccode + 'XT',Date(server_dt),if_getid_ture,commit_transaction) ELSEIF relid = 1 THEN outwarecode = getid(scid,ls_sccode + 'QS',Date(server_dt),if_getid_ture,commit_transaction) END IF END IF CASE 3 IF relint_1 = 0 THEN //生产领料 outwarecode = getid(scid,ls_sccode + 'LL',Date(server_dt),if_getid_ture,commit_transaction) ELSEIF relint_1 = 1 THEN //超额发料单 outwarecode = getid(scid,ls_sccode + 'BL',Date(server_dt),if_getid_ture,commit_transaction) ELSEIF relint_1 = 2 THEN //生产还料单 outwarecode = getid(scid,ls_sccode + 'HL',Date(server_dt),if_getid_ture,commit_transaction) ELSEIF relint_1 = 3 THEN //其他领料 outwarecode = getid(scid,ls_sccode + 'OL',Date(server_dt),if_getid_ture,commit_transaction) ELSEIF relint_1 = 4 THEN //发料单 outwarecode = getid(scid,ls_sccode + 'FO',Date(server_dt),if_getid_ture,commit_transaction) ELSEIF relint_1 = 5 THEN //生产补料单 outwarecode = getid(scid,ls_sccode + 'BU',Date(server_dt),if_getid_ture,commit_transaction) END IF CASE 4 IF thflag = 0 THEN outwarecode = getid(scid,ls_sccode + 'KL',Date(server_dt),if_getid_ture,commit_transaction) ELSE outwarecode = getid(scid,ls_sccode + 'TL',Date(server_dt),if_getid_ture,commit_transaction) END IF CASE 5 //来料加工 IF thflag = 0 THEN outwarecode = getid(scid,ls_sccode + 'XL',Date(server_dt),if_getid_ture,commit_transaction) ELSE outwarecode = getid(scid,ls_sccode + 'LT',Date(server_dt),if_getid_ture,commit_transaction) END IF CASE 6 outwarecode = getid(scid,ls_sccode + 'SU',Date(server_dt),if_getid_ture,commit_transaction) CASE 7 IF thflag = 0 THEN outwarecode = getid(scid,ls_sccode + 'KW',Date(server_dt),if_getid_ture,commit_transaction) ELSE outwarecode = getid(scid,ls_sccode + 'TW',Date(server_dt),if_getid_ture,commit_transaction) END IF CASE 8 outwarecode = getid(scid,ls_sccode + 'CC',Date(server_dt),if_getid_ture,commit_transaction) CASE 9 outwarecode = getid(scid,ls_sccode + 'PQ',Date(server_dt),if_getid_ture,commit_transaction) CASE 10 outwarecode = getid(scid,ls_sccode + 'KF',Date(server_dt),if_getid_ture,commit_transaction) CASE 12 outwarecode = getid(scid,ls_sccode + 'OC',Date(server_dt),if_getid_ture,commit_transaction) CASE 15 outwarecode = getid(scid,ls_sccode + 'DI',Date(server_dt),if_getid_ture,commit_transaction) CASE 16 outwarecode = getid(scid,ls_sccode + 'LC',Date(server_dt),if_getid_ture,commit_transaction) CASE 17 outwarecode = getid(scid,ls_sccode + 'RO',Date(server_dt),if_getid_ture,commit_transaction) CASE 18 outwarecode = getid(scid,ls_sccode + 'OA',Date(server_dt),if_getid_ture,commit_transaction) CASE 19 outwarecode = getid(scid,ls_sccode + 'CO',Date(server_dt),if_getid_ture,commit_transaction) CASE 20 outwarecode = getid(scid,ls_sccode + 'WO',Date(server_dt),if_getid_ture,commit_transaction) CASE 21 outwarecode = getid(scid,ls_sccode + 'BO',Date(server_dt),if_getid_ture,commit_transaction) CASE 22 outwarecode = getid(scid,ls_sccode + 'QO',Date(server_dt),if_getid_ture,commit_transaction) CASE 23 outwarecode = getid(scid,ls_sccode + 'HO',Date(server_dt),if_getid_ture,commit_transaction) CASE 24 outwarecode = getid(scid,ls_sccode + 'LY',Date(server_dt),if_getid_ture,commit_transaction) CASE 25 outwarecode = getid(scid,ls_sccode + 'FW',Date(server_dt),if_getid_ture,commit_transaction) END CHOOSE IF outwarecode = "err" Or outwarecode = '' THEN outwarecode = '' rslt = 0 arg_msg = "无法获取进仓单编号"+"~n"+commit_transaction.SQLErrText GOTO ext END IF INSERT INTO u_outware ( scid, outwareid, outwarecode, billtype, relid, storageid, outdate, outrep, part, dscrp, cusid, cusname, thflag, opdate, opemp, relstr_1, relstr_2, relstr_3, relint_1, relint_2, relint_3, relint_4, otheramt, damt, rel_address, rel_tele, rel_fax, rel_rep, mrate, upname, ifauto, viewdate, deptid, totalamt, getamt, lsflag, carcode, transcode, typeid, exchangeid, station_address) VALUES ( :scid, :ls_newid, :outwarecode, :billtype, :relid, :storageid, :outdate, :outrep, :part, :dscrp, :cusid, :cusname, :thflag, :server_dt, :publ_operator, :relstr_1, :relstr_2, :relstr_3, :relint_1, :relint_2, :relint_3, :relint_4, :otheramt, :damt, :rel_address, :rel_tele, :rel_fax, :rel_rep, :mrate, :upname, :ifauto, :viewdate, :deptid, :totalamt, :getamt, :lsflag, :carcode, :transcode, :typeid, :exchangeid, :station_address) Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //读取新outwareid outwareid = ls_newid FOR i = 1 To it_mxbt //如果是发料单,计算实际超发数量 IF billtype = 3 And relint_1 = 4 THEN IF outwaremx[i].qty - outwaremx[i].planqty > 0 THEN ld_trueoverqty = outwaremx[i].qty - outwaremx[i].planqty ELSE ld_trueoverqty = 0 END IF END IF INSERT INTO u_outwaremx (scid, outwareid, mtrlwareid, printid, mtrlid, plancode, status, qty, fprice, rebate, price, planprice, mxdscrp, sptid, dxflag, costamt, ifrel, relid, packqty, olmtrlid, woodcode, relcode, pcode, enprice, newpriceamt, outtypestr, dftsaleprice, cost, planqty, relprintid, unit, rate, uqty, storageid, scidprice, mtrlcuscode, location, pricetype, formula, capacity, saleqty, saleoutid, saleoutprintid, mxdscrp2, net_weight, gross_weight, cubage, taxrate, priceformula, qtyformula, enacprice, ifvqty, trueoverqty, backtype, ifnotinout) VALUES ( :scid, :ls_newid, :outwaremx[i].mtrlwareid, :outwaremx[i].printid, :outwaremx[i].mtrlid, :outwaremx[i].plancode, :outwaremx[i].status, :outwaremx[i].qty, :outwaremx[i].fprice, :outwaremx[i].rebate, :outwaremx[i].price, :outwaremx[i].planprice, :outwaremx[i].mxdscrp, :outwaremx[i].sptid, :outwaremx[i].dxflag, :outwaremx[i].costamt, :outwaremx[i].ifrel, :outwaremx[i].relid, :outwaremx[i].packqty, :outwaremx[i].olmtrlid, :outwaremx[i].woodcode, :outwaremx[i].relcode, :outwaremx[i].pcode, :outwaremx[i].enprice, :outwaremx[i].newpriceamt, :outwaremx[i].outtype, :outwaremx[i].dftsaleprice, :outwaremx[i].cost, :outwaremx[i].planqty, :outwaremx[i].relprintid, :outwaremx[i].unit, :outwaremx[i].rate, :outwaremx[i].uqty, :outwaremx[i].storageid, :outwaremx[i].scidprice, :outwaremx[i].mtrlcuscode, :outwaremx[i].Location, :outwaremx[i].pricetype, :outwaremx[i].formula, :outwaremx[i].capacity, :outwaremx[i].qty, :outwaremx[i].saleoutid, :outwaremx[i].saleoutprintid, :outwaremx[i].mxdscrp2, :outwaremx[i].net_weight, :outwaremx[i].gross_weight, :outwaremx[i].cubage, :outwaremx[i].taxrate, :outwaremx[i].priceformula, :outwaremx[i].qtyformula, :outwaremx[i].enacprice, :outwaremx[i].ifvqty, :ld_trueoverqty, :outwaremx[i].backtype, :outwaremx[i].ifnotinout) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN outwareid = 0 //还原outwareid rslt = 0 arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT FOR i = 1 To it_mxbt_mx INSERT INTO u_outwaremx_mx (scid, outwareid, mtrlwareid, printid, mxprintid, mtrlid, plancode, status, qty, mxdscrp, sptid, dxflag, woodcode, pcode, planqty, storageid, mtrlcuscode, location, ifnotinout) VALUES ( :scid, :ls_newid, :outwaremx_mx[i].mtrlwareid, :outwaremx_mx[i].printid, :outwaremx_mx[i].mxprintid, :outwaremx_mx[i].mtrlid, :outwaremx_mx[i].plancode, :outwaremx_mx[i].status, :outwaremx_mx[i].qty, :outwaremx_mx[i].mxdscrp, :outwaremx_mx[i].sptid, :outwaremx_mx[i].dxflag, :outwaremx_mx[i].woodcode, :outwaremx_mx[i].pcode, :outwaremx_mx[i].planqty, :outwaremx_mx[i].storageid, :outwaremx_mx[i].mtrlcuscode, :outwaremx_mx[i].Location, :outwaremx_mx[i].ifnotinout) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN outwareid = 0 //还原outwareid rslt = 0 arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT FOR i = 1 To it_mxbt_item INSERT INTO u_outware_itemmx (scid, outwareid, printid, itemid, amt, mxdscrp) VALUES (:scid, :ls_newid, :outware_itemmx[i].printid, :outware_itemmx[i].itemid, :outware_itemmx[i].amt, :outware_itemmx[i].mxdscrp) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN outwareid = 0 //还原taskid rslt = 0 arg_msg = "因网络或其它原因导致插入费用明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT //增加已开单数 IF billtype <> 21 And billtype <> 12 THEN IF uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF IF uo_option_outware_pack_save_cmp = 1 And billtype <> 23 And uo_option_mtrlware_autocmp = 1 THEN FOR i = 1 To it_mxbt If ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) THEN ins_ref_mxbt++ ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid END IF NEXT END IF ELSE //////////////////////////////////////////////// //更新 // IF (billtype = 1 OR billtype = 5) AND sys_option_autowaste = 1 THEN // uo_outware_waste uo_waste // uo_waste = CREATE uo_outware_waste // uo_waste.commit_transaction = commit_transaction // IF uo_waste.insertwaste(1,scid,outwareid,arg_msg,FALSE) = 0 THEN // rslt = 0 // GOTO ext // END IF // DESTROY uo_waste // END IF IF uo_option_outware_pack_save_cmp = 1 And billtype <> 23 And uo_option_mtrlware_autocmp = 1 THEN ins_ref_mxbt = 1 DECLARE cur_outwaremx_ori CURSOR FOR SELECT u_outwaremx.mtrlid, u_outwaremx.plancode, u_outwaremx.mtrlcuscode, u_outwaremx.storageid FROM u_outwaremx,u_mtrldef WHERE u_outwaremx.outwareid = :outwareid AND u_outwaremx.mtrlid = u_mtrldef.mtrlid AND u_outwaremx.scid = :scid AND ( u_mtrldef.ifpack = 1 OR u_mtrldef.ifpack = 2 OR u_mtrldef.ifpackpro = 3 OR u_mtrldef.ifpackpro = 4 ) Order By u_outwaremx.printid Using commit_transaction; OPEN cur_outwaremx_ori; FETCH cur_outwaremx_ori Into :ins_ref_outwaremx[ins_ref_mxbt].mtrlid,:ins_ref_outwaremx[ins_ref_mxbt].plancode,:ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode,:ins_ref_outwaremx[ins_ref_mxbt].storageid; DO WHILE sqlca.SQLCode = 0 ins_ref_mxbt++ FETCH cur_outwaremx_ori Into :ins_ref_outwaremx[ins_ref_mxbt].mtrlid,:ins_ref_outwaremx[ins_ref_mxbt].plancode,:ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode,:ins_ref_outwaremx[ins_ref_mxbt].storageid; LOOP CLOSE cur_outwaremx_ori; ins_ref_mxbt = ins_ref_mxbt - 1 FOR i = 1 To it_mxbt If ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) THEN FOR j = 1 To ins_ref_mxbt IF ins_ref_outwaremx[j].mtrlid = outwaremx[i].mtrlid And ins_ref_outwaremx[j].plancode = outwaremx[i].plancode And ins_ref_outwaremx[j].mtrlcuscode = outwaremx[i].mtrlcuscode And ins_ref_outwaremx[j].storageid = storageid THEN GOTO _next_mtrl END IF NEXT ins_ref_mxbt++ ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid END IF _next_mtrl: NEXT END IF If (billtype > 1 And billtype <> 5 ) Or ((billtype = 1 Or billtype = 5) And flag = 0 And priceflag = 0) THEN UPDATE u_outware SET billtype = :billtype, relid = :relid, storageid = :storageid, outdate = :outdate, outrep = :outrep, part = :part, dscrp = :dscrp, cusid = :cusid, cusname = :cusname, thflag = :thflag, moddate = :server_dt, modemp = :publ_operator, relstr_1 = :relstr_1, relstr_2 = :relstr_2, relstr_3 = :relstr_3, relint_1 = :relint_1, relint_2 = :relint_2, relint_3 = :relint_3, relint_4 = :relint_4, otheramt = :otheramt, damt = :damt, rel_address = :rel_address, rel_tele = :rel_tele, rel_fax = :rel_fax, rel_rep = :rel_rep, mrate = :mrate, upname = :upname, viewdate = :viewdate, deptid = :deptid, totalamt = :totalamt, getamt = :getamt, lsflag = :lsflag, carcode = :carcode, transcode = :transcode, typeid = :typeid, exchangeid = :exchangeid, station_address = :station_address WHERE u_outware.outwareid = :outwareid AND u_outware.scid = :scid And flag = 0 Using commit_transaction; IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致更新单据操作失败(1)"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //更新库存已开单数(减) IF billtype <> 21 And billtype <> 12 THEN IF uof_noauditingqty_del(scid,outwareid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF //删除原有明细 DELETE FROM u_outwaremx WHERE u_outwaremx.outwareid = :outwareid And u_outwaremx.scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF FOR i = 1 To it_mxbt //如果是发料单,计算实际超发数量 IF billtype = 3 And relint_1 = 4 THEN IF outwaremx[i].qty - outwaremx[i].planqty > 0 THEN ld_trueoverqty = outwaremx[i].qty - outwaremx[i].planqty ELSE ld_trueoverqty = 0 END IF END IF INSERT INTO u_outwaremx (scid, outwareid, mtrlwareid, printid, mtrlid, plancode, status, qty, fprice, rebate, price, planprice, mxdscrp, sptid, dxflag, costamt, ifrel, relid, packqty, olmtrlid, woodcode, relcode, pcode, enprice, newpriceamt, outtypestr, dftsaleprice, cost, planqty, relprintid, unit, rate, uqty, storageid, scidprice, mtrlcuscode, location, pricetype, formula, capacity, saleqty, saleoutid, saleoutprintid, mxdscrp2, net_weight, gross_weight, cubage, taxrate, priceformula, qtyformula, enacprice, ifvqty, trueoverqty, backtype, ifnotinout) VALUES ( :scid, :outwareid, :outwaremx[i].mtrlwareid, :outwaremx[i].printid, :outwaremx[i].mtrlid, :outwaremx[i].plancode, :outwaremx[i].status, :outwaremx[i].qty, :outwaremx[i].fprice, :outwaremx[i].rebate, :outwaremx[i].price, :outwaremx[i].planprice, :outwaremx[i].mxdscrp, :outwaremx[i].sptid, :outwaremx[i].dxflag, :outwaremx[i].costamt, :outwaremx[i].ifrel, :outwaremx[i].relid, :outwaremx[i].packqty, :outwaremx[i].olmtrlid, :outwaremx[i].woodcode, :outwaremx[i].relcode, :outwaremx[i].pcode, :outwaremx[i].enprice, :outwaremx[i].newpriceamt, :outwaremx[i].outtype, :outwaremx[i].dftsaleprice, :outwaremx[i].cost, :outwaremx[i].planqty, :outwaremx[i].relprintid, :outwaremx[i].unit, :outwaremx[i].rate, :outwaremx[i].uqty, :outwaremx[i].storageid, :outwaremx[i].scidprice, :outwaremx[i].mtrlcuscode, :outwaremx[i].Location, :outwaremx[i].pricetype, :outwaremx[i].formula, :outwaremx[i].capacity, :outwaremx[i].qty, :outwaremx[i].saleoutid, :outwaremx[i].saleoutprintid, :outwaremx[i].mxdscrp2, :outwaremx[i].net_weight, :outwaremx[i].gross_weight, :outwaremx[i].cubage, :outwaremx[i].taxrate, :outwaremx[i].priceformula, :outwaremx[i].qtyformula, :outwaremx[i].enacprice, :outwaremx[i].ifvqty, :ld_trueoverqty, :outwaremx[i].backtype, :outwaremx[i].ifnotinout) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT //删除原有明细 DELETE FROM u_outwaremx_mx WHERE u_outwaremx_mx.outwareid = :outwareid And u_outwaremx_mx.scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF FOR i = 1 To it_mxbt_mx INSERT INTO u_outwaremx_mx (scid, outwareid, mtrlwareid, printid, mxprintid, mtrlid, plancode, status, qty, mxdscrp, sptid, dxflag, woodcode, pcode, planqty, storageid, mtrlcuscode, location, ifnotinout) VALUES ( :scid, :outwareid, :outwaremx_mx[i].mtrlwareid, :outwaremx_mx[i].printid, :outwaremx_mx[i].mxprintid, :outwaremx_mx[i].mtrlid, :outwaremx_mx[i].plancode, :outwaremx_mx[i].status, :outwaremx_mx[i].qty, :outwaremx_mx[i].mxdscrp, :outwaremx_mx[i].sptid, :outwaremx_mx[i].dxflag, :outwaremx_mx[i].woodcode, :outwaremx_mx[i].pcode, :outwaremx_mx[i].planqty, :outwaremx_mx[i].storageid, :outwaremx_mx[i].mtrlcuscode, :outwaremx_mx[i].Location, :outwaremx_mx[i].ifnotinout) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN outwareid = 0 //还原outwareid rslt = 0 arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT DELETE FROM u_outware_itemmx WHERE u_outware_itemmx.outwareid = :outwareid And u_outware_itemmx.scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF FOR i = 1 To it_mxbt_item INSERT INTO u_outware_itemmx (scid, outwareid, printid, itemid, amt, mxdscrp) VALUES (:scid, :outwareid, :outware_itemmx[i].printid, :outware_itemmx[i].itemid, :outware_itemmx[i].amt, :outware_itemmx[i].mxdscrp) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN outwareid = 0 //还原taskid rslt = 0 arg_msg = "因网络或其它原因导致插入费用明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT //增加已开单数 IF billtype <> 21 And billtype <> 12 THEN IF uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF ElseIf (billtype = 1 Or billtype = 5) And flag = 0 And priceflag = 1 THEN UPDATE u_outware SET billtype = :billtype, relid = :relid, storageid = :storageid, outdate = :outdate, outrep = :outrep, part = :part, dscrp = :dscrp, cusid = :cusid, cusname = :cusname, thflag = :thflag, moddate = :server_dt, modemp = :publ_operator, relstr_1 = :relstr_1, relstr_2 = :relstr_2, relstr_3 = :relstr_3, relint_1 = :relint_1, relint_2 = :relint_2, otheramt = :otheramt, damt = :damt, rel_address = :rel_address, rel_tele = :rel_tele, rel_fax = :rel_fax, rel_rep = :rel_rep, mrate = :mrate, upname = :upname, viewdate = :viewdate, deptid = :deptid, carcode = :carcode, transcode = :transcode, typeid = :typeid, exchangeid = :exchangeid, station_address = :station_address WHERE u_outware.outwareid = :outwareid AND u_outware.scid = :scid AND flag = 0 AND secflag = 0 And priceflag = 1 Using commit_transaction; IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致更新单据操作失败(3)"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //更新库存已开单数(减) IF billtype <> 21 And billtype <> 12 THEN IF uof_noauditingqty_del(scid,outwareid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF FOR i = 1 To it_mxbt UPDATE u_outWAREmx SET qty = :outWAREmx[i].qty, saleqty = :outwaremx[i].qty, mxdscrp = :outwaremx[I].mxdscrp, fprice = :outwaremx[I].fprice, rebate = :outwaremx[I].rebate, enprice = :outwaremx[I].enprice, enacprice = :outwaremx[I].enacprice, packqty = :outwaremx[I].packqty, outtype = :outwaremx[I].outtype, formula = :outwaremx[i].formula, capacity = :outwaremx[i].capacity, mxdscrp2 = :outwaremx[i].mxdscrp2, net_weight = :outwaremx[i].net_weight, gross_weight = :outwaremx[i].gross_weight, cubage = :outwaremx[i].cubage, taxrate = :outwaremx[i].taxrate, priceformula = :outwaremx[i].priceformula, qtyformula = :outwaremx[i].qtyformula WHERE ( scid = :scid AND outWAREid = :outwareid AND printid = :outwaremx[i].printid); IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致更新明细实发数操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT FOR i = 1 To it_mxbt_mx UPDATE u_outwaremx_mx SET qty = :outwaremx_mx[i].qty, mxdscrp = :outwaremx_mx[I].mxdscrp WHERE ( scid = :scid AND outWAREid = :outwareid AND printid = :outwaremx_mx[i].printid AND mxprintid = :outwaremx_mx[i].mxprintid); IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致更新应发明细实发数操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT DELETE FROM u_outware_itemmx WHERE u_outware_itemmx.outwareid = :outwareid And u_outware_itemmx.scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF FOR i = 1 To it_mxbt_item INSERT INTO u_outware_itemmx (scid, outwareid, printid, itemid, amt, mxdscrp) VALUES (:scid, :outwareid, :outware_itemmx[i].printid, :outware_itemmx[i].itemid, :outware_itemmx[i].amt, :outware_itemmx[i].mxdscrp) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致插入费用明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT //增加已开单数 IF billtype <> 21 And billtype <> 12 THEN IF uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF ELSE UPDATE u_outware SET billtype = :billtype, relid = :relid, storageid = :storageid, outdate = :outdate, outrep = :outrep, part = :part, dscrp = :dscrp, cusid = :cusid, cusname = :cusname, thflag = :thflag, moddate = :server_dt, modemp = :publ_operator, relstr_1 = :relstr_1, relstr_2 = :relstr_2, relstr_3 = :relstr_3, relint_1 = :relint_1, relint_2 = :relint_2, otheramt = :otheramt, damt = :damt, rel_address = :rel_address, rel_tele = :rel_tele, rel_fax = :rel_fax, rel_rep = :rel_rep, mrate = :mrate, upname = :upname, viewdate = :viewdate, deptid = :deptid, carcode = :carcode, transcode = :transcode, typeid = :typeid, exchangeid = :exchangeid, station_address = :station_address WHERE u_outware.outwareid = :outwareid AND u_outware.scid = :scid AND flag = 1 And secflag = 0 Using commit_transaction; IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致更新单据操作失败(2)"+"~n"+commit_transaction.SQLErrText GOTO ext END IF FOR i = 1 To it_mxbt UPDATE u_outWAREmx SET price = :outWAREmx[i].price, mxdscrp = :outwaremx[I].mxdscrp, fprice = :outwaremx[I].fprice, rebate = :outwaremx[I].rebate, enprice = :outwaremx[I].enprice, enacprice = :outwaremx[I].enacprice, taxrate = :outwaremx[i].taxrate, priceformula = :outwaremx[i].priceformula, qtyformula = :outwaremx[i].qtyformula WHERE ( scid = :scid AND outWAREid = :outwareid AND printid = :outwaremx[i].printid); IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致更新明细价格操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT DELETE FROM u_outware_itemmx WHERE u_outware_itemmx.outwareid = :outwareid And u_outware_itemmx.scid = :scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF FOR i = 1 To it_mxbt_item INSERT INTO u_outware_itemmx (scid, outwareid, printid, itemid, amt, mxdscrp) VALUES (:scid, :outwareid, :outware_itemmx[i].printid, :outware_itemmx[i].itemid, :outware_itemmx[i].amt, :outware_itemmx[i].mxdscrp) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN outwareid = 0 //还原taskid rslt = 0 arg_msg = "因网络或其它原因导致插入费用明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT END IF END IF it_newbegin = False it_updatebegin = False // ext: IF rslt = 0 THEN ROLLBACK Using commit_transaction; p_clearmx() ELSEIF rslt = 1 And arg_ifcommit THEN COMMIT Using commit_transaction; END IF RETURN rslt end function public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1 Long cnt = 0,i,j,mx_barcode_cnt String ls_storagename Int li_outtype,li_storagetype,li_if_pd_usebarcode Decimal ld_sumnotoutqty,ld_sumnotoutqty_bill s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst ins_ref_outwaremx = ins_empty_outwaremx ins_ref_mxbt = 0 Long ll_taskid,ll_taskprintid Decimal ld_assign_outqty,ld_outmx_qty uo_sqlpro uo_pro uo_pro = Create uo_sqlpro uo_pro.commit_transaction = commit_transaction uo_cmpl_packpro uo_cmpl_p uo_cmpl_p = Create uo_cmpl_packpro uo_cmpl_p.commit_transaction = commit_transaction If f_aps_mrp_cklock(scid,arg_msg) = 0 Then rslt = 0 Goto ext End If If uo_option_inout_type = -1000 Then rslt = 0 arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_barcode_outwareother_paudit = -1000 Then rslt = 0 arg_msg = '选项:[205]仓库使用条码流程,其它出仓单使用先确认后审核流程,读取初始默认值失败,操作取消!' Goto ext End If uo_mtrlware_assign uo_ma uo_ma = Create uo_mtrlware_assign uo_ma.commit_transaction = commit_transaction //库存分配ds datastore ds_out_assign ds_out_assign = Create datastore If thflag = 0 Then ds_out_assign.DataObject = 'ds_outwaremx_assign' Else ds_out_assign.DataObject = 'ds_outwaremx_assign_cancel' End If ds_out_assign.SetTransObject(commit_transaction) If outwareid = 0 Then rslt = 0 arg_msg = "没有出仓审核对象" Goto ext End If If storageid = 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 End If Select storagename,outtype,storagetype,if_pd_usebarcode Into :ls_storagename,:li_outtype,:li_storagetype,:li_if_pd_usebarcode From u_storage Where storageid = :storageid Using commit_transaction ; If commit_transaction.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(storageid)+',') <= 0 Then rslt = 0 arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许审核该仓库的单据' Goto ext End If End If // If uo_option_inout_type = 2 And li_outtype = 2 And & ( uo_option_barcode_outwareother_paudit = 1 And billtype = 8 ) Then If priceflag = 0 Then arg_msg = '单据未确认,不能审核' rslt = 0 Goto ext End If End If If flag = 1 Then rslt = 0 arg_msg = "单据已经审核" Goto ext End If If li_outtype = 2 Then For i = 1 To it_mxbt If outwaremx[i].outtype_mtrl = 2 Then mx_barcode_cnt++ Next If mx_barcode_cnt > 0 And ( billtype = 8 Or billtype = 9 And & ( li_if_pd_usebarcode = 1 Or li_if_pd_usebarcode = 0 And if_pd_py_check_barcode )) Then If uof_check_qty_to_bqty(arg_msg) = 0 Then rslt = 0 Goto ext End If End If End If Update u_outware Set Auditingrep = :publ_operator, Auditingdate = getdate(), flag = 1 Where u_outware.outwareid = :outwareid And flag = 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 = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText Goto ext End If For i = 1 To it_mxbt Decimal ld_ref_costamt // ld_ref_costamt = 0 If p_update_cost(outwaremx[i].mtrlwareid,outwaremx[i].mtrlcode,& outwaremx[i].qty,outwaremx[i].printid,ld_ref_costamt,arg_msg,False) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If If billtype <> 19 Then //先取消分配再扣库存 //更新库存分配(销售出仓单包件出仓) If billtype = 21 And li_storagetype = 1 And li_outtype > 0 And thflag = 0 Then ll_taskid = 0 ll_taskprintid = 0 ld_assign_outqty = 0 Select u_outwaremx.relid, u_outwaremx.relprintid Into :ll_taskid, :ll_taskprintid From u_outwaremx Where u_outwaremx.scid = :scid And u_outwaremx.outwareid = :relid //发货单id And u_outwaremx.printid = :outwaremx[i].olmtrlid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(包件明细)行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If If ll_taskid > 0 Then ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid) If ds_out_assign.RowCount() > 0 Then ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1] Else ld_sumnotoutqty = 0 End If ld_sumnotoutqty_bill = 0 ld_sumnotoutqty_bill = outwaremx[i].qty ds_out_assign.AcceptText() If ld_sumnotoutqty_bill > ld_sumnotoutqty Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(包件明细)行:'+String(i)+'订单库存分配数不足,请检查库存分配未出仓明细' rslt = 0 Goto ext Else ld_assign_outqty = 0 For j = 1 To ds_out_assign.RowCount() If ds_out_assign.Object.notoutqty[j] >= ld_sumnotoutqty_bill Then ld_assign_outqty = ld_sumnotoutqty_bill If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(包件明细)行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Exit Else ld_assign_outqty = ds_out_assign.Object.notoutqty[j] If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(包件明细)行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If ld_sumnotoutqty_bill = ld_sumnotoutqty_bill - ds_out_assign.Object.notoutqty[j] End If Next End If End If End If If sys_option_inout_procedure = 0 Then If p_update_mtrlware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, & outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,& outwaremx[i].status, outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,& outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,& outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,outwaremx[i].ifvqty,arg_msg) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Else If uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,& outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,& outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,& outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,& outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If End If //更新库存分配销售退货单 If billtype = 21 And li_storagetype = 1 And li_outtype > 0 And thflag = 1 Then ll_taskid = 0 ll_taskprintid = 0 ld_assign_outqty = 0 Select u_outwaremx.relid, u_outwaremx.relprintid Into :ll_taskid, :ll_taskprintid From u_outwaremx Where u_outwaremx.scid = :scid And u_outwaremx.outwareid = :relid And u_outwaremx.printid = :outwaremx[i].olmtrlid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If If ll_taskid > 0 Then ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid) If ds_out_assign.RowCount() > 0 Then ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1] Else ld_sumnotoutqty = 0 End If ds_out_assign.AcceptText() ld_outmx_qty = Abs(outwaremx[i].qty) If ld_outmx_qty > ld_sumnotoutqty And ll_taskid > 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+'订单库存分配已出仓数不足,不能撤审,请检查库存分配已出仓明细' rslt = 0 Goto ext Else ld_assign_outqty = 0 For j = 1 To ds_out_assign.RowCount() If ds_out_assign.Object.notoutqty[j] >= ld_outmx_qty Then ld_assign_outqty = ld_outmx_qty If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Exit Else ld_assign_outqty = ds_out_assign.Object.notoutqty[j] If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If ld_outmx_qty = ld_outmx_qty - ds_out_assign.Object.notoutqty[j] End If Next End If End If End If Else If sys_option_inout_procedure = 0 Then If p_update_mtrlware_ws( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, & outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,& outwaremx[i].status, outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,& outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,& outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Else If uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,& outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,& outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,& outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,& outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If End If End If //yyx2012-9-29返回计算可装数库存id数组 If billtype <> 23 And ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) And uo_option_mtrlware_autocmp = 1 Then If uo_option_noauditingqty_mode = 0 Then If uo_cmpl_p.uof_ref_mtrlwarid_array(outwaremx[i].mtrlid,outwaremx[i].plancode,outwaremx[i].mtrlcuscode,storageid,s_mtrlwareid_array_rst,arg_msg) = 0 Then rslt = 0 Goto ext End If Else ins_ref_mxbt++ ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid End If End If // Next //更新条码 If li_outtype = 2 And & mx_barcode_cnt > 0 And & ( billtype <> 9 Or billtype = 9 And & ( li_if_pd_usebarcode = 1 Or li_if_pd_usebarcode = 0 And if_pd_py_check_barcode )) Then If uof_p_barcode(1,arg_msg) = 0 Then rslt = 0 Goto ext End If End If //更新库存已开单数(减) If billtype <> 21 And billtype <> 12 Then If uof_noauditingqty_del(scid,outwareid,arg_msg) = 0 Then rslt = 0 Goto ext End If End If //yyx2012-9-29返回计算可装数库存id数组计算可装数 If billtype <> 23 And UpperBound(s_mtrlwareid_array_rst.mtrlwareid) > 0 And uo_option_mtrlware_autocmp = 1 Then If uo_option_noauditingqty_mode = 0 Then If uo_cmpl_p.uof_cmpl_diqty(s_mtrlwareid_array_rst,arg_msg) = 0 Then rslt = 0 Goto ext End If End If End If // flag = 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_ma Destroy ds_out_assign Destroy uo_pro Destroy uo_cmpl_p Return rslt end function public function integer updatebegin (long arg_scid, long arg_outwareid, integer arg_billtype, ref string arg_msg);Long rslt = 1 IF uo_option_inout_type = -1000 THEN rslt = 0 arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_barcode_outwareother_paudit= -1000 THEN rslt = 0 arg_msg = '选项:[205]仓库使用条码流程,其它出仓单使用先确认后审核流程,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_confirmaudit_sale = -1000 THEN rslt = 0 arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_sale_use_planqty = -1000 THEN rslt = 0 arg_msg = '选项:[115]销售发货单使用计划发货数,读取初始默认值失败,操作取消!' GOTO ext END IF IF arg_scid < 0 THEN arg_msg = '请选择分部' rslt = 0 GOTO ext END IF IF arg_outwareid <= 0 THEN rslt = 0 GOTO ext END IF IF Not (arg_billtype = 1 OR & arg_billtype = 2 OR & arg_billtype = 3 OR & arg_billtype = 4 OR & arg_billtype = 5 OR & arg_billtype = 6 OR & arg_billtype = 7 OR & arg_billtype = 8 OR & arg_billtype = 9 OR & arg_billtype = 10 OR & arg_billtype = 12 OR & arg_billtype = 15 OR & arg_billtype = 16 OR & arg_billtype = 17 or & arg_billtype = 18 or & arg_billtype = 19 or & arg_billtype = 20 or & arg_billtype = 21 or & arg_billtype = 22 or & arg_billtype = 23 or & arg_billtype = 24 or & arg_billtype = 25) THEN rslt = 0 arg_msg = '此单据类型必须为:' arg_msg = arg_msg+'1-销售单[记帐模式],' arg_msg = arg_msg+'2-销售单[不记帐模式],' arg_msg = arg_msg+'3-领料出仓单,' arg_msg = arg_msg+'4-外加工出仓单,' arg_msg = arg_msg+'5-来料加工发货,' arg_msg = arg_msg+'6-售后服务出仓单,' arg_msg = arg_msg+'7-外协销售出仓单,' arg_msg = arg_msg+'8-其他出仓单,' arg_msg = arg_msg+'9-盘亏出仓单,' arg_msg = arg_msg+'10-工具出仓单,' arg_msg = arg_msg+'12-调拨出仓单,' arg_msg = arg_msg+'15-拆装出仓单,' arg_msg = arg_msg+'16-生产进仓车间自动出仓(未分配),' arg_msg = arg_msg+'17-还货出仓单,' arg_msg = arg_msg+'18-自动组装出仓单,' arg_msg = arg_msg+'19-生产进仓车间自动出仓单(已分配)' arg_msg = arg_msg+'20-车间库存转换自动出仓单' arg_msg = arg_msg+'21-销售发货单包件明细自动出仓单' arg_msg = arg_msg+'22-欠货终止单自动出仓单' arg_msg = arg_msg+'23-采购收货单收货明细自动出仓单' arg_msg = arg_msg+'24-员工物品领用单' arg_msg = arg_msg+'25-发料损耗自动出仓单' GOTO ext END IF IF arg_billtype = 12 THEN rslt = 0 arg_msg = '单据类型:12-调拨出仓>>不能修改' GOTO ext END IF IF arg_billtype = 17 THEN rslt = 0 arg_msg = '单据类型:17-还货出仓单>>不能修改' GOTO ext END IF IF arg_billtype = 18 THEN rslt = 0 arg_msg = '单据类型:18-自动组装出仓单>>不能修改' GOTO ext END IF rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg) IF rslt = 0 THEN GOTO ext IF uo_option_inout_type = 2 AND & ( uo_option_barcode_outwareother_paudit = 1 AND arg_billtype = 8 ) THEN IF priceflag = 1 THEN arg_msg = '单据已确认,不能修改' rslt = 0 GOTO ext END IF END IF String ls_storagename SELECT storagename INTO :ls_storagename FROM u_storage Where storageid = :storageid USING commit_transaction ; IF commit_transaction.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(storageid)+',') <= 0 THEN rslt = 0 arg_msg = '没有仓库: '+ls_storagename+' 的建立权限,不允许修改该仓库的单据' GOTO ext END IF END IF // IF arg_billtype = 1 THEN IF uo_option_confirmaudit_sale = 1 AND uo_option_sale_use_planqty = 1 THEN IF priceflag = 1 AND flag = 1 AND secflag = 1 THEN rslt = 0 arg_msg = '单据已经过仓库及财务审核,不可以修改' GOTO ext ELSEIF priceflag = 1 AND flag = 0 AND secflag = 0 THEN rslt = 0 arg_msg = '单据已经确认,仓审前不可以修改' GOTO ext END IF ELSE IF flag = 1 AND secflag = 1 THEN rslt = 0 arg_msg = '单据已经过仓库及财务审核,不可以修改' GOTO ext ELSEIF priceflag = 1 AND flag = 0 AND secflag = 0 THEN rslt = 0 arg_msg = '单据已经确认,仓审前不可以修改' GOTO ext END IF END IF ELSEIF arg_billtype = 5 THEN IF flag = 1 AND secflag = 1 THEN rslt = 0 arg_msg = '单据已经过仓库及财务审核,不可以修改' GOTO ext ELSEIF priceflag = 1 AND flag = 0 AND secflag = 0 THEN rslt = 0 arg_msg = '单据已经确认,仓审前不可以修改,不可以修改' GOTO ext END IF ELSE IF flag = 1 THEN rslt = 0 arg_msg = '单据已经审核,不可以修改' GOTO ext END IF END IF outwareid = arg_outwareid billtype = arg_billtype scid = arg_scid it_newbegin = FALSE it_updatebegin = TRUE p_clearmx() //清除明细 ext: IF rslt = 0 THEN p_reset() RETURN rslt end function public function integer getinfo (long arg_scid, long arg_outwareid, ref string arg_msg);//getinfo(arg_scid,arg_outwareid,arg_msg) //0 失败 1成功 Int rslt = 1 Long i = 1,no_mxcheck = 0,j = 1,no_mxcheck_barcode = 0,k = 1,l = 1,ll_i Int li_outtype Decimal ld_planprice sum_amt = 0 sum_amt_en = 0 sum_taxamt = 0 sum_taxamt_en = 0 IF arg_outwareid <= 0 THEN rslt = 0 arg_msg = "非法出仓单唯一码" GOTO ext END IF rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg) IF rslt = 0 THEN GOTO ext SELECT outtype INTO :li_outtype FROM u_storage Where storageid = :storageid Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,仓库出仓类型,"+commit_transaction.SQLErrText GOTO ext END IF //用游标读取明细 DECLARE cur_outwaremx CURSOR FOR SELECT u_outwaremx.printid, u_outwaremx.mtrlid, u_outwaremx.plancode, u_outwaremx.status, u_outwaremx.qty, u_outwaremx.fprice, u_outwaremx.rebate, u_outwaremx.price, u_outwaremx.mxdscrp, u_mtrldef.mtrlcode, u_outwaremx.sptid, u_outwaremx.dxflag, u_outwaremx.mtrlwareid, u_outwaremx.storageid, u_outwaremx.costamt, u_outwaremx.ifrel, u_outwaremx.relid, u_outwaremx.olmtrlid, u_outwaremx.packqty, u_outwaremx.woodcode, u_outwaremx.pcode, u_outwaremx.enprice, u_outwaremx.newpriceamt, u_outwaremx.outtypestr, u_outwaremx.dftsaleprice, u_outwaremx.cost, u_outwaremx.planqty, u_outwaremx.relprintid, u_outwaremx.relcode, u_outwaremx.unit, u_outwaremx.rate, u_outwaremx.uqty, u_outwaremx.overqty, u_outwaremx.mtrlcuscode, u_outwaremx.location, u_outwaremx.pricetype, u_outwaremx.formula, u_outwaremx.capacity, u_mtrldef.ifpackpro, u_mtrldef.ifpack, u_mtrldef.outtype, u_outwaremx.saleqty, u_outwaremx.saleoutid, u_outwaremx.saleoutprintid, u_outwaremx.mxdscrp2, u_outwaremx.net_weight, u_outwaremx.gross_weight, u_outwaremx.cubage, u_outwaremx.taxrate, u_outwaremx.priceformula, u_outwaremx.qtyformula, u_mtrldef.iffp, u_outwaremx.enacprice, u_outwaremx.ifvqty, u_outwaremx.backtype, u_outwaremx.ifnotinout FROM u_outwaremx,u_mtrldef,u_outware WHERE u_outware.outwareid = :arg_outwareid AND u_outwaremx.mtrlid = u_mtrldef.mtrlid AND u_outware.scid = :arg_scid AND u_outware.outwareid = u_outwaremx.outwareid AND u_outware.scid = u_outwaremx.scid Order By u_outwaremx.printid Using commit_transaction; OPEN cur_outwaremx; FETCH cur_outwaremx INTO :outwaremx[i].printid,:outwaremx[i].mtrlid,:outwaremx[i].plancode, :outwaremx[i].status,:outwaremx[i].qty,:outwaremx[i].fprice, :outwaremx[i].rebate,:outwaremx[i].price, :outwaremx[i].mxdscrp,:outwaremx[i].mtrlcode, :outwaremx[i].sptid,:outwaremx[i].dxflag, :outwaremx[i].mtrlwareid,:outwaremx[i].storageid, :outwaremx[i].costamt,:outwaremx[i].ifrel, :outwaremx[i].relid,:outwaremx[i].olmtrlid,:outwaremx[i].packqty, :outwaremx[i].woodcode,:outwaremx[i].pcode,:outwaremx[i].enprice, :outwaremx[i].newpriceamt,:outwaremx[i].outtype,:outwaremx[i].dftsaleprice, :outwaremx[i].cost,:outwaremx[i].planqty,:outwaremx[i].relprintid,:outwaremx[i].relcode, :outwaremx[i].unit,:outwaremx[i].rate,:outwaremx[i].uqty,:outwaremx[i].overqty, :outwaremx[i].mtrlcuscode,:outwaremx[i].Location,:outwaremx[i].pricetype,:outwaremx[i].formula, :outwaremx[i].capacity,:outwaremx[i].ifpackpro,:outwaremx[i].ifpack,:outwaremx[i].outtype_mtrl, :outwaremx[i].saleqty,:outwaremx[i].saleoutid,:outwaremx[i].saleoutprintid, :outwaremx[i].mxdscrp2,:outwaremx[i].net_weight,:outwaremx[i].gross_weight,:outwaremx[i].cubage, :outwaremx[i].taxrate,:outwaremx[i].priceformula,:outwaremx[i].qtyformula,:outwaremx[i].iffp, :outwaremx[i].enacprice,:outwaremx[i].ifvqty,:outwaremx[i].backtype,:outwaremx[i].ifnotinout; DO WHILE commit_transaction.SQLCode = 0 sum_amt = sum_amt + Round( (outwaremx[i].saleqty * outwaremx[i].price) / ( 1 + outwaremx[i].taxrate) ,2) //计算单据总金额 sum_amt_en = sum_amt_en + Round((outwaremx[i].saleqty * outwaremx[i].enacprice) / ( 1 + outwaremx[i].taxrate),2) //计算单据总金额 sum_taxamt = sum_taxamt + Round( ( outwaremx[i].saleqty * outwaremx[i].price * outwaremx[i].taxrate) / ( 1 + outwaremx[i].taxrate) ,2) sum_taxamt_en = sum_taxamt_en + Round( (outwaremx[i].saleqty * outwaremx[i].enacprice * outwaremx[i].taxrate) / ( 1 + outwaremx[i].taxrate),2) i++ FETCH cur_outwaremx INTO :outwaremx[i].printid,:outwaremx[i].mtrlid,:outwaremx[i].plancode, :outwaremx[i].status,:outwaremx[i].qty,:outwaremx[i].fprice, :outwaremx[i].rebate,:outwaremx[i].price, :outwaremx[i].mxdscrp,:outwaremx[i].mtrlcode, :outwaremx[i].sptid,:outwaremx[i].dxflag, :outwaremx[i].mtrlwareid,:outwaremx[i].storageid, :outwaremx[i].costamt,:outwaremx[i].ifrel, :outwaremx[i].relid,:outwaremx[i].olmtrlid,:outwaremx[i].packqty, :outwaremx[i].woodcode,:outwaremx[i].pcode,:outwaremx[i].enprice, :outwaremx[i].newpriceamt,:outwaremx[i].outtype,:outwaremx[i].dftsaleprice, :outwaremx[i].cost,:outwaremx[i].planqty,:outwaremx[i].relprintid,:outwaremx[i].relcode, :outwaremx[i].unit,:outwaremx[i].rate,:outwaremx[i].uqty,:outwaremx[i].overqty, :outwaremx[i].mtrlcuscode,:outwaremx[i].Location,:outwaremx[i].pricetype,:outwaremx[i].formula, :outwaremx[i].capacity,:outwaremx[i].ifpackpro,:outwaremx[i].ifpack,:outwaremx[i].outtype_mtrl, :outwaremx[i].saleqty,:outwaremx[i].saleoutid,:outwaremx[i].saleoutprintid, :outwaremx[i].mxdscrp2,:outwaremx[i].net_weight,:outwaremx[i].gross_weight,:outwaremx[i].cubage, :outwaremx[i].taxrate,:outwaremx[i].priceformula,:outwaremx[i].qtyformula,:outwaremx[i].iffp, :outwaremx[i].enacprice,:outwaremx[i].ifvqty,:outwaremx[i].backtype,:outwaremx[i].ifnotinout; LOOP CLOSE cur_outwaremx; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck FROM u_outwaremx WHERE u_outwaremx.outwareid = :arg_outwareid And scid = :arg_scid Using commit_transaction; IF commit_transaction.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 //取计划价 FOR ll_i = 1 To i - 1 ld_planprice = 0 f_get_planprice_mtrl(outwaremx[ll_i].mtrlid,outwaremx[ll_i].status,outwaremx[ll_i].woodcode,outwaremx[ll_i].pcode,ld_planprice) IF IsNull(ld_planprice) THEN ld_planprice = 0 outwaremx[ll_i].planprice = ld_planprice NEXT DECLARE cur_outwaremx_mx CURSOR FOR SELECT u_outwaremx_mx.printid, u_outwaremx_mx.mxprintid, u_outwaremx_mx.mtrlwareid, u_outwaremx_mx.storageid, u_outwaremx_mx.mtrlid, u_outwaremx_mx.plancode, u_outwaremx_mx.status, u_outwaremx_mx.woodcode, u_outwaremx_mx.pcode, u_outwaremx_mx.mtrlcuscode, u_outwaremx_mx.location, u_outwaremx_mx.sptid, u_outwaremx_mx.dxflag, u_outwaremx_mx.planqty, u_outwaremx_mx.qty, u_outwaremx_mx.mxdscrp, u_outwaremx_mx.ifnotinout, u_mtrldef.ifpackpro, u_mtrldef.ifpack,u_mtrldef.mtrlcode FROM u_outwaremx_mx INNER JOIN u_mtrldef ON u_outwaremx_mx.mtrlid = u_mtrldef.mtrlid WHERE u_outwaremx_mx.scid = :arg_scid AND u_outwaremx_mx.outwareid = :arg_outwareid Order By u_outwaremx_mx.mxprintid Using commit_transaction; OPEN cur_outwaremx_mx; FETCH cur_outwaremx_mx INTO :outwaremx_mx[j].printid,:outwaremx_mx[j].mxprintid, :outwaremx_mx[j].mtrlwareid,:outwaremx_mx[j].storageid,:outwaremx_mx[j].mtrlid, :outwaremx_mx[j].plancode,:outwaremx_mx[j].status,:outwaremx_mx[j].woodcode, :outwaremx_mx[j].pcode,:outwaremx_mx[j].mtrlcuscode,:outwaremx_mx[j].location, :outwaremx_mx[j].sptid,:outwaremx_mx[j].dxflag,:outwaremx_mx[j].planqty, :outwaremx_mx[j].qty,:outwaremx_mx[j].mxdscrp,:outwaremx_mx[j].ifnotinout, :outwaremx_mx[j].ifpackpro, :outwaremx_mx[j].ifpack, :outwaremx_mx[j].mtrlcode; DO WHILE commit_transaction.SQLCode = 0 j++ FETCH cur_outwaremx_mx INTO :outwaremx_mx[j].printid,:outwaremx_mx[j].mxprintid, :outwaremx_mx[j].mtrlwareid,:outwaremx_mx[j].storageid,:outwaremx_mx[j].mtrlid, :outwaremx_mx[j].plancode,:outwaremx_mx[j].status,:outwaremx_mx[j].woodcode, :outwaremx_mx[j].pcode,:outwaremx_mx[j].mtrlcuscode,:outwaremx_mx[j].location, :outwaremx_mx[j].sptid,:outwaremx_mx[j].dxflag,:outwaremx_mx[j].planqty, :outwaremx_mx[j].qty,:outwaremx_mx[j].mxdscrp,:outwaremx_mx[j].ifnotinout, :outwaremx_mx[j].ifpackpro, :outwaremx_mx[j].ifpack, :outwaremx_mx[j].mtrlcode; LOOP CLOSE cur_outwaremx_mx; SELECT count(*) INTO :no_mxcheck FROM u_outwaremx_mx WHERE u_outwaremx_mx.outwareid = :arg_outwareid And scid = :arg_scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,出仓单应发明细数量" GOTO ext END IF IF j <> (no_mxcheck+1) THEN rslt = 0 arg_msg = "查询操作失败,出仓单应发明细" GOTO ext END IF //用游标读取条码明细 IF li_outtype = 2 THEN DECLARE cur_outwaremx_barcode CURSOR FOR SELECT u_outwaremx_mx_barcode.barcode, u_outwaremx_mx_barcode.qty, u_mtrlware_mx.packqty, u_mtrlware_mx.mtrlwareid, u_outwaremx_mx_barcode.qty * u_mtrlware_mx.packqty FROM u_outwaremx_mx_barcode,u_mtrlware_mx WHERE u_outwaremx_mx_barcode.barcode = u_mtrlware_mx.barcode AND u_outwaremx_mx_barcode.outwareid = :arg_outwareid AND u_outwaremx_mx_barcode.scid = :arg_scid AND u_outwaremx_mx_barcode.billtype = :billtype Order By u_outwaremx_mx_barcode.barcode Using commit_transaction; OPEN cur_outwaremx_barcode; FETCH cur_outwaremx_barcode INTO :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty, :s_mx_barcode[k].packqty,:s_mx_barcode[k].mtrlwareid,:s_mx_barcode[k].outqty; DO WHILE commit_transaction.SQLCode = 0 k++ FETCH cur_outwaremx_barcode INTO :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty, :s_mx_barcode[k].packqty,:s_mx_barcode[k].mtrlwareid,:s_mx_barcode[k].outqty; LOOP CLOSE cur_outwaremx_barcode; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck_barcode FROM u_outwaremx_mx_barcode WHERE u_outwaremx_mx_barcode.outwareid = :arg_outwareid AND u_outwaremx_mx_barcode.scid = :arg_scid And u_outwaremx_mx_barcode.billtype = :billtype Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,出仓单明细数量" GOTO ext END IF IF k <> (no_mxcheck_barcode+1) THEN rslt = 0 arg_msg = "查询操作失败,出仓单条码明细" GOTO ext END IF it_mxbt_barcode = k - 1 END IF //读取来料加工订单费用明细 DECLARE cur_outware_itemmx CURSOR FOR SELECT scid, outwareid, printid, itemid, amt, mxdscrp,IsCusAmt FROM u_outware_itemmx WHERE outwareid = :arg_outwareid AND scid = :arg_scid Using commit_transaction; OPEN cur_outware_itemmx; FETCH cur_outware_itemmx INTO :outware_itemmx[l].scid,:outware_itemmx[l].outwareid, :outware_itemmx[l].printid,:outware_itemmx[l].itemid, :outware_itemmx[l].amt,:outware_itemmx[l].mxdscrp, :outware_itemmx[l].IsCusAmt; DO WHILE commit_transaction.SQLCode = 0 l++ FETCH cur_outware_itemmx INTO :outware_itemmx[l].scid,:outware_itemmx[l].outwareid, :outware_itemmx[l].printid,:outware_itemmx[l].itemid, :outware_itemmx[l].amt,:outware_itemmx[l].mxdscrp, :outware_itemmx[l].IsCusAmt; LOOP CLOSE cur_outware_itemmx; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck FROM u_outware_itemmx Where outwareid = :arg_outwareid And scid = :arg_scid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,费用明细数量" GOTO ext END IF IF l <> (no_mxcheck+1) THEN rslt = 0 arg_msg = "查询操作失败,费用明细" GOTO ext END IF it_mxbt_item = l - 1 outwareid = arg_outwareid scid = arg_scid it_mxbt = i - 1 it_mxbt_mx = j - 1 it_mxbt_barcode = k - 1 it_newbegin = False it_updatebegin = False ext: IF rslt = 0 THEN p_reset() RETURN rslt end function public function integer add_dscrp (long arg_scid, long arg_outwareid, string arg_newdescppart, ref string arg_msg);Int rslt = 1 IF uo_option_confirmaudit_sale = -1000 THEN rslt = 0 arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!' GOTO ext END IF arg_newdescppart = Trim(arg_newdescppart) IF it_updatebegin OR it_newbegin THEN rslt = 0 arg_msg = "编辑状态下不可用" GOTO ext END IF IF arg_newdescppart = '' THEN rslt = 0 arg_msg = "要添加内容为空,操作取消" GOTO ext END IF rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg) IF rslt = 0 THEN GOTO ext IF billtype = 1 and uo_option_confirmaudit_sale = 1 THEN IF priceflag = 0 THEN rslt = 0 arg_msg = "单据未确认,不能增备注" GOTO ext END IF ELSE IF flag = 0 THEN rslt = 0 arg_msg = "非审核状态下不可用" GOTO ext END IF END IF UPDATE u_outware SET dscrp = dscrp+' '+:arg_newdescppart WHERE outwareid = :outwareid AND scid = :scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN ROLLBACK ; rslt = 0 arg_msg = "因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF COMMIT USING commit_transaction; dscrp = dscrp+' '+arg_newdescppart ext: Return (rslt) end function public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1 Long cnt = 0,i,j,mx_barcode_cnt String ls_storagename Int li_outtype,li_storagetype,li_if_pd_usebarcode Decimal ld_sumnotoutqty Decimal ld_assign_outqty,ld_outmx_qty,ld_sumnotoutqty_bill Long ll_taskid,ll_taskprintid DateTime null_dt SetNull(null_dt) s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst uo_sqlpro uo_pro uo_pro = Create uo_sqlpro uo_pro.commit_transaction = commit_transaction uo_cmpl_packpro uo_cmpl_p uo_cmpl_p = Create uo_cmpl_packpro uo_cmpl_p.commit_transaction = commit_transaction ins_ref_outwaremx = ins_empty_outwaremx ins_ref_mxbt = 0 If f_aps_mrp_cklock(scid,arg_msg) = 0 Then rslt = 0 Goto ext End If uo_mtrlware_assign uo_ma uo_ma = Create uo_mtrlware_assign uo_ma.commit_transaction = commit_transaction //库存分配ds datastore ds_out_assign ds_out_assign = Create datastore If thflag = 0 Then ds_out_assign.DataObject = 'ds_outwaremx_assign_cancel' Else ds_out_assign.DataObject = 'ds_outwaremx_assign' End If ds_out_assign.SetTransObject(commit_transaction) If storageid = 0 Then rslt = 0 arg_msg = '没有正确的仓库' Goto ext End If If billtype <> 9 And Not (billtype = 3 And Pos(dscrp,'电脑生成的') > 0 And Pos(dscrp,'的领料单') > 0) Then If uof_check_warepdb_audit(storageid,arg_msg) = 0 Then rslt = 0 Goto ext End If End If Select storagename,outtype,storagetype,if_pd_usebarcode Into :ls_storagename,:li_outtype,:li_storagetype,:li_if_pd_usebarcode From u_storage Where storageid = :storageid Using commit_transaction ; If commit_transaction.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(storageid)+',') <= 0 Then rslt = 0 arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许撤审该仓库的单据' Goto ext End If End If // If outwareid = 0 Then rslt = 0 arg_msg = "没有出仓撤审对象" Goto ext End If If ctmint > 0 Then arg_msg = '单据已截数,不能操作' rslt = 0 Goto ext End If If flag = 0 Then rslt = 0 arg_msg = "单据还未审核" Goto ext End If If balcflag = 1 Then rslt = 0 arg_msg = "单据已经日结,不能撤审" Goto ext End If Update u_outware Set Auditingrep = '', Auditingdate = :null_dt, flag = 0 Where u_outware.outwareid = :outwareid 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 = "单据正在撤审,请稍后查询。"+"~n"+commit_transaction.SQLErrText Goto ext End If For i = 1 To it_mxbt If billtype <> 19 Then //销售退货单更新分配明细 If billtype = 21 And li_storagetype = 1 And li_outtype > 0 And thflag = 1 Then ll_taskid = 0 ll_taskprintid = 0 ld_assign_outqty = 0 Select u_outwaremx.relid, u_outwaremx.relprintid Into :ll_taskid, :ll_taskprintid From u_outwaremx Where u_outwaremx.scid = :scid And u_outwaremx.outwareid = :relid //发货单id And u_outwaremx.printid = :outwaremx[i].olmtrlid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If If ll_taskid > 0 Then ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid) If ds_out_assign.RowCount() > 0 Then ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1] Else ld_sumnotoutqty = 0 End If ld_sumnotoutqty_bill = 0 ld_sumnotoutqty_bill = Abs(outwaremx[i].qty) ds_out_assign.AcceptText() If ld_sumnotoutqty_bill > ld_sumnotoutqty Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+'订单库存分配数不足,请检查库存分配未出仓明细' rslt = 0 Goto ext Else ld_assign_outqty = 0 For j = 1 To ds_out_assign.RowCount() If ds_out_assign.Object.notoutqty[j] >= ld_sumnotoutqty_bill Then ld_assign_outqty = ld_sumnotoutqty_bill If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Exit Else ld_assign_outqty = ds_out_assign.Object.notoutqty[j] If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If ld_sumnotoutqty_bill = ld_sumnotoutqty_bill - ds_out_assign.Object.notoutqty[j] End If Next End If End If End If If sys_option_inout_procedure = 0 Then If p_update_mtrlware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, & outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,& outwaremx[i].status, 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,& outwaremx[i].planprice, outwaremx[i].sptid, outwaremx[i].dxflag,& outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,outwaremx[i].ifvqty,arg_msg) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Else If uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,& outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,& 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,& outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,& outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If End If //发货单更新库存分配 If billtype = 21 And li_storagetype = 1 And li_outtype > 0 And thflag = 0 Then ll_taskid = 0 ll_taskprintid = 0 ld_assign_outqty = 0 Select u_outwaremx.relid, u_outwaremx.relprintid Into :ll_taskid, :ll_taskprintid From u_outwaremx Where u_outwaremx.scid = :scid And u_outwaremx.outwareid = :relid And u_outwaremx.printid = :outwaremx[i].olmtrlid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售出仓单明细行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If If ll_taskid > 0 Then ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid) If ds_out_assign.RowCount() > 0 Then ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1] Else ld_sumnotoutqty = 0 End If ds_out_assign.AcceptText() ld_outmx_qty = outwaremx[i].qty If ld_outmx_qty > ld_sumnotoutqty Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+'订单库存分配已出仓数不足,不能撤审,请检查库存分配已出仓明细' rslt = 0 Goto ext Else ld_assign_outqty = 0 For j = 1 To ds_out_assign.RowCount() If ds_out_assign.Object.notoutqty[j] >= ld_outmx_qty Then ld_assign_outqty = ld_outmx_qty If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Exit Else ld_assign_outqty = ds_out_assign.Object.notoutqty[j] If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If ld_outmx_qty = ld_outmx_qty - ds_out_assign.Object.notoutqty[j] End If Next End If End If End If Else If sys_option_inout_procedure = 0 Then If p_update_mtrlware_ws( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, & outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,& outwaremx[i].status, 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,& outwaremx[i].planprice, outwaremx[i].sptid, outwaremx[i].dxflag,& outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Else If uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,& outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,& 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,& outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,& outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If End If End If If li_outtype = 2 And outwaremx[i].outtype_mtrl = 2 Then mx_barcode_cnt++ //yyx2012-9-29返回计算可装数库存id数组 If billtype <> 23 And ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) And uo_option_mtrlware_autocmp = 1 Then If uo_option_noauditingqty_mode = 0 Then If uo_cmpl_p.uof_ref_mtrlwarid_array(outwaremx[i].mtrlid,outwaremx[i].plancode,outwaremx[i].mtrlcuscode,storageid,s_mtrlwareid_array_rst,arg_msg) = 0 Then rslt = 0 Goto ext End If Else ins_ref_mxbt++ ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid End If End If // Next //更新条码 If li_outtype = 2 And & mx_barcode_cnt > 0 And & ( billtype <> 9 Or billtype = 9 And & ( li_if_pd_usebarcode = 1 Or li_if_pd_usebarcode = 0 And if_pd_py_check_barcode )) Then If uof_p_barcode(0,arg_msg) = 0 Then rslt = 0 Goto ext End If End If //增加已开单数 If billtype <> 21 And billtype <> 12 Then If uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 Then rslt = 0 Goto ext End If End If //yyx2012-9-29返回计算可装数库存id数组计算可装数 If billtype <> 23 And UpperBound(s_mtrlwareid_array_rst.mtrlwareid) > 0 And uo_option_mtrlware_autocmp = 1 Then If uo_option_noauditingqty_mode = 0 Then If uo_cmpl_p.uof_cmpl_diqty(s_mtrlwareid_array_rst,arg_msg) = 0 Then rslt = 0 Goto ext End If End If End If // flag = 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_ma Destroy ds_out_assign Destroy uo_pro Destroy uo_cmpl_p Return rslt end function public function integer p_clearmx ();//int p_clearmx() //清除明细 it_mxbt = 0 it_mxbt_mx = 0 it_mxbt_barcode = 0 it_mxbt_item = 0 RETURN 1 end function public function integer p_getinfo (long arg_scid, long arg_outwareid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg) //0 失败 1成功 Int rslt = 1 IF arg_outwareid <= 0 THEN rslt = 0 arG_MSG = "非法出仓单唯一码" GOTO ext END IF SELECT u_outware.outwarecode, u_outware.billtype, u_outware.relid, u_outware.storageid, u_outware.outdate, u_outware.outrep, u_outware.part, u_outware.cusid, u_outware.cusname, u_outware.dscrp, u_outware.thflag, u_outware.flag, u_outware.secflag, u_outware.balcflag, u_outware.relstr_1, u_outware.relstr_2, u_outware.relstr_3, u_outware.relint_1, u_outware.relint_2, u_outware.relint_3, u_outware.priceflag, u_outware.otheramt, u_outware.damt, u_outware.rel_address, u_outware.rel_tele, u_outware.rel_fax, u_outware.rel_rep, u_outware.mrate, u_outware.upname, u_outware.ctmint, u_outware.ifauto, u_outware.viewdate, u_outware.deptid, u_outware.carcode, u_outware.transcode, u_outware.pda_flag, u_outware.pda_date, u_outware.typeid, u_outware.exchangeid, u_outware.balcdateint, u_outware.relint_4, u_outware.station_address INTO :outwarecode, :billtype, :relid, :storageid, :outdate, :outrep, :part, :cusid, :cusname, :dscrp, :thflag, :flag, :secflag, :balcflag, :relstr_1, :relstr_2, :relstr_3, :relint_1, :relint_2, :relint_3, :priceflag, :otheramt, :damt, :rel_address, :rel_tele, :rel_fax, :rel_rep, :mrate, :upname, :ctmint, :ifauto, :viewdate, :deptid, :carcode, :transcode, :pda_flag, :pda_date, :typeid, :exchangeid, :balcdateint, :relint_4, :station_address FROM u_outware WHERE u_outware.outwareid = :arg_outwareid AND scid = :arg_scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arG_MSG = "查询操作失败(错误出仓单唯一码),出仓单,"+string(arg_outwareid)+','+string(commit_transaction.SQLCode)+'~n'+commit_transaction.SQLErrText GOTO ext END IF outwareid = arg_outwareid scid = arg_scid ext: IF rslt = 0 THEN p_reset() RETURN rslt end function public function integer p_reset ();//int p_reset() //清除对象及其明细 scid = 0 outwareid = 0 outwarecode = '' billtype = 0 opemp = '' modemp = '' auditingrep = '' secauditingrep = '' flag = 0 secflag = 0 relid = 0 storageid = 0 outrep = '' part = '' dscrp = '' cusid = 0 cusname = '' thflag = 0 otheramt = 0 damt = 0 rel_address = '' rel_tele = '' rel_fax = '' rel_rep= '' deptid = 0 station_address = '' exchangeid = 0 balcdateint = 0 relint_4 = 0 carcode = '' transcode = '' typeid = 0 it_newbegin = FALSE it_updatebegin = FALSE //清除明细 p_clearmx() RETURN 1 end function public function integer p_update_cost (long arg_mtrlwareid, string arg_mtrlcode, decimal arg_qty, long arg_printid, ref decimal arg_ref_costamt, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Decimal ld_cost,ld_cost_cmpl,ld_noallocqty,ld_wareamt Long ll_storagescid SELECT scid INTO :ll_storagescid FROM u_storage Where storageid = :storageid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询仓库分部失败'+ commit_transaction.SQLErrText GOTO ext END IF //yyx2012-9-21 storageid = :storageid 这个无用 //SELECT cost INTO :ld_cost // FROM u_mtrlware // WHERE storageid = :storageid // AND mtrlwareid = :arg_mtrlwareid // AND scid = :ll_storagescid USING commit_transaction; //IF commit_transaction.SQLCode <> 0 THEN // arg_msg = '查询'+arg_mtrlcode+'库存成本价失败,'+commit_transaction.SQLErrText // rslt = 0 // GOTO ext //END IF SELECT u_mtrlware.cost,u_mtrlware.noallocqty,u_mtrlware.wareamt INTO :ld_cost,:ld_noallocqty,:ld_wareamt FROM u_mtrlware WHERE u_mtrlware.mtrlwareid = :arg_mtrlwareid And u_mtrlware.scid = :ll_storagescid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询'+arg_mtrlcode+'库存成本价失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF //yyx2013-8-31 IF ld_noallocqty = 0 THEN ld_cost = ld_cost ELSE ld_cost_cmpl = Round(ld_wareamt/ld_noallocqty,uo_option_cost_dec) IF ld_cost <> ld_cost_cmpl THEN ld_cost = ld_cost_cmpl END IF END IF //yyx2013-8-31_end arg_ref_costamt = Round(ld_cost * arg_qty ,2) UPDATE u_outwaremx SET costamt = :arg_ref_costamt, cost = :ld_cost WHERE scid = :scid AND outwareid = :outwareid And printid = :arg_printid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '更新'+arg_mtrlcode+'出仓成本价失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF billtype = 3 Or & billtype = 4 Or & billtype = 8 Or & billtype = 9 Or & billtype = 12 Or & billtype = 24 THEN UPDATE u_outwaremx SET u_outwaremx.fprice = :ld_cost, u_outwaremx.price = :ld_cost WHERE scid = :scid AND outwareid = :outwareid And printid = :arg_printid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '更新'+arg_mtrlcode+'出仓面价失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF END IF 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 del (long arg_scid, long arg_outwareid, integer arg_ifcheck_auto, ref string arg_msg, boolean arg_ifcommit);//如果单据还没有审核删除单据极其明细 //0 FAIL, 1 SUCCESS Int rslt = 1 Long i s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst ins_ref_outwaremx = ins_empty_outwaremx ins_ref_mxbt = 0 If uo_option_disuse_outware_sale = -1000 Then rslt = 0 arg_msg = '选项:[292]启用销售发货单废弃单,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_confirmaudit_sale = -1000 Then rslt = 0 arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_confirmaudit_scll = -1000 Then rslt = 0 arg_msg = '选项:[006]生产领料单先确认后审核,读取初始默认值失败,操作取消!' Goto ext End If If arg_outwareid <= 0 Then rslt = 0 arg_msg = "没有删除对象,操作取消" Goto ext End If If getinfo(arg_scid,arg_outwareid,arg_msg) = 0 Then rslt = 0 Goto ext End If //IF ( billtype = 1 or billtype = 5 ) AND uo_option_autowaste = 1 THEN // uo_outware_waste uo_waste // uo_waste = CREATE uo_outware_waste // uo_waste.commit_transaction = commit_transaction // IF uo_waste.insertwaste(0,arg_scid,arg_outwareid,arG_MSG,FALSE) = 0 THEN // rslt = 0 // GOTO ext // END IF // // DESTROY uo_waste //END IF If ( billtype = 1 Or billtype = 5 ) And uo_option_confirmaudit_sale = 1 Then If priceflag = 1 Then arg_msg = '单据已确认,不能删除' rslt = 0 Goto ext End If End If If billtype = 3 And relint_1 = 0 And uo_option_confirmaudit_scll = 1 Then If priceflag = 1 Then arg_msg = '单据已确认,不能删除' rslt = 0 Goto ext End If End If If flag = 1 Then rslt = 0 arg_msg = "单据已经审核,不可以删除" Goto ext End If If arg_ifcheck_auto = 1 Then If ifauto = 1 Then rslt = 0 arg_msg = '单据为动建立的单据,不可以删除' Goto ext End If End If If billtype = 1 And thflag = 0 And uo_option_disuse_outware_sale = 1 Then If uof_disuse(arg_scid,arg_outwareid,1,arg_msg,False) = 0 Then rslt = 0 Goto ext End If End If If uo_option_outware_pack_save_cmp = 1 And billtype <> 23 And uo_option_mtrlware_autocmp = 1 Then For i = 1 To it_mxbt If ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) Then ins_ref_mxbt++ ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid End If Next End If //更新库存已开单数(减) If billtype <> 21 And billtype <> 12 Then If uof_noauditingqty_del(arg_scid,arg_outwareid,arg_msg) = 0 Then rslt = 0 Goto ext End If End If Delete From u_outware Where u_outware.outwareid = :arg_outwareid And u_outware.scid = :arg_scid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "删除出仓单操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If Delete From u_outwaremx Where u_outwaremx.outwareid = :arg_outwareid And u_outwaremx.scid = :arg_scid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "删除出仓单明细操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If Delete From u_outwaremx_mx Where u_outwaremx_mx.outwareid = :arg_outwareid And u_outwaremx_mx.scid = :arg_scid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "删除出仓单应发明细操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If Delete From u_outwaremx_mx_barcode Where u_outwaremx_mx_barcode.outwareid = :arg_outwareid And u_outwaremx_mx_barcode.scid = :arg_scid And u_outwaremx_mx_barcode.billtype = :billtype Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "删除出仓单条码明细操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If Delete From u_outware_itemmx Where u_outware_itemmx.outwareid = :arg_outwareid And u_outware_itemmx.scid = :arg_scid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "删除出仓单费用明细操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If it_newbegin = False it_updatebegin = False ext: If rslt = 0 Then Rollback Using commit_transaction; p_reset() ElseIf rslt = 1 And arg_ifcommit Then Commit Using commit_transaction; End If Return (rslt) end function public function integer p_update_mtrlware_ws (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_uqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, string arg_mtrlcuscode, string arg_location, ref string arg_msg);Int rslt = 1 Long ls_newid Decimal ld_cost Int li_storMtrlprp Long ll_storagescid Int li_ifunit Int li_statusflag Decimal ld_capacity,ld_capacity_zj s_mtrlcfg_expr s_pz[] String ls_status_zj Long ll_i Int li_ifpack Int if_recmp_balc Int li_ifcost IF sys_if_recmp_balc < 0 THEN SELECT if_recmp_balc INTO :if_recmp_balc From sys_msg Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询是否执行结存表重算失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF if_recmp_balc = 0 THEN rslt = 0 arg_msg = '由于系统升级,结存表结构与原来不同,请先通知管理员执行危险功能中的[按新结构重算现结存表]功能,才能审核和撤审进出仓单据' GOTO ext END IF ELSE IF sys_if_recmp_balc = 0 THEN rslt = 0 arg_msg = '由于系统升级,结存表结构与原来不同,请先通知管理员执行危险功能中的[按新结构重算现结存表]功能,才能审核和撤审进出仓单据' GOTO ext END IF END IF IF uo_option_change_status = '-1000' THEN rslt = 0 arg_msg = '选项:[029]配置标题文本,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_change_woodcode = '-1000' THEN rslt = 0 arg_msg = '选项:[027]配置1标题文本,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_change_pcode = '-1000' THEN rslt = 0 arg_msg = '选项:[028]配置2标题文本,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_cost_dec = -1000 THEN rslt = 0 arg_msg = '选项:[022]库存成本价转换小数点,读取初始默认值失败,操作取消!' GOTO ext END IF SELECT Mtrlprp,scid,ifcost INTO :li_storMtrlprp,:ll_storagescid,:li_ifcost FROM u_storage Where storageid = :arg_storageid Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询仓库信息失败' rslt = 0 GOTO ext END IF SELECT ifunit,ifpack,capacity,statusflag INTO :li_ifunit,:li_ifpack,:ld_capacity,:li_statusflag FROM u_mtrldef Where mtrlid = :arg_mtrlid Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询物料信息失败' rslt = 0 GOTO ext END IF IF li_statusflag = 2 THEN ld_capacity = 0 f_checkpz(arg_status,s_pz[]) FOR ll_i = 1 To UpperBound(s_pz) ls_status_zj = s_pz[ll_i].cfgname SELECT capacity INTO :ld_capacity_zj FROM u_mtrl_configure WHERE mtrlid = :arg_mtrlid And Name = :ls_status_zj; IF commit_transaction.SQLCode <> 0 THEN ld_capacity_zj = 0 END IF ld_capacity = ld_capacity + ld_capacity_zj * Dec(s_pz[ll_i].qty) NEXT END IF Int li_ifupdate_date String ls_str String or_err_part IF billtype = 1 Or & billtype = 2 Or & billtype = 3 Or & billtype = 4 Or & billtype = 5 Or & billtype = 7 Or & billtype = 8 Or & billtype = 10 THEN li_ifupdate_date = 1 ELSE li_ifupdate_date = 0 END IF IF li_ifunit = 0 THEN arg_uqty = 0 IF li_ifcost = 1 THEN UPDATE u_mtrlware SET noallocqty = noallocqty - :arg_qty , wsallocqty = wsallocqty - :arg_qty, unoallocqty = unoallocqty - :arg_uqty, capacity = capacity + :ld_capacity * :arg_qty, wareamt = case noallocqty - :arg_qty when 0 then 0 else wareamt - :arg_costamt END , cost = case noallocqty - :arg_qty when 0 then cost else round((wareamt - :arg_costamt)/(noallocqty - :arg_qty),:uo_option_cost_dec) END , saledate = case :li_ifupdate_date when 1 then getdate() else saledate END WHERE ( mtrlwareid = :arg_mtrlwareid ) AND ( scid = :ll_storagescid ) Using commit_transaction ; IF commit_transaction.SQLCode = 0 THEN IF commit_transaction.SQLNRows = 0 THEN ls_newid = f_sys_scidentity(ll_storagescid,"u_mtrlware","mtrlwareid",arg_msg,True,id_sqlca) IF ls_newid <= 0 THEN rslt = 0 GOTO ext END IF ld_cost = Round(arg_costamt/arg_qty,uo_option_cost_dec) INSERT INTO u_mtrlware ( scid, mtrlwareid, mtrlid, storageid, plancode, status, noallocqty, unoallocqty, wareamt, planprice, sptid, dxflag, woodcode, pcode, cost, storMtrlprp, mtrlcuscode, location, capacity, wsallocqty) VALUES ( :ll_storagescid, :ls_newid, :arg_mtrlid, :arg_storageid, :arg_plancode, :arg_status, :arg_qty, :arg_uqty, :arg_costamt, :arg_planprice, :arg_sptid, :arg_dxflag, :arg_woodcode, :arg_pcode, :ld_cost, :li_storMtrlprp, :arg_mtrlcuscode, :arg_location, :ld_capacity * :arg_qty, :arg_qty) Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 IF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN IF arg_status <> '' THEN ls_str = ' '+uo_option_change_status+':'+arg_status END IF IF arg_pcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode END IF IF arg_woodcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode END IF arg_msg = "物料:"+arg_mtrlcode+ls_str+" 同仓库内同批号没有足够的库存支持冲减" ELSE arg_msg = "因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF END IF ELSE rslt = 0 or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement' IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN arg_msg = "物料:"+arg_mtrlcode+"同仓库内同批号没有足够的库存支持冲减" ELSEIF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN IF arg_status <> '' THEN ls_str = ' '+uo_option_change_status+':'+arg_status END IF IF arg_pcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode END IF IF arg_woodcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode END IF arg_msg = "物料:"+arg_mtrlcode+ls_str+" 同仓库内同批号没有足够的库存支持冲减" ELSE arg_msg = "因网络或其它原因导致物料:"+arg_mtrlcode+' '+uo_option_change_status+':'+arg_status+' '+uo_option_change_pcode+':'+arg_pcode+' '+uo_option_change_woodcode+':'+arg_woodcode+"库存更新操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF ELSE UPDATE u_mtrlware SET noallocqty = noallocqty - :arg_qty , wsallocqty = wsallocqty - :arg_qty, unoallocqty = unoallocqty - :arg_uqty, capacity = capacity + :ld_capacity * :arg_qty, wareamt = 0 , cost = 0 , saledate = case :li_ifupdate_date when 1 then getdate() else saledate END WHERE ( mtrlwareid = :arg_mtrlwareid ) AND ( scid = :ll_storagescid ) Using commit_transaction ; IF commit_transaction.SQLCode = 0 THEN IF commit_transaction.SQLNRows = 0 THEN ls_newid = f_sys_scidentity(ll_storagescid,"u_mtrlware","mtrlwareid",arg_msg,True,id_sqlca) IF ls_newid <= 0 THEN rslt = 0 GOTO ext END IF INSERT INTO u_mtrlware ( scid, mtrlwareid, mtrlid, storageid, plancode, status, noallocqty, unoallocqty, wareamt, planprice, sptid, dxflag, woodcode, pcode, cost, storMtrlprp, mtrlcuscode, location, capacity, wsallocqty) VALUES ( :ll_storagescid, :ls_newid, :arg_mtrlid, :arg_storageid, :arg_plancode, :arg_status, :arg_qty, :arg_uqty, 0, 0, :arg_sptid, :arg_dxflag, :arg_woodcode, :arg_pcode, 0, :li_storMtrlprp, :arg_mtrlcuscode, :arg_location, :ld_capacity * :arg_qty, :arg_qty) Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 IF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN IF arg_status <> '' THEN ls_str = ' '+uo_option_change_status+':'+arg_status END IF IF arg_pcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode END IF IF arg_woodcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode END IF arg_msg = "物料:"+arg_mtrlcode+ls_str+" 同仓库内同批号没有足够的库存支持冲减" ELSE arg_msg = "因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF END IF ELSE rslt = 0 or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement' IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN arg_msg = "物料:"+arg_mtrlcode+"同仓库内同批号没有足够的库存支持冲减" ELSEIF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN IF arg_status <> '' THEN ls_str = ' '+uo_option_change_status+':'+arg_status END IF IF arg_pcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode END IF IF arg_woodcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode END IF arg_msg = "物料:"+arg_mtrlcode+ls_str+" 同仓库内同批号没有足够的库存支持冲减" ELSE arg_msg = "因网络或其它原因导致物料:"+arg_mtrlcode+' '+uo_option_change_status+':'+arg_status+' '+uo_option_change_pcode+':'+arg_pcode+' '+uo_option_change_woodcode+':'+arg_woodcode+"库存更新操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF END IF ext: IF rslt = 0 THEN ROLLBACK Using commit_transaction ; END IF RETURN rslt end function public function integer uof_p_barcode (integer arg_audittype, ref string arg_msg);Int rslt = 1 Long i Long ll_scid,ll_mtrlwareid Int li_storagetype_storage String ls_location_top1 IF billtype <> 1 And billtype <> 8 And billtype <> 9 And billtype <> 12 And billtype <> 17 THEN rslt = 1 GOTO ext END IF uo_getbar uo_gb uo_gb = Create uo_getbar IF it_mxbt_barcode = 0 THEN arg_msg = '没有条码明细,请检查' rslt = 0 GOTO ext END IF IF f_rst_storage_storagetype(storageid,li_storagetype_storage) = 0 THEN arg_msg = '查询仓库库存策略失败,请检查' rslt = 0 GOTO ext END IF FOR i = 1 To it_mxbt_barcode IF thflag = 0 THEN IF uo_gb.uof_barcode_out(s_mx_barcode[i].barcode,arg_audittype,False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF ELSE IF arg_audittype = 1 THEN IF uo_option_barcodelocation_use_inwaremx_location = 0 THEN ls_location_top1 = '' ELSE SELECT top 1 u_outwaremx.location INTO :ls_location_top1 FROM u_outwaremx WHERE u_outwaremx.scid = :scid AND u_outwaremx.outwareid = :outwareid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询出仓单明细仓位信息失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF END IF SELECT u_mtrlware.scid,u_mtrlware.mtrlwareid INTO :ll_scid,:ll_mtrlwareid FROM u_mtrlware,u_mtrlware_mx,u_mtrldef WHERE u_mtrlware.storageid = :storageid AND u_mtrlware_mx.barcode = :s_mx_barcode[i].barcode AND u_mtrlware.mtrlid = u_mtrlware_mx.mtrlid AND u_mtrlware.mtrlid = u_mtrldef.mtrlid AND ( u_mtrlware.sptid = u_mtrlware_mx.sptid AND :li_storagetype_storage = 0 OR u_mtrlware.sptid = 0 AND :li_storagetype_storage = 1 ) AND u_mtrlware.status = u_mtrlware_mx.status AND u_mtrlware.woodcode = u_mtrlware_mx.woodcode AND u_mtrlware.pcode = u_mtrlware_mx.pcode AND u_mtrlware.plancode = u_mtrlware_mx.plancode AND ( u_mtrlware.mtrlcuscode = u_mtrlware_mx.mtrlcuscode AND :li_storagetype_storage = 0 OR :li_storagetype_storage = 1 AND u_mtrlware.mtrlcuscode = u_mtrlware_mx.mtrlcuscode AND (u_mtrldef.ifpackpro = 4 OR u_mtrldef.ifpack = 2) OR :li_storagetype_storage = 1 AND u_mtrlware.mtrlcuscode = '' AND u_mtrldef.ifpackpro <> 4 AND u_mtrldef.ifpack <> 2 ) AND (u_mtrlware.Location = u_mtrlware_mx.Location AND :uo_option_barcodelocation_use_inwaremx_location = 0 OR u_mtrlware.Location = :ls_location_top1 And :uo_option_barcodelocation_use_inwaremx_location = 1 ) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '条码:'+s_mx_barcode[i].barcode+',查询库存资料失败,请检查对应条码单与库存资料,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF ELSE ll_scid = 0 ll_mtrlwareid = 0 END IF IF uo_gb.uof_barcode_in(s_mx_barcode[i].barcode,& ll_scid,ll_mtrlwareid,'',0,0,arg_audittype,0,False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF NEXT ext: IF rslt = 0 THEN ROLLBACK; END IF Destroy uo_getbar RETURN rslt end function public function integer uof_outbarcode_add (integer arg_billtype, long arg_scid, long arg_outwareid, string arg_barcode, decimal arg_qty, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 INSERT INTO u_outwaremx_mx_barcode (billtype,scid,outwareid,barcode,qty) VALUES (:arg_billtype, :arg_scid,:arg_outwareid,:arg_barcode,:arg_qty); IF sqlca.SQLCode <> 0 THEN arg_msg = '出仓明细保存条码失败,条码:'+arg_barcode+','+sqlca.SQLErrText rslt = 0 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 priceaudit (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i IF priceflag = 1 THEN rslt = 0 arg_msg = "单据已经确认" GOTO ext END IF UPDATE u_outware SET priceemp = :publ_operator, pricedate = getdate(), priceflag = 1 WHERE u_outware.outwareid = :outwareid AND priceflag = 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 = "单据正在确认,请稍后查询。"+"~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 (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i DateTime null_dt SetNull(null_dt) IF priceflag = 0 THEN rslt = 0 arg_msg = "单据还未确认,不能反确认" GOTO ext END IF IF flag = 1 THEN rslt = 0 arg_msg = "单据已仓审,不能反确认" GOTO ext END IF IF it_mxbt_barcode > 0 THEN arg_msg = '单据已扫描条码,不能反确认,如果要反确认,请先清除条码' rslt = 0 GOTO ext END IF UPDATE u_outware SET priceemp = '', pricedate = :null_dt, priceflag = 0 WHERE u_outware.outwareid = :outwareid AND priceflag = 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 = "单据正在反确认,请稍后查询。"+"~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 public function integer uof_set_qty_equal_bqty (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Int li_ref_outtype Long ll_i,ll_j,ll_k Long ll_f,ll_arr Long ll_mtrlware_arr[] Decimal ld_outqty_arr[],ld_updateqty IF arg_outwareid <= 0 THEN arg_msg = '错误的单据id' rslt = 0 GOTO ext END IF IF getinfo(arg_scid,arg_outwareid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF f_rst_storage_outtype(storageid,li_ref_outtype) = 0 THEN arg_msg = '查询仓库出仓策略失败,请检查仓库资料' rslt = 0 GOTO ext END IF IF li_ref_outtype <> 2 THEN arg_msg = '仓库出仓策略不是使用条码出仓,操作取消,请检查仓库资料' rslt = 0 GOTO ext END IF IF priceflag = 0 THEN arg_msg = '单据未确认,操作取消' rslt = 0 GOTO ext END IF IF flag = 1 THEN arg_msg = '单据已仓审,操作取消' rslt = 0 GOTO ext END IF //计算条码出仓数 FOR ll_j = 1 TO it_mxbt_barcode ll_f = 0 ll_arr = UpperBound(ll_mtrlware_arr) FOR ll_k = 1 TO ll_arr IF ll_mtrlware_arr[ll_k] = s_mx_barcode[ll_j].mtrlwareid THEN ll_f = ll_k EXIT END IF NEXT IF ll_f > 0 THEN ld_outqty_arr[ll_f] += s_mx_barcode[ll_j].outqty ELSE ll_arr++ ll_mtrlware_arr[ll_arr] = s_mx_barcode[ll_j].mtrlwareid ld_outqty_arr[ll_arr] = s_mx_barcode[ll_j].outqty END IF NEXT UPDATE u_outwaremx SET u_outwaremx.uqty = 0, u_outwaremx.qty = 0 FROM u_outwaremx,u_mtrldef WHERE u_outwaremx.scid = :arg_scid AND u_outwaremx.outwareid = :arg_outwareid AND u_outwaremx.mtrlid = u_mtrldef.mtrlid AND u_mtrldef.outtype = 2 USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '清除出仓明细按条码出仓物料出仓数失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF FOR ll_i = 1 TO it_mxbt ld_updateqty = 0 IF outwaremx[ll_i].outtype_mtrl <> 2 THEN CONTINUE FOR ll_k = 1 TO UpperBound(ll_mtrlware_arr) IF ld_outqty_arr[ll_k] = 0 THEN CONTINUE IF outwaremx[ll_i].mtrlwareid = ll_mtrlware_arr[ll_k] THEN IF outwaremx[ll_i].qty >= ld_outqty_arr[ll_k] THEN ld_updateqty = ld_outqty_arr[ll_k] ld_outqty_arr[ll_k] = 0 ELSE ld_updateqty = outwaremx[ll_i].qty ld_outqty_arr[ll_k] = ld_outqty_arr[ll_k] - outwaremx[ll_i].qty END IF EXIT END IF NEXT IF ld_updateqty > 0 THEN UPDATE u_outwaremx SET u_outwaremx.uqty = :ld_updateqty, u_outwaremx.qty = :ld_updateqty WHERE u_outwaremx.scid = :arg_scid AND u_outwaremx.outwareid = :arg_outwareid AND u_outwaremx.printid = :outwaremx[ll_i].printid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '行:'+String(ll_i)+',更新出仓明细按条码出仓物料出仓数失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF END IF NEXT 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 uof_check_qty_to_bqty (ref string arg_msg);Int rslt = 1 Long ll_j,ll_k Long ll_f,ll_arr,ll_find String ls_mtrlcode_array[],ls_mtrlcode Long ll_mtrlware_arr[] Decimal ld_outqty_arr[] Long ll_mtrlware_arr_bill[] Decimal ld_outqty_arr_bill[] Boolean lb_equal = False //计算条码出仓数 FOR ll_j = 1 To it_mxbt_barcode ll_f = 0 ll_arr = UpperBound(ll_mtrlware_arr) FOR ll_k = 1 To ll_arr IF ll_mtrlware_arr[ll_k] = s_mx_barcode[ll_j].mtrlwareid THEN ll_f = ll_k EXIT END IF NEXT IF ll_f > 0 THEN ld_outqty_arr[ll_f] += s_mx_barcode[ll_j].outqty ELSE ll_arr++ ll_mtrlware_arr[ll_arr] = s_mx_barcode[ll_j].mtrlwareid ld_outqty_arr[ll_arr] = s_mx_barcode[ll_j].outqty END IF NEXT //计算出仓明细出仓数 IF billtype = 1 THEN FOR ll_j = 1 To it_mxbt_mx ll_f = 0 ll_arr = UpperBound(ll_mtrlware_arr_bill) FOR ll_k = 1 To ll_arr IF ll_mtrlware_arr_bill[ll_k] = outwaremx_mx[ll_j].mtrlwareid THEN ll_f = ll_k EXIT END IF NEXT IF ll_f > 0 THEN ld_outqty_arr_bill[ll_f] += outwaremx_mx[ll_j].qty ELSE ll_arr++ ls_mtrlcode_array[ll_arr] = outwaremx_mx[ll_j].mtrlcode ll_mtrlware_arr_bill[ll_arr] = outwaremx_mx[ll_j].mtrlwareid ld_outqty_arr_bill[ll_arr] = outwaremx_mx[ll_j].qty END IF NEXT ELSE FOR ll_j = 1 To it_mxbt IF outwaremx[ll_j].outtype_mtrl <> 2 THEN CONTINUE ll_f = 0 ll_arr = UpperBound(ll_mtrlware_arr_bill) FOR ll_k = 1 To ll_arr IF ll_mtrlware_arr_bill[ll_k] = outwaremx[ll_j].mtrlwareid THEN ll_f = ll_k EXIT END IF NEXT IF ll_f > 0 THEN ld_outqty_arr_bill[ll_f] += outwaremx[ll_j].qty ELSE ll_arr++ ls_mtrlcode_array[ll_arr] = outwaremx[ll_j].mtrlcode ll_mtrlware_arr_bill[ll_arr] = outwaremx[ll_j].mtrlwareid ld_outqty_arr_bill[ll_arr] = outwaremx[ll_j].qty END IF NEXT END IF //检查1 FOR ll_j = 1 To UpperBound(ll_mtrlware_arr_bill) lb_equal = False IF ld_outqty_arr_bill[ll_j] = 0 THEN CONTINUE ll_find = 0 FOR ll_k = 1 To UpperBound(ll_mtrlware_arr) IF ll_mtrlware_arr_bill[ll_j] = ll_mtrlware_arr[ll_k] THEN ll_find = ll_k IF ld_outqty_arr_bill[ll_j] = ld_outqty_arr[ll_k] THEN lb_equal = True EXIT END IF END IF NEXT IF Not lb_equal THEN IF ll_find = 0 THEN arg_msg = '出仓明细:'+ls_mtrlcode_array[ll_j]+',按条码出仓物料的出仓数:'+String( ld_outqty_arr_bill[ll_j],'#0.##########')+',与条码扫描明细数量:0,不相等请检查' ELSE arg_msg = '出仓明细:'+ls_mtrlcode_array[ll_j]+',按条码出仓物料的出仓数:'+String( ld_outqty_arr_bill[ll_j],'#0.##########')+',与条码扫描明细数量:'+String( ld_outqty_arr[ll_find],'#0.##########')+',不相等请检查' END IF rslt = 0 GOTO ext END IF NEXT //检查2 FOR ll_j = 1 To UpperBound(ll_mtrlware_arr) lb_equal = False IF ld_outqty_arr[ll_j] = 0 THEN CONTINUE ll_find = 0 FOR ll_k = 1 To UpperBound(ll_mtrlware_arr_bill) IF ll_mtrlware_arr[ll_j] = ll_mtrlware_arr_bill[ll_k] THEN ll_find = ll_k IF ld_outqty_arr[ll_j] = ld_outqty_arr_bill[ll_k] THEN lb_equal = True EXIT END IF END IF NEXT IF Not lb_equal THEN ls_mtrlcode = '' SELECT u_mtrldef.mtrlcode INTO :ls_mtrlcode FROM u_mtrlware,u_mtrldef WHERE u_mtrlware.mtrlid = u_mtrldef.mtrlid AND u_mtrlware.scid = :scid And u_mtrlware.mtrlwareid = :ll_mtrlware_arr[ll_j] Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询条码库存id:'+String(ll_mtrlware_arr[ll_j])+',查询物料编码失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF ll_find = 0 THEN arg_msg = '条码扫描明细物料:'+ls_mtrlcode+',数量:'+String( ld_outqty_arr[ll_j],'#0.##########')+',与出仓明细按条码出仓物料的出仓数:0,不相等,请检查' ELSE arg_msg = '条码扫描明细物料:'+ls_mtrlcode+',数量:'+String( ld_outqty_arr[ll_j],'#0.##########')+',与出仓明细按条码出仓物料的出仓数:'+String( ld_outqty_arr_bill[ll_find],'#0.##########')+',不相等,请检查' END IF rslt = 0 GOTO ext END IF NEXT ext: RETURN rslt end function public function integer uof_secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,i IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF secflag = 1 THEN rslt = 0 arg_msg = "单据已经财审,不能再财审" GOTO ext END IF UPDATE u_outware SET secauditingrep = :publ_operator, secauditingdate = getdate(), secflag = 1 WHERE outwareid = :outwareid 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 = "单据正在确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText GOTO ext 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 RETURN rslt end function public function integer uof_c_secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,i DateTime null_dt SetNull(null_dt) Int li_StoreBalcType,li_AmtAuditFlag IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF secflag = 0 THEN rslt = 0 arg_msg = "单据不在财审状态,不能执行财撤" GOTO ext END IF //检查仓库是否分开结存 IF balcdateint <> 0 THEN SELECT StoreBalcType INTO :li_StoreBalcType FROM u_storage Where storageid = :storageid; IF sqlca.SQLCode <> 0 THEN li_StoreBalcType = 0 END IF //如果分开结存,检查结存表是否已金额结存 IF li_StoreBalcType = 1 THEN SELECT top 1 AmtAuditFlag INTO :li_AmtAuditFlag FROM u_warebalc WHERE storageid = :storageid And balcdateint = :balcdateint; IF sqlca.SQLCode <> 0 THEN li_AmtAuditFlag = 0 END IF IF li_AmtAuditFlag = 1 THEN rslt = 0 arg_msg = '仓库结存日期段已执行过金额结存,不能财撤单据' GOTO ext END IF END IF END IF UPDATE u_outware SET secauditingrep = '', secauditingdate = :null_dt, secflag = 0 WHERE outwareid = :outwareid 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 = "单据正在确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText GOTO ext 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 RETURN rslt end function public function integer acceptmx_item (long arg_printid, long arg_itemid, decimal arg_amt, string arg_mxdscrp, ref string arg_msg);Int rslt = 1 Long cnt cnt = 0 IF it_newbegin = False And it_updatebegin = False THEN rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" GOTO ext END IF IF IsNull(arg_printid) THEN arg_printid = 0 IF IsNull(arg_itemid) THEN arg_itemid = 0 IF IsNull(arg_amt) THEN arg_amt = 0 IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = '' IF arg_itemid = 0 Or arg_amt = 0 THEN rslt = 1 GOTO ext END IF SELECT count(*) INTO :cnt FROM u_itemdef Where itemid = :arg_itemid; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询收支项目是否存在失败,'+commit_transaction.SQLErrText GOTO ext END IF IF cnt = 0 THEN rslt = 0 arg_msg = '第'+String(arg_printid)+'行,收支项目不存在,请检查' GOTO ext END IF it_mxbt_item++ outware_itemmx[it_mxbt_item].printid = arg_printid outware_itemmx[it_mxbt_item].itemid = arg_itemid outware_itemmx[it_mxbt_item].amt = arg_amt outware_itemmx[it_mxbt_item].mxdscrp = arg_mxdscrp ext: IF rslt = 0 THEN p_clearmx() RETURN rslt end function public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_olmtrlid, long arg_packqty, string arg_outtype, decimal arg_planqty, long arg_relprintid, string arg_unit, decimal arg_uqty, decimal arg_rate, string arg_pricetype, string arg_formula, long arg_saleoutid, long arg_saleoutprintid, string arg_mxdscrp2, decimal arg_net_weight, decimal arg_gross_weight, decimal arg_cubage, decimal arg_taxrate, string arg_priceformula, string arg_qtyformula); s_outwaremx s_mx s_mx.mtrlwareid = arg_mtrlwareid s_mx.qty = arg_qty s_mx.fprice = arg_fprice s_mx.rebate = arg_rebate s_mx.mxdscrp = arg_mxdscrp s_mx.printid = arg_printid s_mx.ifrel = arg_ifrel s_mx.relid = arg_relid s_mx.olmtrlid = arg_olmtrlid s_mx.packqty = arg_packqty s_mx.outtype = arg_outtype s_mx.planqty = arg_planqty s_mx.relprintid = arg_relprintid s_mx.unit = arg_unit s_mx.uqty = arg_uqty s_mx.rate = arg_rate s_mx.pricetype = arg_pricetype s_mx.formula = arg_formula s_mx.saleoutid = arg_saleoutid s_mx.saleoutprintid = arg_saleoutprintid s_mx.mxdscrp2 = arg_mxdscrp2 s_mx.net_weight = arg_net_weight s_mx.gross_weight = arg_gross_weight s_mx.cubage = arg_cubage s_mx.taxrate = arg_taxrate s_mx.priceformula = arg_priceformula s_mx.qtyformula = arg_qtyformula return acceptmx(s_mx, arg_msg) end function public function integer uof_check_warepdb_audit (long arg_storageid, ref string arg_msg);Int rslt = 1 Long cnt SELECT count(*) INTO :cnt FROM u_warepdb WHERE storageid = :arg_storageid And flag = 0 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询仓库是否有盘点表未审核失败,'+commit_transaction.SQLErrText GOTO ext END IF IF cnt > 0 THEN rslt = 0 arg_msg = '仓库有盘点表未审核,不能仓审或仓撤单据,请检查' GOTO ext END IF ext: RETURN rslt end function public function integer uof_disuse (long arg_scid, long arg_outwareid, integer arg_disusetype, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Long ll_disuseid //arg_disusetype 0 - 修改, 1-删除 Select max(disuseid) Into :ll_disuseid From u_outware_disuse Where scid = :arg_scid And outwareid = :arg_outwareid Using commit_transaction; If commit_transaction.SQLCode = -1 Then rslt = 0 arg_msg = '获取销售发货单废弃单序号失败,'+ commit_transaction.SQLErrText Goto ext ElseIf commit_transaction.SQLCode = 100 Then ll_disuseid = 0 End If if isnull(ll_disuseid) then ll_disuseid = 0 ll_disuseid++ Insert Into u_outware_disuse (scid, outwareid, outwarecode, billtype, relid, StorageID, opdate, opemp, Modemp, moddate, flag, auditingdate, auditingrep, outdate, outrep, part, dscrp, cusid, cusname, balcflag, balcdateint, thflag, secflag, secauditingdate, secauditingrep, ctmint, printnum, wagemth, otheramt, relstr_1, relstr_2, relstr_3, relint_1, relint_2, relint_3, priceflag, pricedate, priceemp, rel_address, rel_tele, rel_fax, rel_rep, mrate, damt, upname, ifauto, viewdate, deptid, senduser, sendcnt, sendtime, pda_flag, pda_date, carcode, transcode, lsflag, totalamt, getamt, moneyname, banktypename, storagename, disuseemp, disusedate, disusetype, disuseid) Select u_outware.scid, u_outware.outwareid, u_outware.outwarecode, u_outware.billtype, u_outware.relid, u_outware.StorageID, u_outware.opdate, u_outware.opemp, u_outware.Modemp, u_outware.moddate, u_outware.flag, u_outware.auditingdate, u_outware.auditingrep, u_outware.outdate, u_outware.outrep, u_outware.part, u_outware.dscrp, u_outware.cusid, u_outware.cusname, u_outware.balcflag, u_outware.balcdateint, u_outware.thflag, u_outware.secflag, u_outware.secauditingdate, u_outware.secauditingrep, u_outware.ctmint, u_outware.printnum, u_outware.wagemth, u_outware.otheramt, u_outware.relstr_1, u_outware.relstr_2, u_outware.relstr_3, u_outware.relint_1, u_outware.relint_2, u_outware.relint_3, u_outware.priceflag, u_outware.pricedate, u_outware.priceemp, u_outware.rel_address, u_outware.rel_tele, u_outware.rel_fax, u_outware.rel_rep, u_outware.mrate, u_outware.damt, u_outware.upname, u_outware.ifauto, u_outware.viewdate, u_outware.deptid, u_outware.senduser, u_outware.sendcnt, u_outware.sendtime, u_outware.pda_flag, u_outware.pda_date, u_outware.carcode, u_outware.transcode, u_outware.lsflag, u_outware.totalamt, u_outware.getamt, cw_currency.name, cw_banktype.banktypename, u_storage.storagename, :publ_operator,getdate(),:arg_disusetype,:ll_disuseid From u_outware LEFT Outer JOIN u_storage ON u_outware.StorageID = u_storage.storageid LEFT Outer JOIN cw_banktype ON u_outware.relint_1 = cw_banktype.banktypeid LEFT Outer JOIN cw_currency ON u_outware.relint_2 = cw_currency.moneyid Where u_outware.scid = :arg_scid And u_outware.outwareid = :arg_outwareid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '插入销售发货单废弃单失败,'+commit_transaction.SQLErrText Goto ext End If Insert Into u_outwaremx_disuse (scid, outwareid, printid, mtrlwareid, mtrlid, storageid, plancode, status, qty, fprice, rebate, price, costamt, planprice, mxdscrp, Sptid, Dxflag, ifrel, olmtrlid, relid, packqty, woodcode, relcode, pcode, enprice, newpriceamt, ctmint, outtype, dftsaleprice, cost, planqty, relprintid, uqty, rate, unit, scidprice, outtypestr, overqty, mtrlcuscode, location, pricetype, formula, capacity, saleqty, saleoutid, saleoutprintid, net_weight, gross_weight, cubage, mxdscrp2, taxrate, priceformula, qtyformula, mtrlwareprintid, mtrlcode, mtrlname,disuseid) Select u_outwaremx.scid, u_outwaremx.outwareid, u_outwaremx.printid, u_outwaremx.mtrlwareid, u_outwaremx.mtrlid, u_outwaremx.storageid, u_outwaremx.plancode, u_outwaremx.status, u_outwaremx.qty, u_outwaremx.fprice, u_outwaremx.rebate, u_outwaremx.price, u_outwaremx.costamt, u_outwaremx.planprice, u_outwaremx.mxdscrp, u_outwaremx.Sptid, u_outwaremx.Dxflag, u_outwaremx.ifrel, u_outwaremx.olmtrlid, u_outwaremx.relid, u_outwaremx.packqty, u_outwaremx.woodcode, u_outwaremx.relcode, u_outwaremx.pcode, u_outwaremx.enprice, u_outwaremx.newpriceamt, u_outwaremx.ctmint, u_outwaremx.outtype, u_outwaremx.dftsaleprice, u_outwaremx.cost, u_outwaremx.planqty, u_outwaremx.relprintid, u_outwaremx.uqty, u_outwaremx.rate, u_outwaremx.unit, u_outwaremx.scidprice, u_outwaremx.outtypestr, u_outwaremx.overqty, u_outwaremx.mtrlcuscode, u_outwaremx.location, u_outwaremx.pricetype, u_outwaremx.formula, u_outwaremx.capacity, u_outwaremx.saleqty, u_outwaremx.saleoutid, u_outwaremx.saleoutprintid, u_outwaremx.net_weight, u_outwaremx.gross_weight, u_outwaremx.cubage, u_outwaremx.mxdscrp2, u_outwaremx.taxrate, u_outwaremx.priceformula, u_outwaremx.qtyformula, u_outwaremx.mtrlwareprintid, u_mtrldef.mtrlcode, u_mtrldef.mtrlname,:ll_disuseid From u_outwaremx LEFT Outer JOIN u_mtrldef ON u_outwaremx.mtrlid = u_mtrldef.mtrlid Where u_outwaremx.scid = :arg_scid And u_outwaremx.outwareid = :arg_outwareid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '插入销售发货单废弃单明细失败,'+commit_transaction.SQLErrText Goto ext End If Insert Into u_outwaremx_mx_disuse (scid, outwareid, printid, mxprintid, mtrlwareid, storageid, mtrlid, plancode, status, woodcode, pcode, mtrlcuscode, location, sptid, dxflag, planqty, qty, mxdscrp, ctmint, mtrlcode, mtrlname, disuseid) Select u_outwaremx_mx.scid, u_outwaremx_mx.outwareid, u_outwaremx_mx.printid, u_outwaremx_mx.mxprintid, u_outwaremx_mx.mtrlwareid, u_outwaremx_mx.storageid, u_outwaremx_mx.mtrlid, u_outwaremx_mx.plancode, u_outwaremx_mx.status, u_outwaremx_mx.woodcode, u_outwaremx_mx.pcode, u_outwaremx_mx.mtrlcuscode, u_outwaremx_mx.location, u_outwaremx_mx.sptid, u_outwaremx_mx.dxflag, u_outwaremx_mx.planqty, u_outwaremx_mx.qty, u_outwaremx_mx.mxdscrp, u_outwaremx_mx.ctmint, u_mtrldef.mtrlcode, u_mtrldef.mtrlname,:ll_disuseid From u_outwaremx_mx LEFT Outer JOIN u_mtrldef ON u_outwaremx_mx.mtrlid = u_mtrldef.mtrlid Where u_outwaremx_mx.scid = :arg_scid And u_outwaremx_mx.outwareid = :arg_outwareid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '插入销售发货单废弃单包件明细失败,'+commit_transaction.SQLErrText Goto ext End If Insert Into u_outwaremx_mx_barcode_disuse (billtype, scid, outwareid, barcode, qty, ctmint, printid, opemp, opdate, disuseid) Select billtype, scid, outwareid, barcode, qty, ctmint, printid, opemp, opdate, :ll_disuseid From u_outwaremx_mx_barcode Where u_outwaremx_mx_barcode.scid = :arg_scid And u_outwaremx_mx_barcode.outwareid = :arg_outwareid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '插入销售发货单废弃单条码明细失败,'+commit_transaction.SQLErrText Goto ext End If Insert Into u_outware_itemmx_disuse (scid, outwareid, printid, itemid, amt, mxdscrp, itemcode, itemname, itemtype, disuseid) Select u_outware_itemmx.scid, u_outware_itemmx.outwareid, u_outware_itemmx.printid, u_outware_itemmx.itemid, u_outware_itemmx.amt, u_outware_itemmx.mxdscrp, u_itemdef.itemcode, u_itemdef.itemname, u_itemdef.itemtype,:ll_disuseid From u_outware_itemmx LEFT Outer JOIN u_itemdef ON u_outware_itemmx.itemid = u_itemdef.itemid Where u_outware_itemmx.scid = :arg_scid And u_outware_itemmx.outwareid = :arg_outwareid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '插入销售发货单废弃单费用明细失败,'+commit_transaction.SQLErrText Goto ext End If 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 uof_updatesaleoutcodestr (long arg_scid, long arg_outwareid, ref string arg_msg);if sys_option_if_saleout = 0 then return 1 Int rslt = 1 Long i Long ll_scid, ll_taskid, ll_printid uo_bgtr_timer uo_tr uo_tr = Create uo_bgtr_timer IF getinfo(arg_scid, arg_outwareid, arg_msg) = 0 THEN rslt = 0 GOTO ext END IF FOR i = 1 To it_mxbt ll_taskid = outwaremx[i].relid ll_printid = outwaremx[i].relprintid IF ll_taskid > 0 And ll_printid > 0 THEN IF uo_tr.uf_update_saleoutcodestr(arg_scid, ll_taskid, ll_printid, arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF NEXT ext: Destroy uo_tr RETURN rslt end function public function integer acceptmx (s_outwaremx s_mx, ref string arg_msg);Long rslt = 1,cnt = 0,LS_i Long i_mtrlid,i_storageid,i_sptid Int i_dxflag,li_mtrlkind String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode Decimal i_planprice,ld_dftsaleprice Double i_cost,i_newprice Decimal i_notauditqty,i_allouseqty String ls_relcode,ls_relcode_saleout Decimal lde_noconqty,lde_notauditqty,lde_mx_qty Decimal ld_saletqty_task,ld_fpqty_task,ld_consignedqty_task Decimal lde_notauditqty_plan Long ll_storagescid String ls_unit Int li_ifunit Decimal ld_scllrate String i_mtrlcuscode,i_location Decimal ld_viewqty Int li_if_cus_mtrlware Int ls_noallocflag Long ll_storagetype,ll_storagetype_storage,ll_outtype_storage Int li_statusflag Decimal ld_capacity,ld_capacity_zj s_mtrlcfg_expr s_pz[] String ls_status_zj Long ll_i Long li_storagetype Decimal ld_upsalerate,ld_upsaleqty String ls_status_task,ls_woodcode_task,ls_pcode_task Long ll_mtrlid_task Decimal ld_scllqty Int li_status_ck,li_woodcode_ck,li_pcode_ck Decimal ld_noaudit_planqty Int i_ifpackpro,li_outtype,i_ifpack Decimal i_packqty_fp,ld_pack_noauditqty //uo_option_confirmaudit_sale //uo_option_sale_use_planqty //uo_option_mtrlware_limit //uo_option_inout_type //uo_option_if_pricetype //uo_option_checkprice_native uo_cusprice uo_price uo_price = Create uo_cusprice If uo_option_confirmaudit_sale = -1000 Then rslt = 0 arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_sale_use_planqty = -1000 Then rslt = 0 arg_msg = '选项:[115]销售发货单使用计划发货数,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_mtrlware_limit = -1000 Then rslt = 0 arg_msg = '选项:[037]客户库存选择限制,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_inout_type = -1000 Then rslt = 0 arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_if_pricetype = -1000 Then rslt = 0 arg_msg = '选项:[154]启用价格分类,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_checkprice_native = -1000 Then rslt = 0 arg_msg = '选项:[056]销售价按本位币限价,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_if_saleout = -1000 Then rslt = 0 arg_msg = '选项:[200]使用发货通知单,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_outware_sale_checkprice = -1000 Then rslt = 0 arg_msg = '选项:[320]销售发货单保存时检查实价是否与销售订单一致,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_scll_use_planqty = -1000 Then rslt = 0 arg_msg = '选项:[123]领料单使用计划领料数,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_price_rmb = -1000 Then rslt = 0 arg_msg = '选项:[238]销售单价按人民币单价折算,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_pk_notauditqty_check = -1000 Then rslt = 0 arg_msg = '选项:[397]盘亏单保存时检查库存未开单数,读取初始默认值失败,操作取消!' Goto ext End If If it_newbegin = False And it_updatebegin = False Then rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" Goto ext End If If uo_option_canpack_ifzanyong = -1000 Then rslt = 0 arg_msg = '选项:[417]通用包件产品可装数选项,读取初始默认值失败,操作取消!' Goto ext End If Select scid, storagetype, outtype, balctype, noallocflag Into :ll_storagescid, :ll_storagetype_storage, :ll_outtype_storage, :li_if_cus_mtrlware, :ls_noallocflag From u_storage Where storageid = :storageid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '查询仓库分部失败'+commit_transaction.SQLErrText Goto ext End If //清除空值 If IsNull(s_mx.mtrlwareid) Then s_mx.mtrlwareid = 0 If IsNull(s_mx.printid) Then s_mx.printid = 0 If IsNull(s_mx.qty) Then s_mx.qty = 0 If IsNull(s_mx.fprice) Then s_mx.fprice = 0 If IsNull(s_mx.rebate) Then s_mx.rebate = 0 If IsNull(s_mx.mxdscrp) Then s_mx.mxdscrp = '' If IsNull(s_mx.ifrel) Then s_mx.ifrel = 0 If IsNull(s_mx.relid) Then s_mx.relid = 0 If IsNull(s_mx.olmtrlid) Then s_mx.olmtrlid = 0 If IsNull(s_mx.packqty) Then s_mx.packqty = 0 If IsNull(s_mx.outtype) Then s_mx.outtype = '' If IsNull(s_mx.planqty) Then s_mx.planqty = 0 If IsNull(s_mx.relprintid) Then s_mx.relprintid = 0 If IsNull(s_mx.unit) Then s_mx.unit = '' If IsNull(s_mx.uqty) Then s_mx.uqty = 0 If IsNull(s_mx.rate) Then s_mx.rate = 1 If IsNull(s_mx.pricetype) Then s_mx.pricetype = '' If IsNull(s_mx.formula) Then s_mx.formula = '' If IsNull(s_mx.saleoutid) Then s_mx.saleoutid = 0 If IsNull(s_mx.saleoutprintid) Then s_mx.saleoutprintid = 0 If IsNull(s_mx.mxdscrp2) Then s_mx.mxdscrp2 = '' If IsNull(s_mx.net_weight) Then s_mx.net_weight = 0 If IsNull(s_mx.gross_weight) Then s_mx.gross_weight = 0 If IsNull(s_mx.cubage) Then s_mx.cubage = 0 If IsNull(s_mx.taxrate) Then s_mx.taxrate = 0 If IsNull(s_mx.priceformula) Then s_mx.priceformula = '' If IsNull(s_mx.qtyformula) Then s_mx.qtyformula = '' If IsNull(s_mx.ifvqty) Then s_mx.ifvqty = 0 If IsNull(s_mx.backtype) Then s_mx.backtype = 0 If IsNull(s_mx.ifnotinout) Then s_mx.ifnotinout = 0 If s_mx.mtrlwareid = 0 Or ( s_mx.qty = 0 And s_mx.planqty = 0 And s_mx.uqty = 0 ) Then rslt = 1 Goto ext End If If billtype <> 9 Then If s_mx.uqty = 0 And s_mx.rate = 0 Then rslt = 1 Goto ext End If End If If s_mx.uqty = 0 Then s_mx.rate = 1 Else If billtype = 1 Then s_mx.rate = s_mx.planqty / s_mx.uqty Else s_mx.rate = s_mx.qty / s_mx.uqty End If End If If s_mx.rebate < 0 Then arg_msg = '折扣错误,请检查' rslt = 0 Goto ext End If //检查物料库存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_mtrldef.unit, u_mtrlware.mtrlcuscode, u_mtrlware.location, u_mtrldef.storagetype, u_mtrldef.statusflag, u_mtrldef.capacity * u_mtrldef.capaparm, u_mtrldef.storagetype, u_mtrldef.upsalerate, u_mtrldef.upsaleqty, u_mtrldef.ifunit, u_mtrldef.outtype, u_mtrldef.ifpackpro, u_mtrldef.ifpack, u_mtrlware.packqty_fp Into :i_mtrlid, :i_storageid, :i_plancode, :i_status, :i_cost, :i_mtrlcode, :i_sptid, :i_dxflag, :i_woodcode, :i_pcode, :i_notauditqty, :i_allouseqty, :ls_unit, :i_mtrlcuscode, :i_location, :ll_storagetype, :li_statusflag, :ld_capacity, :li_storagetype, :ld_upsalerate, :ld_upsaleqty, :li_ifunit, :li_outtype, :i_ifpackpro, :i_ifpack, :i_packqty_fp From u_mtrlware Inner JOIN u_mtrldef ON u_mtrlware.mtrlid = u_mtrldef.mtrlid Where ( u_mtrlware.mtrlwareid = :s_mx.mtrlwareid ) And ( u_mtrlware.scid = :ll_storagescid ) Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "第"+String(s_mx.printid)+"行,查询操作失败,库存编号(出仓单)错误,分部:"+String(ll_storagescid)+'库存:'+String(s_mx.mtrlwareid)+',~n'+commit_transaction.SQLErrText Goto ext End If If IsNull(ld_dftsaleprice) Then ld_dftsaleprice = 0 If IsNull(i_cost) Then i_cost = 0 If IsNull(i_plancode) Then i_plancode = '' If IsNull(i_status) Then i_status = '' If IsNull(i_mtrlid) Then i_mtrlid = 0 If IsNull(i_storageid) Then i_storageid = 0 If IsNull(i_sptid) Then i_sptid = 0 If IsNull(i_dxflag) Then i_dxflag = 0 If IsNull(i_woodcode) Then i_woodcode = '' If IsNull(i_pcode) Then i_pcode = '' If IsNull(i_mtrlcuscode) Then i_mtrlcuscode = '' If IsNull(i_location) Then i_location = '' If IsNull(ll_storagetype) Then ll_storagetype = 0 If IsNull(li_statusflag) Then li_statusflag = 0 If IsNull(ld_capacity) Then ld_capacity = 0 If IsNull(ld_upsalerate) Then ld_upsalerate = 0 If IsNull(ld_upsaleqty) Then ld_upsaleqty = 0 If IsNull(i_packqty_fp) Then i_packqty_fp = 0 If billtype = 1 And thflag = 0 Then If uo_option_confirmaudit_sale = 0 Or uo_option_sale_use_planqty = 0 Then If ll_outtype_storage = 0 Then //And ll_storagetype_storage = 0 THEN // // dyy edit 2012-02-23 s_mx.qty = s_mx.planqty End If If li_ifunit = 0 And s_mx.rate <> 0 Then s_mx.uqty = s_mx.qty / s_mx.rate End If End If End If //销售发货单检查高级进出仓属性 If billtype = 1 Then If uo_option_inout_type <> 0 And ll_outtype_storage <> 0 And i_ifpackpro <> 0 And li_outtype = 0 Then rslt = 0 arg_msg = "第"+String(s_mx.printid)+"行,物料编码:"+i_mtrlcode+",仓库使用包件出仓或条码出仓,发货明细物料资料是包件产品,但产品资料没设为包件出仓或条码出仓,不能保存" Goto ext End If End If If s_mx.mtrlwareid = 0 Or ( s_mx.qty = 0 And s_mx.planqty = 0 And s_mx.uqty = 0 ) Then rslt = 1 Goto ext End If //IF billtype <> 9 THEN // IF li_ifunit = 1 THEN // IF s_mx.uqty = s_mx.qty And s_mx.uqty > 0 And s_mx.qty > 0 And s_mx.unit <> ls_unit THEN // rslt = 0 // arg_msg = "第"+String(s_mx.printid)+"行,物料使用库存双数量核算,但录入的计量单位数量与库存单位数量相同,操作取消" // GOTO ext // END IF // END IF //END IF // f_get_planprice_mtrl(i_mtrlid,i_status,i_woodcode,i_pcode,i_planprice) If IsNull(i_planprice) Then i_planprice = 0 If li_statusflag = 2 Then ld_capacity = 0 f_checkpz(i_status,s_pz[]) For ll_i = 1 To UpperBound(s_pz) ls_status_zj = s_pz[ll_i].cfgname Select capacity * capaparm Into :ld_capacity_zj From u_mtrl_configure Where mtrlid = :i_mtrlid And Name = :ls_status_zj Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "第"+String(s_mx.printid)+"行,物料编码:"+i_mtrlcode+",查询子件 "+ls_status_zj+" 折算套数参数操作失败" Goto ext End If ld_capacity = ld_capacity + ld_capacity_zj * Dec(s_pz[ll_i].qty) Next End If Select sum(qty) Into :ld_viewqty From u_mtrlware_view Where scid = :ll_storagescid And mtrlwareid = :s_mx.mtrlwareid And inuse = 1 And cusid = :cusid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "第"+String(s_mx.printid)+"行,查询操作失败,库存虚拟数量,分部:"+String(ll_storagescid)+'库存:'+String(s_mx.mtrlwareid)+',~n'+commit_transaction.SQLErrText Goto ext End If If IsNull(ld_viewqty) Then ld_viewqty = 0 If billtype = 1 Or billtype = 5 Then If ll_storagetype = 0 Then If li_if_cus_mtrlware = 1 And uo_option_mtrlware_limit = 0 And flag = 0 Then If cusid <> i_sptid Then rslt = 0 arg_msg = "查询操作失败,明细纪录对应的库存不是该客户的库存!" Goto ext End If End If End If End If If billtype = 1 Then f_get_defsaleprice(cusid,i_mtrlid,i_status,i_pcode,i_woodcode,relint_2,ld_dftsaleprice) Else ld_dftsaleprice = 0 mrate = 1 End If If billtype <> 9 Then // IF Trim(ls_unit) <> Trim(s_mx.unit) And s_mx.rate = 1 THEN // arg_msg = '出仓单,行:'+String(s_mx.printid)+' '+i_mtrlcode+',物料库存单位:'+Trim(ls_unit)+'与采购单位:'+Trim(s_mx.unit)+'不同,但转换率为1,请检查' // rslt = 0 // GOTO ext // END IF If Trim(ls_unit) = Trim(s_mx.unit) And s_mx.rate <> 1 Then arg_msg = '出仓单,行:'+String(s_mx.printid)+' '+i_mtrlcode+',物料库存单位:'+Trim(ls_unit)+'与采购单位:'+Trim(s_mx.unit)+'相同,但转换率不为1,请检查' rslt = 0 Goto ext End If End If //*****检查大于未开数不可以开单 If (flag = 0 And billtype <> 12 And billtype <> 21 And billtype <> 23 And billtype <> 17 And billtype <> 4 And billtype <> 7 ) And thflag = 0 Then If uo_option_pk_notauditqty_check = 0 And billtype = 9 Then Goto _end_check_qty End If If Not (billtype = 3 And relint_1 = 4 And it_newbegin) Then Decimal ol_mtrl_qty = 0,ld_mx_qty = 0,ld_ref_qty = 0 Decimal ol_mtrl_qty_plan = 0,ol_mtrl_qty_sf = 0 String ls_msg Boolean lb_ifplan = False If billtype = 1 And uo_option_confirmaudit_sale = 1 And uo_option_sale_use_planqty = 1 Then lb_ifplan = True If billtype = 1 And ll_outtype_storage = 2 Then lb_ifplan = True If billtype = 3 And relint_1 <> 4 And relint_1 <> 5 And uo_option_scll_use_planqty = 1 Then lb_ifplan = True If ls_noallocflag = 1 Then If it_updatebegin Then Select sum(u_outwaremx.qty),sum(u_outwaremx.planqty) Into :ol_mtrl_qty_sf,:ol_mtrl_qty_plan From u_outwaremx Where u_outwaremx.outwareid = :outwareid And u_outwaremx.mtrlwareid = :s_mx.mtrlwareid And scid = :scid Using commit_transaction; If commit_transaction.SQLCode = -1 Then rslt = 0 arg_msg = "物料编码:"+i_mtrlcode+',查询原开单数量失败' Goto ext End If End If For LS_i = 1 To it_mxbt If s_mx.mtrlwareid = outwaremx[LS_i].mtrlwareid Then If lb_ifplan Then ld_mx_qty = ld_mx_qty + outwaremx[LS_i].planqty Else ld_mx_qty = ld_mx_qty + outwaremx[LS_i].qty End If End If Next If lb_ifplan Then ld_mx_qty = ld_mx_qty + s_mx.planqty Else ld_mx_qty = ld_mx_qty + s_mx.qty End If If IsNull(i_allouseqty) Then i_allouseqty = 0 If IsNull(i_notauditqty) Then i_notauditqty = 0 If IsNull(ol_mtrl_qty_sf) Then ol_mtrl_qty_sf = 0 If IsNull(ol_mtrl_qty_plan) Then ol_mtrl_qty_plan = 0 If IsNull(ld_mx_qty) Then ld_mx_qty = 0 Select ifpackpro Into :i_ifpackpro From u_mtrldef Where mtrlid = :i_mtrlid Using commit_transaction ; If commit_transaction.SQLCode <> 0 Then arg_msg = "物料编码:"+i_mtrlcode+',查询物料是否包件产品失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If ld_ref_qty = 0 If i_ifpackpro > 0 Then If f_cmp_di_qty_outware(scid,outwareid,i_mtrlid,storageid,i_status,i_woodcode,i_pcode,i_plancode,i_mtrlcuscode,cusid,ld_ref_qty,ls_msg,arg_msg) = 0 Then ld_ref_qty = 0 // arg_msg = '第'+String(s_mx.printid)+'行,计算可装数失败,'+arg_msg // rslt = 0 // GOTO ext End If If uo_option_inout_type = 0 Then If lb_ifplan Then ol_mtrl_qty = ol_mtrl_qty_plan Else ol_mtrl_qty = ol_mtrl_qty_sf End If Else ol_mtrl_qty = 0 End If Else If lb_ifplan Then ol_mtrl_qty = ol_mtrl_qty_plan Else ol_mtrl_qty = ol_mtrl_qty_sf End If End If If ld_mx_qty > ( i_allouseqty - i_notauditqty + ol_mtrl_qty + ld_ref_qty + ld_viewqty ) Then rslt = 0 arg_msg = String(i_mtrlcode)+"库存未开单数不够,不能开单.未开单数{"+String(i_allouseqty - i_notauditqty + ol_mtrl_qty,'#####,0.00#######')+"}" + "可组装数{"+String(ld_ref_qty,'#####,0.00#######')+"}"+ "库存虚拟数量{"+String(ld_viewqty,'#####,0.00#######')+"},不能开单:"+String(ld_mx_qty,'#####,0.00#######') Goto ext End If //如果包件产品使用占用数流程, 直接开单发包件,要检查数量不能超出未分配占用数(盘亏单除外) If i_ifpack = 1 And uo_option_canpack_ifzanyong = 1 And billtype <> 9 Then Select SUM(Case u_outwaremx.qty WHEN 0 Then u_outwaremx.planqty Else u_outwaremx.qty End) Into :ld_pack_noauditqty From u_outwaremx Inner JOIN u_outware On u_outwaremx.scid = u_outware.scid And u_outwaremx.outwareid = u_outware.outwareid Where (u_outware.flag = 0) And (u_outware.thflag = 0) And ( u_outwaremx.mtrlwareid = :s_mx.mtrlwareid ) And ( u_outwaremx.scid = :scid ) and (u_outware.outwareid <> :outwareid) Using commit_transaction; If commit_transaction.SQLCode = -1 Then rslt = 0 arg_msg = "物料编码:"+i_mtrlcode+',查询包件直接开单数量失败' Goto ext End If If IsNull(ld_pack_noauditqty) Then ld_pack_noauditqty = 0 If ld_mx_qty - ol_mtrl_qty + ld_pack_noauditqty > i_allouseqty - i_packqty_fp Then rslt = 0 arg_msg = String(i_mtrlcode)+"库存未分配数不够,不能开单.未分配占用数{"+String(i_allouseqty - i_packqty_fp + ol_mtrl_qty,'#####,0.00#######')+"}" + "包件已直接开单数{"+string(ld_pack_noauditqty,'#####,0.00#######')+"},不能开单:"+String(ld_mx_qty,'#####,0.00#######') Goto ext End If End If End If End If _end_check_qty: End If //*********************************************** If uo_option_sale_ifuse_negativeprice = 0 Then If s_mx.fprice * s_mx.rebate < 0 Then //检查单价 rslt = 0 arg_msg = '明细行:'+String(s_mx.printid)+",物料或产品:" + String(i_mtrlcode)+" 单价错误" Goto ext End If End If If s_mx.rebate < 0 Then rslt = 0 arg_msg = '明细行:'+String(s_mx.printid)+",物料或产品:" + String(i_mtrlcode)+" 折扣错误" Goto ext End If Choose Case billtype Case 1 If s_mx.ifrel > 0 Then If flag = 0 Then //检查订单 If s_mx.relid = 0 Then arg_msg = '请先择相应的订单' rslt = 0 Goto ext End If Select u_saletask.taskcode, u_saletaskmx.saleqty * (1 + :ld_upsalerate) + :ld_upsaleqty - u_saletaskmx.consignedqty , u_saletaskmx.mtrlid, u_saletaskmx.status, u_saletaskmx.woodcode, u_saletaskmx.pcode, u_saletaskmx.fpqty, u_saletaskmx.saleqty * (1 + :ld_upsalerate) + :ld_upsaleqty, u_saletaskmx.consignedqty Into :ls_relcode, :lde_noconqty, :ll_mtrlid_task, :ls_status_task, :ls_woodcode_task, :ls_pcode_task, :ld_fpqty_task, :ld_saletqty_task, :ld_consignedqty_task From u_saletaskmx,u_saletask Where u_saletaskmx.taskid = :s_mx.relid And u_saletaskmx.scid = :scid And u_saletaskmx.scid = u_saletask.scid And u_saletaskmx.printid = :s_mx.relprintid And u_saletaskmx.taskid = u_saletask.taskid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '查询销售订单是否有订购产品:'+i_mtrlcode+'失败' rslt = 0 Goto ext End If If ll_mtrlid_task <> i_mtrlid Then arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+' 与发货单明细的库存信息(物料id)不匹配,不允许保存,请检查相关订单信息与库存信息' rslt = 0 Goto ext End If Select Top 1 Case WHEN ltrim(rtrim(:i_status)) = ltrim(rtrim(:ls_status_task)) Then 0 Else 1 End, Case WHEN ltrim(rtrim(:i_woodcode)) = ltrim(rtrim(:ls_woodcode_task)) Then 0 Else 1 End, Case WHEN ltrim(rtrim(:i_pcode)) = ltrim(rtrim(:ls_pcode_task)) Then 0 Else 1 End Into :li_status_ck,:li_woodcode_ck,:li_pcode_ck From u_user Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '查询订单:'+ls_relcode+' 产品:'+i_mtrlcode+',3个配置信息与库存3个配置信息是否相同失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If If li_status_ck + li_woodcode_ck + li_pcode_ck > 0 Then arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+' 与发货单明细的库存信息不匹配,不允许保存,请检查相关订单信息与库存信息' rslt = 0 Goto ext End If lde_mx_qty = 0 For LS_i = 1 To it_mxbt If i_mtrlid = outwaremx[LS_i].mtrlid And & s_mx.relid = outwaremx[LS_i].relid And & i_status = outwaremx[LS_i].status And & i_woodcode = outwaremx[LS_i].woodcode And & i_pcode = outwaremx[LS_i].pcode And & (i_plancode = outwaremx[LS_i].plancode Or li_storagetype = 1) And & s_mx.relprintid = outwaremx[LS_i].relprintid Then If lb_ifplan Then lde_mx_qty = lde_mx_qty + outwaremx[LS_i].planqty Else lde_mx_qty = lde_mx_qty + outwaremx[LS_i].qty End If End If Next If lb_ifplan Then lde_mx_qty = lde_mx_qty + s_mx.planqty Else lde_mx_qty = lde_mx_qty + s_mx.qty End If //查询相关订单已开发货单未审核数量 Select isnull(sum(qty),0),isnull(sum(planqty),0) Into :lde_notauditqty,:lde_notauditqty_plan From u_outwaremx,u_outware Where u_outwaremx.relid = :s_mx.relid And u_outwaremx.relprintid = :s_mx.relprintid And u_outware.flag = 0 And u_outware.billtype = 1 And u_outwaremx.outwareid = u_outware.outwareid And u_outwaremx.scid = u_outware.scid And u_outware.outwareid <> :outwareid And u_outware.scid = :scid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '查询销售订单:'+ls_relcode+'产品:'+i_mtrlcode+'已开发货单未审核数量失败' rslt = 0 Goto ext End If If lb_ifplan Then If lde_notauditqty_plan + lde_mx_qty > lde_noconqty Then arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'未发货数上限:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty_plan,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########') rslt = 0 Goto ext End If If ll_storagetype_storage = 1 And ls_noallocflag = 1 Then If lde_notauditqty_plan + lde_mx_qty > ld_fpqty_task - ld_consignedqty_task Then arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'分配未发货数上限:'+String(ld_fpqty_task - ld_consignedqty_task,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty_plan,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########') rslt = 0 Goto ext End If End If Else If lde_notauditqty + lde_mx_qty > lde_noconqty Then arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'未发货数上限:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########') rslt = 0 Goto ext End If If ll_storagetype_storage = 1 And ls_noallocflag = 1 Then If lde_notauditqty + lde_mx_qty > ld_fpqty_task - ld_consignedqty_task Then arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'分配未发货数上限:'+String(ld_fpqty_task - ld_consignedqty_task,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########') rslt = 0 Goto ext End If End If End If //检查发货通知单 If uo_option_if_saleout = 1 And thflag = 0 Then If s_mx.saleoutid = 0 Then arg_msg = '请先择相应的发货通知单' rslt = 0 Goto ext End If Select u_saleoutmx.saleqty - u_saleoutmx.consignedqty - u_saleoutmx.stopqty, u_saleout.taskcode Into :lde_noconqty,:ls_relcode_saleout From u_saleoutmx,u_saleout Where u_saleoutmx.taskid = :s_mx.saleoutid And u_saleoutmx.printid = :s_mx.saleoutprintid And u_saleoutmx.taskid = u_saleout.taskid And u_saleout.scid = :scid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '查询发货通知单是否有产品:'+i_mtrlcode+'失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If lde_mx_qty = 0 For LS_i = 1 To it_mxbt If s_mx.saleoutid = outwaremx[LS_i].saleoutid And & s_mx.saleoutprintid = outwaremx[LS_i].saleoutprintid Then If lb_ifplan Then lde_mx_qty = lde_mx_qty + outwaremx[LS_i].planqty Else lde_mx_qty = lde_mx_qty + outwaremx[LS_i].qty End If End If Next If lb_ifplan Then lde_mx_qty = lde_mx_qty + s_mx.planqty Else lde_mx_qty = lde_mx_qty + s_mx.qty End If //查询相关订单已开发货单未审核数量 Select isnull(sum(qty),0),isnull(sum(planqty),0) Into :lde_notauditqty,:lde_notauditqty_plan From u_outwaremx,u_outware Where u_outwaremx.saleoutid = :s_mx.saleoutid And u_outwaremx.saleoutprintid = :s_mx.saleoutprintid And u_outware.flag = 0 And u_outware.billtype = 1 And u_outwaremx.outwareid = u_outware.outwareid And u_outwaremx.scid = u_outware.scid And u_outware.outwareid <> :outwareid And u_outware.scid = :scid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '查询发货通知单:'+ls_relcode_saleout+',明细id:'+String(s_mx.saleoutprintid)+',产品:'+i_mtrlcode+'已开发货单未审核数量失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If If lb_ifplan Then If lde_notauditqty_plan + lde_mx_qty > lde_noconqty Then arg_msg = '发货通知单:'+ls_relcode_saleout+',明细id:'+String(s_mx.saleoutprintid)+',产品:'+i_mtrlcode+'未发货数:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty_plan,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########') rslt = 0 Goto ext End If Else If lde_notauditqty + lde_mx_qty > lde_noconqty Then arg_msg = '发货通知单:'+ls_relcode_saleout+',明细id:'+String(s_mx.saleoutprintid)+',产品:'+i_mtrlcode+'未发货数:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########') rslt = 0 Goto ext End If End If End If End If End If Case 3 // IF uo_option_scll_limit = 0 AND NOT relint_1 = 3 THEN If Not (relint_1 = 3 Or relint_1 = 4 ) Then Select u_mtrldef.mtrlkind, u_mtrldef.scllrate, u_mtrldef.scllqty Into :li_mtrlkind, :ld_scllrate, :ld_scllqty From u_mtrldef,u_mtrlware Where u_mtrldef.mtrlid = u_mtrlware.mtrlid And u_mtrlware.mtrlwareid = :s_mx.mtrlwareid And u_mtrlware.scid = :ll_storagescid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '查询物料:'+i_mtrlcode+'分摊属性失败' rslt = 0 Goto ext End If // If li_mtrlkind = 0 And Not f_power_ind(119,sys_msg_pow) And ( s_mx.ifrel = 0 Or s_mx.relid = 0 ) Then // arg_msg = '请先选择计划,第'+String(s_mx.printid)+'行' // rslt = 0 // Goto ext // End If // // If li_mtrlkind = 1 And ( s_mx.ifrel = 1 Or s_mx.relid > 0 ) Then // arg_msg = '不能选择计划,第'+String(s_mx.printid)+'行' // rslt = 0 // Goto ext // End If If (li_mtrlkind = 0 Or (li_mtrlkind = 2 And ld_scllrate > 0)) And (relint_1 = 0 Or relint_1 = 5) And s_mx.relid > 0 Then Decimal ld_RqQty,ld_DstrQty,ld_noaudit_DstrQty Decimal ld_allowqty Long ll_wrkGrpid Decimal ld_backqty,ld_backbuqty Select u_OrderRqMtrl_scll.trueRqQty, u_OrderRqMtrl_scll.DstrQty, u_OrderRqMtrl_scll.wrkGrpid, isnull(uv_outware_scll_back.qty,0) Into :ld_RqQty, :ld_DstrQty, :ll_wrkGrpid, :ld_backqty From u_OrderRqMtrl_scll Inner JOIN u_workgroup ON u_OrderRqMtrl_scll.wrkGrpid = u_workgroup.wrkGrpid LEFT Outer JOIN uv_outware_scll_back ON u_OrderRqMtrl_scll.MtrlID = uv_outware_scll_back.mtrlid And u_OrderRqMtrl_scll.status = uv_outware_scll_back.status And u_OrderRqMtrl_scll.woodcode = uv_outware_scll_back.woodcode And u_OrderRqMtrl_scll.pcode = uv_outware_scll_back.pcode And u_OrderRqMtrl_scll.scid = uv_outware_scll_back.scid And u_OrderRqMtrl_scll.OrderID = uv_outware_scll_back.relid Where u_OrderRqMtrl_scll.scid = :scid And u_OrderRqMtrl_scll.orderid = :s_mx.relid And u_OrderRqMtrl_scll.MtrlID = :i_mtrlid And u_OrderRqMtrl_scll.status = :i_status And u_OrderRqMtrl_scll.woodcode = :i_woodcode And u_OrderRqMtrl_scll.pcode = :i_pcode And u_workgroup.workgroupid = :relid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '查询物料'+i_mtrlcode+'计划领料数和已领料数失败,'+sqlca.SQLErrText rslt = 0 Goto ext End If If relint_1 = 5 Then Select sum(u_Outwaremx.qty) Into :ld_backbuqty From u_outware,u_Outwaremx,u_workgroup Where u_outware.scid = u_Outwaremx.scid And u_outware.outwareid = u_Outwaremx.outwareid And u_outware.billtype = 3 And u_outware.relint_1 = 5 And u_outware.outwareid <> :outwareid And u_Outwaremx.scid = :scid And u_Outwaremx.mtrlid = :i_mtrlid And u_outware.relid = u_workgroup.workgroupid And u_workgroup.wrkGrpid = :ll_wrkGrpid And u_Outwaremx.relid = :s_mx.relid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '查询物料'+i_mtrlcode+'已补料单数失败,'+sqlca.SQLErrText rslt = 0 Goto ext End If If IsNull(ld_backbuqty) Then ld_backbuqty = 0 If 0 - ld_backqty < s_mx.qty + ld_backbuqty Then arg_msg = '第'+String(s_mx.printid)+'行,物料超领料:'+i_mtrlcode+',可补料总数:'+String(0 - ld_backqty,'#,#0.0#########')+',已补料数:'+String(ld_backbuqty,'#,#0.0#########')+',不可再补料:'+String(s_mx.qty,'#,#0.0#########') rslt = 0 Goto ext End If End If Select sum(u_Outwaremx.qty),sum(u_Outwaremx.planqty) Into :ld_noaudit_DstrQty,:ld_noaudit_planqty From u_outware,u_Outwaremx,u_workgroup Where u_outware.scid = u_Outwaremx.scid And u_outware.outwareid = u_Outwaremx.outwareid And u_outware.billtype = 3 And u_outware.flag = 0 And u_outware.outwareid <> :outwareid And u_Outwaremx.scid = :scid And u_Outwaremx.mtrlid = :i_mtrlid And u_outware.relid = u_workgroup.workgroupid And u_workgroup.wrkGrpid = :ll_wrkGrpid And u_Outwaremx.relid = :s_mx.relid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '查询物料'+i_mtrlcode+'已开单领料数失败,'+sqlca.SQLErrText rslt = 0 Goto ext End If If IsNull(ld_RqQty) Then ld_RqQty = 0 If IsNull(ld_DstrQty) Then ld_DstrQty = 0 If IsNull(ld_noaudit_DstrQty) Then ld_noaudit_DstrQty = 0 // IF li_mtrlkind = 0 THEN // ld_scllrate = 0 // ld_scllqty ld_allowqty = ld_RqQty * (1 + ld_scllrate) + ld_scllqty - ld_DstrQty - ld_noaudit_DstrQty If ld_RqQty * (1 + ld_scllrate) + ld_scllqty < ld_DstrQty + ld_noaudit_DstrQty + s_mx.qty Then arg_msg = '第'+String(s_mx.printid)+'行,物料超领料:'+i_mtrlcode+',可领料:'+String(ld_allowqty,'#,#0.0####')+',需求数:'+String(ld_RqQty,'#,#0.0####')+',已领数:'+String(ld_DstrQty,'#,#0.0####')+',已开单数:'+String(ld_noaudit_DstrQty,'#,#0.0####') rslt = 0 Goto ext End If If uo_option_scll_use_planqty = 1 And Not f_power_ind(3863,sys_msg_pow) Then ld_allowqty = ld_RqQty * (1 + ld_scllrate) + ld_scllqty - ld_DstrQty - ld_noaudit_planqty If ld_RqQty * (1 + ld_scllrate) + ld_scllqty < ld_DstrQty + ld_noaudit_planqty + s_mx.planqty Then arg_msg = '第'+String(s_mx.printid)+'行,物料超领料:'+i_mtrlcode+',可领料:'+String(ld_allowqty,'#,#0.0####')+',需求数:'+String(ld_RqQty,'#,#0.0####')+',已领数:'+String(ld_DstrQty,'#,#0.0####')+',已开单计划数:'+String(ld_noaudit_planqty,'#,#0.0####') rslt = 0 Goto ext End If End If End If End If If s_mx.ifrel > 0 And relint_1 <> 4 Then If s_mx.relid = 0 Then arg_msg = '请先择相应的计划' rslt = 0 Goto ext End If Select ordercode Into :ls_relcode From u_order_ml Where u_order_ml.orderid = :s_mx.relid And u_order_ml.scid = :scid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '查询生产计划是否有生产产品失败' rslt = 0 Goto ext End If End If If relint_1 = 4 Then Select outwarecode Into :ls_relcode From u_outware_scllplan Where outwareid = :s_mx.relid And scid = :scid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '查询相关发料通知单失败' rslt = 0 Goto ext End If End If End Choose //销售发货单要取分部结算价 Decimal ld_scidprice,ld_price_task If flag = 0 Then If billtype = 1 Or billtype = 5 Then If s_mx.ifrel = 1 Then Select scidprice,price Into :ld_scidprice,:ld_price_task From u_saletaskmx Where scid = :scid And u_saletaskmx.printid = :s_mx.relprintid And u_saletaskmx.taskid = :s_mx.relid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '第'+String(s_mx.printid)+'行,物料编码:'+i_mtrlcode+'查询相关销售订单分部结算价失败'+commit_transaction.SQLErrText rslt = 0 Goto ext End If Else Select scidprice Into :ld_scidprice From u_mtrldef Where mtrlid = :i_mtrlid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '第'+String(s_mx.printid)+'行,物料编码:'+i_mtrlcode+'查询物料分部结算价失败'+commit_transaction.SQLErrText rslt = 0 Goto ext End If End If End If End If //**取最新价 Select price Into :i_newprice From v_maxprice_sptprice Where mtrlid = :i_mtrlid Using commit_transaction; If commit_transaction.SQLCode <> 0 Or IsNull(i_newprice) Then i_newprice = 0 If billtype = 1 Then // IF uo_option_if_pricetype = 1 And s_mx.pricetype <> '' THEN Int li_ifcheckprice If s_mx.pricetype <> '' Then Select ifcheckprice Into :li_ifcheckprice From u_pricetype Where pricetype = :s_mx.pricetype Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '第'+String(s_mx.printid)+'行,物料编码:'+i_mtrlcode+'查询价格分类是否属于赠送类型失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If Else li_ifcheckprice = 1 End If If li_ifcheckprice = 2 Then s_mx.rebate = 0 If li_ifcheckprice = 1 And s_mx.ifrel = 0 Then If uo_option_checkprice_native = 1 Then If uo_price.uof_check_price (cusid,i_mtrlid,& i_mtrlcode,i_status,i_pcode,& i_woodcode,relint_2,s_mx.fprice * mrate * s_mx.rebate,s_mx.qty,arg_msg) = 0 Then rslt = 0 Goto ext End If Else If uo_price.uof_check_price (cusid,i_mtrlid,& i_mtrlcode,i_status,i_pcode,& i_woodcode,relint_2,s_mx.fprice * s_mx.rebate,s_mx.qty,arg_msg) = 0 Then rslt = 0 Goto ext End If End If End If // END IF End If //写入内容 it_mxbt++ outwaremx[it_mxbt].dftsaleprice = ld_dftsaleprice outwaremx[it_mxbt].mtrlwareid = s_mx.mtrlwareid outwaremx[it_mxbt].mtrlid = i_mtrlid outwaremx[it_mxbt].status = i_status outwaremx[it_mxbt].qty = s_mx.qty outwaremx[it_mxbt].planqty = s_mx.planqty outwaremx[it_mxbt].storageid = i_storageid outwaremx[it_mxbt].cost = i_cost outwaremx[it_mxbt].costamt = Round(i_cost * s_mx.qty,2) outwaremx[it_mxbt].newpriceamt = Round(i_newprice * s_mx.qty,2) outwaremx[it_mxbt].plancode = i_plancode outwaremx[it_mxbt].planprice = i_planprice outwaremx[it_mxbt].mtrlcode = i_mtrlcode outwaremx[it_mxbt].mxdscrp = s_mx.mxdscrp outwaremx[it_mxbt].printid = s_mx.printid outwaremx[it_mxbt].outtype = s_mx.outtype outwaremx[it_mxbt].enprice = s_mx.fprice outwaremx[it_mxbt].rebate = s_mx.rebate If uo_option_price_rmb = 1 And billtype = 1 Then outwaremx[it_mxbt].fprice = Round(s_mx.fprice * mrate,2) outwaremx[it_mxbt].price = Round(outwaremx[it_mxbt].fprice * s_mx.rebate,2) Else outwaremx[it_mxbt].fprice = s_mx.fprice * mrate outwaremx[it_mxbt].price = outwaremx[it_mxbt].fprice * s_mx.rebate End If If billtype = 1 And s_mx.ifrel = 1 And uo_option_outware_sale_checkprice = 1 Then If Abs(outwaremx[it_mxbt].price - ld_price_task) > 0.02 Then arg_msg = '第'+String(s_mx.printid)+'行,物料编码:'+i_mtrlcode+',销售发货单实价:'+String(outwaremx[it_mxbt].price,'#,##0.00')+' 与对应销售订单实价:'+String(ld_price_task,'#,##0.00')+' 不一致,请检查' rslt = 0 Goto ext End If End If If billtype = 1 Then If uo_option_price_rmb = 1 Then outwaremx[it_mxbt].enacprice = Round(outwaremx[it_mxbt].fprice * s_mx.rebate/mrate,2) Else outwaremx[it_mxbt].enacprice = outwaremx[it_mxbt].fprice * s_mx.rebate/mrate End If Else outwaremx[it_mxbt].enacprice = 0 End If outwaremx[it_mxbt].sptid = i_sptid outwaremx[it_mxbt].dxflag = i_dxflag outwaremx[it_mxbt].ifrel = s_mx.ifrel outwaremx[it_mxbt].relid = s_mx.relid outwaremx[it_mxbt].olmtrlid = s_mx.olmtrlid outwaremx[it_mxbt].packqty = s_mx.packqty outwaremx[it_mxbt].woodcode = i_woodcode outwaremx[it_mxbt].pcode = i_pcode outwaremx[it_mxbt].relcode = ls_relcode outwaremx[it_mxbt].relprintid = s_mx.relprintid outwaremx[it_mxbt].unit = s_mx.unit outwaremx[it_mxbt].rate = s_mx.rate outwaremx[it_mxbt].uqty = s_mx.uqty outwaremx[it_mxbt].mtrlcuscode = i_mtrlcuscode outwaremx[it_mxbt].Location = i_location outwaremx[it_mxbt].scidprice = ld_scidprice outwaremx[it_mxbt].pricetype = s_mx.pricetype outwaremx[it_mxbt].formula = s_mx.formula outwaremx[it_mxbt].capacity = ld_capacity * s_mx.qty outwaremx[it_mxbt].saleoutid = s_mx.saleoutid outwaremx[it_mxbt].saleoutprintid = s_mx.saleoutprintid outwaremx[it_mxbt].mxdscrp2 = s_mx.mxdscrp2 outwaremx[it_mxbt].net_weight = s_mx.net_weight outwaremx[it_mxbt].gross_weight = s_mx.gross_weight outwaremx[it_mxbt].cubage = s_mx.cubage outwaremx[it_mxbt].taxrate = s_mx.taxrate outwaremx[it_mxbt].priceformula = s_mx.priceformula outwaremx[it_mxbt].qtyformula = s_mx.qtyformula outwaremx[it_mxbt].ifvqty = s_mx.ifvqty outwaremx[it_mxbt].backtype = s_mx.backtype outwaremx[it_mxbt].ifnotinout = s_mx.ifnotinout outwaremx[it_mxbt].ifpackpro = i_ifpackpro outwaremx[it_mxbt].ifpack = i_ifpack ext: If rslt = 0 Then p_clearmx() Destroy uo_price Return rslt end function protected function integer p_update_mtrlware (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_uqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, string arg_mtrlcuscode, string arg_location, integer arg_ifvqty, ref string arg_msg);Int rslt = 1 Long ls_newid Decimal ld_cost Int li_storMtrlprp,li_storagetype,li_outtype_storage Long ll_storagescid Int li_ifunit,li_ifpack,li_ifpackpro Int li_statusflag Decimal ld_capacity,ld_capacity_zj s_mtrlcfg_expr s_pz[] String ls_status_zj Long ll_i Decimal ld_noallocqty,ld_allocqty String ls_storagename Int li_ifcost Int if_recmp_balc String or_err_part Decimal ld_pypkqty,ld_pypkamt Decimal ld_saleoutqty,ld_saleoutamt Decimal ld_saleoutqty_pack,ld_saleoutamt_pack Decimal ld_buyoutqty_packpro,ld_buyoutamt_packpro Decimal ld_cpoutqty,ld_cpoutamt Decimal ld_jgoutqty,ld_jgoutamt Decimal ld_dioutqty,ld_dioutamt Decimal ld_mvoutqty,ld_mvoutamt Decimal ld_otoutqty,ld_otoutamt Decimal ld_pkoutqty,ld_pkoutamt int li_ifmrp IF sys_if_recmp_balc < 0 THEN SELECT if_recmp_balc INTO :if_recmp_balc From sys_msg Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询是否执行结存表重算失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF if_recmp_balc = 0 THEN rslt = 0 arg_msg = '由于系统升级,结存表结构与原来不同,请先通知管理员执行危险功能中的[按新结构重算现结存表]功能,才能审核和撤审进出仓单据' GOTO ext END IF ELSE IF sys_if_recmp_balc = 0 THEN rslt = 0 arg_msg = '由于系统升级,结存表结构与原来不同,请先通知管理员执行危险功能中的[按新结构重算现结存表]功能,才能审核和撤审进出仓单据' GOTO ext END IF END IF IF uo_option_change_status = '-1000' THEN rslt = 0 arg_msg = '选项:[029]配置标题文本,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_change_woodcode = '-1000' THEN rslt = 0 arg_msg = '选项:[027]配置1标题文本,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_change_pcode = '-1000' THEN rslt = 0 arg_msg = '选项:[028]配置2标题文本,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_cost_dec = -1000 THEN rslt = 0 arg_msg = '选项:[022]库存成本价转换小数点,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_mtrlware_autocmp = -1000 THEN rslt = 0 arg_msg = '选项:[158]自动计算库存包件可装数,读取初始默认值失败,操作取消!' GOTO ext END IF If uo_option_djqty_check = -1000 Then rslt = 0 arg_msg = '选项:[378]进出仓检查冻结数不能大于库存数,读取初始默认值失败,操作取消!' Goto ext End If uo_cmpl_packpro uo_cmpl_p uo_cmpl_p = Create uo_cmpl_packpro uo_cmpl_p.commit_transaction = commit_transaction SELECT Mtrlprp,scid,storagetype,outtype,storagename,ifcost,ifmrp INTO :li_storMtrlprp,:ll_storagescid,:li_storagetype,:li_outtype_storage,:ls_storagename,:li_ifcost,:li_ifmrp FROM u_storage Where storageid = :arg_storageid Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询仓库信息失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF li_storagetype = 1 THEN IF billtype <> 1 And billtype <> 23 Or billtype = 1 And li_outtype_storage = 0 THEN SELECT noallocqty,allocqty INTO :ld_noallocqty,:ld_allocqty FROM u_mtrlware WHERE ( mtrlwareid = :arg_mtrlwareid ) AND ( scid = :ll_storagescid ) Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '仓库:'+ls_storagename+',查询库存信息失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF ld_noallocqty - arg_qty < ld_allocqty THEN arg_msg = '仓库:'+ls_storagename+',库存数小于已分配数,请检查库存,库存id:'+string(arg_mtrlwareid)+',库存数:'+String(ld_noallocqty - arg_qty,'#0.##########')+',已分配数:'+String(ld_allocqty,'#0.##########') rslt = 0 GOTO ext END IF END IF END IF SELECT ifunit,ifpack,capacity,statusflag,ifpackpro INTO :li_ifunit,:li_ifpack,:ld_capacity,:li_statusflag,:li_ifpackpro FROM u_mtrldef Where mtrlid = :arg_mtrlid Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询物料信息失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF li_statusflag = 2 THEN ld_capacity = 0 f_checkpz(arg_status,s_pz[]) FOR ll_i = 1 To UpperBound(s_pz) ls_status_zj = s_pz[ll_i].cfgname SELECT capacity INTO :ld_capacity_zj FROM u_mtrl_configure WHERE mtrlid = :arg_mtrlid And Name = :ls_status_zj; IF commit_transaction.SQLCode <> 0 THEN ld_capacity_zj = 0 END IF ld_capacity = ld_capacity + ld_capacity_zj * Dec(s_pz[ll_i].qty) NEXT END IF Int li_ifupdate_date String ls_str IF billtype = 1 Or & billtype = 2 Or & billtype = 3 Or & billtype = 4 Or & billtype = 5 Or & billtype = 7 Or & billtype = 8 Or & billtype = 10 Or & billtype = 12 Or & billtype = 17 Or & billtype = 21 Or & billtype = 24 THEN li_ifupdate_date = 1 ELSE li_ifupdate_date = 0 END IF IF li_ifunit = 0 THEN arg_uqty = 0 IF li_ifcost = 1 THEN UPDATE u_mtrlware SET noallocqty = noallocqty - :arg_qty , unoallocqty = unoallocqty - :arg_uqty, capacity = capacity + :ld_capacity * :arg_qty , wareamt = case noallocqty - :arg_qty when 0 then 0 else wareamt - :arg_costamt END , cost = case noallocqty - :arg_qty when 0 then cost else round((wareamt - :arg_costamt)/(noallocqty - :arg_qty),:uo_option_cost_dec) END , saledate = case :li_ifupdate_date when 1 then getdate() else saledate END WHERE ( mtrlwareid = :arg_mtrlwareid ) AND ( scid = :ll_storagescid ) Using commit_transaction ; IF commit_transaction.SQLCode = 0 THEN IF commit_transaction.SQLNRows = 0 THEN ls_newid = f_sys_scidentity(ll_storagescid,"u_mtrlware","mtrlwareid",arg_msg,True,id_sqlca) IF ls_newid <= 0 THEN rslt = 0 GOTO ext END IF ld_cost = Round(arg_costamt/arg_qty,uo_option_cost_dec) INSERT INTO u_mtrlware ( scid, mtrlwareid, mtrlid, storageid, plancode, status, noallocqty, unoallocqty, allocqty, wareamt, planprice, sptid, dxflag, woodcode, pcode, cost, storMtrlprp, mtrlcuscode, location, capacity) VALUES ( :ll_storagescid, :ls_newid, :arg_mtrlid, :arg_storageid, :arg_plancode, :arg_status, :arg_qty, :arg_uqty, 0, :arg_costamt, :arg_planprice, :arg_sptid, :arg_dxflag, :arg_woodcode, :arg_pcode, :ld_cost, :li_storMtrlprp, :arg_mtrlcuscode, :arg_location, :ld_capacity * :arg_qty) Using commit_transaction ; IF arg_status <> '' THEN ls_str = ' '+uo_option_change_status+':'+arg_status END IF IF arg_pcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode END IF IF arg_woodcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode END IF IF commit_transaction.SQLCode <> 0 THEN rslt = 0 IF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号没有足够的库存数量支持冲减,"+commit_transaction.SQLErrText ELSEIF Pos(commit_transaction.SQLErrText,'CREATE RULE') > 0 And Pos(commit_transaction.SQLErrText,'cost') > 0 THEN arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号的库存金额不够冲减,"+commit_transaction.SQLErrText ELSE arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF END IF ELSE rslt = 0 IF arg_status <> '' THEN ls_str = ' '+uo_option_change_status+':'+arg_status END IF IF arg_pcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode END IF IF arg_woodcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode END IF or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement' IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+",同仓库内同批号没有足够的库存支持冲减,"+commit_transaction.SQLErrText ELSEIF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号没有足够的库存支持冲减,"+commit_transaction.SQLErrText ELSEIF Pos(commit_transaction.SQLErrText,'CREATE RULE') > 0 And Pos(commit_transaction.SQLErrText,'cost') > 0 THEN arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号的库存金额不够冲减" ELSE arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",因网络或其它原因导致物料:"+arg_mtrlcode+' '+uo_option_change_status+':'+arg_status+' '+uo_option_change_pcode+':'+arg_pcode+' '+uo_option_change_woodcode+':'+arg_woodcode+"库存更新操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF //-----------------------------------更新结存 CHOOSE CASE billtype CASE 1,2,5,6 ld_saleoutqty = arg_qty ld_saleoutamt = arg_costamt CASE 3 ld_cpoutqty = arg_qty ld_cpoutamt = arg_costamt CASE 4,7 ld_jgoutqty = arg_qty ld_jgoutamt = arg_costamt CASE 8 ld_otoutqty = arg_qty ld_otoutamt = arg_costamt CASE 9 ld_pkoutqty = arg_qty ld_pkoutamt = arg_costamt ld_pypkqty = arg_qty ld_pypkamt = arg_costamt CASE 12 ld_mvoutqty = arg_qty ld_mvoutamt = arg_costamt CASE 15 ld_dioutqty = arg_qty ld_dioutamt = arg_costamt CASE 21 ld_saleoutqty_pack = arg_qty ld_saleoutamt_pack = arg_costamt CASE 23 ld_buyoutqty_packpro = arg_qty ld_buyoutamt_packpro = arg_costamt CASE ELSE ld_otoutqty = arg_qty ld_otoutamt = arg_costamt END CHOOSE UPDATE u_warebalc SET desqty = desqty + :arg_qty , udesqty = udesqty + :arg_uqty, desamt = desamt + :arg_costamt, vdesqty = case :arg_ifvqty when 0 then vdesqty else vdesqty + :arg_qty END , uvdesqty = case :arg_ifvqty when 0 then uvdesqty else uvdesqty + :arg_uqty END , vdesamt = case :arg_ifvqty when 0 then vdesamt else vdesamt + :arg_costamt END , balcqty = balcqty - :arg_qty, ubalcqty = ubalcqty - :arg_uqty, balcamt = case balcqty - :arg_qty when 0 then 0 else balcamt - :arg_costamt END, pypk = pypk - :ld_pypkqty, pypkamt = pypkamt - :ld_pypkamt, saleoutqty = saleoutqty + :ld_saleoutqty, saleoutamt = saleoutamt + :ld_saleoutamt, saleoutqty_pack = saleoutqty_pack + :ld_saleoutqty_pack, saleoutamt_pack = saleoutamt_pack + :ld_saleoutamt_pack, buyoutqty_packpro = buyoutqty_packpro + :ld_buyoutqty_packpro, buyoutamt_packpro = buyoutamt_packpro + :ld_buyoutamt_packpro, cpoutqty = cpoutqty + :ld_cpoutqty, cpoutamt = cpoutamt + :ld_cpoutamt, jgoutqty = jgoutqty + :ld_jgoutqty, jgoutamt = jgoutamt + :ld_jgoutamt, otoutqty = otoutqty + :ld_otoutqty, otoutamt = otoutamt + :ld_otoutamt, mvoutqty = mvoutqty + :ld_mvoutqty, mvoutamt = mvoutamt + :ld_mvoutamt, dioutqty = dioutqty + :ld_dioutqty, dioutamt = dioutamt + :ld_dioutamt, pkoutqty = pkoutqty + :ld_pkoutqty, pkoutamt = pkoutamt + :ld_pkoutamt WHERE ( balcdateint = 0 ) AND ( scid = :ll_storagescid) AND ( mtrlwareid = :arg_mtrlwareid) Using commit_transaction ; IF commit_transaction.SQLCode = 0 THEN IF commit_transaction.SQLNRows = 0 THEN INSERT INTO u_warebalc ( balcdateint, mtrlid, storageid, bgqty, bgamt, incqty, incamt, desqty, desamt, balcqty, balcamt, pypk, pypkamt, status, scid , saleoutqty, saleoutamt, saleoutqty_pack, saleoutamt_pack, buyoutqty_packpro, buyoutamt_packpro, cpoutqty, cpoutamt, jgoutqty, jgoutamt, dioutqty, dioutamt, mvoutqty, mvoutamt, otoutqty, otoutamt, pkoutqty, pkoutamt, woodcode, pcode, ubgqty, uincqty, udesqty, ubalcqty, plancode, sptid, dxflag, mtrlcuscode, location, mtrlwareid) VALUES ( 0, :arg_mtrlid, :arg_storageid, 0, 0, 0, 0, :arg_qty, :arg_costamt, 0 - :arg_qty, 0 - :arg_costamt, 0 - :ld_pypkqty, 0 - :ld_pypkamt, :arg_status, :ll_storagescid, :ld_saleoutqty, :ld_saleoutamt, :ld_saleoutqty_pack, :ld_saleoutamt_pack, :ld_buyoutqty_packpro, :ld_buyoutamt_packpro, :ld_cpoutqty, :ld_cpoutamt, :ld_jgoutqty, :ld_jgoutamt, :ld_dioutqty, :ld_dioutamt, :ld_mvoutqty, :ld_mvoutamt, :ld_otoutqty, :ld_otoutamt, :ld_pkoutqty, :ld_pkoutamt, :arg_woodcode, :arg_pcode, 0, 0, :arg_uqty, 0 - :arg_uqty, :arg_plancode, :arg_sptid, :arg_dxflag, :arg_mtrlcuscode, :arg_location, :arg_mtrlwareid) Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '仓库:'+ls_storagename+",因网络或其它原因导致物料["+arg_mtrlcode+"]结存建立操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF END IF ELSE rslt = 0 or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement' IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN arg_msg = '仓库:'+ls_storagename+",物料"+arg_mtrlcode+"同仓库内同批号没有足够的结存支持冲减" ELSE arg_msg = '仓库:'+ls_storagename+",因网络或其它原因导致物料:"+arg_mtrlcode+'颜色:'+arg_status+'面料:'+arg_pcode+'材质:'+arg_woodcode+"结存更新操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF ELSE UPDATE u_mtrlware SET noallocqty = noallocqty - :arg_qty , unoallocqty = unoallocqty - :arg_uqty, capacity = capacity + :ld_capacity * :arg_qty , wareamt = 0 , cost = 0 , saledate = case :li_ifupdate_date when 1 then getdate() else saledate END WHERE ( mtrlwareid = :arg_mtrlwareid ) AND ( scid = :ll_storagescid ) Using commit_transaction ; IF commit_transaction.SQLCode = 0 THEN IF commit_transaction.SQLNRows = 0 THEN ls_newid = f_sys_scidentity(ll_storagescid,"u_mtrlware","mtrlwareid",arg_msg,True,id_sqlca) IF ls_newid <= 0 THEN rslt = 0 GOTO ext END IF INSERT INTO u_mtrlware ( scid, mtrlwareid, mtrlid, storageid, plancode, status, noallocqty, unoallocqty, allocqty, wareamt, planprice, sptid, dxflag, woodcode, pcode, cost, storMtrlprp, mtrlcuscode, location, capacity) VALUES ( :ll_storagescid, :ls_newid, :arg_mtrlid, :arg_storageid, :arg_plancode, :arg_status, :arg_qty, :arg_uqty, 0, 0, 0, :arg_sptid, :arg_dxflag, :arg_woodcode, :arg_pcode, 0, :li_storMtrlprp, :arg_mtrlcuscode, :arg_location, :ld_capacity * :arg_qty) Using commit_transaction ; IF arg_status <> '' THEN ls_str = ' '+uo_option_change_status+':'+arg_status END IF IF arg_pcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode END IF IF arg_woodcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode END IF IF commit_transaction.SQLCode <> 0 THEN rslt = 0 IF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号没有足够的库存数量支持冲减,"+commit_transaction.SQLErrText ELSEIF Pos(commit_transaction.SQLErrText,'CREATE RULE') > 0 And Pos(commit_transaction.SQLErrText,'cost') > 0 THEN arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号的库存金额不够冲减,"+commit_transaction.SQLErrText ELSE arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF END IF ELSE rslt = 0 IF arg_status <> '' THEN ls_str = ' '+uo_option_change_status+':'+arg_status END IF IF arg_pcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode END IF IF arg_woodcode <> '' THEN ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode END IF or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement' IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+",同仓库内同批号没有足够的库存支持冲减,"+commit_transaction.SQLErrText ELSEIF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号没有足够的库存支持冲减,"+commit_transaction.SQLErrText ELSEIF Pos(commit_transaction.SQLErrText,'CREATE RULE') > 0 And Pos(commit_transaction.SQLErrText,'cost') > 0 THEN arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号的库存金额不够冲减" ELSE arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",因网络或其它原因导致物料:"+arg_mtrlcode+' '+uo_option_change_status+':'+arg_status+' '+uo_option_change_pcode+':'+arg_pcode+' '+uo_option_change_woodcode+':'+arg_woodcode+"库存更新操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF //-----------------------------------更新结存 CHOOSE CASE billtype CASE 1,2,5,6 ld_saleoutqty = arg_qty CASE 3 ld_cpoutqty = arg_qty CASE 4,7 ld_jgoutqty = arg_qty CASE 8 ld_otoutqty = arg_qty CASE 9 ld_pkoutqty = arg_qty ld_pypkqty = arg_qty CASE 12 ld_mvoutqty = arg_qty CASE 15 ld_dioutqty = arg_qty CASE 21 ld_saleoutqty_pack = arg_qty CASE 23 ld_buyoutqty_packpro = arg_qty CASE ELSE ld_otoutqty = arg_qty END CHOOSE UPDATE u_warebalc SET desqty = desqty + :arg_qty , udesqty = udesqty + :arg_uqty, desamt = 0, vdesqty = case :arg_ifvqty when 0 then vdesqty else vdesqty + :arg_qty END , uvdesqty = case :arg_ifvqty when 0 then uvdesqty else uvdesqty + :arg_uqty END , vdesamt = 0 , balcqty = balcqty - :arg_qty, ubalcqty = ubalcqty - :arg_uqty, balcamt = 0, pypk = pypk - :ld_pypkqty, pypkamt = 0, saleoutqty = saleoutqty + :ld_saleoutqty, saleoutamt = 0, saleoutqty_pack = saleoutqty_pack + :ld_saleoutqty_pack, saleoutamt_pack = 0, buyoutqty_packpro = buyoutqty_packpro + :ld_buyoutqty_packpro, buyoutamt_packpro = 0, cpoutqty = cpoutqty + :ld_cpoutqty, cpoutamt = 0, jgoutqty = jgoutqty + :ld_jgoutqty, jgoutamt = 0, otoutqty = otoutqty + :ld_otoutqty, otoutamt = 0, mvoutqty = mvoutqty + :ld_mvoutqty, mvoutamt = 0, dioutqty = dioutqty + :ld_dioutqty, dioutamt = 0, pkoutqty = pkoutqty + :ld_pkoutqty, pkoutamt = 0 WHERE ( balcdateint = 0 ) AND ( scid = :ll_storagescid) AND ( mtrlwareid = :arg_mtrlwareid) Using commit_transaction ; IF commit_transaction.SQLCode = 0 THEN IF commit_transaction.SQLNRows = 0 THEN INSERT INTO u_warebalc ( balcdateint, mtrlid, storageid, bgqty, bgamt, incqty, incamt, desqty, desamt, balcqty, balcamt, pypk, pypkamt, status, scid , saleoutqty, saleoutamt, saleoutqty_pack, saleoutamt_pack, buyoutqty_packpro, buyoutamt_packpro, cpoutqty, cpoutamt, jgoutqty, jgoutamt, dioutqty, dioutamt, mvoutqty, mvoutamt, otoutqty, otoutamt, pkoutqty, pkoutamt, woodcode, pcode, ubgqty, uincqty, udesqty, ubalcqty, plancode, sptid, dxflag, mtrlcuscode, location, mtrlwareid) VALUES ( 0, :arg_mtrlid, :arg_storageid, 0, 0, 0, 0, :arg_qty, 0, 0 - :arg_qty, 0, 0 - :ld_pypkqty, 0, :arg_status, :ll_storagescid, :ld_saleoutqty, 0, :ld_saleoutqty_pack, 0, :ld_buyoutqty_packpro, 0, :ld_cpoutqty, 0, :ld_jgoutqty, 0, :ld_dioutqty, 0, :ld_mvoutqty, 0, :ld_otoutqty, 0, :ld_pkoutqty, 0, :arg_woodcode, :arg_pcode, 0, 0, :arg_uqty, 0 - :arg_uqty, :arg_plancode, :arg_sptid, :arg_dxflag, :arg_mtrlcuscode, :arg_location, :arg_mtrlwareid) Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '仓库:'+ls_storagename+",因网络或其它原因导致物料["+arg_mtrlcode+"]结存建立操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF END IF ELSE rslt = 0 or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement' IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN arg_msg = '仓库:'+ls_storagename+",物料"+arg_mtrlcode+"同仓库内同批号没有足够的结存支持冲减" ELSE arg_msg = '仓库:'+ls_storagename+",因网络或其它原因导致物料:"+arg_mtrlcode+'颜色:'+arg_status+'面料:'+arg_pcode+'材质:'+arg_woodcode+"结存更新操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF END IF //自动计算包件产品可装数yyx20100414 //yyx2012-9-28取消 //IF ( li_ifpack = 1 or li_ifpack = 2 Or li_ifpackpro = 3 Or li_ifpackpro = 4 ) AND uo_option_mtrlware_autocmp = 1 THEN // IF uo_cmpl_p.uof_cmpl(arg_mtrlid,arg_plancode,arg_mtrlcuscode,arg_storageid,arg_msg) = 0 THEN // rslt = 0 // GOTO ext // END IF //END IF If uo_option_djqty_check = 1 and not (billtype = 3 And relint_1 = 2 ) and li_ifmrp = 1 and not ( billtype = 3 And relint_1 = 4) Then Decimal ld_djqty Select SUM(u_OrderRqMtrl_scll.wareqty - u_OrderRqMtrl_scll.DstrQty + isnull(uv_outware_scll_back.qty,0)) Into :ld_djqty FROM u_OrderRqMtrl_scll INNER JOIN u_Order_ml ON u_OrderRqMtrl_scll.OrderID = u_Order_ml.OrderID LEFT OUTER JOIN uv_outware_scll_back ON u_OrderRqMtrl_scll.scid = uv_outware_scll_back.scid AND u_OrderRqMtrl_scll.OrderID = uv_outware_scll_back.relid AND u_OrderRqMtrl_scll.MtrlID = uv_outware_scll_back.mtrlid AND u_OrderRqMtrl_scll.status = uv_outware_scll_back.status AND u_OrderRqMtrl_scll.woodcode = uv_outware_scll_back.woodcode AND u_OrderRqMtrl_scll.pcode = uv_outware_scll_back.pcode Where (u_OrderRqMtrl_scll.wareqty <> 0) And (u_Order_ml.Status Not In (3,5,6)) And u_OrderRqMtrl_scll.wareqty - u_OrderRqMtrl_scll.DstrQty + isnull(uv_outware_scll_back.qty,0) > 0 And u_OrderRqMtrl_scll.MtrlID = :arg_mtrlid And u_OrderRqMtrl_scll.scid = :scid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then ld_djqty = 0 End If If IsNull(ld_djqty) Then ld_djqty = 0 Select SUM(u_mtrlware.noallocqty) Into :ld_noallocqty From u_mtrlware Inner JOIN u_storage ON u_mtrlware.storageid = u_storage.storageid Where (u_storage.inuse = 1) And u_storage.ifmrp = 1 And u_mtrlware.mtrlid = :arg_mtrlid And u_mtrlware.scid = :scid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then ld_noallocqty = 0 End If If IsNull(ld_noallocqty) Then ld_noallocqty = 0 If ld_djqty > ld_noallocqty Then rslt = 0 arg_msg = '冻结数不能大于库存数,冻结数:'+String(ld_djqty,'#,##0.##########')+',库存数:'+String(ld_noallocqty,'#,##0.##########') Goto ext End If End If ext: IF rslt = 0 THEN ROLLBACK Using commit_transaction ; END IF Destroy uo_cmpl_p RETURN rslt end function public function integer acceptmx_mx (long arg_printid, long arg_mtrlwareid, decimal arg_planqty, decimal arg_qty, string arg_mxdscrp, long arg_mxprintid, integer arg_ifnotinout, ref string arg_msg);Long rslt = 1,cnt = 0,LS_i String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode Long ll_storagescid Long i_mtrlid,i_storageid,i_sptid Int i_dxflag string i_mtrlcuscode,i_location int i_ifpackpro,i_ifpack IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" GOTO ext END IF SELECT scid INTO :ll_storagescid FROM u_storage Where storageid = :storageid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询仓库分部失败'+commit_transaction.SQLErrText GOTO ext END IF //清除空值 IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0 IF IsNull(arg_printid) THEN arg_printid = 0 IF IsNull(arg_qty) THEN arg_qty = 0 IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = '' IF IsNull(arg_planqty) THEN arg_planqty = 0 IF IsNull(arg_mxprintid) THEN arg_mxprintid = 0 IF arg_mtrlwareid = 0 Or ( arg_qty = 0 AND arg_planqty = 0 ) THEN rslt = 1 GOTO ext END IF //检查物料库存ID SELECT u_mtrlware.mtrlid, u_mtrlware.storageid, u_mtrlware.plancode, u_mtrlware.status, u_mtrldef.mtrlcode, u_mtrlware.sptid, u_mtrlware.dxflag, u_mtrlware.woodcode, u_mtrlware.pcode, u_mtrlware.mtrlcuscode, u_mtrlware.location, u_mtrldef.ifpackpro, u_mtrldef.ifpack INTO :i_mtrlid, :i_storageid, :i_plancode, :i_status, :i_mtrlcode, :i_sptid, :i_dxflag, :i_woodcode, :i_pcode, :i_mtrlcuscode, :i_location, :i_ifpackpro, :i_ifpack FROM u_mtrlware ,u_mtrldef WHERE ( u_mtrlware.mtrlwareid = :arg_mtrlwareid ) AND ( u_mtrlware.mtrlid = u_mtrldef.mtrlid ) And ( u_mtrlware.scid = :ll_storagescid ) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "第"+String(arg_printid)+"行,查询操作失败,库存编号(出仓单)错误,分部:"+String(ll_storagescid)+'库存:'+String(arg_mtrlwareid)+',~n'+commit_transaction.SQLErrText GOTO ext END IF IF IsNull(i_plancode) THEN i_plancode = '' IF IsNull(i_status) THEN i_status = '' IF IsNull(i_mtrlid) THEN i_mtrlid = 0 IF IsNull(i_storageid) THEN i_storageid = 0 IF IsNull(i_sptid) THEN i_sptid = 0 IF IsNull(i_dxflag) THEN i_dxflag = 0 IF IsNull(i_woodcode) THEN i_woodcode = '' IF IsNull(i_pcode) THEN i_pcode = '' IF IsNull(i_mtrlcuscode) THEN i_mtrlcuscode = '' IF IsNull(i_location) THEN i_location = '' IF IsNull(i_ifpackpro) THEN i_ifpackpro = 0 IF IsNull(i_ifpack) THEN i_ifpack = 0 //写入内容 it_mxbt_mx++ outwaremx_mx[it_mxbt_mx].mtrlwareid = arg_mtrlwareid outwaremx_mx[it_mxbt_mx].mtrlid = i_mtrlid outwaremx_mx[it_mxbt_mx].status = i_status outwaremx_mx[it_mxbt_mx].qty = arg_qty outwaremx_mx[it_mxbt_mx].planqty = arg_planqty outwaremx_mx[it_mxbt_mx].storageid = i_storageid outwaremx_mx[it_mxbt_mx].plancode = i_plancode outwaremx_mx[it_mxbt_mx].mtrlcode = i_mtrlcode outwaremx_mx[it_mxbt_mx].mxdscrp = arg_mxdscrp outwaremx_mx[it_mxbt_mx].printid = arg_printid outwaremx_mx[it_mxbt_mx].mxprintid = arg_mxprintid outwaremx_mx[it_mxbt_mx].sptid = i_sptid outwaremx_mx[it_mxbt_mx].dxflag = i_dxflag outwaremx_mx[it_mxbt_mx].woodcode = i_woodcode outwaremx_mx[it_mxbt_mx].pcode = i_pcode outwaremx_mx[it_mxbt_mx].mtrlcuscode = i_mtrlcuscode outwaremx_mx[it_mxbt_mx].location = i_location outwaremx_mx[it_mxbt_mx].ifnotinout = arg_ifnotinout outwaremx_mx[it_mxbt_mx].ifpackpro = i_ifpackpro outwaremx_mx[it_mxbt_mx].ifpack = i_ifpack ext: IF rslt = 0 THEN p_clearmx() RETURN rslt end function public function integer uof_noauditingqty_add (long arg_scid, long arg_billtype, integer arg_relint_1, ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1 Int rslt = 1 Long i Decimal ld_qty,ld_uqty If thflag = 1 Then rslt = 1 Goto ext End If For i = 1 To it_mxbt ld_qty = 0 ld_uqty = 0 If arg_billtype <> 1 And arg_billtype <> 3 Then ld_qty = outwaremx[i].qty ld_uqty = outwaremx[i].uqty ElseIf arg_billtype = 3 And arg_relint_1 <> 4 And arg_relint_1 <> 2 Then ld_qty = outwaremx[i].qty ld_uqty = outwaremx[i].uqty ElseIf arg_billtype = 3 And arg_relint_1 = 4 And uo_option_scllplan_outware_auto = 1 Then ld_qty = outwaremx[i].qty ld_uqty = outwaremx[i].uqty ElseIf arg_billtype = 1 And uo_option_inout_type = 0 Then If outwaremx[i].qty = 0 Then ld_qty = outwaremx[i].planqty Else ld_qty = outwaremx[i].qty End If ld_uqty = outwaremx[i].uqty ElseIf arg_billtype = 1 And uo_option_inout_type > 0 And outwaremx[i].ifpack = 0 And outwaremx[i].ifpackpro = 0 Then If outwaremx[i].qty = 0 Then ld_qty = outwaremx[i].planqty Else ld_qty = outwaremx[i].qty End If ld_uqty = outwaremx[i].uqty End If Update u_mtrlware Set noauditingqty = noauditingqty + :ld_qty, noauditinguqty = noauditingqty + :ld_uqty Where scid = :arg_scid And mtrlwareid = :outwaremx[i].mtrlwareid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = '物料:'+String(outwaremx[i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText Goto ext End If Next For i = 1 To it_mxbt_mx ld_qty = 0 ld_uqty = 0 If uo_option_inout_type > 0 Then If outwaremx_mx[i].ifpack = 1 Or outwaremx_mx[i].ifpackpro = 4 Or outwaremx_mx[i].ifpackpro = 3 Then If outwaremx_mx[i].qty = 0 Then ld_qty = outwaremx_mx[i].planqty Else ld_qty = outwaremx_mx[i].qty End If ld_uqty = ld_qty Update u_mtrlware Set noauditingqty = noauditingqty + :ld_qty, noauditinguqty = noauditingqty + :ld_uqty Where scid = :arg_scid And mtrlwareid = :outwaremx_mx[i].mtrlwareid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = '物料:'+String(outwaremx_mx[i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText Goto ext End If End If End If Next ext: Return rslt end function public function integer uof_noauditingqty_del (long arg_scid, long arg_outwareid, ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1 Int rslt = 1 Long i,ll_i,j Decimal ld_qty,ld_uqty Int arg_billtype,arg_relint_1 If thflag = 1 Then rslt = 1 Goto ext End If i = 1 j = 1 s_outwaremx arg_s_mx[] s_outwaremx_mx arg_s_mxmx[] Select billtype,relint_1 Into :arg_billtype,:arg_relint_1 From u_outware Where scid = :arg_scid And outwareid = :arg_outwareid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '查询单据信息失败,'+commit_transaction.SQLErrText Goto ext End If Declare cur_outwaremx Cursor For Select u_outwaremx.mtrlwareid, u_outwaremx.planqty, u_outwaremx.qty, u_outwaremx.uqty, u_mtrldef.mtrlcode, u_mtrldef.ifpackpro, u_mtrldef.ifpack From u_outwaremx,u_mtrldef Where u_outwaremx.outwareid = :arg_outwareid And u_outwaremx.mtrlid = u_mtrldef.mtrlid And u_outwaremx.scid = :arg_scid Order By u_outwaremx.printid Using commit_transaction; Open cur_outwaremx; Fetch cur_outwaremx Into :arg_s_mx[i].mtrlwareid,:arg_s_mx[i].planqty,:arg_s_mx[i].qty,:arg_s_mx[i].uqty, :arg_s_mx[i].mtrlcode,:arg_s_mx[i].ifpackpro,:arg_s_mx[i].ifpack; Do While sqlca.SQLCode = 0 i++ Fetch cur_outwaremx Into :arg_s_mx[i].mtrlwareid,:arg_s_mx[i].planqty,:arg_s_mx[i].qty,:arg_s_mx[i].uqty, :arg_s_mx[i].mtrlcode,:arg_s_mx[i].ifpackpro,:arg_s_mx[i].ifpack; Loop Close cur_outwaremx; Declare cur_outwaremx_mx Cursor For Select u_outwaremx_mx.mtrlwareid, u_outwaremx_mx.planqty, u_outwaremx_mx.qty, u_mtrldef.ifpackpro, u_mtrldef.ifpack, u_mtrldef.mtrlcode From u_outwaremx_mx Inner JOIN u_mtrldef ON u_outwaremx_mx.mtrlid = u_mtrldef.mtrlid Where u_outwaremx_mx.scid = :arg_scid And u_outwaremx_mx.outwareid = :arg_outwareid Order By u_outwaremx_mx.mxprintid Using commit_transaction; Open cur_outwaremx_mx; Fetch cur_outwaremx_mx Into :arg_s_mxmx[j].mtrlwareid,:arg_s_mxmx[j].planqty,:arg_s_mxmx[j].qty, :arg_s_mxmx[j].ifpackpro, :arg_s_mxmx[j].ifpack, :arg_s_mxmx[j].mtrlcode; Do While sqlca.SQLCode = 0 j++ Fetch cur_outwaremx_mx Into :arg_s_mxmx[j].mtrlwareid,:arg_s_mxmx[j].planqty,:arg_s_mxmx[j].qty, :arg_s_mxmx[j].ifpackpro, :arg_s_mxmx[j].ifpack, :arg_s_mxmx[j].mtrlcode; Loop Close cur_outwaremx_mx; For ll_i = 1 To i - 1 ld_qty = 0 ld_uqty = 0 If arg_billtype <> 1 And arg_billtype <> 3 Then ld_qty = arg_s_mx[ll_i].qty ld_uqty = arg_s_mx[ll_i].uqty ElseIf arg_billtype = 3 And arg_relint_1 <> 4 And arg_relint_1 <> 2 Then ld_qty = arg_s_mx[ll_i].qty ld_uqty = arg_s_mx[ll_i].uqty ElseIf arg_billtype = 3 And arg_relint_1 = 4 And uo_option_scllplan_outware_auto = 1 Then ld_qty = arg_s_mx[ll_i].qty ld_uqty = arg_s_mx[ll_i].uqty ElseIf arg_billtype = 1 And uo_option_inout_type = 0 Then If arg_s_mx[ll_i].qty = 0 Then ld_qty = arg_s_mx[ll_i].planqty Else ld_qty = arg_s_mx[ll_i].qty End If ld_uqty = arg_s_mx[ll_i].uqty ElseIf arg_billtype = 1 And uo_option_inout_type > 0 And arg_s_mx[ll_i].ifpack = 0 And arg_s_mx[ll_i].ifpackpro = 0 Then If arg_s_mx[ll_i].qty = 0 Then ld_qty = arg_s_mx[ll_i].planqty Else ld_qty = arg_s_mx[ll_i].qty End If ld_uqty = arg_s_mx[ll_i].uqty End If Update u_mtrlware Set noauditingqty = noauditingqty - :ld_qty, noauditinguqty = noauditingqty - :ld_uqty Where scid = :arg_scid 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 For ll_i = 1 To j - 1 ld_qty = 0 ld_uqty = 0 If uo_option_inout_type > 0 Then If arg_s_mxmx[ll_i].ifpack = 1 Or arg_s_mxmx[ll_i].ifpackpro = 4 Or arg_s_mxmx[ll_i].ifpackpro = 3 Then If arg_s_mxmx[ll_i].qty = 0 Then ld_qty = arg_s_mxmx[ll_i].planqty Else ld_qty = arg_s_mxmx[ll_i].qty End If ld_uqty = ld_qty Update u_mtrlware Set noauditingqty = noauditingqty - :ld_qty, noauditinguqty = noauditingqty - :ld_uqty Where scid = :arg_scid And mtrlwareid = :arg_s_mxmx[ll_i].mtrlwareid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = '物料:'+String(arg_s_mxmx[ll_i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText Goto ext End If End If End If Next ext: Return rslt end function on uo_outware.create call super::create TriggerEvent( this, "constructor" ) end on on uo_outware.destroy TriggerEvent( this, "destructor" ) call super::destroy end on event constructor;String str_optionvalue,arg_msg //f_get_sys_option_value('030',str_optionvalue,arg_msg) //uo_option_autowaste = Long(str_optionvalue) // f_get_sys_option_value('142',str_optionvalue,arg_msg) uo_option_inout_type = Long(str_optionvalue) f_get_sys_option_value('205',str_optionvalue,arg_msg) uo_option_barcode_outwareother_paudit = Long(str_optionvalue) f_get_sys_option_value('025',str_optionvalue,arg_msg) uo_option_confirmaudit_sale = Long(str_optionvalue) f_get_sys_option_value('115',str_optionvalue,arg_msg) uo_option_sale_use_planqty = Long(str_optionvalue) f_get_sys_option_value('006',str_optionvalue,arg_msg) uo_option_confirmaudit_scll = Long(str_optionvalue) f_get_sys_option_value('022',str_optionvalue,arg_msg) uo_option_cost_dec = Long(str_optionvalue) f_get_sys_option_value('029',str_optionvalue,arg_msg) uo_option_change_status = str_optionvalue f_get_sys_option_value('027',str_optionvalue,arg_msg) uo_option_change_woodcode = str_optionvalue f_get_sys_option_value('028',str_optionvalue,arg_msg) uo_option_change_pcode = str_optionvalue f_get_sys_option_value('158',str_optionvalue,arg_msg) uo_option_mtrlware_autocmp = Long(str_optionvalue) f_get_sys_option_value('037',str_optionvalue,arg_msg) uo_option_mtrlware_limit = Long(str_optionvalue) f_get_sys_option_value('200',str_optionvalue,arg_msg) uo_option_if_saleout = Long(str_optionvalue) f_get_sys_option_value('154',str_optionvalue,arg_msg) uo_option_if_pricetype = Long(str_optionvalue) f_get_sys_option_value('056',str_optionvalue,arg_msg) uo_option_checkprice_native = Long(str_optionvalue) f_get_sys_option_value('292',str_optionvalue,arg_msg) uo_option_disuse_outware_sale = Long(str_optionvalue) f_get_sys_option_value('300',str_optionvalue,arg_msg) uo_option_sale_ifuse_negativeprice = Long(str_optionvalue) f_get_sys_option_value('310',str_optionvalue,arg_msg) uo_option_pda_sale_lock = Long(str_optionvalue) f_get_sys_option_value('238',str_optionvalue,arg_msg) uo_option_price_rmb = Long(str_optionvalue) f_get_sys_option_value('320',str_optionvalue,arg_msg) uo_option_outware_sale_checkprice = Long(str_optionvalue) f_get_sys_option_value('123',str_optionvalue,arg_msg) uo_option_scll_use_planqty = Long(str_optionvalue) f_get_sys_option_value('287',str_optionvalue,arg_msg) uo_option_barcodelocation_use_inwaremx_location = Long(str_optionvalue) f_get_sys_option_value('378',str_optionvalue,arg_msg) uo_option_djqty_check = long(str_optionvalue) f_get_sys_option_value('147',str_optionvalue,arg_msg) uo_option_outware_saleout = Long(str_optionvalue) f_get_sys_option_value('248',str_optionvalue,arg_msg) uo_option_scllplan_outware_auto = Long(str_optionvalue) f_get_sys_option_value('390',str_optionvalue,arg_msg) uo_option_noauditingqty_mode = Long(str_optionvalue) f_get_sys_option_value('395',str_optionvalue,arg_msg) uo_option_outware_pack_save_cmp = Long(str_optionvalue) f_get_sys_option_value('397',str_optionvalue,arg_msg) uo_option_pk_notauditqty_check = Long(str_optionvalue) f_get_sys_option_value('417',str_optionvalue,arg_msg) uo_option_canpack_ifzanyong = Long(str_optionvalue) end event