123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589 |
- $PBExportHeader$uo_outware_waste.sru
- forward
- global type uo_outware_waste from nonvisualobject
- end type
- end forward
- global type uo_outware_waste from nonvisualobject
- end type
- global uo_outware_waste uo_outware_waste
- type variables
- Transaction commit_transaction //数据commit事务
- end variables
- forward prototypes
- public function integer wastedel (long arg_wastenum, long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
- public function integer insertwaste (long arg_wastetype, long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
- public function integer wastemove (boolean arg_ifcommit, ref string arg_msg)
- public function integer wastemoveback (long arg_wastenum, long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
- end prototypes
- public function integer wastedel (long arg_wastenum, long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);long rslt=1
- long cnt
- int ll_wastetype
- select wastetype
- into :ll_wastetype
- from u_outware_waste
- where u_outware_waste.wastenum=:arg_wastenum and u_outware_waste.scid=:arg_scid and u_outware_waste.outwareid=:arg_outwareid using commit_transaction;
- if commit_transaction.sqlcode<>0 then
- rslt=0
- arg_msg='查询操作失败,废弃单据的废弃原因'+commit_transaction.sqlerrtext
- goto ext
- end if
- if ll_wastetype=1 then
- rslt=0
- arg_msg='废弃单据的废弃原因是修改废弃,不能还原'
- goto ext
- end if
-
- delete from u_outwaremx_waste
- where u_outwaremx_waste.wastenum=:arg_wastenum and u_outwaremx_waste.scid=:arg_scid and u_outwaremx_waste.outwareid=:arg_outwareid using commit_transaction;
- if commit_transaction.sqlcode<>0 then
- rslt=0
- arg_msg='删除操作失败,废弃发货单/明细'+commit_transaction.sqlerrtext
- goto ext
- end if
- delete from u_outware_waste
- where u_outware_waste.wastenum=:arg_wastenum and u_outware_waste.scid=:arg_scid and u_outware_waste.outwareid=:arg_outwareid using commit_transaction;
- if commit_transaction.sqlcode<>0 then
- rslt=0
- arg_msg='删除操作失败,废弃发货单'+commit_transaction.sqlerrtext
- goto ext
- end if
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- return rslt
- end function
- public function integer insertwaste (long arg_wastetype, long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt
- Long ll_wastenum
- DateTime server_dt
- IF arg_scid < 0 THEN
- arg_msg = '错误的分部'
- rslt = 0
- GOTO ext
- END IF
- IF arg_outwareid <= 0 THEN
- arg_msg = '错误销售单唯一码'
- rslt = 0
- 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
- //明细
- cnt = 0
- SELECT count(*)
- INTO :cnt
- FROM u_outware_waste
- Where scid = :arg_scid AND outwareid = :arg_outwareid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询操作失败,明细单据'+commit_transaction.SQLErrText
- GOTO ext
- ELSE
- IF cnt = 0 THEN
- ll_wastenum = 1
- ELSE
- SELECT max(wastenum)
- INTO :ll_wastenum
- FROM u_outware_waste
- Where scid = :arg_scid AND outwareid = :arg_outwareid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询操作失败,明细单据'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- ll_wastenum++
- END IF
- END IF
- INSERT INTO u_outwaremx_waste
- (
- wastenum,
- scid,
- outwareid,
- mtrlwareid,
- mtrlid,
- storageid,
- plancode,
- status,
- qty,
- addqty,
- fprice,
- rebate,
- price,
- costamt,
- planprice,
- mxdscrp,
- Sptid,
- Dxflag,
- printid,
- sys_changetime,
- ifrel,
- olmtrlid,
- relid,
- packqty,
- woodcode,
- relcode,
- pcode,
- enprice,
- newpriceamt,
- ctmint,
- outtype,
- dftsaleprice,
- cost)
- SELECT :ll_wastenum,
- scid,
- outwareid,
- mtrlwareid,
- mtrlid,
- storageid,
- plancode,
- status,
- qty,
- addqty,
- fprice,
- rebate,
- price,
- costamt,
- planprice,
- mxdscrp,
- Sptid,
- Dxflag,
- printid,
- sys_changetime,
- ifrel,
- olmtrlid,
- relid,
- packqty,
- woodcode,
- relcode,
- pcode,
- enprice,
- newpriceamt,
- ctmint,
- outtype,
- dftsaleprice,
- cost
- FROM u_outwaremx
- Where scid = :arg_scid AND outwareid = :arg_outwareid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
-
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_outwaremx_waste') > 0 THEN
- arg_msg = '插入单据明细资料失败,关键字ID重复'
- ELSE
- arg_msg = '插入单据明细资料失败,'+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
- INSERT INTO u_outware_waste
- (wastenum,
- wastedate,
- wasterep,
- wastetype,
- scid,
- outwareid,
- outwarecode,
- billtype,
- relid,
- StorageID,
- opdate,
- opemp,
- Modemp,
- moddate,
- flag,
- auditingdate,
- auditingrep,
- outdate,
- outrep,
- part,
- dscrp,
- cusid,
- cusname,
- balcflag,
- balcdateint,
- thflag,
- secflag,
- secauditingdate,
- secauditingrep,
- sys_changetime,
- ctmint,
- printnum,
- wagemth,
- otheramt,
- relstr_1,
- relstr_2,
- relstr_3,
- relint_1,
- relint_2,
- relint_3,
- priceflag,
- pricedate,
- priceemp,
- rel_address,
- rel_tele,
- rel_fax,
- rel_rep,
- mrate)
- SELECT :ll_wastenum,
- :server_dt,
- :publ_operator,
- :arg_wastetype,
- scid,
- outwareid,
- outwarecode,
- billtype,
- relid,
- StorageID,
- opdate,
- opemp,
- Modemp,
- moddate,
- flag,
- auditingdate,
- auditingrep,
- outdate,
- outrep,
- part,
- dscrp,
- cusid,
- cusname,
- balcflag,
- balcdateint,
- thflag,
- secflag,
- secauditingdate,
- secauditingrep,
- sys_changetime,
- ctmint,
- printnum,
- wagemth,
- otheramt,
- relstr_1,
- relstr_2,
- relstr_3,
- relint_1,
- relint_2,
- relint_3,
- priceflag,
- pricedate,
- priceemp,
- rel_address,
- rel_tele,
- rel_fax,
- rel_rep,
- mrate
- FROM u_outware
- Where scid = :arg_scid AND outwareid = :arg_outwareid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
-
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_outware_waste') > 0 THEN
- arg_msg = '插入发货单据资料失败,关键字ID重复'
- ELSE
- arg_msg = '插入发货单据资料失败,'+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer wastemove (boolean arg_ifcommit, ref string arg_msg);long rslt=1
- //long cnt
- //datetime server_dt
- //
- //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
- //
- //datetime ld_3day_before
- //ld_3day_before=datetime(RelativeDate(date(server_dt), -3),time(0))
- //
- //long ll_ds_rowcount
- //datastore ds_waste
- //ds_waste = CREATE datastore
- //ds_waste.DataObject = "ds_outware_waste"
- //ds_waste.SetTransObject(sqlca)
- //ds_waste.Retrieve(ld_3day_before)
- //ds_waste.accepttext()
- //ll_ds_rowcount=ds_waste.rowcount()
- ////没有,不用转移
- //if ll_ds_rowcount<=0 then
- // rslt=1
- // goto ext
- //end if
- //uo_outware_sale uo_sale
- //uo_sale = create uo_outware_sale
- //uo_sale.commit_transaction=commit_transaction
- //long ls_i
- //long ls_temp_scid,ls_temp_outwareid
- //string ls_temp_outwarecode
- //
- ////循环转移
- //for ls_i=1 to ll_ds_rowcount
- // ls_temp_scid=ds_waste.object.scid[ls_i]
- // ls_temp_outwareid=ds_waste.object.outwareid[ls_i]
- // ls_temp_outwarecode=ds_waste.object.outwarecode[ls_i]
- //
- // if uo_sale.del(ls_temp_scid,ls_temp_outwareid,arg_msg,false)=0 then
- // rslt=0
- // goto ext
- // else
- // //日志
- // f_setsysoplog('销售发货单','销售发货单删除,id:'+string(ls_temp_outwareid)+',code:'+ls_temp_outwarecode,arg_msg,true)
- // end if
- //next
- //DESTROY uo_sale
- //ext:
- //IF rslt = 0 THEN
- // ROLLBACK USING commit_transaction;
- //ELSEIF rslt = 1 AND arg_ifcommit THEN
- // COMMIT USING commit_transaction;
- //END IF
- RETURN rslt
- end function
- public function integer wastemoveback (long arg_wastenum, long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);int rslt=1
- long cnt
- int ll_wastetype
- select wastetype
- into :ll_wastetype
- from u_outware_waste
- where u_outware_waste.wastenum=:arg_wastenum and u_outware_waste.scid=:arg_scid and u_outware_waste.outwareid=:arg_outwareid using commit_transaction;
- if commit_transaction.sqlcode<>0 then
- rslt=0
- arg_msg='查询操作失败,废弃单据的废弃原因'+commit_transaction.sqlerrtext
- goto ext
- end if
- if ll_wastetype=1 then
- rslt=0
- arg_msg='废弃单据的废弃原因是修改废弃,不能还原'
- goto ext
- end if
- INSERT INTO u_outwaremx
- (scid,
- outwareid,
- mtrlwareid,
- mtrlid,
- storageid,
- plancode,
- status,
- qty,
- addqty,
- fprice,
- rebate,
- price,
- costamt,
- planprice,
- mxdscrp,
- Sptid,
- Dxflag,
- printid,
- sys_changetime,
- ifrel,
- olmtrlid,
- relid,
- packqty,
- woodcode,
- relcode,
- pcode,
- enprice,
- newpriceamt,
- ctmint,
- outtype,
- dftsaleprice,
- cost)
- select scid,
- outwareid,
- mtrlwareid,
- mtrlid,
- storageid,
- plancode,
- status,
- qty,
- addqty,
- fprice,
- rebate,
- price,
- costamt,
- planprice,
- mxdscrp,
- Sptid,
- Dxflag,
- printid,
- sys_changetime,
- ifrel,
- olmtrlid,
- relid,
- packqty,
- woodcode,
- relcode,
- pcode,
- enprice,
- newpriceamt,
- ctmint,
- outtype,
- dftsaleprice,
- cost
- from u_outwaremx_waste
- where u_outwaremx_waste.wastenum=:arg_wastenum and u_outwaremx_waste.scid=:arg_scid and u_outwaremx_waste.outwareid=:arg_outwareid using commit_transaction;
- if commit_transaction.sqlcode<>0 then
- rslt=0
- arg_msg='插入操作失败,废弃发货单/明细'+commit_transaction.sqlerrtext
- goto ext
- end if
- INSERT INTO u_outware
- (scid,
- outwareid,
- outwarecode,
- billtype,
- relid,
- StorageID,
- opdate,
- opemp,
- Modemp,
- moddate,
- flag,
- auditingdate,
- auditingrep,
- outdate,
- outrep,
- part,
- dscrp,
- cusid,
- cusname,
- balcflag,
- balcdateint,
- thflag,
- secflag,
- secauditingdate,
- secauditingrep,
- sys_changetime,
- ctmint,
- printnum,
- wagemth,
- otheramt,
- relstr_1,
- relstr_2,
- relstr_3,
- relint_1,
- relint_2,
- relint_3,
- priceflag,
- pricedate,
- priceemp,
- rel_address,
- rel_tele,
- rel_fax,
- rel_rep,
- mrate)
- select scid,
- outwareid,
- outwarecode,
- billtype,
- relid,
- StorageID,
- opdate,
- opemp,
- Modemp,
- moddate,
- flag,
- auditingdate,
- auditingrep,
- outdate,
- outrep,
- part,
- dscrp,
- cusid,
- cusname,
- balcflag,
- balcdateint,
- thflag,
- secflag,
- secauditingdate,
- secauditingrep,
- sys_changetime,
- ctmint,
- printnum,
- wagemth,
- otheramt,
- relstr_1,
- relstr_2,
- relstr_3,
- relint_1,
- relint_2,
- relint_3,
- priceflag,
- pricedate,
- priceemp,
- rel_address,
- rel_tele,
- rel_fax,
- rel_rep,
- mrate
- from u_outware_waste
- where u_outware_waste.wastenum=:arg_wastenum and u_outware_waste.scid=:arg_scid and u_outware_waste.outwareid=:arg_outwareid using commit_transaction;
- if commit_transaction.sqlcode<>0 then
- rslt=0
- arg_msg='插入操作失败,废弃发货单'+commit_transaction.sqlerrtext
- goto ext
- end if
- if wastedel(arg_wastenum,arg_scid,arg_outwareid,arg_msg,false) =0 then
- rslt=0
- goto ext
- end if
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- on uo_outware_waste.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_outware_waste.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|