$PBExportHeader$uo_wfjg_py.sru forward global type uo_wfjg_py from nonvisualobject end type end forward global type uo_wfjg_py from nonvisualobject end type global uo_wfjg_py uo_wfjg_py type variables PUBLIC PROTECTEDWRITE Long scid = 0 //分部id PUBLIC PROTECTEDWRITE Long outwareid //进仓单表自动增量id PUBLIC PROTECTEDWRITE String outwarecode //单据的唯一编号 PUBLIC PROTECTEDWRITE Int billtype = 0 //业务类型 //billtype = 4 正常出仓 //billtype =16 加工商盘盈 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 //审核操作员 Long relid = 0 //关联id DateTime outdate //进仓发生时间 String outrep = '' //经手人 String part = '' //相关号码 String dscrp = '' //备注 Long sptid = 0 //供应户id String sptname = '' //供应商名称  Int thflag = 0 //退货标记 Boolean if_getid_ture = TRUE Transaction commit_transaction //数据commit事务 s_outwaremx_wfjg outwaremx[] //明细结构数组 Long it_mxbt = 0 //明细结构数组末指针 Boolean it_newbegin = FALSE //新建标志 Boolean it_updatebegin = FALSE //修改标志 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 del (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit) 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_sptware (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, string arg_woodcode, string arg_pcode, ref string arg_msg) public function integer acceptmx (long arg_mtrlwareid, decimal arg_uqty, string arg_uunit, decimal arg_qty, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_mtrlid, long arg_storageid, integer arg_dxflag, string arg_plancode, string arg_mtrlcode, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_fprice, decimal arg_rebate, long arg_sptid, decimal arg_rate, string arg_jgdscrp, string arg_mxdscrp2) end prototypes public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg);//==================================================================== // Function: newbegin(long arg_scid,int arg_billtype,ref string arg_msg) //-------------------------------------------------------------------- // Description: 从置对象,设定业务类型,准备建立新进仓单 //-------------------------------------------------------------------- // Arguments: // value long arg_scid // value integer arg_billtype // reference string arg_msg //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: yyx Date: 2003.11.12 //-------------------------------------------------------------------- // Modify History: // //==================================================================== int rslt=1 if arg_scid < 0 then arg_msg = '请选择分部' rslt = 0 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,cnt = 0,i DateTime server_dt Long ls_newid String ls_sccode IF IsNull(relid) THEN relid = 0 IF IsNull(outrep) THEN outrep = '' IF IsNull(dscrp) THEN dscrp = '' IF IsNull(part) THEN part = '' IF IsNull(sptid) THEN sptid = 0 IF IsNull(sptname) THEN sptname = '' IF IsNull(thflag) THEN thflag = 0 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 IF Year(Date(outdate)) < 2000 OR IsNull(outdate) THEN rslt = 0 arg_msg = "缺少出仓发生时间或不合理" GOTO ext END IF //==================================================================== // Script - save ( boolean arg_ifcommit, ref string arg_msg ) // Reason: //-------------------------------------------------------------------- // Modified By: yyx Date: 2004.01.02 //-------------------------------------------------------------------- IF DaysAfter(Date(String(server_dt,'yyyy-mm-dd')),Date(String(outdate,'yyyy-mm-dd'))) > sys_option_input_days THEN rslt = 0 arg_msg = '出仓日期错误,日期不能超前系统日期' GOTO ext END IF IF DaysAfter(Date(String(outdate,'yyyy-mm-dd')),Date(String(server_dt,'yyyy-mm-dd'))) > sys_option_input_days THEN rslt = 0 arg_msg = '出仓日期错误,日期不能落后系统日期' GOTO ext END IF //==================================================================== SELECT name INTO :sptname FROM u_spt Where sptid = :sptid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,加工商资料" GOTO ext END IF ////////////////////////////////////////////////开始区分:新建/更新 处理 IF outwareid = 0 THEN //新建 ls_newid = f_sys_scidentity(scid,"ow_wfjg_out","outwareid",arg_msg,if_getid_ture,commit_transaction) IF ls_newid <= 0 THEN rslt = 0 GOTO ext END IF //取分部代号 IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF //取得新单据编号 IF thflag = 0 THEN IF billtype = 5 THEN outwarecode = getid(scid,ls_sccode + 'WF',Date(server_dt),if_getid_ture,commit_transaction) ELSEIF billtype = 9 THEN outwarecode = getid(scid,ls_sccode + 'WY',Date(server_dt),if_getid_ture,commit_transaction) ELSEIF billtype = 10 THEN outwarecode = getid(scid,ls_sccode + 'FI',Date(server_dt),if_getid_ture,commit_transaction) END IF ELSE outwarecode = getid(scid,ls_sccode + 'OF',Date(server_dt),if_getid_ture,commit_transaction) END IF IF outwarecode = "err" THEN outwarecode = '' rslt = 0 arg_msg = "无法获取出仓单编号"+"~n"+commit_transaction.SQLErrText GOTO ext END IF INSERT INTO ow_wfjg_out ( scid, outwareid, outwarecode, billtype, relid, outdate, outrep, part, dscrp, sptid, sptname, thflag, opdate, opemp) VALUES ( :scid, :ls_newid, :outwarecode, :billtype, :relid, :outdate, :outrep, :part, :dscrp, :sptid, :sptname, :thflag, :server_dt, :publ_operator ) USING commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'pk_ow_wfjg_out') > 0 THEN arg_msg = '插入操作失败,关键字分部ID、单据ID重复' ELSEIF Pos(Lower(commit_transaction.SQLErrText),'ix_ow_wfjg_inspt') > 0 THEN arg_msg = '插入操作失败,单据编号重复' ELSE arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF //读取新outwareid outwareid = ls_newid FOR i = 1 TO it_mxbt INSERT INTO ow_wfjgmx_out (scid, storageid, outwareid, mtrlwareid, printid, mtrlid, plancode, status, qty, fprice, rebate, price, mxdscrp, costamt, ifrel, relid, woodcode, relcode, pcode, cost, uqty, uunit, rate, uprice, jgdscrp, mxdscrp2) VALUES ( :scid, :outwaremx[i].storageid, :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].mxdscrp, :outwaremx[i].costamt, :outwaremx[i].ifrel, :outwaremx[i].relid, :outwaremx[i].woodcode, :outwaremx[i].relcode, :outwaremx[i].pcode, :outwaremx[i].cost, :outwaremx[i].uqty, :outwaremx[i].uunit, :outwaremx[i].rate, :outwaremx[i].uprice, :outwaremx[i].jgdscrp, :outwaremx[i].mxdscrp2) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN outwareid = 0 //还原outwareid rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'pk_ow_wfjgmx_out') > 0 THEN arg_msg = '插入明细操作失败,关键字分部ID、单据ID、明细ID重复' ELSE arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF NEXT ELSE //////////////////////////////////////////////////更新 UPDATE ow_wfjg_out SET billtype = :billtype, relid = :relid, outdate = :outdate, outrep = :outrep, part = :part, dscrp = :dscrp, sptid = :sptid, sptname = :sptname, thflag = :thflag, moddate = :server_dt, modemp = :publ_operator WHERE ow_wfjg_out.outwareid = :outwareid AND ow_wfjg_out.scid = :scid AND flag = 0 USING commit_transaction; IF commit_transaction.SQLCode <> 0 OR commit_transaction.SQLNRows <= 0 THEN rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'pk_ow_wfjg_out') > 0 THEN arg_msg = '插入操作失败,关键字分部ID、单据ID重复' ELSEIF Pos(Lower(commit_transaction.SQLErrText),'ix_ow_wfjg_inspt') > 0 THEN arg_msg = '插入操作失败,单据编号重复' ELSE arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF //删除原有明细 DELETE FROM ow_wfjgmx_out WHERE ow_wfjgmx_out.outwareid = :outwareid AND ow_wfjgmx_out.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 INSERT INTO ow_wfjgmx_out (scid, storageid, outwareid, mtrlwareid, printid, mtrlid, plancode, status, qty, fprice, rebate, price, mxdscrp, costamt, ifrel, relid, woodcode, relcode, pcode, cost, uqty, uunit, rate, uprice, jgdscrp, mxdscrp2) VALUES ( :scid, :outwaremx[i].storageid, :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].mxdscrp, :outwaremx[i].costamt, :outwaremx[i].ifrel, :outwaremx[i].relid, :outwaremx[i].woodcode, :outwaremx[i].relcode, :outwaremx[i].pcode, :outwaremx[i].cost, :outwaremx[i].uqty, :outwaremx[i].uunit, :outwaremx[i].rate, :outwaremx[i].uprice, :outwaremx[i].jgdscrp, :outwaremx[i].mxdscrp2) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'pk_ow_wfjgmx_out') > 0 THEN arg_msg = '插入明细操作失败,关键字分部ID、单据ID、明细ID重复' ELSE arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF NEXT 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 IF thflag = 0 THEN arg_msg = '车间外协发出单,'+ arg_msg ELSE arg_msg = '车间外协退回单,'+ arg_msg END IF RETURN rslt end function public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i Dec new_noallocqty = 0 Long ls_newid IF outwareid = 0 THEN rslt = 0 arg_msg = "没有审核对象" GOTO ext END IF IF it_newbegin OR it_updatebegin THEN rslt = 0 arg_msg = "编辑状态下不可以执行审核" GOTO ext END IF IF flag = 1 THEN rslt = 0 arg_msg = "单据已经审核" GOTO ext END IF UPDATE ow_wfjg_out SET Auditingemp = :publ_operator, Auditingdate = getdate(), flag = 1 WHERE ow_wfjg_out.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 = "单据正在审核,请稍后查询。" GOTO ext END IF Long ll_orderid uo_order_wfjg uo_wfjg uo_wfjg = CREATE uo_order_wfjg uo_wfjg.commit_transaction = commit_transaction //更新供应商库存 FOR i = 1 TO it_mxbt // IF p_update_sptware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, & // outwaremx[i].mtrlcode, outwaremx[i].plancode,& // outwaremx[i].status, outwaremx[i].qty, outwaremx[i].costamt,& // outwaremx[i].planprice, sptid, & // outwaremx[i].woodcode, outwaremx[i].pcode,arg_msg) = 0 THEN // rslt = 0 // GOTO ext // END IF IF f_update_mtrlware_spt_out (billtype,thflag,scid,outwaremx[i].mtrlid, & outwaremx[i].mtrlcode, outwaremx[i].plancode,& outwaremx[i].status, outwaremx[i].qty, outwaremx[i].costamt,& outwaremx[i].planprice, sptid, & outwaremx[i].woodcode, outwaremx[i].pcode,arg_msg,& FALSE,commit_transaction) = 0 THEN rslt = 0 GOTO ext END IF IF outwaremx[i].relid > 0 THEN IF uo_wfjg.addmxcmpl_out(scid,outwaremx[i].relid,outwaremx[i].mtrlid,0,outwaremx[i].status,& outwaremx[i].woodcode,outwaremx[i].pcode,outwaremx[i].qty,& arg_msg,FALSE) = 0 THEN rslt = 0 GOTO ext END IF END IF NEXT flag = 1 ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT USING commit_transaction; END IF if thflag = 0 then arg_msg = '车间外协发出单,'+ arg_msg else arg_msg = '车间外协退回单,'+ arg_msg end if RETURN rslt end function public function integer updatebegin (long arg_scid, long arg_outwareid, integer arg_billtype, ref string arg_msg);//==================================================================== // Function: updatebegin(arg_scid,arg_inwareid,arg_billtype,arg_msg) //-------------------------------------------------------------------- // Description: 从置对象,设定业务类型与关联ID,准备更新进仓单 //-------------------------------------------------------------------- // Arguments: // value long arg_scid // value long arg_inwareid // value integer arg_billtype // reference string arg_msg //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: yyx Date: 2003.11.12 //-------------------------------------------------------------------- // Modify History: // //==================================================================== long rslt=1 if arg_scid < 0 then arg_msg = '请选择分部' rslt = 0 goto ext end if if arg_outwareid<=0 then rslt=0 goto ext end if rslt=p_getinfo(arg_scid,arg_outwareid,arg_msg) if rslt=0 then goto ext if flag=1 then rslt=0 arg_msg='单据已经审核,不可以修改' goto ext 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() if thflag = 0 then arg_msg = '车间外协发出单,'+ arg_msg else arg_msg = '车间外协退回单,'+ arg_msg end if 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,i = 1,no_mxcheck = 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 //用游标读取明细 DECLARE cur_inwaermx CURSOR FOR SELECT ow_wfjgmx_out.printid, ow_wfjgmx_out.mtrlid, ow_wfjgmx_out.plancode, ow_wfjgmx_out.status, ow_wfjgmx_out.qty, ow_wfjgmx_out.fprice, ow_wfjgmx_out.rebate, ow_wfjgmx_out.price, ow_wfjgmx_out.mxdscrp, u_mtrldef.mtrlcode, ow_wfjgmx_out.mtrlwareid, ow_wfjgmx_out.storageid, ow_wfjgmx_out.costamt, ow_wfjgmx_out.ifrel, ow_wfjgmx_out.relid, ow_wfjgmx_out.woodcode, ow_wfjgmx_out.pcode, ow_wfjgmx_out.cost, ow_wfjgmx_out.uprice, ow_wfjgmx_out.uqty, ow_wfjgmx_out.rate, ow_wfjgmx_out.uunit, ow_wfjgmx_out.mxdscrp2 FROM ow_wfjgmx_out,u_mtrldef,ow_wfjg_out WHERE ow_wfjg_out.outwareid = :arg_outwareid AND ow_wfjgmx_out.mtrlid = u_mtrldef.mtrlid AND ow_wfjg_out.scid = :arg_scid AND ow_wfjg_out.outwareid = ow_wfjgmx_out.outwareid AND ow_wfjg_out.scid = ow_wfjgmx_out.scid USING commit_transaction; OPEN cur_inwaermx; FETCH cur_inwaermx 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].mtrlwareid,:outwaremx[i].storageid, :outwaremx[i].costamt,:outwaremx[i].ifrel, :outwaremx[i].relid, :outwaremx[i].woodcode,:outwaremx[i].pcode, :outwaremx[i].cost,:outwaremx[i].uprice, :outwaremx[i].uqty, :outwaremx[i].rate, :outwaremx[i].uunit, :outwaremx[i].mxdscrp2; DO WHILE commit_transaction.SQLCode = 0 i++ FETCH cur_inwaermx 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].mtrlwareid,:outwaremx[i].storageid, :outwaremx[i].costamt,:outwaremx[i].ifrel, :outwaremx[i].relid, :outwaremx[i].woodcode,:outwaremx[i].pcode, :outwaremx[i].cost,:outwaremx[i].uprice, :outwaremx[i].uqty, :outwaremx[i].rate, :outwaremx[i].uunit, :outwaremx[i].mxdscrp2; LOOP CLOSE cur_inwaermx; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck FROM ow_wfjgmx_out,u_mtrldef,ow_wfjg_out WHERE ow_wfjg_out.outwareid = :arg_outwareid AND ow_wfjgmx_out.mtrlid = u_mtrldef.mtrlid AND ow_wfjg_out.scid = :arg_scid AND ow_wfjg_out.outwareid = ow_wfjgmx_out.outwareid AND ow_wfjg_out.scid = ow_wfjgmx_out.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 outwareid = arg_outwareid scid = arg_scid it_mxbt = i - 1 it_newbegin = FALSE it_updatebegin = FALSE ext: IF rslt = 0 THEN p_reset() RETURN rslt end function public function integer del (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);//如果单据还没有审核删除单据极其明细 //0 FAIL, 1 SUCCESS Int rslt = 1 IF arg_outwareid <= 0 THEN rslt = 0 arG_MSG = "没有删除对象,操作取消" GOTO ext END IF p_getinfo(arg_scid,arg_outwareid,arg_msg) IF flag = 1 THEN rslt = 0 arG_MSG = "单据已经审核,不可以删除" GOTO ext END IF DELETE FROM ow_wfjg_out WHERE ow_wfjg_out.outwareid = :arg_outwareid AND ow_wfjg_out.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 ow_wfjgmx_out WHERE ow_wfjgmx_out.outwareid = :arg_outwareid AND ow_wfjgmx_out.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 if thflag = 0 then arg_msg = '车间外协发出单,'+ arg_msg else arg_msg = '车间外协退回单,'+ arg_msg end if RETURN (rslt) end function public function integer add_dscrp (long arg_scid, long arg_outwareid, string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart) //0 fail 1 success Int rslt = 1 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 flag = 0 THEN rslt = 0 arg_msg = "非审核状态下不可用" GOTO ext END IF UPDATE u_outware SET dscrp = dscrp+' '+:arg_newdescppart WHERE u_outware.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: IF thflag = 0 THEN arg_msg = '车间外协发出单,'+ arg_msg ELSE arg_msg = '车间外协退回单,'+ arg_msg END IF Return (rslt) end function public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg); Long rslt = 1,cnt = 0,i Long ls_newid DateTime null_dt SetNull(null_dt) IF outwareid = 0 THEN rslt = 0 arg_msg = "没有审核对象" GOTO ext END IF IF it_newbegin OR it_updatebegin THEN rslt = 0 arg_msg = "编辑状态下不可以执行审核" GOTO ext END IF IF flag = 0 THEN rslt = 0 arg_msg = "单据还未审核" GOTO ext END IF IF balcflag = 1 THEN rslt = 0 arg_msg = "单据已经日结,不能撤审" GOTO ext END IF UPDATE ow_wfjg_out SET Auditingemp = '', Auditingdate = :null_dt, flag = 0 WHERE ow_wfjg_out.outwareid = :outwareid AND flag = 1 AND scid = :scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext ELSEIF commit_transaction.SQLNRows = 0 THEN rslt = 0 arg_msg = "单据正在撤审,请稍后查询。" GOTO ext END IF uo_order_wfjg uo_wfjg uo_wfjg=create uo_order_wfjg uo_wfjg.commit_transaction=commit_transaction FOR i = 1 TO it_mxbt // IF p_update_sptware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, & // outwaremx[i].mtrlcode, outwaremx[i].plancode,& // outwaremx[i].status, 0 - outwaremx[i].qty, 0 - outwaremx[i].costamt,& // outwaremx[i].planprice, sptid, & // outwaremx[i].woodcode, outwaremx[i].pcode,arg_msg) = 0 THEN // rslt = 0 // GOTO ext // END IF IF f_update_mtrlware_spt_out(billtype,thflag,scid,outwaremx[i].mtrlid, & outwaremx[i].mtrlcode, outwaremx[i].plancode,& outwaremx[i].status, 0 - outwaremx[i].qty, 0 - outwaremx[i].costamt,& outwaremx[i].planprice, sptid, & outwaremx[i].woodcode, outwaremx[i].pcode,arg_msg,false,commit_transaction) = 0 THEN rslt = 0 GOTO ext END IF IF outwaremx[i].relid > 0 THEN IF uo_wfjg.addmxcmpl_out(scid,outwaremx[i].relid,outwaremx[i].mtrlid,0,outwaremx[i].status,& outwaremx[i].woodcode,outwaremx[i].pcode,0 - outwaremx[i].qty,& arg_msg,FALSE) = 0 THEN rslt = 0 GOTO ext END IF end if NEXT flag = 0 ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT USING commit_transaction; END IF if thflag = 0 then arg_msg = '车间外协发出单,'+ arg_msg else arg_msg = '车间外协退回单,'+ arg_msg end if RETURN rslt end function public function integer p_clearmx ();//int p_clearmx() //清除明细 it_mxbt=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 ow_wfjg_out.outwarecode, ow_wfjg_out.billtype, ow_wfjg_out.relid, ow_wfjg_out.outdate, ow_wfjg_out.outrep, ow_wfjg_out.part, ow_wfjg_out.sptid, ow_wfjg_out.sptname, ow_wfjg_out.dscrp, ow_wfjg_out.thflag, ow_wfjg_out.flag, ow_wfjg_out.balcflag INTO :outwarecode, :billtype, :relid, :outdate, :outrep, :part, :sptid, :sptname, :dscrp, :thflag, :flag, :balcflag FROM ow_wfjg_out WHERE ow_wfjg_out.outwareid = :arg_outwareid and scid=:arg_scid using commit_transaction; if commit_transaction.sqlcode<>0 then rslt=0 if pos(lower(commit_transaction.SQLErrText),'more than') > 0 then arg_msg = '查询操作失败,查询数据返回值多于一个' else arG_MSG="查询操作失败(错误出仓单唯一码)" end if 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 = '' flag = 0 relid = 0 //storageid = 0 outrep = '' part = '' dscrp = '' sptid = 0 sptname = '' thflag = 0 it_newbegin = FALSE it_updatebegin = FALSE //清除明细 p_clearmx() RETURN 1 end function public function integer p_update_sptware (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, string arg_woodcode, string arg_pcode, ref string arg_msg);Int rslt = 1 Long ls_newid Decimal ld_cost UPDATE ow_wfjgware SET noallocqty = noallocqty + :arg_qty , wareamt = wareamt + :arg_costamt, cost = case noallocqty + :arg_qty when 0 then cost else round((wareamt + :arg_costamt)/(noallocqty + :arg_qty),10) END , waredate = getdate() WHERE ( mtrlid = :arg_mtrlid ) AND ( scid = :scid ) AND (status = :arg_Status) AND woodcode = :arg_woodcode AND pcode = :arg_pcode AND plancode = :arg_plancode AND sptid = :arg_sptid USING commit_transaction ; IF commit_transaction.SQLCode = 0 THEN IF commit_transaction.SQLNRows = 0 THEN ls_newid = f_sys_scidentity(scid,"ow_wfjgware","mtrlwareid",arg_msg,FALSE,commit_transaction) IF ls_newid <= 0 THEN rslt = 0 GOTO ext END IF ld_cost = Round(arg_costamt/arg_qty,10) INSERT INTO ow_wfjgware ( scid, mtrlwareid, mtrlid, plancode, status, noallocqty, allocqty, wareamt, planprice, sptid, woodcode, pcode, cost) VALUES ( :scid, :ls_newid, :arg_mtrlid, :arg_plancode, :arg_status, :arg_qty, 0, :arg_costamt, :arg_planprice, :arg_sptid, :arg_woodcode, :arg_pcode, :ld_cost) USING commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 if pos(lower(commit_transaction.SQLErrText),'pk_ow_wfjgware') > 0 then arg_msg = '插入外协商库存操作失败,关键字分部ID、库存ID重复' else arg_msg = "因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText end if GOTO ext END IF END IF ELSE rslt = 0 String 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+"]同供应商仓库内同批号没有足够的库存支持冲减" ELSE arg_msg = "因网络或其它原因导致物料["+arg_mtrlcode+"]库存更新操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF //--------------------更新结存 Decimal ld_thqty,ld_thamt Decimal ld_inqty,ld_inamt Decimal ld_balcqty,ld_balcamt ld_balcqty = arg_qty ld_balcamt = arg_costamt IF thflag = 0 THEN ld_inqty = arg_qty ld_inamt = arg_costamt ld_thqty = 0 ld_thamt = 0 ELSE ld_inqty = 0 ld_inamt = 0 ld_thqty = 0 - arg_qty ld_thamt = 0 - arg_costamt END IF UPDATE ow_wfjgbalc SET balcqty = balcqty + :ld_balcqty, balcamt = balcamt + :ld_balcamt, inqty = inqty + :ld_inqty, inamt = inamt + :ld_inamt, thqty = thqty + :ld_thqty, thamt = thamt + :ld_thamt WHERE ( mtrlid = :arg_mtrlid ) AND ( balcdateint = 0 ) AND ( status = :arg_status ) AND ( woodcode = :arg_woodcode ) AND ( sptid = :arg_sptid ) USING commit_transaction ; IF commit_transaction.SQLCode = 0 THEN IF commit_transaction.SQLNRows = 0 THEN INSERT INTO ow_wfjgbalc (scid, balcdateint, sptid, mtrlid, status, woodcode, thqty, thamt, inqty, inamt, balcqty, balcamt) VALUES (:scid, 0, :arg_sptid, :arg_mtrlid, :arg_status, :arg_woodcode, :ld_thqty, :ld_thamt, :ld_inqty, :ld_inamt, :ld_balcqty, :ld_balcamt) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 if pos(lower(commit_transaction.SQLErrText),'pk_ow_wfjgbalc') > 0 then arg_msg = '插入外协商结存操作失败,关键字重复' 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+"]同仓库内同批号没有足够的结存支持冲减" ELSE arg_msg = "因网络或其它原因导致物料["+arg_mtrlcode+"]结存更新操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF ext: IF rslt = 0 THEN ROLLBACK; END IF RETURN rslt end function public function integer acceptmx (long arg_mtrlwareid, decimal arg_uqty, string arg_uunit, decimal arg_qty, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_mtrlid, long arg_storageid, integer arg_dxflag, string arg_plancode, string arg_mtrlcode, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_fprice, decimal arg_rebate, long arg_sptid, decimal arg_rate, string arg_jgdscrp, string arg_mxdscrp2);//此对象淘汰不用 Long rslt = 1,cnt = 0,LS_i Decimal i_planprice,ld_dftsaleprice Double i_newprice String ls_relcode IF it_newbegin = False And it_updatebegin = False THEN rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" 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_ifrel) THEN arg_ifrel = 0 IF IsNull(arg_relid) THEN arg_relid = 0 IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0 IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = '' IF IsNull(arg_plancode) THEN arg_plancode = '' IF IsNull(arg_status) THEN arg_status = '' IF IsNull(arg_fprice) THEN arg_fprice = 0 IF IsNull(arg_rebate) THEN arg_rebate = 0 IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = '' IF IsNull(arg_relid) THEN arg_relid = 0 IF IsNull(arg_ifrel) THEN arg_ifrel = 0 IF IsNull(arg_mxdscrp) THEN arg_woodcode = '' IF IsNull(arg_pcode) THEN arg_pcode = '' IF IsNull(arg_storageid) THEN arg_storageid = 0 IF IsNull(arg_uqty) THEN arg_uqty = 0 IF IsNull(arg_uunit) THEN arg_uunit = '' IF IsNull(arg_rate) THEN arg_rate = 1 IF IsNull(arg_jgdscrp) THEN arg_jgdscrp = '' IF IsNull(arg_mxdscrp2) THEN arg_mxdscrp2 = '' // 如果出仓数量为 0,或物料编号为空,则不作任何处理 IF arg_mtrlid = 0 Or arg_qty = 0 THEN rslt = 1 GOTO ext END IF IF sys_option_2unit = 1 THEN IF arg_uqty = 0 THEN arg_msg = '行:'+String(arg_printid)+ ',请输入计价数量' rslt = 0 GOTO ext END IF IF Trim(arg_uunit) = '' THEN arg_msg = '行:'+String(arg_printid)+ ',请输入计价单位' rslt = 0 GOTO ext END IF END IF //检查物料id SELECT planprice INTO :i_planprice FROM u_mtrldef Where u_mtrldef.mtrlid = :arg_mtrlid Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'more than') > 0 THEN arg_msg = '查询物料资料操作失败,查询数据返回值多于一个' ELSE arg_msg = "查询操作失败,编码:"+arg_mtrlcode END IF GOTO ext END IF IF f_check_status(1, arg_status) = 0 THEN rslt = 0 arg_msg = "查询操作失败,可能颜色未定义,编码:"+arg_mtrlcode+",颜色:"+arg_status GOTO ext END IF IF arg_ifrel = 1 THEN IF arg_relid = 0 THEN rslt = 0 arg_msg = '请选择加工计划!' GOTO ext END IF SELECT taskcode INTO :ls_relcode FROM u_order_wfjg Where wfjgID = :arg_relid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询加工计划号失败!没有对应的外加工计划' GOTO ext END IF SELECT count(*) INTO :cnt FROM u_order_wfjgMx_out WHERE wfjgid = :arg_relid AND mtrlid = :arg_mtrlid AND status = :arg_status Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询加工计划出仓明细失败!,外加工计划没有对应物料明细' GOTO ext END IF IF cnt = 0 THEN rslt = 0 arg_msg = '出仓物料:'+arg_mtrlcode+'不在加工计划出仓明细中!' GOTO ext END IF END IF //*********************************************** IF arg_fprice * arg_rebate < 0 THEN //检查进仓价 rslt = 0 arg_msg = "编码:" + String(arg_mtrlcode)+" 单价错误" GOTO ext END IF //写入内容 it_mxbt++ outwaremx[it_mxbt].mtrlwareid = arg_mtrlwareid outwaremx[it_mxbt].mtrlid = arg_mtrlid outwaremx[it_mxbt].status = arg_status outwaremx[it_mxbt].qty = arg_qty outwaremx[it_mxbt].storageid = arg_storageid outwaremx[it_mxbt].cost = arg_fprice outwaremx[it_mxbt].costamt = Round(arg_fprice * arg_qty,2) outwaremx[it_mxbt].newpriceamt = Round(i_newprice * arg_qty,2) //IF sys_option_buyprice_type = 1 THEN outwaremx[it_mxbt].plancode = arg_plancode //ELSE // outwaremx[it_mxbt].plancode = String(Round(arg_fprice * arg_rebate,10)) //END IF outwaremx[it_mxbt].planprice = i_planprice outwaremx[it_mxbt].mtrlcode = arg_mtrlcode outwaremx[it_mxbt].mxdscrp = arg_mxdscrp outwaremx[it_mxbt].mxdscrp2 = arg_mxdscrp2 outwaremx[it_mxbt].printid = arg_printid outwaremx[it_mxbt].rebate = arg_rebate outwaremx[it_mxbt].fprice = arg_fprice outwaremx[it_mxbt].price = Round(arg_fprice * arg_rebate,10) outwaremx[it_mxbt].sptid = arg_sptid outwaremx[it_mxbt].dxflag = arg_dxflag outwaremx[it_mxbt].ifrel = arg_ifrel outwaremx[it_mxbt].relid = arg_relid outwaremx[it_mxbt].rate = arg_rate outwaremx[it_mxbt].woodcode = arg_woodcode outwaremx[it_mxbt].pcode = arg_pcode outwaremx[it_mxbt].relcode = ls_relcode outwaremx[it_mxbt].jgdscrp = arg_jgdscrp IF sys_option_2unit = 0 THEN outwaremx[it_mxbt].uprice = arg_fprice outwaremx[it_mxbt].uqty = arg_qty ELSE outwaremx[it_mxbt].uprice = Round(arg_qty * arg_fprice/arg_uqty,5) outwaremx[it_mxbt].uqty = arg_uqty END IF outwaremx[it_mxbt].uunit = arg_uunit ext: IF rslt = 0 THEN p_clearmx() IF thflag = 0 THEN arg_msg = '车间外协发出单,'+ arg_msg ELSE arg_msg = '车间外协退回单,'+ arg_msg END IF RETURN rslt end function on uo_wfjg_py.create call super::create TriggerEvent( this, "constructor" ) end on on uo_wfjg_py.destroy TriggerEvent( this, "destructor" ) call super::destroy end on