1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282 |
- $PBExportHeader$uo_update_cost.sru
- forward
- global type uo_update_cost from nonvisualobject
- end type
- end forward
- global type uo_update_cost from nonvisualobject
- end type
- global uo_update_cost uo_update_cost
- type variables
- public protectedwrite long scid =0 //分部id
- public protectedwrite long wareid //进仓单表自动增量id
- public protectedwrite string warecode //单据的唯一编号
- public protectedwrite int billtype=0 //业务类型
- //业务类型
- //1-采购进仓[记帐模式]
- //2-采购进仓[不记帐模式]
- //3-成品进仓
- //8-其他进仓
- //9-盘盈进仓
- //12-调拨入仓
- public protectedwrite datetime opdate //建立时间,自动
- public protectedwrite string opemp //建立人
- public protectedwrite datetime modidate //修改时间,自动
- public protectedwrite string modiemp //修改操作员
- public protectedwrite int flag=0 //仓库审核标志
- public protectedwrite int balcflag=0 //仓库结存标志
- public protectedwrite datetime auditingdate //审核时间
- public protectedwrite string auditingrep //审核操作员
- long storageid=0 //进仓仓库
- datetime moddate //进仓发生时间
- string modrep='' //经手人
- string part='' //相关号码
- string dscrp='' //备注
- int relint_1
- int relint_2
- boolean if_getid_ture=true
- transaction commit_transaction //数据commit事务
- //uo_unit uo_unit_change
- s_inwaremx inwaremx[] //明细结构数组
- 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 p_clearmx ()
- public function integer p_reset ()
- public function integer updatebegin (long arg_scid, long arg_wareid, integer arg_billtype, ref string arg_msg)
- public function integer p_getinfo (long arg_scid, long arg_wareid, ref string arg_msg)
- public function integer getinfo (long arg_scid, long arg_wareid, ref string arg_msg)
- public function integer add_dscrp (long arg_scid, long arg_wareid, string arg_newdescppart, ref string arg_msg)
- public function integer del (long arg_scid, long arg_wareid, ref string arg_msg, boolean arg_ifcommit)
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer uof_create_inware (ref string arg_msg)
- public function integer acceptmx (long arg_printid, long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_newprice, string arg_mxdscrp, ref string arg_msg, string arg_woodcode, string arg_pcode, decimal arg_cost, decimal arg_newcost, decimal arg_amt, decimal arg_planprice, string arg_unit, decimal arg_cost_notax, decimal arg_newcost_notax)
- 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
- //if not (arg_billtype=1 or arg_billtype=2 or arg_billtype=3 or arg_billtype=4 or arg_billtype=8 or arg_billtype=9 or arg_billtype=12 or arg_billtype=15) 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+'8-其他进仓,'
- // arg_msg=arg_msg+'9-盘盈进仓,'
- // arg_msg=arg_msg+'12-调拨进仓'
- // arg_msg=arg_msg+'15-拆装进仓'
- // 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(storageid) THEN storageid = 0
- IF IsNull(modrep) THEN modrep = ''
- IF IsNull(dscrp) THEN dscrp = ''
- IF IsNull(part) THEN part = ''
- 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
- cnt = 0
- //检查仓库
- SELECT count(*)
- INTO :cnt
- FROM u_storage
- Where u_storage.storageid = :storageid 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 = "错误的仓库编号: "+String(storageid)
- GOTO ext
- END IF
- IF Year(Date(moddate)) < 2000 OR IsNull(moddate) 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(moddate,'yyyy-mm-dd'))) > sys_option_input_days THEN
- rslt = 0
- arg_msg = '更新日期错误,日期不能超前系统日期'
- GOTO ext
- END IF
- IF DaysAfter(Date(String(moddate,'yyyy-mm-dd')),Date(String(server_dt,'yyyy-mm-dd'))) > sys_option_input_days THEN
- rslt = 0
- arg_msg = '更新日期错误,日期不能落后系统日期'
- GOTO ext
- END IF
- ////////////////////////////////////////////////开始区分:新建/更新 处理
- IF wareid = 0 THEN //新建
- ls_newid = f_sys_scidentity(scid,"u_updatecost","wareid",arg_msg,if_getid_ture,commit_transaction)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取分部代号
- IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取得新单据编号
- CHOOSE CASE billtype
- CASE 1,2
- warecode = getid(scid,ls_sccode + 'CG',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 3
- warecode = getid(scid,ls_sccode + 'CP',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 4
- warecode = getid(scid,ls_sccode + 'WI',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 8
- warecode = getid(scid,ls_sccode + 'JC',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 9
- warecode = getid(scid,ls_sccode + 'PY',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 12
- warecode = getid(scid,ls_sccode + 'IC',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 15
- warecode = getid(scid,ls_sccode + 'DI',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 0
- warecode = getid(scid,ls_sccode + 'JG',Date(server_dt),if_getid_ture,commit_transaction)
- END CHOOSE
-
- IF warecode = "err" THEN
- warecode = ''
- rslt = 0
- arg_msg = "无法获取进仓单编号"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- INSERT INTO u_updatecost (
- scid,
- wareid,
- warecode,
- storageid,
- part,
- moddate,
- modrep,
- dscrp,
- opdate,
- opemp)
- VALUES (
- :scid,
- :ls_newid,
- :warecode,
- :storageid,
- :part,
- :moddate,
- :modrep,
- :dscrp,
- :server_dt,
- :publ_operator) USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
-
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_updatecost') > 0 THEN
- arg_msg = '插入单据资料失败,关键字ID重复'
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),'IX_u_updatecost') > 0 THEN
- arg_msg = '插入单据资料失败,单据编号重复'
- ELSE
- arg_msg = '因网络或其它原因导致插入单据资料失败,'+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
-
- //读取新inwareid
- wareid = ls_newid
-
- FOR i = 1 TO it_mxbt
- INSERT INTO u_updatecostmx
- (scid,
- wareid,
- mtrlwareid,
- mtrlid,
- plancode,
- status,
- mxdscrp,
- noallocqty,
- wareamt,
- planprice,
- newprice,
- woodcode,
- pcode,
- cost,
- newcost,
- printid,
- waredscrp,
- inworkdate,
- cost_notax,
- newcost_notax)
- VALUES (
- :scid,
- :ls_newid,
- :inwaremx[i].mtrlwareid,
- :inwaremx[i].mtrlid,
- :inwaremx[i].plancode,
- :inwaremx[i].status,
- :inwaremx[i].mxdscrp,
- :inwaremx[i].qty,
- :inwaremx[i].amt,
- :inwaremx[i].planprice,
- :inwaremx[i].fprice,
- :inwaremx[i].woodcode,
- :inwaremx[i].pcode,
- :inwaremx[i].cost,
- :inwaremx[i].newcost,
- :inwaremx[i].printid,
- :inwaremx[i].waredscrp,
- :inwaremx[i].inworkdate,
- :inwaremx[i].cost_notax,
- :inwaremx[i].newcost_notax) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- wareid = 0 //还原inwareid
- rslt = 0
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_updatecostmx') > 0 THEN
- arg_msg = '插入单据明细资料失败,关键字ID,序号重复'
- ELSE
- arg_msg = '因网络或其它原因导致插入单据明细资料失败,'+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
- NEXT
- ELSE //////////////////////////////////////////////////更新
- UPDATE u_updatecost
- SET
- storageid = :storageid,
- moddate = :moddate,
- modrep = :modrep,
- part = :part,
- dscrp = :dscrp,
- modidate = :server_dt,
- modiemp = :publ_operator
- WHERE u_updatecost.wareid = :wareid
- AND u_updatecost.scid = :scid
- AND flag = 0 USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 OR commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //删除原有明细
- DELETE FROM u_updatecostmx
- WHERE u_updatecostmx.wareid = :wareid
- AND u_updatecostmx.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 u_updatecostmx
- (scid,
- wareid,
- mtrlwareid,
- mtrlid,
- plancode,
- status,
- mxdscrp,
- noallocqty,
- wareamt,
- planprice,
- newprice,
- woodcode,
- pcode,
- cost,
- newcost,
- printid,
- waredscrp,
- inworkdate,
- cost_notax,
- newcost_notax)
- VALUES (
- :scid,
- :wareid,
- :inwaremx[i].mtrlwareid,
- :inwaremx[i].mtrlid,
- :inwaremx[i].plancode,
- :inwaremx[i].status,
- :inwaremx[i].mxdscrp,
- :inwaremx[i].qty,
- :inwaremx[i].amt,
- :inwaremx[i].planprice,
- :inwaremx[i].fprice,
- :inwaremx[i].woodcode,
- :inwaremx[i].pcode,
- :inwaremx[i].cost,
- :inwaremx[i].newcost,
- :inwaremx[i].printid,
- :inwaremx[i].waredscrp,
- :inwaremx[i].inworkdate,
- :inwaremx[i].cost_notax,
- :inwaremx[i].newcost_notax) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_updatecostmx') > 0 THEN
- arg_msg = '插入单据明细资料失败,关键字ID,序号重复'
- ELSE
- arg_msg = '因网络或其它原因导致插入单据明细资料失败,'+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
- RETURN rslt
- end function
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg);//====================================================================
- // Function: auditing(arg_ifcommit,arg_msg)
- //--------------------------------------------------------------------
- // Description: 审核单据
- //--------------------------------------------------------------------
- // Arguments:
- // value boolean arg_ifcommit
- // reference string arg_msg
- //--------------------------------------------------------------------
- // Returns: integer
- //--------------------------------------------------------------------
- // Author: yyx Date: 2003.11.12
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- Long rslt = 1,cnt = 0,i
- Dec new_noallocqty = 0
- Long ls_newid
- IF wareid = 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
- IF uof_create_inware(arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- UPDATE u_updatecost
- SET auditingrep = :publ_operator,
- auditingdate = getdate(),
- flag = 1
- WHERE u_updatecost.wareid = :wareid
- 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
- 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_in_other
- RETURN rslt
- end function
- public function integer p_clearmx ();//int p_clearmx()
- //清除明细
- it_mxbt=0
- return 1
- end function
- public function integer p_reset ();//int p_reset()
- //清除对象及其明细
- scid=0
- wareid=0
- warecode=''
- billtype=0
- opemp=''
- modiemp=''
- auditingrep=''
- flag=0
- storageid=0
- modrep=''
- part=''
- dscrp=''
- it_newbegin=false
- it_updatebegin=false
- //清除明细
- p_clearmx()
- return 1
- end function
- public function integer updatebegin (long arg_scid, long arg_wareid, 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_wareid<=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=8 or arg_billtype=9 or arg_billtype=12) 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+'8-其他进仓,'
- // arg_msg=arg_msg+'9-盘盈进仓,'
- // arg_msg=arg_msg+'12-调拨进仓'
- // goto ext
- //end if
- //if arg_billtype=12 then
- // rslt=0
- // arg_msg='单据类型:12-调拨进仓>>不能修改'
- // goto ext
- //end if
- //
- rslt=p_getinfo(arg_scid,arg_wareid,arg_msg)
- if rslt=0 then goto ext
- if flag=1 then
- rslt=0
- arg_msg='单据已经审核,不可以修改'
- goto ext
- end if
- wareid=arg_wareid
- 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 p_getinfo (long arg_scid, long arg_wareid, ref string arg_msg);//p_getinfo(arg_scid,arg_inwareid,arg_msg)
- //0 失败 1成功
- INT rslt=1
- IF arg_wareid<=0 THEN
- rslt=0
- arG_MSG="非法进仓单唯一码"
- goto ext
- end if
-
- SELECT u_updatecost.warecode,
- u_updatecost.storageid,
- u_updatecost.moddate,
- u_updatecost.modrep,
- u_updatecost.part,
- u_updatecost.dscrp,
- u_updatecost.modidate,
- u_updatecost.modiemp,
- u_updatecost.auditingdate,
- u_updatecost.auditingrep,
- u_updatecost.flag,
- u_updatecost.relint_1
- INTO :warecode,
- :storageid,
- :moddate,
- :modrep,
- :part,
- :dscrp,
- :modidate,
- :modiemp,
- :auditingdate,
- :auditingrep,
- :flag,
- :relint_1
- FROM u_updatecost
- WHERE u_updatecost.wareid = :arg_wareid
- and scid=:arg_scid
- using commit_transaction;
- if commit_transaction.sqlcode<>0 then
- rslt=0
- arG_MSG="查询操作失败(错误进仓单唯一码),进仓单"+commit_transaction.sqlerrtext
- goto ext
- end if
- wareid = arg_wareid
- scid = arg_scid
- ext:
- IF rslt=0 THEN p_reset()
- return rslt
- end function
- public function integer getinfo (long arg_scid, long arg_wareid, ref string arg_msg);//getinfo(arg_scid,arg_inwareid,arg_msg)
- //0 失败 1成功
- Int rslt = 1,i = 1,no_mxcheck = 0
- IF arg_wareid <= 0 THEN
- rslt = 0
- arg_msg = "非法进仓单唯一码"
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_wareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- //用游标读取明细
- DECLARE cur_waremx CURSOR FOR
- SELECT u_updatecostmx.printid,
- u_updatecostmx.mtrlwareid,
- u_updatecostmx.mtrlid,
- u_updatecostmx.plancode,
- u_updatecostmx.status,
- u_updatecostmx.noallocqty,
- u_updatecostmx.newprice,
- u_updatecostmx.planprice,
- u_updatecostmx.mxdscrp,
- u_mtrldef.mtrlcode,
- u_updatecostmx.woodcode,
- u_updatecostmx.pcode,
- u_updatecostmx.cost,
- u_updatecostmx.newcost,
- u_mtrldef.unit,
- u_mtrldef.mtrlcode,
- u_updatecostmx.waredscrp,
- u_updatecostmx.inworkdate,
- u_mtrlware.sptid,
- u_updatecostmx.cost_notax,
- u_updatecostmx.newcost_notax
- FROM u_updatecostmx,u_mtrldef,u_updatecost ,u_mtrlware
- WHERE u_updatecost.wareid = :arg_wareid AND
- u_updatecostmx.mtrlid = u_mtrldef.mtrlid AND
- u_updatecost.scid = :arg_scid AND
- u_updatecost.wareid = u_updatecostmx.wareid AND
- u_updatecost.scid = u_updatecostmx.scid and
- u_mtrlware.mtrlwareid = u_updatecostmx.mtrlwareid
- order by u_updatecostmx.printid
- USING commit_transaction;
-
- OPEN cur_waremx;
- FETCH cur_waremx INTO :inwaremx[i].printid,
- :inwaremx[i].mtrlwareid,
- :inwaremx[i].mtrlid,
- :inwaremx[i].plancode,
- :inwaremx[i].status,
- :inwaremx[i].qty,
- :inwaremx[i].fprice,
- :inwaremx[i].planprice,
- :inwaremx[i].mxdscrp,
- :inwaremx[i].mtrlcode,
- :inwaremx[i].woodcode,
- :inwaremx[i].pcode,
- :inwaremx[i].cost,
- :inwaremx[i].newcost,
- :inwaremx[i].unit,
- :inwaremx[i].mtrlcode,
- :inwaremx[i].waredscrp,
- :inwaremx[i].inworkdate,
- :inwaremx[i].sptid,
- :inwaremx[i].cost_notax,
- :inwaremx[i].newcost_notax;
-
- DO WHILE commit_transaction.SQLCode = 0
- i++
- FETCH cur_waremx INTO :inwaremx[i].printid,:inwaremx[i].mtrlwareid,:inwaremx[i].mtrlid,
- :inwaremx[i].plancode,:inwaremx[i].status,:inwaremx[i].qty,:inwaremx[i].fprice,
- :inwaremx[i].planprice,:inwaremx[i].mxdscrp,:inwaremx[i].mtrlcode,
- :inwaremx[i].woodcode,:inwaremx[i].pcode,:inwaremx[i].cost,:inwaremx[i].newcost,
- :inwaremx[i].unit,:inwaremx[i].mtrlcode,
- :inwaremx[i].waredscrp,
- :inwaremx[i].inworkdate,
- :inwaremx[i].sptid,
- :inwaremx[i].cost_notax,
- :inwaremx[i].newcost_notax;
- LOOP
- CLOSE cur_waremx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM u_updatecostmx
- WHERE u_updatecostmx.wareid = :arg_wareid
- 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
- wareid = arg_wareid
- 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 add_dscrp (long arg_scid, long arg_wareid, 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_wareid,arg_msg)
- if rslt=0 then goto ext
- if flag=0 then
- rslt=0
- arg_msg="非审核状态下不可用"
- goto ext
- end if
- update u_updatecost
- set dscrp = dscrp+' '+:arg_newdescppart
- where u_updatecost.wareid = :wareid
- and scid=:scid using commit_transaction;
- if commit_transaction.sqlcode<>0 then
- rollback using commit_transaction;
- 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 del (long arg_scid, long arg_wareid, ref string arg_msg, boolean arg_ifcommit);//del(arg_scid,arg_inwareid,arg_msg)
- //如果单据还没有审核删除单据极其明细
- //0 fail, 1 success
- int rslt = 1
- if arg_wareid = 0 then
- rslt = 0
- arg_msg = "没有删除对象,操作取消"
- goto ext
- end if
- rslt = p_getinfo(arg_scid,arg_wareid,arg_msg)
- if rslt = 0 then goto ext
- if flag = 1 then
- rslt = 0
- arg_msg = "单据已经审核,不可以删除"
- goto ext
- end if
- delete from u_updatecostmx
- where u_updatecostmx.mtrlwareid = :arg_wareid
- and 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_updatecost
- where u_updatecost.wareid = :arg_wareid
- and 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;
- elseif rslt=1 and arg_ifcommit then
- commit using commit_transaction;
- end if
- p_reset()
- return rslt
- end function
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);//====================================================================
- // Function: c_auditing(arg_ifcommit,arg_msg)
- //--------------------------------------------------------------------
- // Description: 撤审
- //--------------------------------------------------------------------
- // Arguments:
- // value boolean arg_ifcommit
- // reference string arg_msg
- //--------------------------------------------------------------------
- // Returns: integer
- //--------------------------------------------------------------------
- // Author: yyx Date: 2003.11.19
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- long rslt = 1,cnt = 0,i
- dec new_noallocqty = 0
- long ls_newid
- datetime null_dt
- goto ext
- //setnull(null_dt)
- //
- //if wareid = 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 u_updatecost
- // set auditingrep = '',
- // auditingdate = :null_dt,
- // flag = 0
- // where u_updatecost.wareid = :wareid
- // 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 = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.sqlerrtext
- // goto ext
- //end if
- //
- ////uo_outware_other uo_ware_other
- ////uo_ware_other = create uo_outware_other
- ////uo_ware_other.commit_transaction = sqlca
- ////
- ////IF uo_ware_other.getinfo(scid,relint_1,arg_msg) = 0 THEN
- //// ROLLBACK USING sqlca;
- //// rslt = 0
- //// goto ext
- ////END IF
- ////
- ////IF uo_ware_other.c_auditing(true,arg_msg) = 0 then
- //// ROLLBACK USING sqlca;
- //// rslt = 0
- //// goto ext
- ////end if
- ////
- //////for i = 1 to it_mxbt
- ////// if p_update_mtrlware(inwaremx[i].mtrlid,inwaremx[i].mtrlcode,&
- ////// storageid,inwaremx[i].plancode,inwaremx[i].status,&
- ////// 0 - inwaremx[i].qty,inwaremx[i].cost,inwaremx[i].planprice,&
- ////// 0,inwaremx[i].dxflag,inwaremx[i].woodcode,&
- ////// inwaremx[i].pcode,arg_msg) = 0 then
- ////// rslt = 0
- ////// goto ext
- ////// end if
- //////next
- ////
- ////if uo_ware_other.del(scid,relint_1,arg_msg,false) = 0 then
- //// rslt = 0
- //// goto ext
- ////end if
- //
- //update u_updatecost
- //set relint_1 = 0
- //where wareid=:wareid and scid=:scid using commit_transaction;
- //if commit_transaction.sqlcode <> 0 then
- // rslt = 0
- // arg_msg = "因网络或其它原因导致单据更新操作失败"+"~n"+commit_transaction.sqlerrtext
- // goto ext
- //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_ware_other
- return rslt
- end function
- public function integer uof_create_inware (ref string arg_msg);
- Long rslt = 1,ll_printid = 0,i
- Decimal lde_qty
- uo_inware uo_in_other
- uo_in_other = Create uo_inware
- s_inwaremx s_mx
- //生成进仓单 负
- IF uo_in_other.newbegin(scid,8,arg_msg) = 0 THEN //
- rslt = 0
- GOTO ext
- END IF
- uo_in_other.indate = moddate // DateTime(today(),time(0)) // 发生时间
- uo_in_other.inrep = modrep // 经手人
- IF part = '' THEN
- uo_in_other.part = warecode //相关部门
- ELSE
- uo_in_other.part = warecode + "["+part+"]"
- END IF
- uo_in_other.dscrp = dscrp //备注
- uo_in_other.storageid = storageid
- uo_in_other.sptname = '成本价调整单审核自动生成'
- uo_in_other.relid = wareid
- uo_in_other.commit_transaction = commit_transaction
- uo_in_other.sysautobuild = True
- FOR i = 1 To it_mxbt
- IF inwaremx[i].mtrlwareid > 0 THEN
- ll_printid++
- IF inwaremx[i].qty > 0 THEN
- lde_qty = 0 - inwaremx[i].qty
- ELSE
- lde_qty = -1
- END IF
-
- s_mx.printid = ll_printid
- s_mx.mtrlid = inwaremx[i].mtrlid
- s_mx.mtrlcode = inwaremx[i].mtrlcode
- s_mx.plancode = inwaremx[i].plancode
- s_mx.status = inwaremx[i].status
- s_mx.uqty = lde_qty
- s_mx.addqty = 0
- s_mx.uprice = inwaremx[i].cost
- s_mx.uprice_notax = inwaremx[i].cost_notax
- s_mx.rebate = 1
- s_mx.mxdscrp = inwaremx[i].mxdscrp
- s_mx.jgprice = 0
- s_mx.relid = 0
- s_mx.relprintid = 0
- s_mx.ifrel = 0
- s_mx.woodcode = inwaremx[i].woodcode
- s_mx.pcode = inwaremx[i].pcode
- s_mx.mtrlcuscode = ''
- s_mx.sptid = inwaremx[i].sptid
- s_mx.unit = inwaremx[i].unit
- s_mx.rate = 1
- s_mx.formula = ''
- s_mx.waredscrp = inwaremx[i].waredscrp
- s_mx.inworkdate = inwaremx[i].inworkdate
- s_mx.cost= inwaremx[i].cost
- s_mx.cost_notax = inwaremx[i].cost_notax
-
- IF uo_in_other.acceptmx(s_mx,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- NEXT
- FOR i = 1 To it_mxbt
- IF inwaremx[i].mtrlwareid > 0 THEN
- ll_printid++
- IF inwaremx[i].qty > 0 THEN
- lde_qty = inwaremx[i].qty
- ELSE
- lde_qty = 1
- END IF
-
- s_mx.printid = ll_printid
- s_mx.mtrlid = inwaremx[i].mtrlid
- s_mx.mtrlcode = inwaremx[i].mtrlcode
- s_mx.plancode = inwaremx[i].plancode
- s_mx.status = inwaremx[i].status
- s_mx.uqty = lde_qty
- s_mx.addqty = 0
- s_mx.uprice = inwaremx[i].newcost
- s_mx.uprice_notax = inwaremx[i].newcost_notax
- s_mx.rebate = 1
- s_mx.mxdscrp = inwaremx[i].mxdscrp
- s_mx.jgprice = 0
- s_mx.relid = 0
- s_mx.relprintid = 0
- s_mx.ifrel = 0
- s_mx.woodcode = inwaremx[i].woodcode
- s_mx.pcode = inwaremx[i].pcode
- s_mx.mtrlcuscode = ''
- s_mx.sptid = inwaremx[i].sptid
- s_mx.unit = inwaremx[i].unit
- s_mx.rate = 1
- s_mx.formula = ''
- s_mx.waredscrp = inwaremx[i].waredscrp
- s_mx.inworkdate = inwaremx[i].inworkdate
- s_mx.cost = inwaremx[i].newcost
- s_mx.cost_notax = inwaremx[i].newcost_notax
-
- IF uo_in_other.acceptmx(s_mx,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- NEXT
- IF uo_in_other.it_mxbt > 0 THEN
- IF uo_in_other.Save(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in_other.getinfo(scid,uo_in_other.inwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_in_other.auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- ext:
- Destroy uo_in_other
- RETURN rslt
- end function
- public function integer acceptmx (long arg_printid, long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_newprice, string arg_mxdscrp, ref string arg_msg, string arg_woodcode, string arg_pcode, decimal arg_cost, decimal arg_newcost, decimal arg_amt, decimal arg_planprice, string arg_unit, decimal arg_cost_notax, decimal arg_newcost_notax);Long rslt = 1,cnt = 0,ls_i
- Decimal ld_planprice,ld_cost
- String ls_relcode
- Decimal ld_rate
- Int i_dxflag
- Long i_mtrlid,i_storageid,i_sptid
- String i_plancode,i_status,i_mtrlcode,i_woodcode,i_pcode
- Dec i_cost,i_planprice,i_notauditqty,i_allouseqty
- String i_waredscrp
- DateTime i_inworkdate
- IF it_newbegin = False And it_updatebegin = False THEN
- rslt = 0
- arg_msg = "非编辑状态不可以使用,操作取消"
- GOTO ext
- END IF
- IF arg_mtrlwareid < 0 THEN
- rslt = 0
- GOTO ext
- END IF
- //清除空值
- IF IsNull(arg_printid) THEN arg_printid = 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_qty) THEN arg_qty = 0
- IF IsNull(arg_newprice) THEN arg_newprice = 0
- IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
- IF IsNull(arg_woodcode) THEN arg_woodcode = ''
- IF IsNull(arg_pcode) THEN arg_pcode = ''
- IF IsNull(arg_cost) THEN arg_cost = 0
- IF IsNull(arg_newcost) THEN arg_newcost = 0
- IF IsNull(arg_unit) THEN arg_unit = ''
- IF IsNull(arg_amt) THEN arg_amt = 0
- IF IsNull(arg_planprice) THEN arg_planprice = 0
- IF IsNull(arg_cost_notax) THEN arg_cost_notax = 0
- IF IsNull(arg_newcost_notax) THEN arg_newcost_notax = 0
- // 如果出仓数量为 0,或物料编号为空,则不作任何处理
- IF arg_mtrlwareid = 0 Or arg_qty = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- //检查物料库存ID
- SELECT u_mtrlware.mtrlid,
- u_mtrlware.storageid,
- u_mtrlware.plancode,
- u_mtrlware.status,
- u_mtrlware.cost,
- u_mtrldef.planprice,
- u_mtrldef.mtrlcode,
- u_mtrlware.sptid,
- u_mtrlware.dxflag,
- u_mtrlware.woodcode,
- u_mtrlware.pcode,
- isnull(uv_mtrlware_noauditingqty.noauditingqty,0),
- u_mtrlware.noallocqty,
- u_mtrlware.waredscrp,
- u_mtrlware.inworkdate
- INTO :i_mtrlid,
- :i_storageid,
- :i_plancode,
- :i_status,
- :i_cost,
- :i_planprice,
- :i_mtrlcode,
- :i_sptid,
- :i_dxflag,
- :i_woodcode,
- :i_pcode,
- :i_notauditqty,
- :i_allouseqty,
- :i_waredscrp,
- :i_inworkdate
- FROM u_mtrlware left OUTER join uv_mtrlware_noauditingqty
- on ( u_mtrlware.mtrlwareid = uv_mtrlware_noauditingqty.mtrlwareid)
- AND ( u_mtrlware.scid = uv_mtrlware_noauditingqty.scid),u_mtrldef
- WHERE ( u_mtrlware.mtrlid = u_mtrldef.mtrlid )
- And ( u_mtrlware.mtrlwareid = :arg_mtrlwareid )
- AND ( u_mtrlware.scid = :scid ) Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,库存编号错误"
- GOTO ext
- END IF
- it_mxbt++
- inwaremx[it_mxbt].mtrlwareid = arg_mtrlwareid
- inwaremx[it_mxbt].printid = arg_printid
- inwaremx[it_mxbt].mtrlid = i_mtrlid
- inwaremx[it_mxbt].mtrlcode = arg_mtrlcode
- inwaremx[it_mxbt].plancode = i_plancode
- inwaremx[it_mxbt].status = i_status
- inwaremx[it_mxbt].qty = i_allouseqty
- inwaremx[it_mxbt].fprice = arg_newprice
- inwaremx[it_mxbt].planprice = arg_planprice
- inwaremx[it_mxbt].mxdscrp = arg_mxdscrp
- inwaremx[it_mxbt].woodcode = i_woodcode
- inwaremx[it_mxbt].pcode = i_pcode
- inwaremx[it_mxbt].aunit = arg_unit
- inwaremx[it_mxbt].cost = arg_cost
- inwaremx[it_mxbt].newcost = arg_newcost
- // //inwaremx[it_mxbt].amt = arg_amt
- inwaremx[it_mxbt].dxflag = i_dxflag
- inwaremx[it_mxbt].sptid = i_sptid
- inwaremx[it_mxbt].waredscrp = i_waredscrp
- inwaremx[it_mxbt].inworkdate = i_inworkdate
- inwaremx[it_mxbt].cost_notax = arg_cost_notax
- inwaremx[it_mxbt].newcost_notax = arg_newcost_notax
- ext:
- IF rslt = 0 THEN
- p_clearmx()
- arg_msg = "第" + String(arg_printid) + "行," + arg_msg
- END IF
- Return(rslt)
- end function
- on uo_update_cost.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_update_cost.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
- event constructor;//uo_unit_change = create uo_unit
- end event
- event destructor;//destroy uo_unit_change
- end event
|