$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