1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075 |
- $PBExportHeader$uo_mtrlware_pzcode_trans.sru
- forward
- global type uo_mtrlware_pzcode_trans from nonvisualobject
- end type
- end forward
- global type uo_mtrlware_pzcode_trans from nonvisualobject
- end type
- global uo_mtrlware_pzcode_trans uo_mtrlware_pzcode_trans
- type variables
- Long uo_billid
- end variables
- forward prototypes
- public function integer updatebegin (long arg_billid, ref string arg_msg)
- public function integer caudit (long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer audit (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
- public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg)
- public function integer del (long arg_billid, integer arg_chk_auto, ref string arg_msg, boolean arg_ifcommit)
- public function integer p_getinfo (long arg_billid, ref s_mtrlware_pzcode_trans arg_s_trans, ref string arg_msg)
- public function integer save (s_mtrlware_pzcode_trans arg_s_trans, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
- public function integer getinfo (long arg_billid, ref s_mtrlware_pzcode_trans arg_ref_s_trans, ref long arg_arr_cnt, ref string arg_msg)
- public function integer uof_update_waredate (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
- end prototypes
- public function integer updatebegin (long arg_billid, ref string arg_msg);Int rslt = 1
- s_mtrlware_pzcode_trans arg_s_trans
- IF arg_billid <= 0 THEN
- rslt = 0
- ARG_MSG = '错误单据唯一码'
- GOTO ext
- END IF
- IF p_getinfo(arg_billid,arg_s_trans,ARG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF arg_s_trans.flag = 1 THEN
- rslt = 0
- ARG_MSG = '单据已经审核,不可以修改,要修改请先撤销审核'
- GOTO ext
- END IF
- ext:
- RETURN rslt
- end function
- public function integer caudit (long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- DateTime null_dt
- long ll_arr_cnt
- SetNull(null_dt)
- Long ll_inware_out,ll_inware_in
- IF arg_billid <= 0 THEN
- rslt = 0
- arg_msg = '错误单据唯一码'
- GOTO ext
- END IF
- s_mtrlware_pzcode_trans arg_s_trans
- IF getinfo(arg_billid,arg_s_trans,ll_arr_cnt,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF arg_s_trans.flag = 0 THEN
- rslt = 0
- arg_msg = '单据未审核,不可以撤审'
- GOTO ext
- END IF
- UPDATE u_mtrlware_pzcode_trans
- SET flag = 0,
- auditemp = '',
- auditdate = :null_dt
- WHERE billid = :arg_billid
- AND flag = 1;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致单据撤消审核操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- uo_inware uo_in
- uo_in = CREATE uo_inware
- uo_in.commit_transaction = sqlca
- uo_in.if_getid_ture = FALSE
- //撤审删除相关进仓单(正)
- SELECT inwareid INTO :ll_inware_in
- FROM u_inware
- WHERE scid = :arg_s_trans.scid
- AND relid = :arg_billid
- AND billtype = 22
- AND relint_2 = 1;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询相关进仓单(正)失败'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.getinfo(arg_s_trans.scid,ll_inware_in,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.c_auditing(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.del(arg_s_trans.scid,ll_inware_in,arg_msg,FALSE) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- //撤审删除相关进仓单(负)
- SELECT inwareid INTO :ll_inware_out
- FROM u_inware
- WHERE scid = :arg_s_trans.scid
- AND relid = :arg_billid
- AND billtype = 22
- AND relint_2 = 0;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询相关进仓单(负)失败'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.getinfo(arg_s_trans.scid,ll_inware_out,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.c_auditing(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.del(arg_s_trans.scid,ll_inware_out,arg_msg,FALSE) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- DESTROY uo_in
- RETURN rslt
- end function
- public function integer audit (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long ll_arr_cnt
- String ls_uunit
- Decimal ld_rate,ld_uqty,ld_uprice
- Long ll_i
- Long ll_inwareid_out,ll_inwareid_in
- IF arg_billid <= 0 THEN
- rslt = 0
- arg_msg = '错误单据唯一码'
- GOTO ext
- END IF
- s_mtrlware_pzcode_trans arg_s_trans
- IF getinfo(arg_billid,arg_s_trans,ll_arr_cnt,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF arg_s_trans.flag = 1 THEN
- rslt = 0
- arg_msg = '单据已经审核,不可以再审'
- GOTO ext
- END IF
- //更新审核标记
- UPDATE u_mtrlware_pzcode_trans
- SET auditemp = :arg_opemp,
- auditdate = getdate(),
- flag = 1
- WHERE billid = :arg_billid
- AND flag = 0;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致单据审核操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- uo_inware uo_in
- uo_in = CREATE uo_inware
- uo_in.commit_transaction = sqlca
- uo_in.if_getid_ture = FALSE
- //负单
- IF uo_in.newbegin(arg_s_trans.scid,22,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- uo_in.relid = arg_s_trans.billid
- uo_in.indate = arg_s_trans.billdate
- uo_in.inrep = arg_s_trans.rep
- uo_in.part = arg_s_trans.billcode
- uo_in.dscrp = arg_s_trans.dscrp
- uo_in.relint_2 = 0 // 0 - 负 1 - 正
- uo_in.storageid = arg_s_trans.storageid
- uo_in.sptname = '库存配置调整单(负)'
- FOR ll_i = 1 TO ll_arr_cnt
- //转换
- ls_uunit = ''
- ld_rate = 0
- ld_uqty = 0
- ld_uprice = 0
-
- IF arg_s_trans.arg_s_mx[ll_i].ifunit = 0 THEN
- ls_uunit = arg_s_trans.arg_s_mx[ll_i].unit
- ld_rate = 1
- ld_uqty = arg_s_trans.arg_s_mx[ll_i].qty
- ld_uprice = arg_s_trans.arg_s_mx[ll_i].cost
- ELSE
- IF arg_s_trans.arg_s_mx[ll_i].rate = 0 THEN
- arg_msg = '调货产品资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- GOTO ext
- END IF
-
- ls_uunit = arg_s_trans.arg_s_mx[ll_i].uunit
- ld_rate = arg_s_trans.arg_s_mx[ll_i].rate
- ld_uqty = arg_s_trans.arg_s_mx[ll_i].qty / arg_s_trans.arg_s_mx[ll_i].rate
- ld_uprice = arg_s_trans.arg_s_mx[ll_i].cost * arg_s_trans.arg_s_mx[ll_i].rate
- END IF
-
- IF uo_in.acceptmx(ll_i,&
- arg_s_trans.arg_s_mx[ll_i].mtrlid,&
- arg_s_trans.arg_s_mx[ll_i].mtrlcode,&
- arg_s_trans.arg_s_mx[ll_i].plancode,&
- arg_s_trans.arg_s_mx[ll_i].status,&
- 0 - ld_uqty,&
- ld_uprice,&
- 1,&
- arg_s_trans.arg_s_mx[ll_i].mxdscrp,&
- arg_msg,&
- 0,0,0,arg_s_trans.arg_s_mx[ll_i].woodcode,&
- arg_s_trans.arg_s_mx[ll_i].pcode,&
- arg_s_trans.arg_s_mx[ll_i].sptid,&
- ls_uunit,ld_rate,0 - arg_s_trans.arg_s_mx[ll_i].qty,0,0,'','',0,0,&
- arg_s_trans.arg_s_mx[ll_i].mtrlcuscode,arg_s_trans.arg_s_mx[ll_i].Location,&
- 0 - ld_uqty,&
- 0) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- NEXT
- IF uo_in.Save(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ll_inwareid_out = uo_in.inwareid
- IF uo_in.getinfo(arg_s_trans.scid,ll_inwareid_out,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.auditing(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- //正
- IF uo_in.newbegin(arg_s_trans.scid,22,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- uo_in.relid = arg_s_trans.billid
- uo_in.indate = arg_s_trans.billdate
- uo_in.inrep = arg_s_trans.rep
- uo_in.part = arg_s_trans.billcode
- uo_in.dscrp = arg_s_trans.dscrp
- uo_in.relint_2 = 1 // 0 - 负 1 - 正
- uo_in.storageid = arg_s_trans.storageid
- uo_in.sptname = '库存配置调整单(正)'
- FOR ll_i = 1 TO ll_arr_cnt
- //转换
- ls_uunit = ''
- ld_rate = 0
- ld_uqty = 0
- ld_uprice = 0
-
- IF arg_s_trans.arg_s_mx[ll_i].ifunit = 0 THEN
- ls_uunit = arg_s_trans.arg_s_mx[ll_i].unit
- ld_rate = 1
- ld_uqty = arg_s_trans.arg_s_mx[ll_i].qty
- ld_uprice = arg_s_trans.arg_s_mx[ll_i].cost
- ELSE
- IF arg_s_trans.arg_s_mx[ll_i].rate = 0 THEN
- arg_msg = '调货产品资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- GOTO ext
- END IF
-
- ls_uunit = arg_s_trans.arg_s_mx[ll_i].uunit
- ld_rate = arg_s_trans.arg_s_mx[ll_i].rate
- ld_uqty = arg_s_trans.arg_s_mx[ll_i].qty / arg_s_trans.arg_s_mx[ll_i].rate
- ld_uprice = arg_s_trans.arg_s_mx[ll_i].cost * arg_s_trans.arg_s_mx[ll_i].rate
- END IF
-
- IF uo_in.acceptmx(ll_i,&
- arg_s_trans.arg_s_mx[ll_i].mtrlid,&
- arg_s_trans.arg_s_mx[ll_i].mtrlcode,&
- arg_s_trans.arg_s_mx[ll_i].plancode_new,&
- arg_s_trans.arg_s_mx[ll_i].status_new,&
- ld_uqty,&
- ld_uprice,&
- 1,&
- arg_s_trans.arg_s_mx[ll_i].mxdscrp,&
- arg_msg,&
- 0,0,0,arg_s_trans.arg_s_mx[ll_i].woodcode_new,&
- arg_s_trans.arg_s_mx[ll_i].pcode_new,&
- arg_s_trans.arg_s_mx[ll_i].sptid_new,&
- ls_uunit,ld_rate,arg_s_trans.arg_s_mx[ll_i].qty,0,0,'','',0,0,&
- arg_s_trans.arg_s_mx[ll_i].mtrlcuscode_new,arg_s_trans.arg_s_mx[ll_i].Location_new,&
- ld_uqty,&
- 0) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
-
- NEXT
- IF uo_in.Save(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ll_inwareid_in = uo_in.inwareid
- IF uo_in.getinfo(arg_s_trans.scid,ll_inwareid_in,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.auditing(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uof_update_waredate(arg_billid,FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- DESTROY uo_in
- RETURN rslt
- end function
- public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg);Int rslt = 1
- s_mtrlware_pzcode_trans arg_s_trans
- IF arg_billid <= 0 THEN
- rslt = 0
- arg_msg = '错误单据唯一码'
- GOTO ext
- END IF
- IF arg_newdescppart = '' THEN
- rslt = 0
- arg_msg = "要添加内容为空,操作取消"
- GOTO ext
- END IF
- IF p_getinfo(arg_billid,arg_s_trans,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF arg_s_trans.flag = 0 THEN
- rslt = 0
- arg_msg = '单据未审核,不可以增加备注'
- GOTO ext
- END IF
- UPDATE u_mtrlware_pzcode_trans
- SET DSCRP = DSCRP+' '+:arg_newdescppart
- WHERE billid = :arg_billid
- AND flag = 1;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致添加备注操作失败"+"~n"+SQLCA.SQLErrText
- GOTO ext
- END IF
- ext:
- IF rslt = 1 THEN
- COMMIT;
- ELSE
- ROLLBACK;
- END IF
- Return (rslt)
- end function
- public function integer del (long arg_billid, integer arg_chk_auto, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- s_mtrlware_pzcode_trans arg_s_trans
- IF arg_billid <= 0 THEN
- rslt = 0
- ARG_MSG = '错误单据唯一码'
- GOTO ext
- END IF
- IF p_getinfo(arg_billid,arg_s_trans,ARG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF arg_s_trans.flag = 1 THEN
- rslt = 0
- ARG_MSG = '单据已经审核,不可以删除'
- GOTO ext
- END IF
- DELETE FROM u_mtrlware_pzcode_trans Where billid = :arg_billid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- ARG_MSG = "删除单据操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- DELETE FROM u_mtrlware_pzcode_transmx Where billid = :arg_billid ;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- ARG_MSG = "删除单据明细操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer p_getinfo (long arg_billid, ref s_mtrlware_pzcode_trans arg_s_trans, ref string arg_msg);Int rslt = 1
- IF arg_billid <= 0 THEN
- rslt = 0
- ARG_MSG = '错误单据唯一码'
- GOTO ext
- END IF
- SELECT
- billid,
- billcode,
- scid,
- billdate,
- rep,
- storageid,
- dscrp,
- relcode,
- flag
- INTO
- :arg_s_trans.billid,
- :arg_s_trans.billcode,
- :arg_s_trans.scid,
- :arg_s_trans.billdate,
- :arg_s_trans.rep,
- :arg_s_trans.storageid,
- :arg_s_trans.dscrp,
- :arg_s_trans.relcode,
- :arg_s_trans.flag
- FROM u_mtrlware_pzcode_trans
- Where billid = :arg_billid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- ARG_MSG = '查询库存配置调整单内容失败(错误单据唯一码)'
- GOTO ext
- END IF
- ext:
- RETURN rslt
- end function
- public function integer save (s_mtrlware_pzcode_trans arg_s_trans, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1
- Long cnt = 0
- DateTime server_dt
- Long ll_billid,it_mxbt,ll_i,i
- String ls_unit
- String ls_sccode,ls_billcode,ls_reltaskcode
- IF IsNull(arg_s_trans.scid) THEN arg_s_trans.scid = 0
- IF IsNull(arg_s_trans.billid) THEN arg_s_trans.billid = 0
- IF IsNull(arg_s_trans.rep) THEN arg_s_trans.rep = ''
- IF IsNull(arg_s_trans.relcode) THEN arg_s_trans.relcode = ''
- IF IsNull(arg_s_trans.dscrp) THEN arg_s_trans.dscrp = ''
- IF IsNull(arg_s_trans.storageid) THEN arg_s_trans.storageid = 0
- IF IsNull(arg_s_trans.relcode) THEN arg_s_trans.relcode = ''
- IF arg_s_trans.rep = '' THEN
- rslt = 0
- arg_msg = "请输入经手人"
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_storage
- Where storageid = :arg_s_trans.storageid ;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,仓库资料"
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = "仓库未定义或错误"
- GOTO ext
- END IF
- SELECT Top 1 getdate() INTO :server_dt FROM u_user;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- GOTO ext
- END IF
- it_mxbt = UpperBound(arg_s_trans.arg_s_mx)
- IF it_mxbt <= 0 THEN
- rslt = 0
- arg_msg = "没有正确明细内容"
- GOTO ext
- END IF
- //
- //FOR ll_i = 1 TO it_mxbt
- //
- //NEXT
- IF arg_s_trans.billid = 0 THEN
-
- ll_billid = f_sys_scidentity(0,"u_mtrlware_pzcode_trans","billid",arg_msg,TRUE,id_sqlca)
-
- IF ll_billid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF f_get_sccode(arg_s_trans.scid,sqlca,ls_sccode,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- ls_billcode = getid(arg_s_trans.scid,ls_sccode + 'MP',Date(server_dt),FALSE,sqlca)
-
- IF ls_billcode = "err" THEN
- rslt = 0
- arg_msg = "无法获取单据编号"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
-
-
- INSERT INTO u_mtrlware_pzcode_trans
- (scid,
- billid,
- billcode,
- billdate,
- rep,
- storageid,
- relcode,
- dscrp,
- opemp,
- opdate)
- VALUES (
- :arg_s_trans.scid,
- :ll_billid,
- :ls_billcode,
- :arg_s_trans.billdate,
- :arg_s_trans.rep,
- :arg_s_trans.storageid,
- :arg_s_trans.relcode,
- :arg_s_trans.dscrp,
- :arg_opemp,
- getdate()) ;
-
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致建立单据操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 TO it_mxbt
- INSERT INTO u_mtrlware_pzcode_transmx
- (billid,
- printid,
- scid,
- mtrlwareid,
- mtrlid,
- status,
- woodcode,
- pcode,
- plancode,
- mtrlcuscode,
- location,
- sptid,
- qty,
- cost,
- status_new,
- woodcode_new,
- pcode_new,
- plancode_new,
- mtrlcuscode_new,
- location_new,
- sptid_new,
- mxdscrp)
- VALUES (:ll_billid,
- :arg_s_trans.arg_s_mx[i].printid,
- :arg_s_trans.arg_s_mx[i].scid,
- :arg_s_trans.arg_s_mx[i].mtrlwareid,
- :arg_s_trans.arg_s_mx[i].mtrlid,
- :arg_s_trans.arg_s_mx[i].status,
- :arg_s_trans.arg_s_mx[i].woodcode,
- :arg_s_trans.arg_s_mx[i].pcode,
- :arg_s_trans.arg_s_mx[i].plancode,
- :arg_s_trans.arg_s_mx[i].mtrlcuscode,
- :arg_s_trans.arg_s_mx[i].location,
- :arg_s_trans.arg_s_mx[i].sptid,
- :arg_s_trans.arg_s_mx[i].qty,
- :arg_s_trans.arg_s_mx[i].cost,
- :arg_s_trans.arg_s_mx[i].status_new,
- :arg_s_trans.arg_s_mx[i].woodcode_new,
- :arg_s_trans.arg_s_mx[i].pcode_new,
- :arg_s_trans.arg_s_mx[i].plancode_new,
- :arg_s_trans.arg_s_mx[i].mtrlcuscode_new,
- :arg_s_trans.arg_s_mx[i].location_new,
- :arg_s_trans.arg_s_mx[i].sptid_new,
- :arg_s_trans.arg_s_mx[i].mxdscrp);
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- uo_billid = ll_billid
- ELSE
- UPDATE u_mtrlware_pzcode_trans
- SET rep = :arg_s_trans.rep,
- billdate = :arg_s_trans.billdate,
- storageid = :arg_s_trans.storageid,
- moddate = getdate(),
- modemp = :arg_opemp,
- relcode = :arg_s_trans.relcode,
- dscrp = :arg_s_trans.dscrp
- WHERE billid = :arg_s_trans.billid
- AND flag = 0;
- IF sqlca.SQLCode <> 0 OR sqlca.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
-
- DELETE FROM u_mtrlware_pzcode_transmx
- Where billid = :arg_s_trans.billid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 TO it_mxbt
- INSERT INTO u_mtrlware_pzcode_transmx
- (billid,
- printid,
- scid,
- mtrlwareid,
- mtrlid,
- status,
- woodcode,
- pcode,
- plancode,
- mtrlcuscode,
- location,
- sptid,
- qty,
- cost,
- status_new,
- woodcode_new,
- pcode_new,
- plancode_new,
- mtrlcuscode_new,
- location_new,
- sptid_new,
- mxdscrp)
- VALUES (:arg_s_trans.billid,
- :arg_s_trans.arg_s_mx[i].printid,
- :arg_s_trans.arg_s_mx[i].scid,
- :arg_s_trans.arg_s_mx[i].mtrlwareid,
- :arg_s_trans.arg_s_mx[i].mtrlid,
- :arg_s_trans.arg_s_mx[i].status,
- :arg_s_trans.arg_s_mx[i].woodcode,
- :arg_s_trans.arg_s_mx[i].pcode,
- :arg_s_trans.arg_s_mx[i].plancode,
- :arg_s_trans.arg_s_mx[i].mtrlcuscode,
- :arg_s_trans.arg_s_mx[i].location,
- :arg_s_trans.arg_s_mx[i].sptid,
- :arg_s_trans.arg_s_mx[i].qty,
- :arg_s_trans.arg_s_mx[i].cost,
- :arg_s_trans.arg_s_mx[i].status_new,
- :arg_s_trans.arg_s_mx[i].woodcode_new,
- :arg_s_trans.arg_s_mx[i].pcode_new,
- :arg_s_trans.arg_s_mx[i].plancode_new,
- :arg_s_trans.arg_s_mx[i].mtrlcuscode_new,
- :arg_s_trans.arg_s_mx[i].location_new,
- :arg_s_trans.arg_s_mx[i].sptid_new,
- :arg_s_trans.arg_s_mx[i].mxdscrp);
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- uo_billid = arg_s_trans.billid
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF arg_ifcommit AND rslt = 1 THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer getinfo (long arg_billid, ref s_mtrlware_pzcode_trans arg_ref_s_trans, ref long arg_arr_cnt, ref string arg_msg);Int rslt = 1
- Long i = 1,no_mxcheck = 0
- IF arg_billid <= 0 THEN
- rslt = 0
- arg_msg = '错误单据唯一码'
- GOTO ext
- END IF
- IF p_getinfo(arg_billid,arg_ref_s_trans,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- //用游标读取明细
- DECLARE cur_mx CURSOR FOR
- SELECT u_mtrlware_pzcode_transmx.billid,
- u_mtrlware_pzcode_transmx.printid,
- u_mtrlware_pzcode_transmx.scid,
- u_mtrlware_pzcode_transmx.mtrlwareid,
- u_mtrlware_pzcode_transmx.mtrlid,
- u_mtrlware_pzcode_transmx.status,
- u_mtrlware_pzcode_transmx.woodcode,
- u_mtrlware_pzcode_transmx.pcode,
- u_mtrlware_pzcode_transmx.plancode,
- u_mtrlware_pzcode_transmx.mtrlcuscode,
- u_mtrlware_pzcode_transmx.location,
- u_mtrlware_pzcode_transmx.sptid,
- u_mtrlware_pzcode_transmx.qty,
- u_mtrlware_pzcode_transmx.cost,
- u_mtrlware_pzcode_transmx.status_new,
- u_mtrlware_pzcode_transmx.woodcode_new,
- u_mtrlware_pzcode_transmx.pcode_new,
- u_mtrlware_pzcode_transmx.plancode_new,
- u_mtrlware_pzcode_transmx.mtrlcuscode_new,
- u_mtrlware_pzcode_transmx.location_new,
- u_mtrlware_pzcode_transmx.sptid_new,
- u_mtrlware_pzcode_transmx.mxdscrp,
- u_mtrldef.unit,
- u_mtrldef.ifunit,
- u_mtrldef.unit_buy,
- u_mtrldef.rate_buy
- FROM u_mtrlware_pzcode_transmx INNER JOIN
- u_mtrldef ON u_mtrlware_pzcode_transmx.mtrlid = u_mtrldef.mtrlid
- WHERE billid = :arg_billid
- Order By printid;
-
- OPEN cur_mx;
- FETCH cur_mx
- INTO
- :arg_ref_s_trans.arg_s_mx[i].billid,
- :arg_ref_s_trans.arg_s_mx[i].printid,
- :arg_ref_s_trans.arg_s_mx[i].scid,
- :arg_ref_s_trans.arg_s_mx[i].mtrlwareid,
- :arg_ref_s_trans.arg_s_mx[i].mtrlid,
- :arg_ref_s_trans.arg_s_mx[i].status,
- :arg_ref_s_trans.arg_s_mx[i].woodcode,
- :arg_ref_s_trans.arg_s_mx[i].pcode,
- :arg_ref_s_trans.arg_s_mx[i].plancode,
- :arg_ref_s_trans.arg_s_mx[i].mtrlcuscode,
- :arg_ref_s_trans.arg_s_mx[i].location,
- :arg_ref_s_trans.arg_s_mx[i].sptid,
- :arg_ref_s_trans.arg_s_mx[i].qty,
- :arg_ref_s_trans.arg_s_mx[i].cost,
- :arg_ref_s_trans.arg_s_mx[i].status_new,
- :arg_ref_s_trans.arg_s_mx[i].woodcode_new,
- :arg_ref_s_trans.arg_s_mx[i].pcode_new,
- :arg_ref_s_trans.arg_s_mx[i].plancode_new,
- :arg_ref_s_trans.arg_s_mx[i].mtrlcuscode_new,
- :arg_ref_s_trans.arg_s_mx[i].location_new,
- :arg_ref_s_trans.arg_s_mx[i].sptid_new,
- :arg_ref_s_trans.arg_s_mx[i].mxdscrp,
- :arg_ref_s_trans.arg_s_mx[i].unit,
- :arg_ref_s_trans.arg_s_mx[i].ifunit,
- :arg_ref_s_trans.arg_s_mx[i].uunit,
- :arg_ref_s_trans.arg_s_mx[i].rate;
- DO WHILE sqlca.SQLCode = 0
- i++
- FETCH cur_mx
- INTO
- :arg_ref_s_trans.arg_s_mx[i].billid,
- :arg_ref_s_trans.arg_s_mx[i].printid,
- :arg_ref_s_trans.arg_s_mx[i].scid,
- :arg_ref_s_trans.arg_s_mx[i].mtrlwareid,
- :arg_ref_s_trans.arg_s_mx[i].mtrlid,
- :arg_ref_s_trans.arg_s_mx[i].status,
- :arg_ref_s_trans.arg_s_mx[i].woodcode,
- :arg_ref_s_trans.arg_s_mx[i].pcode,
- :arg_ref_s_trans.arg_s_mx[i].plancode,
- :arg_ref_s_trans.arg_s_mx[i].mtrlcuscode,
- :arg_ref_s_trans.arg_s_mx[i].location,
- :arg_ref_s_trans.arg_s_mx[i].sptid,
- :arg_ref_s_trans.arg_s_mx[i].qty,
- :arg_ref_s_trans.arg_s_mx[i].cost,
- :arg_ref_s_trans.arg_s_mx[i].status_new,
- :arg_ref_s_trans.arg_s_mx[i].woodcode_new,
- :arg_ref_s_trans.arg_s_mx[i].pcode_new,
- :arg_ref_s_trans.arg_s_mx[i].plancode_new,
- :arg_ref_s_trans.arg_s_mx[i].mtrlcuscode_new,
- :arg_ref_s_trans.arg_s_mx[i].location_new,
- :arg_ref_s_trans.arg_s_mx[i].sptid_new,
- :arg_ref_s_trans.arg_s_mx[i].mxdscrp,
- :arg_ref_s_trans.arg_s_mx[i].unit,
- :arg_ref_s_trans.arg_s_mx[i].ifunit,
- :arg_ref_s_trans.arg_s_mx[i].uunit,
- :arg_ref_s_trans.arg_s_mx[i].rate;
- LOOP
- CLOSE cur_mx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM u_mtrlware_pzcode_transmx
- Where billid = :arg_billid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询库存配置调整单操作失败,单据明细数量"
- GOTO ext
- END IF
- IF i <> (no_mxcheck+1) THEN
- rslt = 0
- arg_msg = "查询库存配置调整单操作失败,单据明细"
- GOTO ext
- END IF
- arg_arr_cnt = i - 1
- ext:
- RETURN rslt
- end function
- public function integer uof_update_waredate (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- Long ll_arr_cnt
- DateTime ld_waredate,ld_auditingdate,ld_waradate_mx
- String ls_auditdate,ls_waredate
- Long ll_mtrlid,ll_sptid,ll_mtrlwareid,ll_sptid_new
- String ls_status,ls_woodcode,ls_pcode,ls_plancode
- String ls_mtrlcuscode,ls_location
- String ls_status_new,ls_woodcode_new,ls_pcode_new,ls_plancode_new
- String ls_mtrlcuscode_new,ls_location_new
- Long i
- IF arg_billid <= 0 THEN
- rslt = 0
- arg_msg = '错误单据唯一码'
- GOTO ext
- END IF
- s_mtrlware_pzcode_trans arg_s_trans
- IF getinfo(arg_billid,arg_s_trans,ll_arr_cnt,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- SELECT auditdate INTO :ld_auditingdate
- FROM u_mtrlware_pzcode_trans
- Where billid = :arg_billid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致单据审核操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- ls_auditdate = String(ld_auditingdate,'yyyy-mm-dd hh:mm')
- FOR i = 1 TO ll_arr_cnt
- ll_mtrlid = arg_s_trans.arg_s_mx[i].mtrlid
- ll_sptid = arg_s_trans.arg_s_mx[i].sptid
- ls_status = arg_s_trans.arg_s_mx[i].status
- ls_woodcode = arg_s_trans.arg_s_mx[i].woodcode
- ls_pcode = arg_s_trans.arg_s_mx[i].pcode
- ls_plancode = arg_s_trans.arg_s_mx[i].plancode
- ls_mtrlcuscode = arg_s_trans.arg_s_mx[i].mtrlcuscode
- ls_location = arg_s_trans.arg_s_mx[i].Location
-
- ls_status_new = arg_s_trans.arg_s_mx[i].status_new
- ls_woodcode_new = arg_s_trans.arg_s_mx[i].woodcode_new
- ls_pcode_new = arg_s_trans.arg_s_mx[i].pcode_new
- ls_plancode_new = arg_s_trans.arg_s_mx[i].plancode_new
- ls_mtrlcuscode_new = arg_s_trans.arg_s_mx[i].mtrlcuscode_new
- ls_location_new = arg_s_trans.arg_s_mx[i].Location_new
- ll_sptid_new = arg_s_trans.arg_s_mx[i].sptid_new
- SELECT waredate INTO :ld_waredate
- FROM u_mtrlware
- WHERE scid = :arg_s_trans.scid
- AND storageid = :arg_s_trans.storageid
- AND mtrlid = :ll_mtrlid
- AND sptid = :ll_sptid
- AND status = :ls_status
- AND woodcode = :ls_woodcode
- AND pcode = :ls_pcode
- AND plancode = :ls_plancode
- AND mtrlcuscode = :ls_mtrlcuscode
- AND Location = :ls_location;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '明细行:'+string(i)+',查询明细原库存最近进仓日期失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
-
- SELECT waredate INTO :ld_waradate_mx
- FROM u_mtrlware
- WHERE scid = :arg_s_trans.scid
- AND storageid = :arg_s_trans.storageid
- AND mtrlid = :ll_mtrlid
- AND sptid = :ll_sptid_new
- AND status = :ls_status_new
- AND woodcode = :ls_woodcode_new
- AND pcode = :ls_pcode_new
- AND plancode = :ls_plancode_new
- AND mtrlcuscode = :ls_mtrlcuscode_new
- AND Location = :ls_location_new;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '明细行:'+string(i)+',查询明细新库存最近进仓日期失败,错误:'+string(sqlca.SQLCode)+','+sqlca.SQLErrText
- GOTO ext
- END IF
-
- ls_waredate = String(ld_waradate_mx,'yyyy-mm-dd hh:mm')
-
- IF ls_auditdate = ls_waredate THEN
- UPDATE u_mtrlware
- SET waredate = :ld_waredate
- WHERE scid = :arg_s_trans.scid
- AND storageid = :arg_s_trans.storageid
- AND mtrlid = :ll_mtrlid
- AND sptid = :ll_sptid_new
- AND status = :ls_status_new
- AND woodcode = :ls_woodcode_new
- AND pcode = :ls_pcode_new
- AND plancode = :ls_plancode_new
- AND mtrlcuscode = :ls_mtrlcuscode_new
- AND Location = :ls_location_new;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '明细行:'+string(i)+',更新明细新库存最近进仓日期失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
- END IF
- NEXT
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- on uo_mtrlware_pzcode_trans.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_mtrlware_pzcode_trans.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
- global type uo_incase from nonvisualobject
- end type
|