$PBExportHeader$uo_billdef.sru forward global type uo_billdef from nonvisualobject end type end forward global type uo_billdef from nonvisualobject end type global uo_billdef uo_billdef type variables s_rpt_bill s_bill long billid boolean if_getid_ture=false transaction commit_transaction //数据commit事务 boolean it_newbegin=false //新建标志 boolean it_updatebegin=false //修改标志 end variables forward prototypes public subroutine p_reset () public function integer save (boolean arg_ifcommit, ref string arg_msg) public function integer del (long arg_billid, boolean arg_ifcommit, ref string arg_msg) public function integer newbegin (integer arg_billid) end prototypes public subroutine p_reset ();s_bill.BillID = 0 s_bill.BillName = '' s_bill.WinName = '' s_bill.WhereSql = '' s_bill.arguments = '' s_bill.tablename = '' s_bill.ifuse = 1 end subroutine public function integer save (boolean arg_ifcommit, ref string arg_msg);long rslt =1 long ls_newid if isnull(s_bill.BillID) then s_bill.BillID = 0 if isnull(s_bill.BillName) then s_bill.BillName = '' if isnull(s_bill.WinName) then s_bill.WinName = '' if isnull(s_bill.WhereSql) then s_bill.WhereSql = '' if isnull(s_bill.arguments) then s_bill.arguments = '' if isnull(s_bill.tablename) then s_bill.tablename = '' if isnull(s_bill.ifuse) then s_bill.ifuse = 0 ////////////////////////////////////////////////开始区分:新建/更新 处理 if s_bill.BillID = 0 then //新建 ls_newid = f_sys_scidentity_rpt(0,"u_report_bill","billid",arg_msg,if_getid_ture,commit_transaction) if ls_newid <= 0 then rslt = 0 goto ext end if insert into u_report_bill (BillID, BillName, WinName, WhereSql, arguments, tablename, ifuse) values (:ls_newid, :s_bill.BillName, :s_bill.WinName, :s_bill.WhereSql, :s_bill.arguments, :s_bill.tablename, :s_bill.ifuse) using commit_transaction ; if commit_transaction.sqlcode <> 0 then rslt = 0 arg_msg = "因网络或其它原因导致报表插入操作失败"+"~n"+commit_transaction.sqlerrtext goto ext end if billid = ls_newid else //////////////////////////////////////////////////更新 update u_report_bill set BillName = :s_bill.BillName, WinName = :s_bill.WinName, WhereSql = :s_bill.WhereSql, arguments = :s_bill.arguments, tablename = :s_bill.tablename, ifuse = :s_bill.ifuse where billid = :s_bill.billid 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 billid = s_bill.billid 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 return rslt end function public function integer del (long arg_billid, boolean arg_ifcommit, ref string arg_msg); int rslt = 1 long ls_long if arg_billid = 0 then rslt = 0 arg_msg = "没有删除对象,操作取消" goto ext end if delete from u_report_bill where billid = :arg_billid 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 newbegin (integer arg_billid);long rslt = 1 it_newbegin =true it_updatebegin =false billid = arg_billid return rslt end function on uo_billdef.create call super::create TriggerEvent( this, "constructor" ) end on on uo_billdef.destroy TriggerEvent( this, "destructor" ) call super::destroy end on