123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957 |
- $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 wareid
- PUBLIC PROTECTEDWRITE String warecode
- PUBLIC PROTECTEDWRITE DateTime opdate
- PUBLIC PROTECTEDWRITE String opemp
- PUBLIC PROTECTEDWRITE DateTime modidate
- PUBLIC PROTECTEDWRITE String modiemp
- PUBLIC PROTECTEDWRITE Int flag = 0
- PUBLIC PROTECTEDWRITE DateTime auditingdate
- PUBLIC PROTECTEDWRITE String auditingrep
- Long storageid
- DateTime moddate
- String modrep
- String part
- String dscrp
- Boolean if_getid_ture = TRUE
- Transaction commit_transaction //数据commit事务
- s_inwaremx s_mx[] //明细结构数组
- Long it_mxbt = 0 //明细结构数组末指针
- Boolean it_newbegin = FALSE //新建标志
- Boolean it_updatebegin = FALSE //修改标志
- end variables
- forward prototypes
- 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 add_dscrp (long arg_wareid, string arg_newdescppart, ref string arg_msg)
- public function integer p_getinfo (long arg_wareid, ref string arg_msg)
- public function integer getinfo (long arg_wareid, ref string arg_msg)
- public function integer del (long arg_wareid, ref string arg_msg, boolean arg_ifcommit)
- public function integer updatebegin (long arg_wareid, ref string arg_msg)
- public function integer newbegin ()
- public function integer acceptmx (long arg_printid, long arg_mtrlwarescid, long arg_mtrlwareid, string arg_mtrlcode, string arg_mxdscrp, ref string arg_msg, decimal arg_newcost, string arg_unit, decimal arg_rate)
- end prototypes
- 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
- IF f_check_inoutdate(storageid,moddate,TRUE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ////////////////////////////////////////////////开始区分:新建/更新 处理
- IF wareid = 0 THEN //新建
- ls_newid = f_sys_scidentity(0,"u_updatecost","wareid",arg_msg,TRUE,id_sqlca)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取分部代号
- IF f_get_sccode(0,commit_transaction,ls_sccode,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- warecode = getid(0,ls_sccode + 'UC',Date(server_dt),if_getid_ture,commit_transaction)
-
-
- IF warecode = "err" THEN
- warecode = ''
- rslt = 0
- arg_msg = "无法获取单据编号"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- INSERT INTO u_updatecost (
- wareid,
- warecode,
- storageid,
- part,
- moddate,
- modrep,
- dscrp,
- opdate,
- opemp)
- VALUES (
- :ls_newid,
- :warecode,
- :storageid,
- :part,
- :moddate,
- :modrep,
- :dscrp,
- :server_dt,
- :publ_operator) USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //读取新inwareid
- wareid = ls_newid
-
- FOR i = 1 TO it_mxbt
- INSERT INTO u_updatecostmx
- (wareid,
- mtrlwarescid,
- mtrlwareid,
- mtrlid,
- plancode,
- status,
- mxdscrp,
- noallocqty,
- woodcode,
- pcode,
- cost,
- newcost,
- printid,
- sptid,
- unewcost,
- unit,
- rate,
- mtrlcuscode,
- location)
- VALUES (
- :ls_newid,
- :s_mx[i].scid,
- :s_mx[i].mtrlwareid,
- :s_mx[i].mtrlid,
- :s_mx[i].plancode,
- :s_mx[i].status,
- :s_mx[i].mxdscrp,
- :s_mx[i].qty,
- :s_mx[i].woodcode,
- :s_mx[i].pcode,
- :s_mx[i].cost,
- :s_mx[i].newcost,
- :s_mx[i].printid,
- :s_mx[i].sptid,
- :s_mx[i].unewcost,
- :s_mx[i].uunit,
- :s_mx[i].rate,
- :s_mx[i].mtrlcuscode,
- :s_mx[i].location) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- wareid = 0 //还原inwareid
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- 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 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
- 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
- (wareid,
- mtrlwarescid,
- mtrlwareid,
- mtrlid,
- plancode,
- status,
- mxdscrp,
- noallocqty,
- woodcode,
- pcode,
- cost,
- newcost,
- printid,
- sptid,
- unewcost,
- unit,
- rate,
- mtrlcuscode,
- location)
- VALUES (
- :wareid,
- :s_mx[i].scid,
- :s_mx[i].mtrlwareid,
- :s_mx[i].mtrlid,
- :s_mx[i].plancode,
- :s_mx[i].status,
- :s_mx[i].mxdscrp,
- :s_mx[i].qty,
- :s_mx[i].woodcode,
- :s_mx[i].pcode,
- :s_mx[i].cost,
- :s_mx[i].newcost,
- :s_mx[i].printid,
- :s_mx[i].sptid,
- :s_mx[i].unewcost,
- :s_mx[i].uunit,
- :s_mx[i].rate,
- :s_mx[i].mtrlcuscode,
- :s_mx[i].location) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- 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);Long rslt = 1,cnt = 0,i
- Decimal ld_qty,ld_price
- IF wareid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "单据已经审核"
- GOTO ext
- END IF
- UPDATE u_updatecost
- SET auditingrep = :publ_operator,
- auditingdate = getdate(),
- flag = 1
- WHERE u_updatecost.wareid = :wareid
- AND flag = 0
- 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
- Long ll_scid
- uo_inware uo_1
- SELECT scid INTO :ll_scid
- FROM u_storage
- WHERE storageid = :storageid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询仓库分部资料失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- uo_1 = Create uo_inware
- //生成进仓单 负
- IF uo_1.newbegin(ll_scid,8,arg_msg) = 0 THEN //
- rslt = 0
- GOTO ext
- END IF
- uo_1.indate = moddate
- uo_1.inrep = modrep // 经手人
- uo_1.part = warecode
- uo_1.dscrp = dscrp //备注
- uo_1.storageid = storageid
- uo_1.sptname = '调整成本价(负单)'
- uo_1.relid = wareid
- uo_1.if_getid_ture = False
- uo_1.commit_transaction = commit_transaction
- FOR i = 1 To it_mxbt
- IF s_mx[i].mtrlwareid > 0 THEN
- IF s_mx[i].qty <> 0 THEN
- ld_qty = s_mx[i].qty
- ld_price = s_mx[i].cost
- ELSE
- ld_qty = -1
- ld_price = s_mx[i].newcost
- END IF
-
- IF uo_1.acceptmx(s_mx[i].printid,&
- s_mx[i].mtrlid,&
- s_mx[i].mtrlcode,&
- s_mx[i].plancode,&
- s_mx[i].status,&
- 0 - ld_qty,&
- ld_price,&
- 1,&
- s_mx[i].mxdscrp,&
- arg_msg,&
- 0,0,0,&
- s_mx[i].woodcode,&
- s_mx[i].pcode,&
- s_mx[i].sptid,&
- s_mx[i].unit,1,0 - ld_qty,0,0,'','',0,0,&
- s_mx[i].mtrlcuscode,s_mx[i].Location,&
- 0 - ld_qty,&
- 0) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- END IF
- NEXT
- IF uo_1.it_mxbt > 0 THEN
- IF uo_1.Save(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_1.getinfo(uo_1.scid,uo_1.inwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_1.auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_1.uof_secaudit(uo_1.scid,uo_1.inwareid,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- Destroy uo_1
- uo_1 = Create uo_inware
- //生成进仓单 正
- IF uo_1.newbegin(ll_scid,8,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- uo_1.indate = moddate
- uo_1.inrep = modrep // 经手人
- uo_1.part = warecode //相关部门
- uo_1.dscrp = dscrp //备注
- uo_1.storageid = storageid
- uo_1.sptname = '更新成本价(正单)'
- uo_1.relid = wareid
- uo_1.if_getid_ture = False
- uo_1.commit_transaction = commit_transaction
- FOR i = 1 To it_mxbt
- IF s_mx[i].mtrlwareid > 0 THEN
- IF s_mx[i].qty <> 0 THEN
- ld_qty = s_mx[i].qty
- ld_price = s_mx[i].newcost
- ELSE
- ld_qty = -1
- ld_price = 0
- END IF
-
- IF uo_1.acceptmx(s_mx[i].printid,&
- s_mx[i].mtrlid,&
- s_mx[i].mtrlcode,&
- s_mx[i].plancode,&
- s_mx[i].status,&
- ld_qty,&
- ld_price,&
- 1,&
- s_mx[i].mxdscrp,&
- arg_msg,0,0,0,&
- s_mx[i].woodcode,&
- s_mx[i].pcode,&
- s_mx[i].sptid,&
- s_mx[i].unit,&
- 1,ld_qty,0,0,'','',0,0,&
- s_mx[i].mtrlcuscode,&
- s_mx[i].Location,&
- ld_qty,&
- 0) = 0 THEN
- MessageBox('Error!',arg_msg)
- rslt = 0
- GOTO ext
- END IF
- END IF
- NEXT
- IF uo_1.it_mxbt > 0 THEN
- IF uo_1.Save(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_1.getinfo(uo_1.scid,uo_1.inwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_1.auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_1.uof_secaudit(uo_1.scid,uo_1.inwareid,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- 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_1
- 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()
- //清除对象及其明细
- wareid = 0
- warecode = ''
- 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 add_dscrp (long arg_wareid, string arg_newdescppart, ref string arg_msg);
- 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_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
- 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 p_getinfo (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
- INTO :warecode,
- :storageid,
- :moddate,
- :modrep,
- :part,
- :dscrp,
- :modidate,
- :modiemp,
- :auditingdate,
- :auditingrep,
- :flag
- FROM u_updatecost
- WHERE u_updatecost.wareid = :arg_wareid
- using commit_transaction;
- if commit_transaction.sqlcode<>0 then
- rslt=0
- arG_MSG="查询操作失败(错误单据唯一码)"+commit_transaction.sqlerrtext
- goto ext
- end if
- wareid = arg_wareid
- ext:
- IF rslt=0 THEN p_reset()
- return rslt
- end function
- public function integer getinfo (long arg_wareid, ref string arg_msg);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_wareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- //用游标读取明细
- DECLARE cur_waremx CURSOR FOR
- SELECT u_updatecostmx.printid,
- u_updatecostmx.mtrlwarescid,
- u_updatecostmx.mtrlwareid,
- u_updatecostmx.mtrlid,
- u_updatecostmx.plancode,
- u_updatecostmx.status,
- u_updatecostmx.noallocqty,
- u_updatecostmx.mxdscrp,
- u_mtrldef.mtrlcode,
- u_updatecostmx.woodcode,
- u_updatecostmx.pcode,
- u_updatecostmx.cost,
- u_updatecostmx.newcost,
- u_mtrldef.mtrlcode,
- u_mtrldef.unit,
- u_updatecostmx.unewcost,
- u_updatecostmx.unit,
- u_updatecostmx.rate,
- u_updatecostmx.mtrlcuscode,
- u_updatecostmx.location,
- u_updatecostmx.sptid
- FROM u_updatecostmx,u_mtrldef
- WHERE u_updatecostmx.wareid = :arg_wareid AND
- u_updatecostmx.mtrlid = u_mtrldef.mtrlid
- USING commit_transaction;
-
- OPEN cur_waremx;
- FETCH cur_waremx INTO :s_mx[i].printid,:s_mx[i].scid,
- :s_mx[i].mtrlwareid,:s_mx[i].mtrlid,
- :s_mx[i].plancode,:s_mx[i].status,:s_mx[i].qty,
- :s_mx[i].mxdscrp,:s_mx[i].mtrlcode,
- :s_mx[i].woodcode,:s_mx[i].pcode,:s_mx[i].cost,:s_mx[i].newcost,
- :s_mx[i].mtrlcode,:s_mx[i].unit,:s_mx[i].unewcost,:s_mx[i].uunit,
- :s_mx[i].rate,:s_mx[i].mtrlcuscode,:s_mx[i].location,:s_mx[i].sptid;
-
- DO WHILE commit_transaction.SQLCode = 0
- i++
- FETCH cur_waremx INTO :s_mx[i].printid,:s_mx[i].scid,
- :s_mx[i].mtrlwareid,:s_mx[i].mtrlid,
- :s_mx[i].plancode,:s_mx[i].status,:s_mx[i].qty,
- :s_mx[i].mxdscrp,:s_mx[i].mtrlcode,
- :s_mx[i].woodcode,:s_mx[i].pcode,:s_mx[i].cost,:s_mx[i].newcost,
- :s_mx[i].mtrlcode,:s_mx[i].unit,:s_mx[i].unewcost,:s_mx[i].uunit,
- :s_mx[i].rate,:s_mx[i].mtrlcuscode,:s_mx[i].location,:s_mx[i].sptid;
- LOOP
- CLOSE cur_waremx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM u_updatecostmx
- WHERE u_updatecostmx.wareid = :arg_wareid
- 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
- 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_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_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.wareid = :arg_wareid
- 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
- 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 updatebegin (long arg_wareid, ref string arg_msg);Long rslt = 1
- IF arg_wareid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
- rslt = p_getinfo(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
- it_newbegin = FALSE
- it_updatebegin = TRUE
- p_clearmx() //清除明细
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer newbegin ();int rslt=1
- p_reset()
- it_newbegin=true
- it_updatebegin=false
- return rslt
- end function
- public function integer acceptmx (long arg_printid, long arg_mtrlwarescid, long arg_mtrlwareid, string arg_mtrlcode, string arg_mxdscrp, ref string arg_msg, decimal arg_newcost, string arg_unit, decimal arg_rate);Long rslt = 1,cnt = 0
- Long i_mtrlid,i_storageid,i_sptid,i_dxflag
- String i_plancode,i_status,i_woodcode,i_pcode,i_mtrlcuscode,i_location
- Dec i_cost,i_noallocqty
- string i_unit
-
- 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_mtrlcode) THEN arg_mtrlcode = ''
- IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
- IF IsNull(arg_newcost) THEN arg_newcost = 0
- if isnull(arg_rate) then arg_rate = 1
- if isnull(arg_unit) then arg_unit = ''
- IF arg_rate = 0 THEN arg_rate = 1
- //检查物料库存ID
- SELECT u_mtrlware.mtrlid,
- u_mtrlware.storageid,
- u_mtrlware.plancode,
- u_mtrlware.status,
- u_mtrlware.cost,
- u_mtrlware.woodcode,
- u_mtrlware.pcode,
- u_mtrlware.noallocqty,
- u_mtrlware.dxflag,
- u_mtrlware.sptid,
- u_mtrlware.mtrlcuscode,
- u_mtrlware.location,
- u_mtrldef.unit
- INTO :i_mtrlid,
- :i_storageid,
- :i_plancode,
- :i_status,
- :i_cost,
- :i_woodcode,
- :i_pcode,
- :i_noallocqty,
- :i_dxflag,
- :i_sptid,
- :i_mtrlcuscode,
- :i_location,
- :i_unit
- FROM u_mtrlware,u_mtrldef
- WHERE ( u_mtrlware.mtrlwareid = :arg_mtrlwareid )
- AND ( u_mtrlware.scid = :arg_mtrlwarescid )
- AND ( u_mtrlware.mtrlid = u_mtrldef.mtrlid )
- USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询物料:"+arg_mtrlcode+"库存资料失败,"+commit_transaction.sqlerrtext
- GOTO ext
- END IF
- IF i_storageid <> storageid THEN
- arg_msg = '仓库资料与明细资料不相符'
- rslt = 0
- GOTO ext
- END IF
- it_mxbt++
- s_mx[it_mxbt].scid = arg_mtrlwarescid
- s_mx[it_mxbt].mtrlwareid = arg_mtrlwareid
- s_mx[it_mxbt].printid = arg_printid
- s_mx[it_mxbt].mtrlid = i_mtrlid
- s_mx[it_mxbt].mtrlcode = arg_mtrlcode
- s_mx[it_mxbt].plancode = i_plancode
- s_mx[it_mxbt].status = i_status
- s_mx[it_mxbt].qty = i_noallocqty
- s_mx[it_mxbt].mxdscrp = arg_mxdscrp
- s_mx[it_mxbt].woodcode = i_woodcode
- s_mx[it_mxbt].pcode = i_pcode
- s_mx[it_mxbt].cost = i_cost
- s_mx[it_mxbt].dxflag = i_dxflag
- s_mx[it_mxbt].sptid = i_sptid
- s_mx[it_mxbt].unit = i_unit
- s_mx[it_mxbt].newcost = arg_newcost / arg_rate
- s_mx[it_mxbt].unewcost = arg_newcost
- s_mx[it_mxbt].uunit = arg_unit
- s_mx[it_mxbt].rate = arg_rate
- s_mx[it_mxbt].mtrlcuscode = i_mtrlcuscode
- s_mx[it_mxbt].location = i_location
- ext:
- IF rslt = 0 THEN p_clearmx()
- 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
|